Python synthesizer stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
649B

  1. import pymod
  2. from math import sin, pi
  3. samplerate = 44100
  4. channels = 2
  5. x = pymod._ysynth_init(samplerate, channels)
  6. samples_processed = 0
  7. def sine_wave(channels):
  8. """
  9. Send simple 440Hz to your speakers
  10. """
  11. global samples_processed
  12. if not samples_processed:
  13. print "First time callback occurred"
  14. print "Array shape is: %s" % str(channels.shape)
  15. for i in xrange(channels.shape[0]):
  16. channels[i][0] = channels[i][1]= sin(440.0 * (i + samples_processed) /
  17. samplerate * (pi * 2.0)) * 20000
  18. samples_processed += channels.shape[0]
  19. return
  20. pymod._ysynth_set_callback(x, sine_wave)