Example #1
0
 def playback4(self, file_path=imsend_sound_path):
     print('pb4')
     select = random.random()
     snd = pyo.SfPlayer(file_path, speed=1, loop=False, mul=5)
     rev = pyo.STRev(snd,
                     inpos=select,
                     revtime=4,
                     cutoff=5000,
                     bal=1,
                     roomSize=4)
     panner = pyo.Pan(rev,
                      outs=2,
                      pan=random.random(),
                      spread=random.random()).out()
     time.sleep(rev.revtime + .01)
     rev.stop()
Example #2
0
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