Source

toysynth-example / Example03.py

class Vibrato(object):
    def __init__(self, source=None, frequency=1.0, depth=1.0):
        viv_oscillator = SineWaveOscillator(frequency=frequency)
        amp = Amplifeir(source=viv_oscillator, gain=depth, attenuate=1.0)
        self.output = FrequencyModulator(source=source, diff=amp)

    def get_value(self, tick):
        return self.output.get_value(tick)
    
    

class DeTunedSquareWaveOscillator(object):
    def __init__(self, frequency=0, depth=0):
        self.depth = depth
        self.osc1 = SquareWaveOscillator(frequency=frequency)
        self.osc2 = SquareWaveOscillator(frequency=frequency + depth)
        
        self.mixer = Mixer()
        self.mixer.add_track(0, "base_tone", self.osc1)
        self.mixer.add_track(1, "detuned_tone", self.osc2)


    def get_value(self, tick):
        return self.mixer.get_value(tick)


    def get_frequency(self):
        return self.osc1.frequency


    def set_frequency(self, value):
        self.osc1.frequency = value
        self.osc2.frequency = value + self.depth
        
    frequency = property(get_frequency, set_frequency)
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.