Esempio n. 1
0
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)
Esempio n. 2
0
 def __init__(self, samplerate, bufferSize):
     Instrument.__init__(self)
     Oscilator.__init__(self, samplerate, bufferSize)
     Oscilator.start(self)
Esempio n. 3
0
 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
Esempio n. 4
0
 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