Skip to content

Instantly share code, notes, and snippets.

@analoq
Created June 7, 2014 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save analoq/1a4082afeb6677c2213f to your computer and use it in GitHub Desktop.
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.
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