Skip to content

Instantly share code, notes, and snippets.

View jurihock's full-sized avatar
💭
Think different.

Jürgen Hock jurihock

💭
Think different.
View GitHub Profile
@jurihock
jurihock / 1-vocoder-tsm.py
Last active March 13, 2024 22:55
Basic phase vocoder examples for time-scale and pitch-shifting modifications
# Time-scale modification example (TSM)
import numpy as np
from dhbw import dasp
from sdft import STFT
def princarg(x):
'''Wraps normalized angles `x`, e.g. divided by 2π, to the interval [−0.5, +0.5).'''
@jurihock
jurihock / fvc.py
Created November 6, 2023 21:45
Very simple RMS based frequency estimator
# References:
#
# 1) Simple and Accurate Frequency to Voltage Converter
# https://web.mit.edu/Magic/Public/papers/05491499.pdf
#
# 2) Recursive RMS (STM32 Implementation)
# https://www.youtube.com/watch?v=miUXBXUDJDI
#
# 3) How do I take the discrete derivative of Cosine, and show that it still equals -Sine?
# https://math.stackexchange.com/a/2276816
@jurihock
jurihock / sdft_vs_qdft.py
Last active August 26, 2023 19:29
SDFT vs. QDFT
# Basic SDFT vs. QDFT showcase based on figures from
# "Sliding with a constant Q" by Russell Bradford
import matplotlib.pyplot as plot
import matplotlib.ticker as ticker
import numpy as np
from sdft import SDFT
from qdft import QDFT
@jurihock
jurihock / fast_sdft_response.py
Last active July 1, 2023 12:24
A Fast Guaranteed-Stable Sliding DFT Algorithm
# SDFT network transfer function example according to
# "A Fast Guaranteed-Stable Sliding DFT Algorithm"
# by Richard Lyons
# https://www.dsprelated.com/showarticle/1533.php
import matplotlib.pyplot as plot
import numpy as np
from scipy.fft import fftshift
@jurihock
jurihock / miniconda.sh
Last active February 17, 2023 06:25
Miniconda activation script
#!/bin/bash
# directory containing multiple miniconda installations
MINICONDA=~/Miniconda
# turn off case sensitivity
casematch=$(shopt -p nocasematch)
shopt -s nocasematch
# search for matching subfolder inside miniconda directory
@jurihock
jurihock / oscillator.py
Last active February 20, 2023 13:41
Showcase PolyBLEP Sawtooth Oscillator
import matplotlib.pyplot as plot
import numpy as np
import scipy.signal as signal
class Oscillator:
'''
Complex harmonic oscillator cos(phi) + 1j * sin(phi).
'''
@jurihock
jurihock / tljh-share-data.sh
Last active February 23, 2022 23:27
The Littlest JupyterHub: Share data with existing users
#!/bin/bash
# The official tutorial describes how to create shared folders for new users:
# https://tljh.jupyter.org/en/latest/howto/content/share-data.html
# But it still doesn't reflect how to propagate any new shared folders to existing users.
# This script features an example for the missing task.
if [[ $(id -u) -ne 0 ]]
then