How to use the pyo.Sine 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 belangeo / pyo / pyodemos / Metro_demo.py View on Github external
def ex4():
    from pyo import Biquad, Sine, Clean_objects
    print """
Impulse train:

o_ex1 = Metro(time=.005).play()
o_ex2 = Sine(freq=.5, mul=1500, add=2000)
o_ex3 = Biquad(input=o_ex1, freq=o_ex2, q=5, type=0, mul=.5).out()
"""
    o_ex1 = Metro(time=.005).play()
    o_ex2 = Sine(freq=.5, mul=1500, add=2000)
    o_ex3 = Biquad(input=o_ex1, freq=o_ex2, q=5, type=0, mul=.5).out()

    c = Clean_objects(4, o_ex1, o_ex2, o_ex3)
    c.start()
github wehr-lab / autopilot / taskontrol_remnants / plugins / soundclient.py View on Github external
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):
                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)
github belangeo / pyo / pyodemos / Port_demo.py View on Github external
def ex3():
    from pyo import Sine, Clean_objects
    print """
Distortion filter:

o_ex1 = Sine(freq=500, mul=.5)
o_ex2 = Port(o_ex1, risetime=.001, falltime=.01).out()
"""
    o_ex1 = Sine(freq=500, mul=.5)
    o_ex2 = Port(o_ex1, risetime=.001, falltime=.01).out()

    c = Clean_objects(4, o_ex1, o_ex2)
    c.start()
github wehr-lab / autopilot / sound / sounds.py View on Github external
def init_sound(self):
        if self.server_type == 'pyo':
            sin = pyo.Sine(self.frequency, mul=self.amplitude)
            self.table = self.table_wrap(sin)
        elif self.server_type == 'jack':
            self.get_nsamples()
            t = np.arange(self.nsamples)
            self.table = (self.amplitude*np.sin(2*np.pi*self.frequency*t/self.fs)).astype(np.float32)
            #self.table = np.column_stack((self.table, self.table))
            self.chunk()
github tito / pymt / examples / apps / sinemixer / sinemixer.py View on Github external
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 / taskontrol_remnants / plugins / speakercalibration.py View on Github external
def create_sound(soundParams):
    amplitude = soundParams['amplitude']
    if soundParams['type']=='sine':
        soundObjList = [pyo.Sine(freq=soundParams['frequency'],mul=amplitude)]
    if 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)
        soundObjList = []
        for indcomp in range(nTones):
            soundObjList.append(pyo.Sine(freq=freqEachComp[indcomp],mul=amplitude))
    return soundObjList
github belangeo / pyo / pyodemos / Clip_demo.py View on Github external
def ex2():
    from pyo import Sine, Clean_objects
    print """
Frequency clipping:

o_ex1 = Sine(freq=.75, mul=500, add=700)
o_ex2 = Clip(o_ex2, min=400, max=800)
o_ex3 = Sine(freq=o_ex2, mul=.5).out()
"""
    o_ex1 = Sine(freq=.5, mul=500, add=700)
    o_ex2 = Clip(o_ex1, min=400, max=800)
    o_ex3 = Sine(freq=o_ex2, mul=.5).out()
    
    c = Clean_objects(4, o_ex1, o_ex2, o_ex3)
    c.start()
github wehr-lab / autopilot / core / sounds.py View on Github external
def __init__(self, frequency, duration, amplitude=0.01, phase=0, **kwargs):
        # super(Tone, self).__init__()

        self.frequency = float(frequency)
        self.duration = float(duration)
        self.amplitude = float(amplitude)


        sin = pyo.Sine(self.frequency, mul=self.amplitude)
        self.table = TableWrap(sin, self.duration)
github wehr-lab / autopilot / autopilot / stim / sound / sounds.py View on Github external
def init_sound(self):
        """
        Create a sine wave table using pyo or numpy, depending on the server type.
        """

        if self.server_type == 'pyo':
            sin = pyo.Sine(self.frequency, mul=self.amplitude)
            self.table = self.table_wrap(sin)
        elif self.server_type == 'jack':
            self.get_nsamples()
            t = np.arange(self.nsamples)
            self.table = (self.amplitude*np.sin(2*np.pi*self.frequency*t/self.fs)).astype(np.float32)
            #self.table = np.column_stack((self.table, self.table))
            self.chunk()

        self.initialized = True