def __init__(self): self.trig = pyo.Trig() self.envTableList = [(i*8192/15,1./(i+1)) for i in range(16)] self.envTableList[0] = (0,0) # finite attack self.envTable = pyo.CurveTable(self.envTableList) self.env = pyo.TrigEnv(self.trig, table=self.envTable, dur=0.6, mul=[0.,0.]) self.fm = pyo.FM(carrier=[0.,0.], mul=self.env, ratio=1, index=4).out()
def __init__(self): 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=.25) waveform = pyo.SquareTable() self.osc = pyo.Osc(waveform, freq=[0.,0.], mul=self.env[0]) self.output = self.osc.out()
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.6, mul=[0,0]) self.spectrum = [1.]+[0.]*15 # 16 total self.waveform = pyo.HarmTable(self.spectrum) self.osc = pyo.Osc(self.waveform, freq=[0.,0.], mul=self.env) self.filter = pyo.Biquad(self.osc, freq=[300.,300.], type=2, q=2.) self.output = self.filter.out()
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 build(self): self._beat_dur = 60.0 / self.data.bpm self._ticks_per_beat = self._beat_dur * srate self._trig = pyo.Trig() self.pos = pyo.Count(self._trig, min=0, max=int(self._ticks_per_beat), mul=1. / self._ticks_per_beat) self.trigger = pyo.Thresh(self.pos, 0.7, dir=1)
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()
def __init__(self, input, buf_size=SAMPLE_RATE, buffer_count=2, overlap=0): """ Parameters ---------- input : PyoObject Parent PyoObject length : int Number of samples per buffer buffer_count : int Number of buffers used to record (min 2) overlap : int Number of overlapping samples between adjacent buffers """ self.buf_size = buf_size duration = (buf_size - overlap) / SAMPLE_RATE self.last_thread = None self.data_ready = pyo.Trig() self.rec_triggers = [] self.tables = [] self.ends = [] self.overlap = overlap self.overlap_buffer = np.zeros(self.overlap) self.buffer_count = buffer_count self.curr_buf = 0 self.playing = False self.np_buffer = None for i in range(buffer_count): self.rec_triggers.append(pyo.Trig()) self.tables.append(pyo.NewTable(duration)) table_rec = pyo.TrigTableRec(input, self.rec_triggers[i], self.tables[i]) self.ends.append(pyo.TrigFunc(table_rec['trig'], self._table_full)) self._base_objs = self.data_ready.getBaseObjects() self._trig_objs = self._base_objs
def __init__( self, modules: tuple, ): # init private attributes self._cues = [] self._modules = tuple(modules) self._current_active_cue = None self._current_potential_cue = 0 # init trigger self._new_cue_trigger = pyo.Trig() self._stop_cue_trigger = pyo.Trig() self._changed_potential_cue_trigger = pyo.Trig() # add korg nano control support self._add_thresh_button("previous", self.previous_cue) self._add_thresh_button("next", self.next_cue) self._add_thresh_button("play", self.play) self._add_thresh_button("stop", self.stop) # init logger self._active_module_logger = loclog.ModuleLogger(self) self._cue_logger = loclog.CueLogger(self)
def __init__(self) -> None: self.fader = pyo.Fader(fadein=0.005, fadeout=self._fadeout_time) self.trigger1 = pyo.Trig() self._mul = self.max_vol self.spatialisation = [[pyo.Sig(0) for _ in range(4)] for _ in range(2)] self.table_reads = [ pyo.TableRead( table, freq=table.getRate(), ) for table in self.snd_tables[0] ] self.processed_tables = [ pyo.ButLP(table_read, freq=6000) for table_read in self.table_reads ] self.spatialised_tables = [ pyo.Mix(signal, voices=4, mul=[self.fader * spat_value for spat_value in spat]) for signal, spat in zip(self.processed_tables, self.spatialisation) ] self.generator = self.spatialised_tables[0] + self.spatialised_tables[1]
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()
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()
def __init__(self, server: pyo.Server, midi_data_logger): self.midi_data_logger = midi_data_logger self.server = server self.previous_hauptstimme_instrument = set([]) self.instrument_change_trigger = pyo.Trig() self.pianoteq_trigger = pyo.Trig() self.sine_mixer = pyo.Mixer(outs=3, chnls=1, mul=0.3) self.sine_radio_mixer = pyo.Mixer(outs=4, chnls=1, mul=0.3) self.gong_mixer = pyo.Mixer(outs=4, chnls=1, time=0.05, mul=1) self.transducer_synth = TransducerSynth( self._n_voices_for_transducer_synth) self.gong_synth = GongSynth(self._n_voices_for_gong_synth) self.kenong_synth = KenongSynth(self._n_voices_for_kenong_synth) self.pitch_stack = PitchStack() # sending transducer outputs to sine mixer & sine radio mixer for n in range(3): signal = self.transducer_synth.mixer[0][n] self.sine_mixer.addInput(n, signal) self.sine_mixer.setAmp(n, n, 1) self.sine_radio_mixer.addInput(n, signal) for m in range(4): # TODO(which amp?) self.sine_mixer.setAmp(n, m, 1) self.sine_radio_mixer.setAmp(n, m, 1) # sending gong outputs and kenong outputs to gong mixer for n, mixer in enumerate( (self.kenong_synth.mixer, self.gong_synth.mixer)): added = 4 * n for n in range(4): signal = mixer[0][n] self.gong_mixer.addInput(n + added, signal) self.gong_mixer.setAmp(n + added, n, 1) # sending all transducer and gong inputs out for mixer, mixer2channel_mapping in ( (self.sine_mixer, settings.SINE_MIXER_INSTRUMENT2CHANNEL_MAPPING), ( self.sine_radio_mixer, settings.SINE_TO_RADIO_MIXER_INSTRUMENT2CHANNEL_MAPPING, ), (self.gong_mixer, settings.GONG_MIXER2CHANNEL_MAPPING), ): [mixer[i][0].play() for i in mixer2channel_mapping.values()] self.notes = pyo.Notein( poly=self._n_voices, last=self._last_midi_note, channel=0, ) self.trigger_on = pyo.TrigFunc( self.notes["trigon"], self._trigger_on_function, arg=list(range(self._n_voices)), ) self.trigger_off = pyo.TrigFunc( self.notes["trigoff"], self._trigger_off_function, arg=list(range(self._n_voices)), ) self.sustain_pedal = pyo.Midictl( settings.KEYBOARD_PEDAL_CTRL_NUMBER, 0, 1, init=0, channel=settings.KEYBOARD_CHANNEL, )
def __init__(self, master=None, experiment=[], logger=None): ########################### # INIT EXPERIMENT ########################### self.experiment=experiment ########################### # INIT LOGGING ########################### self.logger=logger self.currentTrial = 0 self.currentBlock = 0 self.blockType = 0 self.mouse = 0 ########################### # INIT TIMING ########################### #self.t = timr(1, self.runexperiment) #placeholder to make sure the variable exists self.timers = [] ########################### # INIT VISUAL ########################### self.waitForRatingAnswer = False self.waitForRatingAnswer2 = False self.numRects = 4 self.rects=range(self.numRects) self.screenWidth = 640 self.screenHeight = 480 Frame.__init__(self,master) self.grid() self.userPrompt = StringVar() # moved these up here so they only happen once pianoimage = Image.open(KEYBOARD_IMAGE) self.pianoImage = ImageTk.PhotoImage(pianoimage) sliderimage = Image.open(SLIDER_IMAGE) self.sliderImage = ImageTk.PhotoImage(sliderimage) self.fingerString = StringVar() self.qString = StringVar() self.countString = StringVar() self.create_GUI() ########################### # INIT AUDI ########################### self.s = pyo.Server(buffersize = 8, nchnls = 1) # before booting the server, I'll prompt the user to choose an input device # NOTE: This can be hard-coded later if you always want it to choose a specific MIDI input device # pyo.pm_list_devices() # self.choice = input("Which device will you choose?") # self.s.setMidiInputDevice(int(self.choice)) self.s.setMidiInputDevice(int(3)) self.s.boot() self.s.start() # test = pyo.LFO(freq=440.0).out() time.sleep(1) # settling time # test.stop() # MIDI Stuff self.refnote = 72 self.polynum = 4 self.pianosound = range(self.polynum) self.notes = pyo.Notein(poly=self.polynum, scale=0, mul=0.5) self.enablePlayback = False self.enableNoteLogging = False self.noteTrig = pyo.TrigFunc(self.notes['trigon'],self.onNoteon,range(self.polynum)) #for p in range(polynum): # note trigger mixer self.trigmix = pyo.Mixer(1,self.polynum) for p in range(self.polynum): self.trigmix.addInput(p,self.notes['trigon'][p]) self.trigmix.setAmp(p,0,1.0) self.polyNoteTrig = self.trigmix[0] global midikeymapping # needs to be visible everywhere midikeymapping = 1 # set mapping to 1 to start with # preload sound files self.melodies = [] self.extract = [] for i in range(self.polynum): self.pianosound[i] = pyo.SfPlayer(EXTRACT_DIR + PIANO_FILE[0], speed=1, loop=False, offset=0, interp=2, mul=1, add=0) for fname in STIM_FILES: self.melodies.append(pyo.SfPlayer(STIM_DIR + fname, mul=0.5)) for fname in EXTRACT_FILES: self.extract.append(pyo.SfPlayer(EXTRACT_DIR + fname, mul=0.5)) self.metronome = pyo.SfPlayer(EXTRACT_DIR + METRO_FILE[0], mul=0.5) # prepare sequence and timing triggers # metroSeq launches the metronome self.trialMetroSeq = pyo.Seq(time=NOTEDUR/1000.0, seq=[3,3,3,1], poly=1, onlyonce=True, speed=1) self.expectedKeySeq = pyo.Seq(time=NOTEDUR/1000.0, seq=[9,1,1,1,1], poly=1, onlyonce=True, speed=1) # trialStartTrigger will be manually launched when we want to start a trial self.trialStartTrigger = pyo.Trig().stop() self.warmuptrialStartTrigger = pyo.Trig().stop() self.dummyTrigger = pyo.Trig().stop() self.timerLogsEnabled = False # eventTimer will measure the time between trial events # eventTimer is initially triggered by the trial start, but will later be switched to measure between note events self.trialEventTimer = pyo.Timer(self.polyNoteTrig,self.trialStartTrigger) self.expectedEventTimer = pyo.Timer(self.expectedKeySeq,self.expectedKeySeq) self.timerMeasurement = pyo.DataTable(1) self.lastTimerMeasurement = 0.0 self.expectedMeasurement = pyo.DataTable(1) self.lastExpectedMeasurement = 0.0 self.measurementRecorder = pyo.TablePut(self.trialEventTimer, self.timerMeasurement).play() self.expectedRecorder = pyo.TablePut(self.expectedEventTimer, self.expectedMeasurement).play() self.resetAtStim = False # triggers for the optimized stim delivery self.t1 = pyo.TrigFunc(self.trialStartTrigger,self.playAudioExtract) self.t2 = pyo.TrigFunc(self.trialStartTrigger,self.trialMetroSeq.out) self.t2b = pyo.TrigFunc(self.trialStartTrigger,self.expectedKeySeq.out) self.t3 = pyo.TrigFunc(self.trialMetroSeq,self.playMetronome) # self.t3 = pyo.TrigFunc(self.trialMetroSeq,self.metronome.out) self.t4 = pyo.TrigFunc(self.polyNoteTrig,self.noteTiming) self.t5 = pyo.TrigFunc(self.expectedKeySeq,self.expectedTiming) # triggers for the optimized stim delivery in training #self.t1 = pyo.TrigFunc(self.warmuptrialStartTrigger,self.playAudioExtract) self.t6 = pyo.TrigFunc(self.warmuptrialStartTrigger,self.trialMetroSeq.out) self.t7 = pyo.TrigFunc(self.warmuptrialStartTrigger,self.expectedKeySeq.out) # self.t3 = pyo.TrigFunc(self.trialMetroSeq,self.playMetronome) # self.t3 = pyo.TrigFunc(self.trialMetroSeq,self.metronome.out) # self.t4 = pyo.TrigFunc(self.notes['trigon'],self.noteTiming) # self.t5 = pyo.TrigFunc(self.expectedKeySeq,self.expectedTiming) ########################### # INIT INPUT DEVICES ########################### self.set_keybinds() self.waitForSpacebar = True ############################ self.enableAudioFeedback = False self.QUIT = False self.pause = False