Source: http://www.matthieuamiguet.ch/blog/diy-guitar-effects-python ''' import pyo import time, sys import subprocess # # https://github.com/belangeo/pyo/blob/master/pyo/lib/server.py # pyo.pa_list_devices() # list all audio devices # sys.exit() s = pyo.Server() s.setInputDevice(4) s.setOutputDevice(4) s.boot() s.start() time.sleep(1) # make sure server is booted # print('s.getNchnls() = %s' % s.getNchnls()) a1 = pyo.Input() p1 = pyo.Pan(a1) #.out() d1 = pyo.Disto(p1, drive=0.25).out() # a2 = pyo.Input(chnl=0) # p2 = pyo.Pan(a2).out(chnl=1)
sock.send(bytes(prefix, "utf8")+msg) # BELOW HERE are the global variables clients = {} addresses = {} # Set only HOST and PORT according to your wifi/lan + Client settings # HOST = '127.0.0.1' # print(getfqdn()) # HOST = gethostbyname(getfqdn()) HOST = gethostbyname("") PORT = 33000 BUFSIZ = 1024 ADDR = (HOST, PORT) SERVER = socket(AF_INET, SOCK_STREAM) SERVER.bind(ADDR) if __name__ == "__main__": SERVER.listen(5) print("Waiting for connection...") print(HOST) # Start main track here s = pyo.Server(sr=48000, nchnls=8, buffersize=512, duplex=1).boot() s.start() ACCEPT_THREAD = Thread(target=accept_incoming_connections) ACCEPT_THREAD.start() ACCEPT_THREAD.join() SERVER.close() s.stop() s.shutdown()
def initialize_sound(self): s = pyo.Server(audio='jack').boot() #s = pyo.Server().boot() s.start() return s
import pyo import os import numpy as np # Run this the first time if 1: ss = pyo.Server(audio="offline") ss.boot() # make a fader duration = 2.0 soundAmp = [0.2, 0.2] ### One way of doing it halfAmp = [x * 0.5 for x in soundAmp] envelope = pyo.Sine(freq=5, mul=halfAmp, add=halfAmp, phase=0.75) soundObj = pyo.Fader(fadein=0.002, fadeout=0.002, dur=duration, mul=envelope) # Make 2 sounds, out to diff channels, mul by the fader a = pyo.Noise(mul=soundObj).out() # b = pyo.Sine(freq=2000, mul=soundObj).out(chnl=1) # play the fader. # -- Set recording parameters -- soundFilename = '/tmp/test.wav' ss.recordOptions(dur=duration, filename=soundFilename, fileformat=0,
import pyo s = pyo.Server(audio="portaudio",nchnls=1).boot() s.start() a = pyo.Input(chnl=0) # disto = pyo.Disto(a, drive=.75, slope=.5).out() chorus = pyo.Chorus(a, depth=.9, feedback=.8, bal=.5).out() delay = pyo.Delay(a, delay=0, feedback=.5) chorustwo = pyo.Chorus(delay, depth=.5, feedback=.3, bal=.5).out() lfo = pyo.Sine(freq=.5,phase=.5,mul=.5,add=.3) delaytwo = pyo.Delay(a, delay=.05,feedback=lfo,maxdelay=3).out() # output = pyo.Tone(a, freq=5000).out() s.gui() # combine this with the controller input detector with pygame # use those button inputs to trigger guitar effects # and they can start and stop loops # functions and shit
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
def __new__(cls): if PyoServer.__server is None: PyoServer.__server = pyo.Server() PyoServer.__server.setOutputDevice(0) PyoServer.__server.boot() return PyoServer.__server
import pyo #importing the library from pyo import Tone #importing the low frequency filter from pyo import Atone #importing the high frequency filter s = pyo.Server().boot() #declaring the server variable s.start() #Starting the Pyo Server i = pyo.Input() #declaring the input low_filter = Tone(i, freq=280, mul=1, add=0) #setting the lowest frequency to 280 Hz high_filter = Atone(low_filter, freq=4000, mul=1, add=0).out() #setting the highest fre to 4000 Hz #source: http://ajaxsoundstudio.com/pyodoc/api/classes/filters.html