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
from time import sleep import pyo import json import redis with open('config.json', 'r') as fp: config = json.load(fp) r = redis.Redis(host='localhost', port=6379, db=0) server = pyo.Server().boot() sf = pyo.SfPlayer("zoomsamples/lastdrop.wav", loop=True) ch = pyo.Chorus(sf).out() hr = pyo.Harmonizer(sf).out() server.start() room_temp = None temp = None while True: temp = r.rpop('temp') if temp is None: #print("Queue is empty") sleep(1) else: print(f'got {temp} on a worker')
import pyo import json with open('config.json', 'r') as fp: config = json.load(fp) # r = redis.Redis(host='localhost', port=6379, db=0) server = pyo.Server().boot() sf = pyo.SfPlayer(<"filename.wav">, loop=True) # replace <filename> sh = pyo.FreqShift(sf) sh.ctrl() hr = pyo.Harmonizer(sh).out() hr.ctrl() ch = pyo.Chorus(sh).out() ch.ctrl() dly = pyo.Delay(sh).out() dly.ctrl() server.gui(locals()) ''' while True: temp = r.rpop('temp') if temp is None: print("Queue is empty") sleep(1) else: print(f'got {temp} on a worker') mod = (int(temp) - 19000) / 1000 # range between -14 and 14 print(f'using mod {mod}') hr.transpo = mod - 7
import pyo from settings import audioSource s = pyo.Server(audio=audioSource, nchnls=1).boot() s.start() a = pyo.Input(chnl=0) chorus = pyo.Chorus(a, depth=.9, feedback=0.5, bal=0.5).out() s.gui()
def chain_effects( initial_source, config_effects_dict ): ''' Loop through the effects and assembles their configuration in order according to their keys. initial_source - the medium by which the audio stream is read (i.e through the input port) config_effects_dict - the list of effects to enable on top of the audio stream. ''' vol = 1 #default volume enabled_effects = [initial_source] # Make the source of the next effect the previously applied effect. source = enabled_effects[len(enabled_effects) - 1] # If the volume was set, change the default value to the requested volume. if "volume" in config_effects_dict: vol = config_effects_dict.pop("volume") enabled_effects.append(pyo.Tone( source, freq = 20000, mul = vol ) ) # Run through all the effects in our configuration file and apply # them to the previously used stream (i.e source) for effect in sorted(config_effects_dict.keys()): source = enabled_effects[len(enabled_effects) - 1] # print("Effect: " + effect + ", Params: " + str(effects_dict[effect])) params = config_effects_dict[effect] if params['name'] == 'distortion': # distortion stuff print("Enable distortion effect") enabled_effects.append(pyo.Disto( source, drive=float(params['drive']), slope=float(params['slope']), mul = vol ) ) elif params['name'] == 'delay': # delay stuff print("Enable delay effect") enabled_effects.append(pyo.Delay( source, delay=[0, float(params['delay'])], feedback=float(params['feedback']), maxdelay=5, mul = vol ) ) elif params['name'] == 'reverb': # reverb stuff print("Enable reverb effect") enabled_effects.append(pyo.STRev( source, inpos=0.25, revtime=float(params['revtime']), cutoff=float(params['cutoff']), bal=float(params['balance']), roomSize=float(params['roomsize']), mul = vol ) ) elif params['name'] == 'chorus': # chorus stuff print("Enable chorus effect") enabled_effects.append(pyo.Chorus( source, depth=[(params['depth_min']), (params['depth_max'])], feedback=float(params['feedback']), bal=float(params['balance']), mul = vol ) ) elif params['name'] == 'flanger': # flanger stuff print("Enable flanger effect") enabled_effects.append(flanger.Flanger( source, depth=float(params['depth']), freq=float(params['freq']), feedback=float(params['feedback']), mul = vol ) ) elif params['name'] == 'freqshift': # frequency shift stuff print("Enable frequency shift effect") enabled_effects.append(pyo.FreqShift( source, shift=params['shift'], mul = vol ) ) elif params['name'] == 'harmonizer': # harmonizer stuff print("Enable harmonizer effect") enabled_effects.append(pyo.Harmonizer( source, transpo=params['transpose'], feedback=float(params['feedback']), winsize=0.1, mul = vol ) ) elif params['name'] == 'phaser': # phaser stuff print("Enable phaser effect") enabled_effects.append(pyo.Phaser( source, freq=float(params['frequency']), spread=float(params['spread']), q=float(params['q']), feedback=float(params['feedback']), num=int(params['num']), mul = vol ) ) return enabled_effects
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 chorus = pyo.Chorus(audioIn, depth=depth, feedback=feedback, bal=balance).out() # chorus.ctrl(title="chorus") # s.gui(locals()) clock.tick(60) pygame.quit()
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