[LAU] Theramin oscillator for LADSPA?

Harry van Haaren harryhaaren at gmail.com
Sun Oct 6 21:12:03 UTC 2013


On Sun, Oct 6, 2013 at 9:59 PM, Fons Adriaensen <fons at linuxaudio.org> wrote:

> #!/usr/bin/python
>
> from math import *
>
>
> X = [ 0.00,  0.70,  1.30,  2.00,  2.70,  3.25,  4.00,  4.65,  5.15,  5.85,
>       6.35,  6.95,  7.40,  7.95,  8.30,  8.75,  9.10,  9.55, 10.00, 10.25,
>      10.55, 10.90, 11.20, 11.53, 11.70, 11.40, 10.98, 10.10,  9.10,  8.00,
>       6.90,  5.75,  4.45,  3.20,  2.10,  1.01,  0.00, -1.00, -1.98, -2.90,
>      -3.70, -4.25, -5.00, -5.60, -6.10, -6.60, -7.02, -7.35, -7.80, -8.00,
>      -8.15, -8.30, -8.40, -8.46, -8.50, -8.50, -8.47, -8.45, -8.27, -8.10,
>      -7.99, -7.80, -7.55, -7.25, -7.00, -6.67, -6.35, -6.05, -5.65, -5.30,
>      -4.98, -4.50, -4.05, -3.60, -3.05, -2.60, -2.00, -1.45, -0.80 ]
>
> N = len(X)
>
> def analyse(f):
>     sx = 0
>     sy = 0
>     w = f * 2 * pi / N
>     for i in range(N):
>         sx += X [i] * sin (i * w)
>         sy += X [i] * cos (i * w)
>     m = hypot (sx, sy)
>     a = atan2(sy, sx) * 180 / pi
>     return m, a
>
>
> for i in range (1, 11):
>     m, a = analyse (i)
>     if i == 1: m1 = m
>     print ("%3d %10.3f %8.1f" % (i, m / m1, a))
>

Wauw, that's a golden nugget of Python! Cheers, -Harry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-user/attachments/20131006/28a4d373/attachment.html>


More information about the Linux-audio-user mailing list