class MonophonicScaleSynth(Instrument): def __init__(self, samplerate, buffer_size, scale): Instrument.__init__(self) self.scale = scale self.oscillator = Oscilator(samplerate, buffer_size) self.oscillator.start() self._callback = self.oscillator.callback def set_scale(self, scale): self.scale = scale def on(self, tone, time=0): frequency = self.scale.get_frequency(tone) self.oscillator.setFreq(frequency) Instrument.on(self, tone, time=time) def __str__(self): return "MonophonicScaleSynth %s" % str(self.scale)
def __init__(self, samplerate, bufferSize): Instrument.__init__(self) Oscilator.__init__(self, samplerate, bufferSize) Oscilator.start(self)
def _callback(self, in_data, frame_count, time_info, status): output_buffer = Oscilator.callback(self, in_data, frame_count, time_info, status) if not self.enabled: output_buffer *= 0 return output_buffer
def __init__(self, samplerate, buffer_size, scale): Instrument.__init__(self) self.scale = scale self.oscillator = Oscilator(samplerate, buffer_size) self.oscillator.start() self._callback = self.oscillator.callback