nfirvine.comwiki

Genth

Filed in: Ideas.Genth · Modified on : Sun, 11 Apr 10

Inspiration

Idea

Make something like Faust, but in Python using generators. Faust "compiles" its input source to C++ code. Gross.

Example

import itertools

sample_rate = 44100
chunk_size = 10
control_rate = sample_rate / chunk_size
step_size = 22050
step_rate = sample_rate / step_size # 2bps

def sin(freq=itertools.repeat(440), amp=itertools.repeat(500)):
  samples =  #chunk_size samples
  controls = yield samples #params allows control-rate changes to params
  • sample_rate must be evenly divisible by chunk_size and step_size
  • All control variables (freq and amp) are fed by generators, even when they're constant.
  • Controls generators may be changed by a control dict passed through generator's send().
  • We can reuse Python's standard itertools.

Powered by PmWiki