Beispiel #1
0
def chirp():
    r = dsp.rand(3.6, 3.99)
    numpoints = dsp.randint(10, 30)

    freq = dsp.rand(200, 1000)
    slength = dsp.rand(0.05, 0.5)
    length = dsp.stf(slength)

    log = data.Logistic(r, size=numpoints)
    mod = dsp.breakpoint([0] + [dsp.rand()
                                for r in range(numpoints / 3)] + [0],
                         numpoints)
    mod = [p * log.get() for p in mod]
    modr = dsp.rand(1, 5)
    modf = 1.0 / slength

    wf = dsp.wavetable('sine2pi', 512)
    win = dsp.wavetable('sine', 512)
    pw = dsp.rand(0.5, 1)
    amp = dsp.rand(0.1, 0.3)

    out = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp)
    out = dsp.env(out, 'random')
    out = dsp.taper(out, dsp.mstf(10))
    out = dsp.pan(out, dsp.rand())
    out = dsp.pad(out, 0, dsp.stf(dsp.rand(0.1, 0.3)))

    return out
Beispiel #2
0
def play(ctl):
    dpc = ctl.get('midi').get('dpc')
    lpd = ctl.get('midi').get('lpd')

    print lpd.get(1)

    dpc.setOffset(111)
    pw = dpc.get(1, low=0.01, high=1)

    scale = [1, 2, 3, 6, 9]
    scale = [1, 4, 6, 8]
    scale = [1, 3, 5, 9]
    scale = tune.fromdegrees(scale, octave = dpc.geti(4, low=0, high=4))

    freq = dsp.randchoose(scale)

    length = dsp.stf(dpc.get(2, low=0.1, high=8) * dsp.rand(0.5, 1.5))
    wf = dsp.wavetable('sine2pi')
    win = dsp.wavetable('sine')
    mod = [ dsp.rand(0, 1) for m in range(1000) ]
    modr = dpc.get(5, low=0, high=0.3)
    modf = dpc.get(6, low=0.001, high=10)
    amp = dpc.get(3, low=0, high=1)

    out = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp)

    out = dsp.env(out, dsp.randchoose(['sine', 'tri']))
    out = dsp.pan(out, dsp.rand())

    return out
Beispiel #3
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

    idxWf = param.get('idxWf', default=0)
    idxWin = param.get('idxWin', default=0)
    idxMod = param.get('idxMod', default=0)
    
    freq = 220
    length = dsp.mstf(lpd.get(8, low=50, high=1000, default=100))
    pw = lpd.get(5, low=0.001, high=1, default=1)
    wf = dsp.wavetable('sine2pi', 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('sine', 512)
    #mod = dsp.breakpoint([ dsp.rand(0, 1) for m in range(10) ], 512)
    #mod = dsp.wavetable('sine', 512)
    modr = lpd.get(6, low=0, high=1, default=0)
    modf = lpd.get(7, low=0.1, high=3, default=0.1)
    amp = 0.3

    idxWf, idxWin, idxMod, out = dsp.pulsarstream(freq, length, pw, wf, win, mod, modr, modf, amp, idxWf, idxWin, idxMod)

    #out = dsp.taper(out, dsp.mstf(2))

    param.set('idxWf', idxWf)
    param.set('idxWin', idxWin)
    param.set('idxMod', idxMod)

    return out
Beispiel #4
0
def spider(snd, numlayers=10, numgrains=20, minlen=40, lenranges=(300,500), reverse=False, env='hann'):
    layers = []

    for layer in range(numlayers):
        lenrange = dsp.rand(lenranges[0], lenranges[1])

        if reverse:
            lengths = dsp.wavetable(env, numgrains * 2)[numgrains:]
        else:
            lengths = dsp.wavetable(env, numgrains * 2)[:numgrains]

        lengths = [ dsp.mstf(l * lenrange + minlen) for l in lengths ]
        pans = dsp.breakpoint([ dsp.rand() for p in range(numgrains / 3)], numgrains)

        startpoint = dsp.randint(0, dsp.flen(snd) - max(lengths))
    
        grains = ''

        for l, p in zip(lengths, pans):
            grain = dsp.cut(snd, startpoint, l)
            grain = dsp.env(grain, 'phasor')
            grain = dsp.taper(grain, dsp.mstf(10))
            grain = dsp.pan(grain, p)
            
            grains += grain

        if reverse:
            layers += [ dsp.env(grains, 'line') ]
        else:
            layers += [ dsp.env(grains, 'phasor') ]

    return dsp.mix(layers)
Beispiel #5
0
def chippy(length=22050, freq=220, amp=0.5):
    wfrm = dsp.wavetable('sine2pi', 512)
    wndw = dsp.wavetable('tri', 512)
    modw = [ 1 for u in range(256) ] + [ 0 for d in range(256) ]
    modr = 1
    modf = dsp.rand(10, 20)
    pw = dsp.rand()

    out = dsp.pulsar(freq, length, pw, wfrm, wndw, modw, modr, modf, amp)

    return out
Beispiel #6
0
def makeLayer(freq):
    pw = dsp.rand()
    wf = dsp.wavetable('tri', 512)
    win = dsp.wavetable('hann', 512)
    mod = dsp.breakpoint([ dsp.rand() for m in range(dsp.randint(4,8)) ], 512)
    modf = dsp.rand(0.1, 2)
    modr = dsp.rand(0, 0.01)
    amp = dsp.rand(0.1, 0.5)

    layer = dsp.pulsar(freq, length, pw, wf, win, mod, modf, modr, amp)

    return layer
Beispiel #7
0
def that(li):
    print 'layer', li

    freqs = tune.fromdegrees([ dsp.randint(1, 20) for f in range(dsp.randint(3, 6)) ], octave = 3)

    length = dsp.stf(dsp.rand(10, 20))

    layers = []

    for fi, freq in enumerate(freqs):
        print '    tone', fi, round(dsp.fts(length), 2)

        waveform = dsp.randchoose(['sine2pi', 'tri', 'hann'])
        waveform = dsp.wavetable(waveform, 512)

        window = dsp.randchoose(['sine', 'tri', 'hann'])
        window = dsp.wavetable(window, 512)

        pulsewidth = dsp.rand(0.1, 1)
        modFreq    = dsp.rand(0.1, 10.0) / dsp.fts(length)

        numgrains = length / 32
        numpoints = dsp.randint(2, 6)

        apoints = [0] + [dsp.rand(0, 1) for p in range(numpoints - 2)] + [0]
        ppoints = [dsp.rand(0, 1) for p in range(numpoints)]

        e = dsp.breakpoint(apoints, numgrains)
        p = dsp.breakpoint(ppoints, numgrains)

        mod = dsp.wavetable('random', 512)
        modRange = dsp.rand(0, 0.001)

        print '    ', round(freq, 2), round(modRange, 3), round(modFreq, 3)
        layer = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, 0.1)

        layer = dsp.split(layer, dsp.flen(layer) / numgrains)
        layer = layer[:numgrains]

        layer = [ dsp.pan(dsp.amp(layer[i], e[i]), p[i]) for i in range(numgrains) ]

        layer = ''.join(layer)

        layers += [ layer ]

    out = dsp.mix(layers)

    return out
Beispiel #8
0
def rhodes(length=22050, freq=220.0, amp=0.5, wavetype='sine'):
    partials = [
            # Multiple, amplitude, duration
            [1, 0.6, 1.0], 
            [2, 0.25, 0.35], 
            [3, 0.08, 0.15],
            [4, 0.005, 0.04],
        ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq, length=length, amp=plist[1], wavetype=wavetype)

        env_length = (length * plist[2] * 2) / 32 
        if env_length <= 2:
            env_length = 4

        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(length - len(wtable))])
        
        partial = dsp.split(partial, 32)
        partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ]
        layer = ''.join(partial)

        layers += [ layer ]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

    out = dsp.mix([out, noise])
    out = dsp.amp(out, amp)

    return out
Beispiel #9
0
def rhodes(total_time, freq=220.0, ampscale=0.5):
    partials = [
        # Multiple, amplitude, duration
        [1, 0.6, 1.0],
        [2, 0.25, 0.35],
        [3, 0.08, 0.15],
        [4, 0.005, 0.04],
    ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq,
                           length=total_time,
                           amp=plist[1] * ampscale)

        env_length = (total_time * plist[2] * 2) / 32
        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(total_time - len(wtable))])
        print env_length, len(wtable), dsp.flen(partial)

        partial = dsp.split(partial, 32)
        partial = [dsp.amp(partial[i], wtable[i]) for i in range(len(partial))]
        layer = ''.join(partial)

        layers += [layer]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

    out = dsp.mix([out, noise])

    return out
Beispiel #10
0
def play(ctl):
    #out = snds.load('genie/piano.wav')

    lenrange = 300
    minlen = 1

    if dsp.rand() > 0.5:
        lengths = dsp.breakpoint([dsp.rand(0, 1) for _ in range(5)], 50)
    else:
        lengths = dsp.wavetable('sine', 50)

    lengths = [dsp.mstf(l * lenrange + minlen) for l in lengths]

    out = ''

    for length in lengths:
        freq = tune.ntf('f', octave=dsp.randint(2, 5))

        if dsp.rand() > 10.85:
            length = dsp.stf(dsp.rand(0.5, 3))
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

        out += keys.pulsar(freq=freq, length=length, env='phasor')

        if dsp.rand() > 10.75:
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

    return out
Beispiel #11
0
def rhodes(total_time, freq=220.0, ampscale=0.5):
    partials = [
            # Multiple, amplitude, duration
            [1, 0.6, 1.0], 
            [2, 0.25, 0.35], 
            [3, 0.08, 0.15],
            [4, 0.005, 0.04],
        ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq, length=total_time, amp=plist[1] * ampscale)

        env_length = (total_time * plist[2] * 2) / 32 
        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(total_time - len(wtable))])
        print env_length, len(wtable), dsp.flen(partial)
        
        partial = dsp.split(partial, 32)
        partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ]
        layer = ''.join(partial)

        layers += [ layer ]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

    out = dsp.mix([out, noise])



    return out
Beispiel #12
0
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose([
                            'impulse', 'sine', 'line', 'phasor', 'cos',
                            'impulse'
                        ])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        #                        lowbend = 0.75
                        highbend = 1.01
#                        highbend = 1.5

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [
                        math.fabs(f) * (highbend - lowbend) + lowbend
                        for f in freqs
                    ]

                    out = [
                        dsp.transpose(out[i], freqs[i])
                        for i in range(len(out))
                    ]
                    return ''.join(out)
Beispiel #13
0
def play(params={}):
    volume = params.get('volume', 100.0)
    volume = volume / 100.0 # TODO: move into param filter
    volume = volume * 0.25
    length = params.get('length', 40)
    env    = params.get('envelope', False)
    wii    = params.get('wii', False)
    speed  = params.get('speed', False)
    
    numcycles = dsp.randint(10, 524)

    # Make breakpoint env with 2-10 vals between 0.1 and 1.0
    curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles)

    # Make wavetable with single cycle from given wave types
    curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse']
    curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles)

    # Make pan curve - always cosine
    pan = dsp.wavetable('cos', numcycles)

    # Multiply breakpoint curve with simple wavetable
    wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ]

    # Scale to max frequency
    wtable = [ (f * 19000) + length for f in wtable ]

    # Possible osc wavetypes
    wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary']

    if wii is True:
        out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ]
    else:
        wtype = dsp.randchoose(wtypes)
        out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ]

    out = dsp.amp(''.join(out), volume)

    if speed != False and speed > 0.0:
        out = dsp.transpose(out, speed)

    if env != False:
        out = dsp.env(out, env)

    return out
Beispiel #14
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

    pw = lpd.get(7, low=0.001, high=1, default=1)
    modr = dsp.rand(0, 0.005)
    modf = dsp.rand(0.01, 0.05)
    amp = lpd.get(8, low=0, high=2, default=0)

    length = dsp.mstf(lpd.get(6, low=40, high=1000, default=100))
    divs = [1, 2, 3.0, 4]
    div = divs[lpd.geti(5, low=0, high=len(divs) - 1)]
    #div = dsp.randchoose(divs)

    length = int(length / div)

    wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for w in range(5) ] + [0], 512)
    wf = dsp.wavetable('sine2pi', 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.breakpoint([0] + [ dsp.rand(0, 1) for m in range(5) ] + [0], 512)

    layers = []

    chord = [ dsp.randchoose([1, 3, 5, 6, 8, 16]) for c in range(dsp.randint(2, 4)) ]

    notes = tune.fromdegrees(chord, root='d', octave=dsp.randint(1, 2))

    for freq in notes:
        a = amp * dsp.rand(0.1, 0.75)

        layer = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, a)
        layer = dsp.pan(layer, dsp.rand())

        layers += [ layer ]

    out = dsp.mix(layers)
    out = dsp.taper(out)
    out = dsp.env(out, 'phasor')

    #out = dsp.pad(out, 0, length)

    #out = out * 4

    return out
Beispiel #15
0
def slurp(snd):
    snd = dsp.split(snd, dsp.flen(snd) / 100)
    numcycles = len(snd)
    curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles)
    curve_b = dsp.wavetable('cos', numcycles)
    wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ]
    wtable = [ math.fabs((f * 5) + 0.75) for f in wtable ]

    snd = [ dsp.transpose(snd[i], wtable[i]) for i in range(numcycles) ]

    return ''.join(snd)
Beispiel #16
0
def clap(length=22050, i=0, amp=0.5, root=3000.0, pw=None):
    wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(50) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

    klen = length / dsp.randint(2, 5) 
    if pw is None:
        pw = dsp.rand(0.1, 1)

    amp = dsp.rand(0.75, 1.0)

    mFreq = 1.0 / dsp.fts(klen)

    k = dsp.pulsar(root, klen, pw, wav, win, mod, 1.0, mFreq, amp) 
    #k = orc.kick(dsp.rand(0.4, 0.7), klen)

    k = dsp.env(k, 'phasor')

    k = dsp.pad(k, 0, length - klen)

    return k
Beispiel #17
0
def pulsar(freq, length=22050, drift=0.01, speed=0.5, amp=0.1, pulsewidth=None, env='flat', wf=None, mod=None):
    if wf is None:
        waveform = dsp.wavetable('sine2pi')
    else:
        waveform = wf

    window = dsp.wavetable('sine')

    if mod is None:
        mod = [ dsp.rand(0, 1) for i in range(10) ]

    modrange = dsp.rand(0, drift)
    modfreq = dsp.rand(0.0001, speed)
    pulsewidth = dsp.rand(0.1, 1) if pulsewidth is None else pulsewidth

    out = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modrange, modfreq, amp)

    out = dsp.pan(out, dsp.rand())
    out = dsp.env(out, env)

    return out
Beispiel #18
0
def play(voice_id):
    volume = P(voice_id, 'volume', 100.0)
    volume = volume / 100.0 # TODO: move into param filter
    volume = volume * 0.65
    length = P(voice_id, 'length', 40)
    env    = False
    wii    = False
#    wii    = True

    speed  = False
    
    numcycles = dsp.randint(1, 200)

    # Make breakpoint env with 2-10 vals between 0.1 and 1.0
    curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles)

    # Make wavetable with single cycle from given wave types
    curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse']
    curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles)

    # Make pan curve - always cosine
    pan = dsp.breakpoint([ dsp.rand() for i in range(dsp.randint(5, 50)) ], numcycles)
    amps = dsp.breakpoint([ dsp.rand(0.1, 0.75) for i in range(dsp.randint(5, 30)) ], numcycles)

    # Multiply breakpoint curve with simple wavetable
    wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ]

    # Scale to max frequency
    wtable = [ (f * 20000) + length for f in wtable ]

    # Possible osc wavetypes
    wtypes = ['sine2pi']
#    wtypes = ['tri', 'sine2pi', 'impulse']
#    wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary']

    if wii is True:
        out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ]
    else:
        wtype = dsp.randchoose(wtypes)
        out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ]

    out = [ dsp.amp(oo, amps[i]) for i, oo in enumerate(out) ]

    out = dsp.amp(''.join(out), volume)

    if speed != False and speed > 0.0:
        out = dsp.transpose(out, speed)

    if env != False:
        out = dsp.env(out, env)

    return out
Beispiel #19
0
def play(voice_id):
    bpm = config('bpm')

    root = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    beat = dsp.bpm2frames(bpm)

    length = dsp.randint(dsp.stf(1), dsp.stf(3))

    wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(10) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('vary', 512)

    root = dsp.randchoose(tune.fromdegrees([1,3,5,8], octave=0, root='a'))

    pw = dsp.rand(0.1, 1)

    amp = dsp.rand(0.5, 1.2)

    mFreq = 0.01 / dsp.fts(length)

    out = dsp.pulsar(root, length, pw, wav, win, mod, 0.05, mFreq, amp)

#    out = dsp.env(out, 'vary')

    out = dsp.vsplit(out, dsp.mstf(1), dsp.mstf(500))
    out = dsp.randshuffle(out)
    out = [ dsp.pad(o, 0, dsp.randint(0, 4410)) for o in out ]
    out = [ dsp.pan(o, dsp.rand()) for o in out ]
    out = [ dsp.alias(o) for o in out ]
    out = [ o * dsp.randint(1, 30) for o in out ]
    out = [ dsp.env(o, 'random') for o in out ]
    out = [ dsp.amp(o, dsp.rand(0.9, 1.5)) for o in out ]

    out = ''.join(out)

    return out
Beispiel #20
0
def bend(snd, freqs=None, amount=0.02):
    out = dsp.split(snd, 441)

    if freqs is None:
        freqs = dsp.wavetable('sine', len(out))
    else:
        freqs = dsp.breakpoint(freqs, len(out))

    freqs = [ freq * amount + (1 - (amount * 0.5)) for freq in freqs ]

    out = [ dsp.transpose(grain, freq) for grain, freq in zip(out, freqs) ]

    return ''.join(out)
Beispiel #21
0
def play(voice_id):
    bpm = config('bpm')

    root = config('key')
    quality = getattr(tune, config('quality'))
    ratios = getattr(tune, config('tune'))

    beat = dsp.bpm2frames(bpm)

    length = dsp.randint(dsp.stf(1), dsp.stf(3))

    wav = dsp.breakpoint([0] + [dsp.rand(-1, 1) for w in range(10)] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('vary', 512)

    root = dsp.randchoose(tune.fromdegrees([1, 3, 5, 8], octave=0, root='a'))

    pw = dsp.rand(0.1, 1)

    amp = dsp.rand(0.5, 1.2)

    mFreq = 0.01 / dsp.fts(length)

    out = dsp.pulsar(root, length, pw, wav, win, mod, 0.05, mFreq, amp)

    #    out = dsp.env(out, 'vary')

    out = dsp.vsplit(out, dsp.mstf(1), dsp.mstf(500))
    out = dsp.randshuffle(out)
    out = [dsp.pad(o, 0, dsp.randint(0, 4410)) for o in out]
    out = [dsp.pan(o, dsp.rand()) for o in out]
    out = [dsp.alias(o) for o in out]
    out = [o * dsp.randint(1, 30) for o in out]
    out = [dsp.env(o, 'random') for o in out]
    out = [dsp.amp(o, dsp.rand(0.9, 1.5)) for o in out]

    out = ''.join(out)

    return out
Beispiel #22
0
def kick(length=22050, i=0, amp=0.5):
    wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(20) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

    root = 30.0
    klen = length / 4
    pw = dsp.rand(0.1, 1)

    amp = dsp.rand(0.5, 1.0)

    mFreq = 1.0 / dsp.fts(klen)

    k = dsp.pulsar(root, klen, pw, wav, win, mod, 2.0, mFreq, amp)

    k = dsp.mix([ sinekick(amp=dsp.rand(0.4, 0.7), length=klen), k ])

    k = dsp.env(k, 'phasor')

    k = dsp.pad(k, 0, length - klen)

    return k
Beispiel #23
0
def slurp(snd):
    snd = dsp.split(snd, dsp.flen(snd) / 100)
    numcycles = len(snd)
    curve_a = dsp.breakpoint(
        [1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0],
        numcycles)
    curve_b = dsp.wavetable('cos', numcycles)
    wtable = [curve_a[i] * curve_b[i] for i in range(numcycles)]
    wtable = [math.fabs((f * 5) + 0.75) for f in wtable]

    snd = [dsp.transpose(snd[i], wtable[i]) for i in range(numcycles)]

    return ''.join(snd)
Beispiel #24
0
def yourlove(length=22050, i=0, bar=5, amp=0.5, chords=None, root='a', octave=3, maxdiv=4, mindiv=1):
    """ Inspired by Terre """
    wav = dsp.wavetable('sine2pi', 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

    if chords is None:
        chords = [
            [5, 7, 1],
            [5, 4, 1],
            [3, 2, 1, 6],
        ]

    pw = dsp.rand(0.1, 1)

    notes = chords[i % len(chords)]
    notes = tune.fromdegrees(notes, root=root, octave=octave)

    klen = length / dsp.randint(mindiv, maxdiv)

    amp = dsp.rand(0.3, 0.5)

    mFreq = dsp.rand(0.5, 1.0) / dsp.fts(klen)

    layers = []

    for note in notes:
        k = dsp.pulsar(note, klen, pw, wav, win, mod, 0.005, mFreq, amp) 
        k = dsp.env(k, 'sine')
        k = dsp.pan(k, dsp.rand())
        k = dsp.pad(k, 0, length - klen)

        layers += [ k ]

    out = dsp.mix(layers)

    return out
Beispiel #25
0
def play(ctl):
    midi = ctl.get('midi')
    midi.setOffset(111)
    pw = midi.get(1, low=0.01, high=1)

    scale = [1, 2, 3, 6, 9]
    scale = tune.fromdegrees(scale, octave=midi.geti(4, low=0, high=4))

    freq = dsp.randchoose(scale)

    length = dsp.stf(midi.get(2, low=0.1, high=8) * dsp.rand(0.5, 1.5))
    wf = dsp.wavetable('sine2pi')
    win = dsp.wavetable('sine')
    mod = [dsp.rand(0, 1) for m in range(1000)]
    modr = midi.get(5, low=0, high=0.3)
    modf = midi.get(6, low=0.001, high=10)
    amp = midi.get(3, low=0, high=1)

    out = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp)

    out = dsp.env(out, dsp.randchoose(['sine', 'tri']))
    out = dsp.pan(out, dsp.rand())

    return out
Beispiel #26
0
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse'])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        highbend = 1.01

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ]

                    out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
                    return ''.join(out)
Beispiel #27
0
def play(ctl):
    lpd = ctl.get('midi').get('lpd')

    def rain(snd, freqs):
        layers = []

        for freq in freqs:
            #layer = dsp.pine(snd, dsp.flen(snd) * 16, freq)

            layer = dsp.pan(snd, dsp.rand())
            layer = dsp.amp(layer, 0.5)
            layer = dsp.alias(layer)
            layers += [ layer ]

        return dsp.mix(layers)

    wf = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(lpd.geti(7, low=4, high=200, default=0)) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = [ dsp.rand(0, 1) for m in range(512) ]

    modr = lpd.get(5, low=0.01, high=1, default=1)
    modf = dsp.rand(0.5, 2)

    amp = lpd.get(3, low=0, high=0.5, default=0)

    length = dsp.mstf(lpd.get(2, low=150, high=500))
    pw = lpd.get(1, low=0.1, high=1, default=1)

    freqs = tune.fromdegrees([1,3,5], octave=2, root='c')

    freq = dsp.randchoose(freqs) / 4.0

    #o = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp)
    #o = dsp.read('/home/hecanjog/sounds/guitarpluck.wav').data
    o = dsp.read('sounds/rhodes.wav').data
    o = dsp.transpose(o, dsp.randchoose([0.5, 1, 2, 1.5, 3]))
    o = dsp.fill(o, dsp.stf(dsp.rand(0.1, 2)))

    out = rain(o, freqs)

    #out = dsp.env(out, 'random')

    return out
Beispiel #28
0
def tempoPath(nsegs):
    maxms = dsp.rand(100, 400)
    minms = dsp.rand(1, 100)
    wavetypes = ['hann', 'sine', 'vary']

    out = []

    for _ in range(nsegs):
        seglen = dsp.randint(20, 200)
        seg = dsp.wavetable(dsp.randchoose(wavetypes), seglen)

        # pull out a randomly selected subsegment of the curve
        sublen = seglen / dsp.randint(2, 5)
        segstart = dsp.randint(0, seglen - sublen)
        segend = segstart + sublen
        seg = seg[segstart:segend]

        out += [ [ dsp.mstf(abs(s) * (maxms - minms) + minms) for s in seg ] ]

    return out
Beispiel #29
0
def tempoPath(nsegs):
    #maxms = dsp.rand(300, 500)
    #minms = dsp.rand(1, 100)
    minms = 1
    maxms = 500
    wavetypes = ['hann', 'sine', 'vary']

    out = []

    for _ in range(nsegs):
        seglen = dsp.randint(20, 100)
        seg = dsp.wavetable(dsp.randchoose(wavetypes), seglen)

        # pull out a randomly selected subsegment of the curve
        sublen = seglen / dsp.randint(2, 5)
        segstart = dsp.randint(0, seglen - sublen)
        segend = segstart + sublen
        seg = seg[segstart:segend]

        out += [[dsp.mstf(abs(s) * (maxms - minms) + minms) for s in seg]]

    return out
Beispiel #30
0
def play(params):
    volume      = params.get('volume', dsp.rand(70.0, 100.0)) / 100.0

    notes       = params.get('note', [ dsp.randchoose(['c', 'f', 'e', 'a', 'd']) for i in range(2) ])

    octave =    params.get('octave', dsp.randint(1, 5)) 

    root        = params.get('root', 27.5)
    bpm         = params.get('bpm', 75.0)

    if dsp.randint(0, 1) == 0:
        length      = params.get('length', dsp.mstf(dsp.rand(10, 2000)))
    else:
        length      = params.get('length', int(dsp.randint(1, 4) * dsp.bpm2frames(bpm) * 0.25))

    env         = params.get('envelope', 'random')
    env         = params.get('envelope', 'tri')
    mod         = params.get('mod', 'random')
    modFreq     = params.get('modfreq', dsp.rand(1.0, 1.5) / dsp.fts(length))
    modRange    = params.get('speed', 0.01)
    modRange    = dsp.rand(0, modRange)

    pulsewidth  = params.get('pulsewidth', dsp.rand(0.01, 0.8))
    window      = params.get('window', 'gauss')
    #waveform    = params.get('waveform', 'random')
    waveform    = params.get('waveform', 'tri')

    glitch    = params.get('glitch', True)

    pulsewidth = 1.0


    freqs   = [ tune.ntf(note, octave) for note in notes ]

    tune.a0 = float(root)

    mod = dsp.wavetable(mod, 512)
    window = dsp.wavetable(window, 512)
    waveform = dsp.wavetable(waveform, 512)

    layers = []

    for freq in freqs:
        layers += [ dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume) ]

    out = dsp.mix(layers)

    try:
        out = dsp.env(out, env)
    except TypeError:
        out = dsp.env(out, 'sine')

    if glitch:
        bitlen = dsp.randint(dsp.mstf(10), dsp.mstf(500))
        bit = dsp.cut(out, dsp.randint(0, len(out) - bitlen), bitlen)
        out = dsp.vsplit(out, dsp.mstf(10), dsp.mstf(500))
        out.insert(dsp.randint(0, len(out) - 2), bit)

        out = ''.join(out)

    out = dsp.pan(out, dsp.rand())

    return out
Beispiel #31
0
from pippi import dsp
from pippi import tune

chord = tune.chord('I', octave=2, key='a', ratios=tune.terry)

numsegs = 2222
length = dsp.stf(60) / numsegs
numpoints = 7

wfs = [
    dsp.breakpoint([dsp.rand(-1, 1) for p in range(numpoints)], 512)
    for _ in range(numsegs)
]
win = dsp.wavetable('tri', 512)

mods = [
    dsp.breakpoint([dsp.rand(0, 1) for p in range(numpoints)], 512)
    for _ in range(numsegs)
]
modfs = [dsp.rand(0.01, 0.1) for _ in range(numsegs)]
modrs = [dsp.rand(0, 0.1) for _ in range(numsegs)]
pws = [dsp.rand(0.01, 1) for _ in range(numsegs)]

out = []

for wf, mod, modf, modr, pw in zip(wfs, mods, modfs, modrs, pws):
    layers = []
    for freq in chord:
        layer = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, 0.1)
        layers += [layer]
Beispiel #32
0
from hcj import fx
from datetime import datetime
import subprocess
import tweepy
import os

slen = dsp.rand(5, dsp.rand(15, 100))

layers = []
numlayers = dsp.randint(4, dsp.randint(10, 250))
for _ in range(numlayers):
    freq = dsp.rand(0.1, 5000) 
    length = dsp.stf(slen)
    pulsewidth = dsp.rand(0.15, 1)
    waveform = [0] + dsp.breakpoint([ dsp.rand(-1, 1) for _ in range(dsp.randint(6, dsp.randint(10, 300))) ], 512) + [0]
    window = dsp.wavetable(dsp.randchoose(['tri', 'hann', 'sine']), 512)
    mod = dsp.breakpoint([ dsp.rand() for _ in range(dsp.randint(5, 2000)) ], 1024*4)
    modrange = dsp.rand(0.01, 10)
    modfreq = 1.0 / slen
    amp = dsp.rand(0.05, 0.25)

    layer = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modrange, modfreq, amp)
    layer = fx.penv(layer)

    bits = []

    layer = dsp.vsplit(layer, dsp.mstf(1), dsp.stf(0.2))

    for bit in layer:
        if dsp.rand() > 0.75:
            bit = ''.join([ dsp.pan(dsp.amp(bit, dsp.rand(0.1, 10)), dsp.rand()) for _ in range(dsp.randint(2, 10)) ])
Beispiel #33
0
def play(voice_id):
    tel = bot.getTel()

    if 'sparse' in tel['name'] or 'ballsout' in tel['name'] and dsp.rand(0, 100) > 70:
        dsp.log('')
        dsp.log(voice_id + ' pulsar silent')
        bot.show_telemetry(tel)
        #return dsp.pad('', 0, dsp.stf(dsp.rand(1, 10)))

    #####################
    # PARAMS 
    ##################### 
    volume = dsp.rand(0.4, 0.7)

    melodies = [[dsp.randchoose([1, 5, 6])]]

    if tel['density'] >= 4:
        melodies += [ [ dsp.randchoose([1, 2, 9, 5, 6]) for i in range(2) ] for m in range(dsp.randint(2, 4)) ]

    if tel['density'] >= 6:
        melodies += [ [ dsp.randchoose([1, 2, 9, 3, 4, 5, 6, 7]) for i in range(dsp.randint(3, 6)) ] for m in range(dsp.randint(2, 5)) ]

    try:
        notes = dsp.randchoose(melodies)
    except IndexError:
        dsp.log(melodies)
        notes = [1]

    if tel['harmonicity'] <= 5:
        octave = (tel['register'] / 10.0) * dsp.randint(1, 3) + 1
    else:
        octave = int(round((tel['register'] / 10.0) * dsp.randint(1, 3) + 1))

    bpm         = p(voice_id, 'bpm', 80.0)

    if 'ballsout' in tel['name']:
        length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(3))
    else:
        length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(4)) + dsp.stf(dsp.rand(0.25, 1))

    # Cap voice length at 60 secs
    if length > dsp.stf(60):
        length = dsp.stf(60)

    env         = 'sine'

    mod         = p(voice_id, 'mod', 'random')
    modFreq     = p(voice_id, 'modfreq', dsp.rand(1.0, 2.5) / dsp.fts(length))

    modRange    = dsp.rand(0.01, 0.04)
    modRange    = dsp.rand(0, modRange)

    pulsewidth = 1.0 / (tel['roughness'] / 10.0)
    pulsewidth -= dsp.rand(0, 0.09)
    if pulsewidth < 0.1:
        pulsewidth = 0.1

    beat = dsp.bpm2frames(bpm)
 
    try:
        freqs   = tune.fromdegrees(notes, octave=octave, ratios=tune.just, root='c')
    except TypeError:
        print 'hm', notes, octave
        freqs = tune.fromdegrees([1,5], octave=octave, ratios=tune.just, root='c')

    #####################
    # NORMAL 
    ##################### 
    numgrains = int(dsp.rand(50, 500))

    if tel['roughness'] <= 2:
        window      = 'sine'
        waveform    = 'sine2pi'
        minplen     = dsp.ftms(length / 4)
        maxplen     = 30000

    elif tel['roughness'] <= 4:
        window      = 'sine'
        waveform    = 'sine2pi'
        minplen     = 10
        maxplen     = 350

    elif tel['roughness'] > 4:
        window      = 'tri'
        waveform    = 'tri'
        minplen     = 10 
        maxplen     = 120

    elif tel['roughness'] >= 7:
        window      = 'vary'
        waveform    = 'tri'
        minplen     = 5
        maxplen     = 80

    mod = dsp.wavetable(mod, 512)
    window = dsp.wavetable(window, 512)
    waveform = dsp.wavetable(waveform, 512)

    pc = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, numgrains))) ], numgrains)

    out = ''
    outlen = 0
    count = 0

    bar = dsp.randint(4, 8)

    dobeats = tel['density'] > 5 and dsp.rand(0, 100) > 20

    if dobeats:
        numbeats = bar * dsp.randint(3, 7)

    while outlen < length:
        layers = []

        if dobeats:
            plen = beat / dsp.randint(1, 10)
        else:
            plen = dsp.mstf(dsp.rand(minplen, maxplen))

        if tel['register'] >= 6 and tel['density'] >= 4:
            maxo = dsp.randint(2, 6)
        else:
            maxo = 1

        if dobeats:
            freqs = dsp.randshuffle(freqs)
            for b in range(numbeats):
                f = freqs[b % len(freqs)] 
                if dsp.rand(0, 100) > 70:
                    f *= 2**dsp.randint(0, maxo)

                b = dsp.pulsar(f, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
                b = dsp.pan(b, dsp.rand())

                out += b
                outlen += dsp.flen(b)

        else:
            for iff, freq in enumerate(freqs):
                if 'gentle' in tel['name']:
                    volume = dsp.rand(0.5, 0.6)
                elif 'sparse' in tel['name']:
                    volume = dsp.rand(0.3, 0.6)
                elif 'upbeat' in tel['name'] or 'ballsout' in tel['name']:
                    volume = dsp.rand(0.5, 0.6)
                else:
                    volume = dsp.rand(0.4, 0.6)

                if dsp.rand(0, 100) > 60:
                    freq *= 2**dsp.randint(0, maxo)

                layer = dsp.pulsar(freq, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume)

                layer = dsp.env(layer, 'sine')
                layer = dsp.pan(layer, dsp.rand())

                layers += [ layer ]

            layer = dsp.mix(layers)
            out += layer
            outlen += dsp.flen(layer)

            count += 1

    out = dsp.env(out, 'sine')

    #if dsp.flen(out) > dsp.mstf(100) and dsp.rand(0, 100) > 50:
        #out = dsp.drift(out, (tel['harmonicity'] - 10.0) * -1 * 0.1, dsp.randint(4, 441))

    dsp.log('')
    dsp.log('pulsar')
    dsp.log('%s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))
    bot.show_telemetry(tel)

    return out
Beispiel #34
0
from pippi import dsp
from matplotlib import pyplot as pp

xlen = 60

x = range(xlen)

points = dsp.wavetable('line', xlen) 
rpoints = dsp.breakpoint([ dsp.rand(-1, 1) for i in range(10) ], xlen)

pp.plot(x, rpoints,
    linestyle=' ',
    marker='x',
    color='b',
    label='Value from buffer'
)

pp.plot(x, points,
    linestyle='dotted',
    color='b',
    label='Phasor'
)

pp.xlabel('Samples')
pp.ylabel('Values')
pp.xlim(0, xlen - 1)
pp.xticks(range(xlen), ['' for i in range(xlen)])
pp.ylim(-1, 1)

pp.grid(True, which='major', linewidth=1.0, axis='y', alpha=0.25)
Beispiel #35
0
from pippi import dsp

dist = dsp.wavetable('hann', 1200)[:600]

lowfreq = 200
highfreq = 1000
length = dsp.stf(60)

layers = []

for freq in dist:
    r = highfreq - lowfreq
    layers += [dsp.tone(length, freq * r + lowfreq, amp=0.01)]

out = dsp.mix(layers)

dsp.write(out, 'basics')
Beispiel #36
0
from pippi import dsp

snd = dsp.read('sounds/seneca3bars.wav').data

numgrains = 40
lens = [1 for _ in range(numgrains / 2)]
lens = lens + dsp.wavetable('hann', numgrains)[len(lens):]
lens = [dsp.mstf(l * 40 + 30) for l in lens]

out = ''

lpos = 0
rpos = dsp.mstf(100)
for i in range(numgrains):
    l = dsp.cut(snd, lpos, lens[i])
    r = dsp.cut(snd, rpos, lens[i])

    lpos += dsp.mstf(dsp.rand(1, 10))
    rpos += dsp.mstf(dsp.rand(1, 10))

    out += dsp.pan(l, 0)
    out += dsp.pan(r, 1)

dsp.write(out, 'alter')
Beispiel #37
0
def play(ctl):
    p = ctl.get('param')
    key = p.get('key', 'c')
    mpk = ctl.get('midi').get('mpk')
    bpm = p.get('bpm', 100)
    beat = dsp.bpm2frames(bpm)
    length = beat * 2 * mpk.geti(6, low=1, high=6)

    gamut = mpk.geti(20)
    poly = mpk.geti(21)
    logistic = mpk.geti(22)
    layered = mpk.geti(23)
    fixed = mpk.get(24)
    perc = mpk.get(25)
    wobble = mpk.get(26)

    min_octave = mpk.geti(4, low=1, high=4)
    max_octave = mpk.geti(4, low=3, high=7)
    octave = dsp.randint(min_octave, max_octave)

    k = dsp.randchoose(snds.search('mc303/*kick*'))
    h = dsp.randchoose(snds.search('mc303/*hat*'))
    c = dsp.randchoose(snds.search('mc303/*clap*'))

    pointer = p.get('pointer', default=0)
    log = data.Logistic(r=dsp.rand(3.9, 3.99), x=0.5, size=1024, pointer=pointer)
    
    if fixed:
        seed = mpk.get(5)
    else:
        seed = time.time()

    dsp.seed(str(seed))

    def makeOnsets(length, wobble, div, num_beats, offset=False):
        if offset:
            offset = dsp.randint(0, 3)
        else:
            offset = 0

        pattern = dsp.eu(num_beats, dsp.randint(1, num_beats/div), offset)
        dsp.log(pattern)

        if wobble:
            points = [ dsp.mstf(100, 500) for _ in range(dsp.randint(2, 8)) ]
            plength = sum(points)
            mult = length / float(plength)
            onsets = curves.bezier(points, num_beats)
            onsets = [ int(o * mult) for o in onsets ]

        else:
            beat = float(length) / num_beats
            num_beats = length / beat
            beat = int(round(beat))
            onsets = [ beat * i for i in range(int(round(num_beats))) ]

        return onsets


    def makeKicks(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 4, True)
        kick = dsp.taper(k, 20)
        kick = dsp.transpose(kick, dsp.rand(1, 2))

        for onset in onsets:
            out.add(kick, onset)

        out = out.mix()

        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)


    def makeHats(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 1, 16, True)

        for onset in onsets:
            out.add(h, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)


    def makeClaps(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 8, True)

        for onset in onsets:
            clap = dsp.stretch(c, int(dsp.flen(c) * log.get(1, 10)), grain_size=dsp.randint(20, 120))
            out.add(clap, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = [ dsp.taper(o, 20) for o in out ]
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)


    if mpk.get(8) == 0:
        return dsp.pad('', 0, dsp.mstf(100))

    def randomScale():
        scale = [1,2,3,4,5,6,7,8]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    def gamutScale():
        num_notes = dsp.randint(3, 6)
        scale = [ dsp.randchoose([1,2,3,4,5,6,7,8]) for _ in range(num_notes) ]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    if gamut:
        freqs = gamutScale()
    else:
        freqs = randomScale()

    if layered:
        num_layers = dsp.randint(2, 4)
    else:
        num_layers = 1

    layers = []

    for _ in range(num_layers):
        layer = ''

        elapsed = 0
        while elapsed < length:
            if poly:
                num_poly = dsp.randint(1, 3)
            else:
                num_poly = 1

            note_length = beat / dsp.randchoose([1, 2, 3, 4])

            notes = []
            for _ in range(num_poly):
                freq = dsp.randchoose(freqs)

                if logistic:
                    pulsewidth = log.get(low=0.05, high=1)

                    if log.get() > 0.5:
                        wf = log.choose(['sine', 'tri', 'saw'])
                        wf = dsp.wavetable(wf, 512)
                    else:
                        points = [ log.get(-1, 1) for _ in range(log.geti(4, 20)) ]
                        wf = dsp.breakpoint(points, 512)
                else:
                    pulsewidth = 1
                    wf = dsp.wavetable('sine', 512)

                note = keys.pulsar(length=note_length, freq=freq, wf=wf, env='phasor', pulsewidth=pulsewidth)
                notes += [ note ]
            
            notes = dsp.mix(notes)
            layer += notes

            elapsed += dsp.flen(notes)

        layers += [ layer ]

    out = dsp.mix(layers)
    out = dsp.amp(out, 0.75)
    out = dsp.fill(out, length)

    #out = dsp.pad(out, 0, int(dsp.stf(0.5, 1) * mpk.get(7)))

    p.set('pointer', log.pointer)

    if perc:
        kicks = makeKicks(length, wobble)
        hats = makeHats(length, wobble)
        claps = makeClaps(length, wobble)
        out = dsp.mix([ out, kicks, hats, claps ])

    out = dsp.amp(out, mpk.get(8))

    return out
Beispiel #38
0
def play(ctl):
    p = ctl.get('param')
    key = p.get('key', 'c')
    mpk = ctl.get('midi').get('mpk')
    bpm = p.get('bpm', 100)
    beat = dsp.bpm2frames(bpm)
    length = beat * 2 * mpk.geti(6, low=1, high=6)

    gamut = mpk.geti(20)
    poly = mpk.geti(21)
    logistic = mpk.geti(22)
    layered = mpk.geti(23)
    fixed = mpk.get(24)
    perc = mpk.get(25)
    wobble = mpk.get(26)

    min_octave = mpk.geti(4, low=1, high=4)
    max_octave = mpk.geti(4, low=3, high=7)
    octave = dsp.randint(min_octave, max_octave)

    k = dsp.randchoose(snds.search('mc303/*kick*'))
    h = dsp.randchoose(snds.search('mc303/*hat*'))
    c = dsp.randchoose(snds.search('mc303/*clap*'))

    pointer = p.get('pointer', default=0)
    log = data.Logistic(r=dsp.rand(3.9, 3.99),
                        x=0.5,
                        size=1024,
                        pointer=pointer)

    if fixed:
        seed = mpk.get(5)
    else:
        seed = time.time()

    dsp.seed(str(seed))

    def makeOnsets(length, wobble, div, num_beats, offset=False):
        if offset:
            offset = dsp.randint(0, 3)
        else:
            offset = 0

        pattern = dsp.eu(num_beats, dsp.randint(1, num_beats / div), offset)
        dsp.log(pattern)

        if wobble:
            points = [dsp.mstf(100, 500) for _ in range(dsp.randint(2, 8))]
            plength = sum(points)
            mult = length / float(plength)
            onsets = curves.bezier(points, num_beats)
            onsets = [int(o * mult) for o in onsets]

        else:
            beat = float(length) / num_beats
            num_beats = length / beat
            beat = int(round(beat))
            onsets = [beat * i for i in range(int(round(num_beats)))]

        return onsets

    def makeKicks(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 4, True)
        kick = dsp.taper(k, 20)
        kick = dsp.transpose(kick, dsp.rand(1, 2))

        for onset in onsets:
            out.add(kick, onset)

        out = out.mix()

        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    def makeHats(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 1, 16, True)

        for onset in onsets:
            out.add(h, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    def makeClaps(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 8, True)

        for onset in onsets:
            clap = dsp.stretch(c,
                               int(dsp.flen(c) * log.get(1, 10)),
                               grain_size=dsp.randint(20, 120))
            out.add(clap, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = [dsp.taper(o, 20) for o in out]
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    if mpk.get(8) == 0:
        return dsp.pad('', 0, dsp.mstf(100))

    def randomScale():
        scale = [1, 2, 3, 4, 5, 6, 7, 8]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    def gamutScale():
        num_notes = dsp.randint(3, 6)
        scale = [
            dsp.randchoose([1, 2, 3, 4, 5, 6, 7, 8]) for _ in range(num_notes)
        ]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    if gamut:
        freqs = gamutScale()
    else:
        freqs = randomScale()

    if layered:
        num_layers = dsp.randint(2, 4)
    else:
        num_layers = 1

    layers = []

    for _ in range(num_layers):
        layer = ''

        elapsed = 0
        while elapsed < length:
            if poly:
                num_poly = dsp.randint(1, 3)
            else:
                num_poly = 1

            note_length = beat / dsp.randchoose([1, 2, 3, 4])

            notes = []
            for _ in range(num_poly):
                freq = dsp.randchoose(freqs)

                if logistic:
                    pulsewidth = log.get(low=0.05, high=1)

                    if log.get() > 0.5:
                        wf = log.choose(['sine', 'tri', 'saw'])
                        wf = dsp.wavetable(wf, 512)
                    else:
                        points = [
                            log.get(-1, 1) for _ in range(log.geti(4, 20))
                        ]
                        wf = dsp.breakpoint(points, 512)
                else:
                    pulsewidth = 1
                    wf = dsp.wavetable('sine', 512)

                note = keys.pulsar(length=note_length,
                                   freq=freq,
                                   wf=wf,
                                   env='phasor',
                                   pulsewidth=pulsewidth)
                notes += [note]

            notes = dsp.mix(notes)
            layer += notes

            elapsed += dsp.flen(notes)

        layers += [layer]

    out = dsp.mix(layers)
    out = dsp.amp(out, 0.75)
    out = dsp.fill(out, length)

    #out = dsp.pad(out, 0, int(dsp.stf(0.5, 1) * mpk.get(7)))

    p.set('pointer', log.pointer)

    if perc:
        kicks = makeKicks(length, wobble)
        hats = makeHats(length, wobble)
        claps = makeClaps(length, wobble)
        out = dsp.mix([out, kicks, hats, claps])

    out = dsp.amp(out, mpk.get(8))

    return out
Beispiel #39
0
import subprocess
import tweepy
import os

slen = dsp.rand(5, dsp.rand(15, 100))

layers = []
numlayers = dsp.randint(4, dsp.randint(10, 250))
for _ in range(numlayers):
    freq = dsp.rand(0.1, 5000)
    length = dsp.stf(slen)
    pulsewidth = dsp.rand(0.15, 1)
    waveform = [0] + dsp.breakpoint(
        [dsp.rand(-1, 1)
         for _ in range(dsp.randint(6, dsp.randint(10, 300)))], 512) + [0]
    window = dsp.wavetable(dsp.randchoose(['tri', 'hann', 'sine']), 512)
    mod = dsp.breakpoint([dsp.rand() for _ in range(dsp.randint(5, 2000))],
                         1024 * 4)
    modrange = dsp.rand(0.01, 10)
    modfreq = 1.0 / slen
    amp = dsp.rand(0.05, 0.25)

    layer = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod,
                       modrange, modfreq, amp)
    layer = fx.penv(layer)

    bits = []

    layer = dsp.vsplit(layer, dsp.mstf(1), dsp.stf(0.2))

    for bit in layer:
Beispiel #40
0
from pippi import dsp

freq = 440

beat = dsp.mstf(100)
length = dsp.stf(30)
numbeats = length / beat

layers = []

for layer in range(10):
    beats_steady = [beat for b in range(numbeats / 10)]
    beats_div = dsp.breakpoint([dsp.rand(1, 200) for b in range(10)],
                               numbeats - len(beats_steady))
    ramp = dsp.wavetable('line', len(beats_div))

    beats_div = [beat + dsp.mstf(d * r) for d, r in zip(beats_div, ramp)]

    beats = beats_steady + beats_div
    freqs = dsp.wavetable(dsp.randchoose(['line', 'phasor', 'tri', 'hann']),
                          len(beats))
    freqs = [freq + (100 * f) for f in freqs]

    layer = ''

    for b, f in zip(beats, freqs):
        blip = dsp.tone(length=b, freq=f, amp=dsp.rand(0.01, 0.2))
        blip = dsp.env(blip, 'phasor')
        blip = dsp.taper(blip, dsp.mstf(5))
        blip = dsp.pan(blip, dsp.rand())
Beispiel #41
0
from pippi import dsp
from hcj import data

layers = []

numgrains = 55555

for _ in range(4):
    layer = ''

    pans = dsp.breakpoint([dsp.rand() for _ in range(55)], numgrains)
    lens = [
        dsp.mstf(l * 80 + 20)
        for l in dsp.wavetable('line', numgrains / dsp.randint(50, 100))
    ]
    seeds = [
        s * 0.3 + 3.69
        for s in dsp.wavetable('line', numgrains / dsp.randint(50, 100))
    ]
    freqs = [
        f * 90 + 10
        for f in dsp.wavetable('line', numgrains / dsp.randint(50, 100))
    ]

    for freq, seed, length, pan in zip(freqs, seeds, lens, pans):
        log = data.Logistic(seed, 0.5, 555)
        amp = dsp.rand(0.1, 0.75)

        grain = dsp.ctone(freq, length, log.data, amp)
        grain = dsp.env(grain, 'random')
        grain = dsp.taper(grain, dsp.mstf(5))
Beispiel #42
0
from pippi import dsp
from matplotlib import pyplot as pp

xlen = 32

x = range(xlen)

sine = dsp.wavetable('sine2pi', xlen) 

control = dsp.breakpoint([ dsp.rand(-1, 1) for i in range(5) ], xlen)

blocks = [ sine[i % len(sine)] for i in range(xlen) ]

pp.bar(x, control, 
    width=0.8,
    color='m', 
    label='Control rate data'
)

pp.plot(x, blocks,
    linestyle='dotted',
    color='b',
    label='Signal rate data'
)

pp.xlabel('Blocks')
pp.ylabel('Values')
pp.xlim(0, 31)
pp.xticks(range(32), ['' for i in range(32)])
pp.ylim(-1, 1)
Beispiel #43
0
def play(voice_id):
    volume = P(voice_id, 'volume', 100.0)
    volume = volume / 100.0  # TODO: move into param filter
    volume = volume * 0.65
    length = P(voice_id, 'length', 40)
    env = False
    wii = False
    #    wii    = True

    speed = False

    numcycles = dsp.randint(1, 200)

    # Make breakpoint env with 2-10 vals between 0.1 and 1.0
    curve_a = dsp.breakpoint(
        [1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0],
        numcycles)

    # Make wavetable with single cycle from given wave types
    curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse']
    curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles)

    # Make pan curve - always cosine
    pan = dsp.breakpoint([dsp.rand() for i in range(dsp.randint(5, 50))],
                         numcycles)
    amps = dsp.breakpoint(
        [dsp.rand(0.1, 0.75) for i in range(dsp.randint(5, 30))], numcycles)

    # Multiply breakpoint curve with simple wavetable
    wtable = [curve_a[i] * curve_b[i] for i in range(numcycles)]

    # Scale to max frequency
    wtable = [(f * 20000) + length for f in wtable]

    # Possible osc wavetypes
    wtypes = ['sine2pi']
    #    wtypes = ['tri', 'sine2pi', 'impulse']
    #    wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary']

    if wii is True:
        out = [
            dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i])
            for i in range(numcycles)
        ]
    else:
        wtype = dsp.randchoose(wtypes)
        out = [
            dsp.pan(dsp.cycle(wtable[i], wtype), pan[i])
            for i in range(numcycles)
        ]

    out = [dsp.amp(oo, amps[i]) for i, oo in enumerate(out)]

    out = dsp.amp(''.join(out), volume)

    if speed != False and speed > 0.0:
        out = dsp.transpose(out, speed)

    if env != False:
        out = dsp.env(out, env)

    return out
Beispiel #44
0
boids = [[dsp.rand(0, 1) for _ in range(numpoints + 1)]
         for b in range(numboids)]

for p in range(numpoints - 1):
    center = 0
    for b in boids:
        center += b[p]

    center = center / float(numboids)

    for i, b in enumerate(boids):
        boids[i][p + 1] = boids[i][p] - ((center - boids[i][p]) / 1000.0)

out = []

freq = 300
wf = dsp.wavetable('sine2pi', 512)
win = dsp.wavetable('hann', 512)
length = dsp.stf(60)
pw = 1
modrange = 300
modfreq = 1.0 / 60

for b in boids:
    out += [dsp.pulsar(freq, length, pw, wf, win, b, modrange, modfreq, 0.1)]

out = dsp.mix(out)

dsp.write(out, 'boids')
Beispiel #45
0
def play(params):
    """ Usage:
            shine.py [length] [volume]
    """
    length      = params.get('length', dsp.stf(dsp.rand(0.1, 1)))
    volume      = params.get('volume', 100.0)
    volume = volume / 100.0 # TODO: move into param filter
    octave      = params.get('octave', 2) + 1 # Add one to compensate for an old error for now
    note        = params.get('note', ['c'])
    note = note[0]
    quality     = params.get('quality', tune.major)
    glitch      = params.get('glitch', False)
    superglitch = params.get('superglitch', False)
    pinecone    = params.get('pinecone', False)
    glitchpad   = params.get('glitch-padding', 0)
    glitchenv   = params.get('glitch-envelope', False)
    env         = params.get('envelope', False)
    ratios      = params.get('ratios', tune.terry)
    pad         = params.get('padding', False)
    bend        = params.get('bend', False)
    bpm         = params.get('bpm', 75.0)
    width       = params.get('width', False)
    wform       = params.get('waveform', False)
    instrument  = params.get('instrument', 'r')
    scale       = params.get('scale', [1,6,5,4,8])
    shuffle     = params.get('shuffle', False) # Reorganize input scale
    reps        = params.get('repeats', len(scale))
    alias       = params.get('alias', False)
    phase       = params.get('phase', False)
    pi          = params.get('pi', False)
    wild        = params.get('wii', False)
    root        = params.get('root', 27.5)
    trigger_id = params.get('trigger_id', 0)

    tune.a0 = float(root)

    try:
        # Available input samples
        if instrument == 'r':
            instrument = 'rhodes'
            tone = dsp.read('sounds/synthrhodes.wav').data
        elif instrument == 's':
            instrument = 'synthrhodes'
            tone = dsp.read('sounds/220rhodes.wav').data
        elif instrument == 'c':
            instrument = 'clarinet'
            tone = dsp.read('sounds/clarinet.wav').data
        elif instrument == 'v':
            instrument = 'vibes'
            tone = dsp.read('sounds/glock220.wav').data
        elif instrument == 't':
            instrument = 'tape triangle'
            tone = dsp.read('sounds/tape220.wav').data
        elif instrument == 'g':
            instrument = 'glade'
            tone = dsp.read('sounds/glade.wav').data 
        elif instrument == 'p':
            instrument = 'paperclips'
            tone = dsp.read('sounds/paperclips.wav').data
        elif instrument == 'i':
            instrument = 'input'
            tone = dsp.capture(dsp.stf(1))
    except:
        instrument = None
        tone = None

    out = ''

    # Shuffle the order of pitches
    if shuffle is not False:
        scale = dsp.randshuffle(scale)

    # Translate the list of scale degrees into a list of frequencies
    freqs = tune.fromdegrees(scale, octave, note, quality, ratios)
    freqs = [ freq / 4.0 for freq in freqs ] 

    # Format is: [ [ path, offset, id, value ] ]
    # Offset for video 
    osc_messages = [ ['/dac', float(dsp.fts(length)), 1, tune.fts(osc_freq)] for osc_freq in freqs ]

    # Phase randomly chooses note lengths from a 
    # set of ratios derived from the current bpm
    if phase is not False:
        ldivs = [0.5, 0.75, 2, 3, 4]
        ldiv = dsp.randchoose(ldivs)
        length = dsp.bpm2ms(bpm) / ldiv
        length = dsp.mstf(length)
        reps = ldiv if ldiv > 1 else 4


    # Construct a sequence of notes
    for i in range(reps):
        # Get the freqency
        freq = freqs[i % len(freqs)]

        # Transpose the input sample or 
        # synthesize tone
        if wform is False and tone is not None:
            # Determine the pitch shift required
            # to arrive at target frequency based on 
            # the pitch of the original samples.
            if instrument == 'clarinet':
                diff = freq / 293.7
            elif instrument == 'vibes':
                diff = freq / 740.0 
            else:
                diff = freq / 440.0

            clang = dsp.transpose(tone, diff)

        elif wform == 'super':
            clang = dsp.tone(length, freq, 'phasor', 0.5)
            clang = [ dsp.drift(clang, dsp.rand(0, 0.02)) for s in range(7) ]
            clang = dsp.mix(clang)

        elif wform is False and tone is None:
            clang = dsp.tone(length, freq, 'sine2pi', 0.75)
            clang = dsp.amp(clang, 0.6)

        else:
            clang = dsp.tone(length, freq, wform, 0.75)
            clang = dsp.amp(clang, 0.6)

        # Stupidly copy the note enough or 
        # trim it to meet the target length
        clang = dsp.fill(clang, length)

        # Give synth tones simple env (can override)
        if wform is not False and env is False:
            clang = dsp.env(clang, 'phasor')

        # Apply an optional amplitude envelope
        if env is not False:
            clang = dsp.env(clang, env)

        # Add optional padding between notes
        if pad != False:
            clang = dsp.pad(clang, 0, pad)

        # Add to the final note sequence
        out += clang

    # Add optional aliasing (crude bitcrushing)
    if alias is not False:
        out = dsp.alias(out)

    # Cut sound into chunks of variable length (between 5 & 300 ms)
    # Pan each chunk to a random position
    # Apply a sine amplitude envelope to each chunk
    # Finally, add variable silence between each chunk and shuffle the
    # order of the chunks before joining.
    if glitch is not False:
        out = dsp.vsplit(out, dsp.mstf(5), dsp.mstf(300))
        out = [dsp.pan(o, dsp.rand()) for o in out]

        out = [dsp.env(o, 'sine') for o in out]
    
        out = [dsp.pad(o, 0, dsp.mstf(dsp.rand(0, glitchpad))) for o in out]

        out = ''.join(dsp.randshuffle(out))

    # Detune between 1.01 and 0.99 times original speed 
    # as a sine curve whose length equals the total output length
    if bend is not False:
        out = dsp.split(out, 441)
        freqs = dsp.wavetable('sine', len(out), 1.01, 0.99)
        out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
        out = ''.join(out)

    if wild is not False:
        #out = dsp.vsplit(out, 400, 10000)
        out = dsp.split(out, 3000)
        out = [ dsp.amp(dsp.amp(o, dsp.rand(10, 50)), 0.5) for o in out ]
        #out = [ o * dsp.randint(1, 5) for o in out ]
        for index, o in enumerate(out):
            if dsp.randint(0, 1) == 0:
                out[index] = dsp.env(dsp.cut(o, 0, dsp.flen(o) / 4), 'gauss') * 4 

            if dsp.randint(0, 6) == 0:
                out[index] = dsp.transpose(o, 8) 

        out = [ dsp.env(o, 'gauss') for o in out ]
        freqs = dsp.wavetable('sine', len(out), 1.02, 0.98)
        out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
        out = ''.join(out)

    if pinecone == True:
        out = dsp.pine(out, int(length * dsp.rand(0.5, 8.0)), dsp.randchoose(freqs) * dsp.rand(0.5, 4.0))

    # Adjust output amplitude as needed and return audio + OSC 
    if pi:
        return (dsp.amp(out, volume), {'osc': osc_messages})
    else:
        return dsp.amp(out, volume)
Beispiel #46
0
from pippi import dsp

g = dsp.read('sounds/seneca3bars.wav').data

numsections = 12
numlayers = 30
numgrains = 22

sections = []
for s in range(numsections):
    layers = []

    for layer in range(numlayers):
        minlen = 40
        lenrange = dsp.rand(300, 500)
        lengths = dsp.wavetable('hann', numgrains * 2)[:numgrains]
        lengths = [ dsp.mstf(l * lenrange + minlen) for l in lengths ]
        pans = dsp.breakpoint([ dsp.rand() for p in range(numgrains / 3)], numgrains)

        layers += [ (lengths, pans) ]

    sections += [ layers ]

out = ''
for section in sections:
    layers = []
    for layer in section:
        startpoint = dsp.randint(0, dsp.flen(g) - max(layer[0]))
        
        grains = ''
        for l, p in zip(layer[0], layer[1]):
Beispiel #47
0
def play(ctl):
    param = ctl.get("param")

    lpd = ctl.get("midi").get("pc")
    lpd.setOffset(111)

    key = "g"

    # bd = dsp.read('/home/hecanjog/sounds/drums/Tinyrim2.wav').data
    # bd = dsp.read('/home/hecanjog/sounds/drums/Jngletam.wav').data
    # bd = dsp.read('/home/hecanjog/sounds/drums/78oh.wav').data
    # bd = dsp.amp(bd, 1)
    # bd = dsp.transpose(bd, dsp.rand(0.65, 0.72) / 1)
    # bd = dsp.transpose(bd, dsp.rand(0.3, 0.32) / 1)

    chord = tune.fromdegrees([1, 8], root="g", octave=dsp.randint(0, 2))
    chord.reverse()
    chord = dsp.rotate(chord, lpd.geti(4, low=0, high=len(chord) - 1))
    # chord = dsp.randshuffle(chord)

    reps = param.get("reps", default=16)
    rep = param.get("rep", default=0)
    beat = dsp.bpm2frames(130) / 4
    beat = dsp.mstf(4100) / 32
    # length = beat

    out = ""
    for n in range(4):
        freq = chord[int(rep) % len(chord)]

        if dsp.rand() > 0.5:
            freq *= 2 ** dsp.randint(0, lpd.geti(7, low=0, high=8, default=0))

        pw = lpd.get(8, low=0.1, high=1, default=1)
        # length = dsp.mstf(lpd.get(2, low=50, high=2500, default=500) * dsp.rand(0.5, 2))
        length = dsp.mstf(lpd.get(14, low=50, high=5000, default=500))

        wf = dsp.wavetable("tri", 512)
        wf = dsp.wavetable("impulse", 512)
        wf = dsp.wavetable("sine2pi", 512)
        wf = dsp.breakpoint([0] + [dsp.rand(-1, 1) for w in range(lpd.geti(15, low=4, high=200, default=4))] + [0], 512)

        win = dsp.wavetable("sine", 512)
        mod = [dsp.rand(0, 1) for m in range(512)]

        modr = dsp.rand(0.01, 0.02)
        modr = lpd.get(16, low=0.01, high=1, default=1)

        modf = dsp.rand(0.5, 2)

        amp = lpd.get(6, low=0, high=2, default=0)
        amp = dsp.rand(0, 2)

        o = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp)
        o = dsp.env(o, "random")
        o = dsp.taper(o, dsp.mstf(10))
        o = dsp.pan(o, dsp.rand())

        rep = rep + 1

        out += o

    # out = dsp.mix([ dsp.fill(bd, dsp.flen(out), silence=True), out ])

    param.set("rep", (rep + 1) % reps)

    return out