Created
June 7, 2014 06:29
-
-
Save analoq/1a4082afeb6677c2213f to your computer and use it in GitHub Desktop.
Miller Puckette's Theory and Technique of Electronic Music. Chapter 3, Exercise 5 graphical solution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from pylab import * | |
def f(t): | |
omega = 200.0 * 2 * math.pi | |
return math.fmod(omega*t, 2*math.pi)/(2*math.pi) | |
def g(t): | |
omega = 300.0 * 2 * math.pi | |
return math.fmod(omega*t, 2*math.pi)/(2*math.pi) | |
def wrap(x): | |
return math.fmod(x, 1.0) | |
# build dataset | |
data = [] | |
rate = 1/100000.0 | |
rng = arange(0.0, 1/100.0 + rate, rate) | |
for t in rng: | |
data.append((f(t), g(t), | |
f(t) + g(t), | |
wrap(f(t) + g(t)))) | |
# plot | |
plt.plot(rng, data) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment