|
-
- import pymod
- from math import sin, pi
-
- samplerate = 44100
- channels = 2
-
- x = pymod._ysynth_init(samplerate, channels)
-
- samples_processed = 0
-
- def sine_wave(channels):
- """
- Send simple 440Hz to your speakers
- """
-
- global samples_processed
-
- if not samples_processed:
- print "First time callback occurred"
- print "Array shape is: %s" % str(channels.shape)
-
- for i in xrange(channels.shape[0]):
- channels[i][0] = channels[i][1]= sin(440.0 * (i + samples_processed) /
- samplerate * (pi * 2.0)) * 20000
-
- samples_processed += channels.shape[0]
-
- return
-
- pymod._ysynth_set_callback(x, sine_wave)
|