Beispiel #1
0
 def __init__(self):
     self.time_var = 20
     self.fade = pyo.Fader(fadein=0.005, fadeout=10, dur=20).play()
     self.amp = pyo.SigTo(value=self.fade, time=0, init=0.0)
     self.freq = pyo.SigTo(2200, time=7, mul=[1, 1.005], init=2200)
     self.sig = pyo.RCOsc([self.freq, self.freq - 20],
                          sharp=4,
                          mul=self.amp).out()
     self.freq.setValue(60)
     self.n = pyo.Noise()
     self.pan_lfo = pyo.Sine(freq=1, mul=.5, add=.5)
     self.fade2 = pyo.Fader(fadein=10, fadeout=10, dur=50).play()
     self.lfo1 = pyo.Sine(freq=.1, mul=500, add=1000)
     self.lfo2 = pyo.Sine(freq=.4).range(2, 8)
     self.bp1 = pyo.ButBP(self.n,
                          freq=self.lfo1,
                          q=self.lfo2,
                          mul=self.fade2)
     self.pan = pyo.SPan(self.bp1, outs=2, pan=self.pan_lfo).out()
     self.fader3 = pyo.Fader(fadein=0.01, fadeout=5, dur=5, mul=3).play()
     self.lfd = pyo.Sine([.4, .3], mul=.2, add=.5)
     self.sawer = pyo.SuperSaw(freq=[49, 50],
                               detune=[self.lfd, self.lfd + 10],
                               bal=0.7,
                               mul=self.fader3).out()
     time.sleep(50)
Beispiel #2
0
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
Beispiel #3
0
 def __init__(self):
     self.fader = pyo.Fader(fadein=0.5, fadeout=0.5)
     self.lfoo0 = pyo.LFO(freq=0.01, mul=1, type=3)
     self.lfoo1 = pyo.Sine(freq=0.02, mul=1)
     self.lfo = pyo.Sine(freq=self.lfoo0 + self.lfoo1, mul=1)
     self.generator = pyo.SineLoop(freq=100,
                                   feedback=0.015 +
                                   ((1 + self.lfo) * 0.025),
                                   mul=[self.fader, 0, 0])
     self.generator.stop()
     self.stop()
     self._mul = self.max_vol
     self._mul_setter = pyo.Trig()
Beispiel #4
0
def Tone(frequency, duration, amplitude=0.3, phase=0, **kwargs):
    '''
    The Humble Sine Wave
    '''
    sin = pyo.Sine(frequency, mul=amplitude)
    tableout = TableWrap(sin, duration)
    return tableout
Beispiel #5
0
    def _pyo_play(self):
        """
        TODO: document
        """

        # Making sure we have a clean server
        if self.server.getIsBooted():
            self.server.shutdown()

        self.server.boot()
        self.server.start()

        # Getting data ready
        duration = self.data.meta["asf_note_duration"]
        pitches = np.repeat(self.data["asf_pitch"], 2)
        delays = np.repeat(self.data["asf_onsets"], 2)

        # TODO: This doesn't seem like the best way to do this, but I don't know
        # how to make it better
        env = pyo.Linseg(list=[(0, 0), (0.01, 1), (duration - 0.1, 1),
                               (duration - 0.05, 0.5), (duration - 0.005, 0)],
                         mul=[.1 for i in range(len(pitches))
                              ]).play(delay=list(delays), dur=duration)

        self.streams = pyo.Sine(list(pitches), 0, env).out(delay=list(delays),
                                                           dur=duration)
Beispiel #6
0
    def _pyo_write(self, filepath):
        """
        TODO: document
        """

        # Getting data ready
        duration = self.data.meta["asf_note_duration"]
        pitches = np.repeat(self.data["asf_pitch"], 2)
        delays = np.repeat(self.data["asf_onsets"], 2)

        # Making sure we have a clean server
        if self.server.getIsBooted():
            self.server.shutdown()

        self.server.reinit(audio="offline")
        self.server.boot()
        self.server.recordOptions(dur=delays[-1] + duration, filename=filepath)

        env = pyo.Linseg(list=[(0, 0), (0.1, 1), (duration - 0.1, 1),
                               (duration - 0.05, 0.5), (duration - 0.005, 0)],
                         mul=[0.05 for i in range(len(pitches))
                              ]).play(delay=list(delays), dur=duration)
        sine = pyo.Sine(list(pitches), 0, env).out(delay=list(delays),
                                                   dur=duration)
        self.server.start()

        # Clean up
        self.server.shutdown()
        self.server.reinit(audio="portaudio")
Beispiel #7
0
def panMove(snd0, snd1, fil, nch, mult):
    if snd0.isPlaying() == True:
        pass
    else:
        snd0.play()
        snd1.play()
        ff = float(1 / po.sndinfo(fil)[1] / 4)
        sin = po.Sine(freq=ff, phase=0)
        cos = po.Sine(freq=ff, phase=0.25)
        ini = np.random.randint(0, nch)
        step = np.random.randint(0, int(nch / 2) + 1)
        end = (ini + step) % nch
        snd0.out(ini, 0).setMul(mult * cos)
        snd1.out(end, 0).setMul(mult * sin)
        snd0.stop(wait=po.sndinfo(fil)[1])
        snd1.stop(wait=po.sndinfo(fil)[1])
Beispiel #8
0
    def write(self, filepath):
        """
        Save data sonification to the given file. 
        Currently the only output option is a wav file.

        Parameters
        ----------
        filepath : str
            The path to the output file.
        """

        # Getting data ready
        duration = self.data.meta["asf_note_duration"]
        pitches = np.repeat(self.data["asf_pitch"], 2)
        delays = np.repeat(self.data["asf_onsets"], 2)

        # Making sure we have a clean server
        if self.server.getIsBooted():
            self.server.shutdown()

        self.server.reinit(audio="offline")
        self.server.boot()
        self.server.recordOptions(dur=delays[-1] + duration, filename=filepath)

        env = pyo.Linseg(list=[(0, 0), (0.1, 1), (duration - 0.1, 1),
                               (duration - 0.05, 0.5), (duration - 0.005, 0)],
                         mul=[self.gain for i in range(len(pitches))
                              ]).play(delay=list(delays), dur=duration)
        sine = pyo.Sine(list(pitches), 0, env).out(delay=list(delays),
                                                   dur=duration)
        self.server.start()

        # Clean up
        self.server.shutdown()
        self.server.reinit(audio="portaudio")
Beispiel #9
0
    def __init__(self, chain):
        self.chain = chain

        self.pitch = pyo.Sig(0)
        self.vol = pyo.Sig(0)
        self.env = pyo.Adsr()

        self.sine = pyo.Sine(self.pitch, mul=self.vol * self.vol)
Beispiel #10
0
 def __init__(self, freq=500):
     self.trig = pyo.Trig()
     self.decayTable = pyo.ExpTable([(0,1),(8191,0.001)], exp=5, inverse=False)
     self.growthTable = pyo.ExpTable([(0,freq),(8191,2*freq)], exp=5, inverse=True)
     self.env = pyo.TrigEnv(self.trig, table=self.decayTable, dur=0.1, mul=0).mix(2)
     self.sweep = pyo.TrigEnv(self.trig, table=self.growthTable, dur=0.1)
     self.sin = pyo.Sine(freq=self.sweep, mul=self.env)
     #self.output = pyo.Delay(self.sin, delay=0.1, feedback=0.5).out()
     self.output = pyo.Freeverb(self.sin, size=[.79,.8], damp=.9, bal=.3).out()
def my_overtone_synth(fundemental_freq):
    ''' plays the decaying overtone series of the fundemental freqeuncy'''
    num_overtones = 10
    amps = [1 / n for n in range(1, num_overtones)]
    freqs = [fundemental_freq * n for n in range(1, num_overtones)]
    signal = []
    for n in range(num_overtones - 1):
        b = pyo.Sine([freqs[n]], mul=amps[n])
        signal += [pyo.Pan(b, outs=2, pan=.5).out()]  # panning to both sides
    return signal
Beispiel #12
0
    def __init__(self, **config):
        super(BinauralBeat, self).__init__(**config)

        self.server = pyo.Server(buffersize=1024).boot()
        centerFreq = pyo.Sig(256)
        binauralFreq = pyo.Sine(freq=0.05, add=10.5, mul=1.5)

        left = pyo.Sine(freq=centerFreq - binauralFreq / 2)
        right = pyo.Sine(freq=centerFreq + binauralFreq / 2)
        left.out(chnl=0)
        right.out(chnl=1)

        #left = pyo.PinkNoise().mix(2).out()

        import thread
        thread.start_new_thread(self.server.start, ())

        self.left = left
        self.right = right
Beispiel #13
0
    def render(self):
        s = pyo.Server(audio="offline")
        s.boot()

        sndinfo = pyo.sndinfo(self.path)
        s.recordOptions(filename=self.complete_output_path, dur=sndinfo[1])

        source = pyo.SfPlayer(self.path)
        source_envelope = pyo.Expseg(list(
            zip(self.source_envelope.times, self.source_envelope.levels)),
                                     exp=5)
        waveguide_envelope = pyo.Expseg(
            list(
                zip(self.waveguide_envelope.times,
                    self.waveguide_envelope.levels)),
            exp=5,
        )
        filter_envelope = pyo.Expseg(
            list(zip(self.filter_envelope.times, self.filter_envelope.levels)),
            exp=5,
        )
        filter_q_envelope = pyo.Linseg(
            list(
                zip(self.filter_q_envelope.times,
                    self.filter_q_envelope.levels)))

        waveguide = pyo.Waveguide(
            source,
            freq=self.frequencies,
            minfreq=self.minfreq,
            mul=self.waveguide_mul,
            dur=self.waveguide_dur,
        )
        bandpass = pyo.Resonx(
            waveguide,
            self.frequencies,
            q=filter_q_envelope,
            stages=4,
            mul=self.bandpass_mul,
        )

        lfo = pyo.Sine(freq=self.pan_lfo_frequency, mul=0.5, add=0.5)
        bandpass_pan = pyo.Pan(bandpass, outs=2, pan=lfo)

        filter_q_envelope.play()
        filter_envelope.play()
        source_envelope.play()
        waveguide_envelope.play()

        (bandpass_pan * filter_envelope).out()
        (waveguide * waveguide_envelope).out()
        (source * source_envelope).out()

        s.start()
Beispiel #14
0
def simple_sine(delay, note, amp, dur=1.):

    # -- Nice, angelic --
    env = pyo.Adsr(attack=dur * 0.1,
                   sustain=0.707,
                   decay=0.1 * dur,
                   release=dur * 0.5,
                   dur=dur * 0.9,
                   mul=amp).play(delay=delay, dur=2.5 * dur)
    osc = pyo.Sine(freq=pyo.midiToHz(note), mul=env).mix(1)
    osc.out(delay=delay, dur=dur)

    return osc, env
Beispiel #15
0
    def _enter(self):
        if _pyo_server is None:
            # try and init it with defaults
            # print some warning
            init_audio_server()

        # process the vars
        self.duration = val(self.dur)
        self._fader = pyo.Fader(fadein=val(self.fadein),
                                fadeout=val(self.fadeout),
                                dur=self.duration,
                                mul=val(self.volume))
        self._sine = pyo.Sine(freq=val(self.freq), mul=self._fader).out()
Beispiel #16
0
 def _enter(self):
     super(Beep, self)._enter()
     default_init_audio_server()
     self._sound_start_time = None
     if self._start_time == self._end_time:
         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)
Beispiel #17
0
    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
Beispiel #18
0
    def __init__(self, sequence, amp=1, pan=0.5):
        BaseSynth.__init__(self, sequence, amp, pan)
        self.env = pyo.CosTable([(0,0.0000),(353,1.0000),(4166,0.6528),(8000,0.0000)])
        self.env_reader = pyo.TrigEnv(self.trig, self.env, dur=pyo.Max(self.dur, comp=0.3125))
        self.sine_freqs = []
        for i in range(-1,1):
            self.sine_freqs.extend([self.freq*(1+0.001*i), self.freq*2*(1+0.002*i), self.freq*3*(1+0.002*i),self.freq*5*(1+0.002*i)])

        self.osc = pyo.Sine(freq=self.sine_freqs, mul=[self.env_reader, self.env_reader*0.2, self.env_reader*0.2, self.env_reader*0.1]*3)

        self.trans_env = pyo.CosTable([(0,0.0000),(123,0.0777),(812,0.0570),(2083,0.0052),(8000,0.0000)])
        self.trans_env_reader = pyo.TrigEnv(self.trig, self.trans_env, dur=0.25)
        self.trans = pyo.Noise(mul=self.trans_env_reader)
        self.trans_filter = pyo.Biquad(self.trans, freq=1690)
        self.trans_resonator = pyo.Biquad(self.trans_filter, q=31, freq=self.freq*4)
        self.panner = pyo.Pan((self.trans_resonator+self.osc).mix(0), mul=(0.1)*self.master_amp, pan=self.master_pan)
        self.last_audio_object = self.panner
Beispiel #19
0
    def __init__(self, sequence, amp=1, pan=0.5):
        BaseSynth.__init__(self, sequence, amp, pan)
        self.env = pyo.CosTable([(0,0.0000),(123,0.9896),(2701,0.4870),(6479,0.2746),(8192,0.0000)])
        self.env_reader = pyo.TrigEnv(self.trig, self.env, dur=pyo.Max(self.dur, comp=0.3125))
        sine_freqs = []
        for i in range(-1,1):
            freqs = [self.freq*j*(1+0.008*i) for j in range(1,8)]
            sine_freqs.extend(freqs)
        harm_amps = [1,0.3,0.4,0.2,0.1,0.04,0.04,0.03,0.02]
        self.osc = pyo.Sine(freq=sine_freqs, mul=[self.env_reader*harm_amps[i] for i in range(8)])

        self.trans_env = pyo.ExpTable([(0,0.3938),(8192,0.0000)])
        self.trans_env_reader = pyo.TrigEnv(self.trig, self.trans_env, dur=0.25)
        self.trans = pyo.Noise(mul=self.trans_env_reader)
        self.trans_filter = pyo.Biquad(self.trans, freq=1690)
        self.trans_resonator = pyo.Delay(pyo.Denorm(self.trans_filter), feedback=0.90, delay=(self.freq**-1))
        self.chorus = pyo.Chorus(self.trans_resonator, depth=0.13, feedback=0.84)
        self.master_filter = pyo.Biquad((self.chorus+self.osc).mix(0), freq=3900)
        self.panner = pyo.Pan(self.master_filter, mul=(0.1)*self.master_amp, pan=self.master_pan)
        self.last_audio_object = self.panner
Beispiel #20
0
    subprocess.run("qjackctl -a patchbay-new.xml -s &", shell=True)
    time.sleep(0.5)

    SERVER = pyo.Server(
        audio="jack",
        midi="jack",
        nchnls=N_CHANNELS,
    )

    # starting server
    SERVER.boot()

    # starting sound loop
    _speaker_cycle = itertools.cycle(range(INCREMENT, N_CHANNELS + INCREMENT))

    ALLOWED_TYPES = {"noise": pyo.Noise(), "sine": pyo.Sine(freq=400)}
    try:
        SIGNAL = ALLOWED_TYPES[TYPE]
    except KeyError:
        msg = "Unknown type '{}'. Valid types would be '{}'.".format(
            TYPE, ALLOWED_TYPES)
        raise NotImplementedError(msg)

    FADER = pyo.Fader(fadein=0.07, fadeout=0.07, dur=TIME, mul=MUL)
    SIGNAL.mul = FADER

    # red & bold printing
    print(
        "\033[91m",
        "\033[1m",
        "\n",
Beispiel #21
0
 def create_sound(self, soundParams):
     '''
     NOTE: This methods needs to return both the soundObj and soundwaveObj to be able to
     play the sound form elsewhere. If soundwaveObj is not returned, it will not exist
     outside this scope, and the pyo server plays nothing on soundObj.play()
     '''
     if isinstance(soundParams['amplitude'], list) or isinstance(
             soundParams['amplitude'], np.ndarray):
         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=float(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=float(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)
         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'] == 'tone_AM':
         if isinstance(soundAmp, list):
             halfAmp = [0.5 * x for x in soundAmp]
         else:
             halfAmp = 0.5 * soundAmp
         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) if nTones > 1 else [centerFreq]
         envelope = pyo.Sine(freq=soundParams['modRate'],
                             mul=halfAmp,
                             add=halfAmp,
                             phase=0.75)
         soundObj = pyo.Fader(fadein=self.risetime,
                              fadeout=self.falltime,
                              dur=soundParams['duration'],
                              mul=envelope)
         soundwaveObjs = []
         for indcomp in range(nTones):
             soundwaveObjs.append(
                 pyo.Sine(freq=float(freqEachComp[indcomp]),
                          mul=soundObj).out())
         return (soundObj, [envelope, soundwaveObjs])
     elif soundParams['type'] == 'band':
         frequency = soundParams['frequency']
         octaves = soundParams['octaves']
         freqhigh = frequency * np.power(2, octaves / 2)
         freqlow = frequency / np.power(2, octaves / 2)
         soundObj = pyo.Fader(fadein=self.risetime,
                              fadeout=self.falltime,
                              dur=soundParams['duration'],
                              mul=soundAmp)
         freqcent = (freqhigh + freqlow) / 2
         bandwidth = freqhigh - freqlow
         n = pyo.Noise(mul=soundObj)
         soundwaveObj = pyo.IRWinSinc(n,
                                      freq=freqcent,
                                      bw=bandwidth,
                                      type=3,
                                      order=400).out()
         return (soundObj, soundwaveObj)
     elif soundParams['type'] == 'band_AM':
         if isinstance(soundAmp, list):
             halfAmp = [0.5 * x for x in soundAmp]
         else:
             halfAmp = 0.5 * soundAmp
         frequency = soundParams['frequency']
         octaves = soundParams['octaves']
         freqhigh = frequency * np.power(2, octaves / 2)
         freqlow = frequency / np.power(2, octaves / 2)
         envelope = pyo.Sine(freq=soundParams['modRate'],
                             mul=halfAmp,
                             add=halfAmp,
                             phase=0.75)
         soundObj = pyo.Fader(fadein=self.risetime,
                              fadeout=self.falltime,
                              dur=soundParams['duration'],
                              mul=envelope)
         freqcent = (freqhigh + freqlow) / 2
         bandwidth = freqhigh - freqlow
         n = pyo.Noise(mul=soundObj)
         soundwaveObj = pyo.IRWinSinc(n,
                                      freq=freqcent,
                                      bw=bandwidth,
                                      type=3,
                                      order=400).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:
             duration = tableObj.getDur()
         if soundParams.get('channel') == 'left':
             fs = [samplingFreq, 0]
         elif soundParams.get('channel') == 'right':
             fs = [0, samplingFreq]
         else:
             fs = 2 * [samplingFreq]
         soundObj = pyo.Fader(fadein=self.risetime,
                              fadeout=self.falltime,
                              dur=duration,
                              mul=soundAmp)
         print duration
         print fs
         soundwaveObj = pyo.Osc(table=tableObj, freq=fs, mul=soundObj).out()
         return (soundObj, soundwaveObj)
     else:
         raise TypeError(
             'Sound type "{0}" has not been implemented.'.format(
                 soundParams['type']))
        20000,
    )
    frequencies = tuple(b - a for a, b in zip(frequencies, frequencies[1:]))
    k50fl_specification = expenvelope.Envelope.from_levels_and_durations(
        levels, frequencies)

    converter = LoudnessToAmplitudeConverter(2)

    server = pyo.Server(audio="jack").boot().start()
    dur = 0.4
    sleep = 0.11

    fifths = list(range(8))
    random.seed(100)
    random.shuffle(fifths)

    for fifth in fifths:
        frequency = 100 * ((15 / 8)**fifth)
        if STATIC:
            amp = 0.03
        else:
            amp = converter.convert(frequency)

        print(frequency, amp)

        f = pyo.Fader(mul=amp, fadeout=0.01, dur=dur)

        sine = pyo.Sine(freq=frequency, mul=f).out(dur=dur)
        f.play()
        time.sleep(dur + sleep)
Beispiel #23
0
 def __init__(self, freq):
     SineInst.__init__(self, freq)
     self.sine = pyo.Sine(freq=[freq * (x + 1) for x in range(10)],
                          mul=self.volmod).out()
Beispiel #24
0
 def __init__(self, freq):
     self.volmod = LiveAdsr(att=.1, dec=.2, sus=.6, rel=.5, mul=.25)
     self.sine = pyo.Sine(freq=freq, mul=self.volmod).out()
Beispiel #25
0
 def __init__(self):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0,0), (100, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.3, mul=.25)
    self.osc = pyo.Sine(freq=[0.,0.], mul=self.env[0])
    self.output = self.osc.out()
Beispiel #26
0
# Run this the first time
if 1:
    ss = pyo.Server(audio="offline")
    ss.boot()

duration = 2.0
octaves = 0.5
soundAmp = 0.3
modRate = 10
centerFreq = 2000

freqhigh = centerFreq * np.power(2, octaves / 2)
freqlow = centerFreq / np.power(2, octaves / 2)
envelope = pyo.Sine(freq=modRate,
                    mul=soundAmp / 2,
                    add=soundAmp / 2,
                    phase=0.75)
soundObj = pyo.Fader(fadein=0.002, fadeout=0.002, dur=duration, mul=envelope)
freqcent = float((freqhigh + freqlow) / 2)
bandwidth = float(freqhigh - freqlow)

n = pyo.Noise(mul=soundObj)
soundwaveObj = pyo.IRWinSinc(n, freq=freqcent, bw=bandwidth, type=3,
                             order=400).out()
#soundwaveObj = pyo.IRWinSinc(n, freq=centerFreq, bw=centerFreq, type=3, order=400).out()

# -- Set recording parameters --
soundFilename = '/home/jarauser/workspace/sounds/{0}octaves.wav'.format(
    octaves)
ss.recordOptions(dur=duration,
                 filename=soundFilename,
Beispiel #27
0
            depth += 0.1
        x_count += 1
    elif y_button:
        if y_count % 30 == 0 and depth > 0:
            depth -= 0.1
        y_count += 1

    if a_button:
        if a_count % 30 == 0 and feedback < 1:
            feedback += 0.05
        a_count += 1
    elif b_button:
        if b_count % 30 == 0 and feedback > 0:
            feedback -= 0.05
        b_count += 1

    if L_button:
        if L_count % 30 == 0 and balance > 0:
            balance -= 0.05
        L_count += 1
    elif R_button:
        if R_count % 30 == 0 and balance < 1:
            balance += 0.05
        R_count += 1

    # Execution Section
    lfo = pyo.Sine(freq=1000, phase=.5, mul=.5, add=.3)
    delay = pyo.Delay(audioIn, delay=delay, feedback=lfo, maxdelay=3).out()

    clock.tick(60)
pygame.quit()
Beispiel #28
0
 def __init__(self, freq):
     SineInst.__init__(self, freq)
     self.sine = pyo.Sine(freq=[freq, freq * (2**(1 / 2))],
                          mul=self.volmod).out()
Beispiel #29
0
            if self.envArChR[i] == 1:
                self.lenlis.append(i)
        for i in range(len(self.lenlis) - 1):
            x = self.lenlis[i + 1] - self.lenlis[i]
            self.lenlis[i] = x
        return np.asarray(self.lenlis)

    def randGate(self):
        self.randGateAr = np.zeros(self.getChange().size)
        self.periodChoice = self.getPeriod()
        for i in range(self.periodChoice.size):
            i = np.random.choice(self.periodChoice)
            self.randGateAr[i] = 1
        return self.randGateAr

    def setGate(self, gate):
        self.gate = gate
        self.getChange()


if __name__ == "__main__":
    s = pyo.Server().boot()

    algo = HistAmp()
    #algo.setMode(LiveIn())
    #algo.setDur(5)
    algo.out()

    osc = pyo.Sine(400, mul=algo.amp()).out()

    s.gui(locals())
Beispiel #30
0
 def __init__(self, freq):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.6, mul=0.2)
    self.osc = pyo.Sine(freq=freq, mul=self.env).mix(2)
    self.output = self.osc.out()