How to use the pyo.Fader function in pyo

To help you get started, we’ve selected a few pyo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wehr-lab / autopilot / taskontrol_remnants / plugins / soundclient.py View on Github external
soundAmp = list(soundParams['amplitude'])
        else:
            soundAmp = 2*[soundParams['amplitude']]
        # -- Define sound according to type --
        if soundParams['type']=='tone':
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=soundAmp)
            soundwaveObj = pyo.Sine(freq=soundParams['frequency'],
                                    mul=soundObj).out()
            return(soundObj,soundwaveObj)
        elif soundParams['type']=='chord':
            nTones = soundParams['ntones']  # Number of components in chord
            factor = soundParams['factor']  # Components will be in range [f/factor, f*factor]
            centerFreq = soundParams['frequency']
            freqEachComp = np.logspace(np.log10(centerFreq/factor),np.log10(centerFreq*factor),nTones)
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=soundAmp)
            soundwaveObjs = []
            for indcomp in range(nTones):
                #soundwaveObjs.append(pyo.Sine(freq=freqEachComp[indcomp],
                #                              mul=soundObj).mix(2).out())
                soundwaveObjs.append(pyo.Sine(freq=freqEachComp[indcomp],
                                              mul=soundObj).out())
            return(soundObj,soundwaveObjs)
        elif soundParams['type']=='noise':
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=soundAmp)
            #soundwaveObj = pyo.Noise(mul=soundObj).mix(2).out()
            soundwaveObj = pyo.Noise(mul=soundObj).out()
            return(soundObj,soundwaveObj)
        elif soundParams['type']=='AM':
            if isinstance(soundAmp, list):
github tito / pymt / examples / apps / sinemixer / sinemixer.py View on Github external
# reajust layout when moving
        hlayout.spacing = w / 10
        hlayout.size = w, h
        hlayout.do_layout()

    w.connect('on_resize', resize_hlayout)

    # We create 4 instances of each of the above
    for widget in range(4):
        vlayouts.append(MTBoxLayout(orientation='vertical', spacing=10))
        sliders.append(MTSlider(min=100, max=1000, size_hint=(1, .9)))
        buttons.append(MTButton(label='', size_hint=(1, .1)))
        vlayouts[widget].add_widget(buttons[widget])
        vlayouts[widget].add_widget(sliders[widget])
        hlayout.add_widget(vlayouts[widget])
        faders.append(pyo.Fader(fadein = 0.5, fadeout = 0.5, dur = 0, mul = 0.25))
        sines.append(pyo.Sine(mul = faders[widget], freq = 300))
        sines[widget].out()

    ctx.c.add_widget(hlayout)

    # This function gets called when a slider moves, it sets the pitch of each sine.
    def on_value_change_callback(slider, value):
        sines[slider].freq = value

    # When the button is pressed, the fader object performs it's fade.
    def on_press_callback(btn, *largs):
        faders[btn].play()

    # When the button is released, the fader object fades back to 0.
    def on_release_callback(btn, *largs):
        faders[btn].stop()
github wehr-lab / autopilot / core / sounds.py View on Github external
def __init__(self, duration, amplitude=0.01, out_chan=1, **kwargs):
        # gap in noise
        self.duration = float(duration)/1000
        self.amplitude = float(amplitude)
        self.fad = pyo.Fader(fadein=0.0001, fadeout=0.0001,
                             dur=self.duration, mul=1.0)
        self.out_chan = out_chan

        # fader is 0 when not playing, then goes to its mul when played.
        # so we multiply the amplitude of the noise generator by 1-fad
        self.noiser = pyo.Noise(mul=float(amplitude)*(1.0-self.fad))

        # start it
        self.noiser.out(self.out_chan)
github wehr-lab / autopilot / taskontrol_remnants / plugins / soundclient.py View on Github external
return(soundObj,soundwaveObjs)
        elif soundParams['type']=='noise':
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=soundAmp)
            #soundwaveObj = pyo.Noise(mul=soundObj).mix(2).out()
            soundwaveObj = pyo.Noise(mul=soundObj).out()
            return(soundObj,soundwaveObj)
        elif soundParams['type']=='AM':
            if isinstance(soundAmp, list):
                halfAmp = [0.5*x for x in soundAmp]
            else:
                halfAmp = 0.5*soundAmp
            envelope = pyo.Sine(freq=soundParams['modFrequency'],
                                mul=halfAmp,
                                add=halfAmp,phase=0.75)
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=envelope)
            soundwaveObj = pyo.Noise(mul=soundObj).out()
            return(soundObj,[envelope,soundwaveObj])
            '''
            soundObj = pyo.Fader(fadein=self.risetime, fadeout=self.falltime,
                                 dur=soundParams['duration'], mul=soundAmp)
            envelope = pyo.Sine(freq=soundParams['modFrequency'],mul=soundObj,add=soundAmp,phase=0)
            soundwaveObj = pyo.Noise(mul=envelope).out()
            return(soundObj,[envelope,soundwaveObj])
            '''
        elif soundParams['type']=='fromfile':
            tableObj = pyo.SndTable(soundParams['filename'])
            samplingFreq = tableObj.getRate()
            if soundParams.get('duration'):
                duration = soundParams['duration']
            else:
github tito / pymt / examples / sinemixer / sinemixer.py View on Github external
faders = []
    
    vlayouts = []
    
    hlayout = MTBoxLayout(spacing = w.size[0] / 5)
    hlayout.pos = (w.size[0] * 0.20, w.size[1] * 0.20)
    
    # We create 4 instances of each of the above
    for widget in range(4):
        vlayouts.append(MTBoxLayout(orientation = 'vertical', spacing = 10))
        sliders.append(MTSlider(min = 100, max = 1000, size = widget_size))
        buttons.append(MTButton(label = '', size = (widget_size[0], widget_size[0])))
        vlayouts[widget].add_widget(buttons[widget])
        vlayouts[widget].add_widget(sliders[widget])
        hlayout.add_widget(vlayouts[widget])
        faders.append(pyo.Fader(fadein = 0.5, fadeout = 0.5, dur = 0, mul = 0.25))
        sines.append(pyo.Sine(mul = faders[widget], freq = 300))
        sines[widget].out()
        
    ctx.c.add_widget(hlayout)

    # This function gets called when a slider moves, it sets the pitch of each sine.
    def on_value_change_callback(slider, value):
        sines[slider].freq = value
        
    # When the button is pressed, the fader object performs it's fade.
    def on_press_callback(btn, *largs):
        faders[btn].play()

    # When the button is released, the fader object fades back to 0.
    def on_release_callback(btn, *largs):
        faders[btn].stop()
github compmem / smile / smile / audio.py View on Github external
def _enter(self):
        super(Beep, self)._enter()
        global _got_pyo

        default_init_audio_server()
        self._sound_start_time = None
        self._sound_stop_time = None

        if (self._start_time == self._end_time) or (not _got_pyo):
            self.__fader = None
            self.__sine = None
        else:
            self.__fader = pyo.Fader(fadein=self._fadein,
                                     fadeout=self._fadeout,
                                     mul=self._volume)
            self.__sine = pyo.Sine(freq=self._freq, mul=self.__fader)
            clock.schedule(self._start_sound, event_time=self._start_time)
            if self._end_time is not None:
                clock.schedule(self._stop_sound,
                               event_time=self._end_time-self._fadeout)