Created
September 18, 2016 20:30
-
-
Save pichenettes/482565a12afe238379d709972c7447cf to your computer and use it in GitHub Desktop.
Pulse waveform additive synthesis
This file contains hidden or 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 numpy | |
import pylab | |
ratio = 0.333 | |
t = numpy.arange(1000.0) / 1000.0 | |
s = 0 | |
for n in xrange(1, 1000): | |
harmonic = numpy.cos(2 * numpy.pi * t * n) | |
amplitude = 2 * numpy.sin(numpy.pi * n * ratio) / (n * numpy.pi * ratio) | |
s += harmonic * amplitude | |
pylab.plot(s) | |
pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment