calculate exponential moving average in python

EDIT: It seems that mov_average_expw() function from scikits.timeseries.lib.moving_funcs submodule from SciKits (add-on toolkits that complement SciPy) better suits the wording of your question. To calculate an exponential smoothing of your data with a smoothing factor alpha (it is (1 – alpha) in Wikipedia’s terms): >>> alpha = 0.5 >>> assert 0 < alpha <= 1.0 … Read more

Chord detection algorithms?

This is quite a good Open Source Project: https://patterns.enm.bris.ac.uk/hpa-software-package It detects chords based on a chromagram – a good solution, breaks down a window of the whole spectrum onto an array of pitch classes (size: 12) with float values. Then, chords can be detected by a Hidden Markov Model. .. should provide you with everything … Read more

Creating sine or square wave in C#

This lets you give frequency, duration, and amplitude, and it is 100% .NET CLR code. No external DLL’s. It works by creating a WAV-formatted MemoryStream which is like creating a file in memory only, without storing it to disk. Then it plays that MemoryStream with System.Media.SoundPlayer. using System; using System.Collections.Generic; using System.IO; using System.Linq; using … Read more

Estimate Autocorrelation using Python

I don’t think there is a NumPy function for this particular calculation. Here is how I would write it: def estimated_autocorrelation(x): “”” http://stackoverflow.com/q/14297012/190597 http://en.wikipedia.org/wiki/Autocorrelation#Estimation “”” n = len(x) variance = x.var() x = x-x.mean() r = np.correlate(x, x, mode=”full”)[-n:] assert np.allclose(r, np.array([(x[:n-k]*x[-(n-k):]).sum() for k in range(n)])) result = r/(variance*(np.arange(n, 0, -1))) return result The assert … Read more

What’s wrong with this simple FM synth design?

Most synthesizers labled ‘FM’ in fact do phase modulation (PM, see https://en.wikipedia.org/wiki/Phase_modulation ). There are some benefits (mostly leading to more stable sound over a large tonal range). The OPL2 may use this too, I found no clear evidence, but the Wikipedia article also uses the term ‘phase modulation’. For short, many musical synthesizers labeled … Read more