From d903249930d2f7240efa37894e7e7a5c341b14a9 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 21 Feb 2018 04:04:24 -0800 Subject: [PATCH] update 40 --- README.md | 45 ++++++++++++++++++++++++++++++++++----------- lib/cepstrum.py | 8 ++------ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 800cdfb..813e5f9 100644 --- a/README.md +++ b/README.md @@ -4,31 +4,51 @@ it's a bunch of half-baked python code that's kinda handy. don't expect commits, docs, or comments to be any verbose. +feel free to modify and adapt the [autoupdate](autoupdate) +shell script for your own repos like this! + ## the stuff * a basic BS.1770-3 normalization implementation — [bs.py](/lib/bs.py) -* biquad butterworth/chebyshev filters [(via DSPFilters)][dspf] +* biquad butterworth/chebyshev filters + [(via DSPFilters)][dspf] — [nsf.py](/lib/nsf.py) -* bilinear transformation: s-plane to z-plane +* modified bilinear transformation: s-plane to z-plane — [planes.py](/lib/planes.py) * various functions for biquad filters -— [bq.py](/lib/bq.py) [\_\_init\_\_.py](/lib/__init__.py) +— [bq.py](/lib/bq.py) -* some functions for state-variable filters [(via Raph Levien)][svf] +* some functions for state-variable filters + [(via Raph Levien)][svf] — [svf.py](/lib/svf.py) -* sine sweeps, and the Optimized Aoshima's Time-Stretched Pulse [(via here)][sweeps] +* sine sweeps, and the Optimized Aoshima's Time-Stretched Pulse + [(via here)][sweeps] — [sweeps.py](/lib/sweeps.py) -* a lot of stuff for magnitude plotting like tilting and smoothing -— [fft.py](/lib/fft.py) [smoothfft.py](/lib/smoothfft.py) [\_\_init\_\_.py](/lib/__init__.py) +* basic [cepstrum][cep] utilities like minimum-phase reconstruction + [(via Julius Smith)][jos3] +— [cepstrum.py](/lib/cepstrum.py) -* rough experiments with psychoacoustic equalization ("neon pink" and other crap) -— [data.py](/lib/data.py) [\_\_init\_\_.py](/lib/__init__.py) +* utilities for magnitude plotting, including tilting and smoothing +— [fft.py](/lib/fft.py) [smoothfft.py](/lib/smoothfft.py) [mag.py](/lib/mag.py) + +* a couple hard-coded polyphase halfband IIRs for nonlinear-phase resampling + or approximating hilbert transforms + (read more: [Olli Niemitalo][olli]) +— [piir.py](/lib/piir.py) + +* a dozen windowing functions and utility functions for constructing them +— [windowing.py](/lib/windowing.py) + +* ad-hoc experiments with psychoacoustic equalization + ("neon pink" and other crap before i realized + "grey noise" was the term i was looking for) +— [data.py](/lib/data.py) * miscellaneous matplotlib stuff — [plot.py](/lib/plot.py) @@ -36,9 +56,12 @@ don't expect commits, docs, or comments to be any verbose. * miscellaneous utility functions — [util.py](/lib/util.py) [wav.py](/lib/wav.py) -[dspf]: https://github.com/vinniefalco/DSPFilters/ +[dspf]: //github.com/vinniefalco/DSPFilters/ +[svf]: http://nbviewer.jupyter.org/github/google/music-synthesizer-for-android/blob/master/lab/Second%20order%20sections%20in%20matrix%20form.ipynb [sweeps]: http://www.sound.sie.dendai.ac.jp/dsp/e-21.html -[svf]: http://nbviewer.ipython.org/urls/music-synthesizer-for-android.googlecode.com/git/lab/Second%20order%20sections%20in%20matrix%20form.ipynb +[cep]: //en.wikipedia.org/wiki/Cepstrum +[jos3]: //ccrma.stanford.edu/~jos/fp/ +[olli]: http://yehar.com/blog/?p=368 all wrapped up in a inconveniently named "lib" module! diff --git a/lib/cepstrum.py b/lib/cepstrum.py index 54eb129..359f09b 100644 --- a/lib/cepstrum.py +++ b/lib/cepstrum.py @@ -42,15 +42,11 @@ def fold(r): return rw -def minphase(s, pad=True, os=False): +def minphase(s, pad=True): # via https://ccrma.stanford.edu/~jos/fp/Matlab_listing_mps_m.html - # TODO: actual oversampling + # TODO: oversampling if pad: s = pad2(s) - if os: - s = np.r_[s, np.zeros(len(s))] cepstrum = np.fft.ifft(np.log(clipdb(np.fft.fft(s), -100))) signal = np.real(np.fft.ifft(np.exp(np.fft.fft(fold(cepstrum))))) - if os: - signal = signal[:len(signal)//2] return signal