Пример #1
0
def play(voice_id):
    tel = bot.getTel()

    degrees = [ dsp.randchoose([1, 2, 3, 5, 6, 8]) for f in range(dsp.randint(2, 20)) ]
    #degrees = [ dsp.randchoose([1, 5, 6, 7, 8]) for f in range(dsp.randint(2, 10)) ]

    octave = dsp.randint(1, 4)

    freqs = tune.fromdegrees(degrees, root='c', octave=octave, ratios=tune.terry)

    out = ''

    for r in range(dsp.randint(2, 20)):
        freq = dsp.randchoose(freqs)
        waveform = dsp.randchoose(['tri', 'sine2pi'])

        length = dsp.randint(dsp.mstf(1), dsp.mstf(4000))
        #length = dsp.mstf(1500)
        #length = dsp.mstf(2500)

        pulsewidth = dsp.rand(0.01, 1)

        mod = dsp.breakpoint([ dsp.rand() for b in range(int(round(tel['density'])) + 3) ], 512)
        window = dsp.breakpoint([0] + [ dsp.rand() for b in range(int(round(tel['harmonicity'] * 2)) + 3) ] + [0], 512)
        waveform = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for b in range(int(round(tel['roughness'] * dsp.randint(1, 4))) + 3) ] + [0], 512)

        modRange = dsp.rand(0.01, 100.08)

        modFreq = dsp.rand(0.0001, 5)

        volume = dsp.rand(0.2, 0.3) * (tel['density'] / 10.0)
        #volume = dsp.rand(0.2, 0.8)

        t = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
        #t = dsp.tone(length, freq, waveform)

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

        t = dsp.alias(t)

        t = dsp.amp(t, dsp.rand(0.5, 15.0))

        t = dsp.pad(t, 0, dsp.randint(dsp.mstf(1), dsp.mstf(10)))

        t = dsp.amp(t, dsp.rand(0.5, 0.95))

        t = dsp.env(t, 'sine')
        #t = dsp.env(t, 'phasor')

        #t = dsp.pine(t, dsp.flen(t) * 4, freq)

        out += t


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

    return out
Пример #2
0
def ping(maxlen=44100, freqs=None):
    out = ''

    if freqs is None:
        freqs = [ dsp.rand(20,10000) for i in range(4) ]

    tlen = dsp.randint(10, maxlen)

    tones = [ dsp.tone(length=tlen, freq=freq, amp=0.1, wavetype='random') 
            for freq in freqs ]

    tones = [ dsp.split(tone, 64) for tone in tones ]

    pcurves = [ dsp.breakpoint([ dsp.rand() for t in range(len(tones[i]) / 20) ],
            len(tones[i])) for i in range(len(tones)) ]

    tones = [ [ dsp.pan(t, pcurves[i][ti]) for ti, t in enumerate(tones[i]) ] 
            for i in range(len(tones)) ]

    fcurves = [ dsp.breakpoint([ dsp.rand(0.0, 0.1) + 0.9 for t in range(len(tones[i]) / 20) ],
            len(tones[i])) for i in range(len(tones)) ]

    tones = [ [ dsp.transpose(t, fcurves[i][ti] + 0.1) for ti, t in enumerate(tones[i]) ] 
            for i in range(len(tones)) ]

    out = dsp.mix([ dsp.env(''.join(tone), 'random') for tone in tones ])
    out = dsp.env(out, 'random')
    out = dsp.pad(out, 0, dsp.randint(0, maxlen * 3))

    return out
Пример #3
0
def fracture(snd):
    numpoints = dsp.randint(3, 20)
    poscurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    poscurve = [ p * (dsp.flen(snd) - dsp.mstf(210)) for p in poscurve ]

    lencurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    lencurve = [ l * dsp.mstf(200) + dsp.mstf(10) for l in lencurve ]

    pancurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)

    prepadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    prepadcurve = [ int(p * dsp.mstf(20)) for p in prepadcurve ]

    postpadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    postpadcurve = [ int(p * dsp.mstf(20)) for p in postpadcurve ]

    speeds = [1.0, 2.0, 0.5, 0.75]

    grains = [ dsp.cut(snd, poscurve[i], lencurve[i]) for i in range(numpoints) ]
    grains = [ dsp.pan(grains[i], pancurve[i]) for i in range(numpoints) ]
    grains = [ dsp.env(grain, 'gauss', True) for grain in grains ]
    grains = [ dsp.transpose(grain, dsp.randchoose(speeds)) for grain in grains ]
    grains = [ dsp.pad(grains[i], prepadcurve[i], postpadcurve[i]) for i in range(numpoints) ]

    for i in range(numpoints):
        if dsp.randint(0, 3) == 0:
            grains[i] = slurp(grains[i])

    etypes = ['line', 'phasor', 'tri', 'sine', 'gauss']

    snd = dsp.env(''.join(grains), dsp.randchoose(etypes))
    snd = dsp.pad(snd, 0, dsp.mstf(dsp.rand(100, 400)))

    return snd
Пример #4
0
def play(voice_id):
    tel = bot.getTel()

    b = dsp.read('sounds/birds.wav').data

    b = dsp.split(b, dsp.randint(100, 1000))

    b = b[:dsp.randint(len(b) / 10, len(b))]

    blen = len(b)

    pans = dsp.breakpoint([ dsp.rand() for i in range(dsp.randint(10, 100)) ], blen)
    speeds = dsp.breakpoint([ dsp.rand(0.25, 1.5) for i in range(dsp.randint(10, 100)) ], blen)
    amps = dsp.breakpoint([ dsp.rand(0.05, 1.5) for i in range(dsp.randint(10, 100)) ], blen)

    b = [ dsp.pan(b[i], pans[i]) for i in range(blen) ]
    b = [ dsp.transpose(b[i], speeds[i]) for i in range(blen) ]
    b = [ dsp.amp(b[i], amps[i]) for i in range(blen) ]

    b = dsp.packet_shuffle(b, dsp.randint(4, 30))

    for i, bb in enumerate(b):
        if dsp.rand(0, 100) > 60:
            b[i] = bb * dsp.randint(2, 10)

    out = ''.join(b)

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

    return out
Пример #5
0
def penv(snd, low=4, high=20):
    packets = dsp.split(snd, dsp.dsp_grain)

    ptable = dsp.breakpoint([ dsp.rand() for _ in range(dsp.randint(low, high)) ], len(packets))
    etable = dsp.breakpoint([0] + [ dsp.rand() for _ in range(dsp.randint(low, high)) ] + [0], len(packets))

    packets = [ dsp.pan(p, ptable[i], etable[i]) for i, p in enumerate(packets) ]

    return ''.join(packets)
Пример #6
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
Пример #7
0
def play(voice_id):
    tel = bot.getTel()

    freqs = tune.fromdegrees([ dsp.randchoose([1, 2, 3, 5, 6, 8]) for f in range(dsp.randint(2, 5)) ], root='c', octave=dsp.randint(1, 3), ratios=tune.just)

    out = ''

    for freq in freqs:
        waveform = dsp.randchoose(['tri', 'sine2pi'])
        length = dsp.randint(dsp.mstf(10), dsp.mstf(300))
        #length = dsp.mstf(150)
        pulsewidth = dsp.rand()

        mod = dsp.breakpoint([ dsp.rand() for b in range(int(round(tel['density'])) + 3) ], 512)
        window = dsp.breakpoint([0] + [ dsp.rand() for b in range(int(round(tel['harmonicity'] * 2)) + 3) ] + [0], 512)
        waveform = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for b in range(int(round(tel['roughness'] * 3)) + 3) ] + [0], 512)

        modRange = 0.005
        modFreq = dsp.rand(0.0001, 5)

        volume = dsp.rand(0.2, 0.3)

        if dsp.rand(0, 100) > 50:
            t = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
        else:
            t = dsp.tone(length, freq, waveform)

        #t = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
        #t = dsp.tone(length, freq, waveform)

        t = dsp.pan(t, dsp.rand())
        t = dsp.alias(t)

        t = dsp.amp(t, dsp.rand(0.5, 5.0))

        t = dsp.pad(t, 0, dsp.randint(dsp.mstf(1), dsp.mstf(500)))
        #t = dsp.pad(t, 0, dsp.mstf(100))
        t = dsp.amp(t, dsp.rand(0.5, 0.75))

        #out += dsp.env(t, 'sine')
        out += t

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

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

    return out
Пример #8
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
Пример #9
0
def roll(snd, length=None, numlayers=2, minlen=10, maxlen=80, env=True, bend=True):
    layers = []

    for _ in range(numlayers):
        if length is None:
            numbeats = dsp.randint(20, 50)
        else:
            numbeats = length / dsp.mstf(minlen)

        lengths = dsp.breakpoint([ dsp.rand(minlen, maxlen) for _ in range(dsp.randint(5, numbeats/2)) ], numbeats)

        layer = ''
        for l in lengths:
            layer += dsp.fill(snd, dsp.mstf(l), silence=True)

        if bend:
            layer = fx.bend(layer, [ dsp.rand(0, 1) for _ in range(dsp.randint(5, 20)) ], dsp.rand(0.02, 1))

        if env:
            layer = fx.penv(layer)

        layers += [ layer ]

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

    return out
Пример #10
0
def ding(tone, tlength=88200, nlength=1000):

    def sequence(tonic='g'):
        numdegrees = dsp.randint(2, 8)
        degrees = [1,5,8,11,12]
        #scale = [ dsp.randchoose(degrees) for i in range(numdegrees) ]
        scale = degrees[dsp.randint(0, 3):]
        scale = dsp.randshuffle(scale)
        scale = tune.fromdegrees(scale, 1, tonic, tune.major, tune.terry) 
        
        return scale

    numtones = tlength / nlength
    numtones = 1 if numtones < 1 else numtones

    freqs = [ note / tune.ntf('g', 4) for note in sequence('g') ]

    tones = [ dsp.transpose(tone, freq) for freq in freqs ]
    #tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength + dsp.randint(0, 500)) for i in range(numtones) ]
    tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength) for i in range(numtones) ]

    #tones = [ dsp.drift(tone, 0.03) for tone in tones ]
    curve = dsp.breakpoint([0] + [ dsp.rand(0, 0.01) for i in range(3) ], len(tones))
    tones = [ dsp.drift(tone, curve[index % len(curve)]) for index, tone in enumerate(tones) ]

    tones = [ fade(tone) for tone in tones ]
    
    return dsp.amp(''.join(tones), 0.5)
Пример #11
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
Пример #12
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
Пример #13
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)
Пример #14
0
def ding(tone, tlength=88200, nlength=1000):
    def sequence(tonic='g'):
        numdegrees = dsp.randint(2, 8)
        degrees = [1, 5, 8, 11, 12]
        #scale = [ dsp.randchoose(degrees) for i in range(numdegrees) ]
        scale = degrees[dsp.randint(0, 3):]
        scale = dsp.randshuffle(scale)
        scale = tune.fromdegrees(scale, 1, tonic, tune.major, tune.terry)

        return scale

    numtones = tlength / nlength
    numtones = 1 if numtones < 1 else numtones

    freqs = [note / tune.ntf('g', 4) for note in sequence('g')]

    tones = [dsp.transpose(tone, freq) for freq in freqs]
    #tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength + dsp.randint(0, 500)) for i in range(numtones) ]
    tones = [
        dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength)
        for i in range(numtones)
    ]

    #tones = [ dsp.drift(tone, 0.03) for tone in tones ]
    curve = dsp.breakpoint([0] + [dsp.rand(0, 0.01) for i in range(3)],
                           len(tones))
    tones = [
        dsp.drift(tone, curve[index % len(curve)])
        for index, tone in enumerate(tones)
    ]

    tones = [fade(tone) for tone in tones]

    return dsp.amp(''.join(tones), 0.5)
Пример #15
0
def section():
    # Meter (beats per bar)
    meter = 5

    # Subdivision (of master beat)
    subdiv = 2

    # Bars
    bars = 8

    # Master tempo (ms)
    tempo = dsp.bpm2ms(200)

    # Longest beat (ms)
    long = (tempo / subdiv) * 1.2

    # Shortest beat (ms)
    short = tempo / subdiv

    # Beat delta (ms)
    delta = long - short

    num_beats = meter * bars * subdiv

    lengths = [ dsp.rand() for i in range(num_beats / 3) ]
    grid = dsp.breakpoint(lengths, num_beats)
    grid = [ dsp.mstf(beat * delta + short) for beat in grid ]

    # Break grid back up into bars
    grid = [ grid[index:index+(meter*2)] for index, beat in enumerate(grid) if index % (meter * 2) == 0 ]

    return grid
Пример #16
0
def play(args):
    length = dsp.stf(0.2)
    volume = 0.2 
    octave = 2 
    notes = ['d', 'a']
    quality = tune.major
    waveform = 'sine'
    ratios = tune.terry

    wtypes = ['sine', 'phasor', 'line', 'saw']

    for arg in args:
        a = arg.split(':')

        if a[0] == 't':
            length = dsp.stf(float(a[1]))

        if a[0] == 'v':
            volume = float(a[1]) / 100.0

        if a[0] == 'o':
            octave = int(a[1])

        if a[0] == 'n':
            notes = a[1].split('.')

        if a[0] == 'q':
            if a[1] == 'M':
                quality = tune.major
            elif a[1] == 'm':
                quality = tune.minor
            else:
                quality = tune.major

        if a[0] == 'tr':
            ratios = getattr(tune, a[1], tune.terry)

    harm = range(1, 12)

    layers = []
    for note in notes:
        freq = tune.ntf(note, octave, ratios) 
        #tonic = dsp.env(dsp.amp(dsp.tone(length, freq, 'sine2pi'), 0.2), 'phasor') * 500

        tones = []

        for t in range(4):
            angles = dsp.breakpoint([ freq * dsp.randchoose(harm) for f in range(dsp.randint(2, 20)) ], 100)
            angles = [ dsp.env(dsp.tone(length, a, 'sine2pi'), 'sine', amp=0.2) for a in angles ]
            tones += [ ''.join(angles) ]

        #layer = dsp.benv(dsp.mix(tones), [ dsp.rand(0.1, 0.7) for i in range(dsp.randint(5, 30)) ]) 
        layers += [ dsp.mix(tones) ]
        #layers += [ dsp.mix([layer, tonic]) ]
        #layers += [ layer ]

    out = dsp.mix(layers)

    return dsp.amp(out, volume)
Пример #17
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
Пример #18
0
def play(voice_id):
    tel = bot.getTel()

    degrees = [ dsp.randchoose([1, 2, 3, 4, 5, 6, 7, 8]) for f in range(dsp.randint(2, 6)) ]

    octave = dsp.randint(1, 4)

    freqs = tune.fromdegrees(degrees, root='c', octave=octave, ratios=tune.just)

    out = ''

    freq = dsp.randchoose(freqs)
    volume = dsp.rand(0.5, 0.8)
    length = dsp.randint(dsp.mstf(20), dsp.mstf(30))

    for p in range(dsp.randint(20, 100)):

        pulsewidth = dsp.rand(0.5, 1)

        mod = dsp.breakpoint([ dsp.rand(0, 1) for b in range(4) ], 512)
        window = dsp.breakpoint([0] + [ dsp.rand(0, 1) for b in range(10) ] + [0], 512)
        waveform = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for b in range(20) ] + [0], 512)

        modRange = 0.01
        modFreq = dsp.rand(0.0001, 5)

        t = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume)

        t = dsp.pad(t, 0, length * 3)

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

        out += t

    out = dsp.env(out, 'sine')
    out = dsp.pan(out, dsp.rand(0, 1))

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

    return out
Пример #19
0
def fracture(snd):
    numpoints = dsp.randint(3, 20)
    poscurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)
    poscurve = [p * (dsp.flen(snd) - dsp.mstf(210)) for p in poscurve]

    lencurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)
    lencurve = [l * dsp.mstf(200) + dsp.mstf(10) for l in lencurve]

    pancurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)

    prepadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                                 numpoints)
    prepadcurve = [int(p * dsp.mstf(20)) for p in prepadcurve]

    postpadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                                  numpoints)
    postpadcurve = [int(p * dsp.mstf(20)) for p in postpadcurve]

    speeds = [1.0, 2.0, 0.5, 0.75]

    grains = [dsp.cut(snd, poscurve[i], lencurve[i]) for i in range(numpoints)]
    grains = [dsp.pan(grains[i], pancurve[i]) for i in range(numpoints)]
    grains = [dsp.env(grain, 'gauss', True) for grain in grains]
    grains = [dsp.transpose(grain, dsp.randchoose(speeds)) for grain in grains]
    grains = [
        dsp.pad(grains[i], prepadcurve[i], postpadcurve[i])
        for i in range(numpoints)
    ]

    for i in range(numpoints):
        if dsp.randint(0, 3) == 0:
            grains[i] = slurp(grains[i])

    etypes = ['line', 'phasor', 'tri', 'sine', 'gauss']

    snd = dsp.env(''.join(grains), dsp.randchoose(etypes))
    snd = dsp.pad(snd, 0, dsp.mstf(dsp.rand(100, 400)))

    return snd
Пример #20
0
def play(voice_id):
    reload(keys)

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

    scale = [1,5,8]

    if dsp.rand() > 0.5:
        scale = reversed(scale)

    freqs = tune.fromdegrees(scale, root=root, octave=dsp.randint(1, 3), ratios=ratios, scale=quality)

    freqs = dsp.rotate(freqs, dsp.randint(0, len(freqs)))

    out = ''

    length = int(dsp.bpm2frames(bpm) * dsp.randchoose([0.25, 0.5, 1]) * 0.5) 
    length = dsp.bpm2frames(bpm) * 4
    length = dsp.stf(dsp.rand(1, 8))
    for n in range(dsp.randint(1, 3)):
        amp = dsp.rand(0.3, 0.65)
        freq = dsp.randchoose(freqs)
        freq = freqs[n%len(freqs)]
        b = keys.chippy(length=length, freq=freq, amp=amp)

        b = dsp.split(b, 100)

        oenvs = dsp.breakpoint([0,0,0,0] + [ dsp.rand() for i in range(len(b) / 10) ], len(b))
        opans = dsp.breakpoint([dsp.rand(0.4, 0.6)] + [ dsp.rand() for i in range(len(b) / 100) ] + [0.5], len(b))
        b = [ dsp.amp(b[i], oenvs[i]) for i in range(len(b)) ]
        b = [ dsp.pan(b[i], opans[i]) for i in range(len(b)) ]

        b = ''.join(b)
        #b = dsp.env(b, 'phasor')
        b = dsp.env(b, 'sine')

        out += b

    return out
Пример #21
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)
Пример #22
0
def make_vary(snd):
    numpoints = dsp.flen(snd) / 40
    curve = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(dsp.randint(5, numpoints / 100)) ] + [0], numpoints)
    
    snd = dsp.split(snd, 40)

    snd = [ dsp.amp(snd[i], curve[i]) for i in range(numpoints) ]

    snd = ''.join(snd)

    return snd
Пример #23
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
Пример #24
0
def makeShape():
    shape = []

    num_shapelets = dsp.randint(3, 8)

    for _ in range(num_shapelets):
        shapelet_size = dsp.randint(20, 100)
        num_points = dsp.randint(4, shapelet_size / dsp.randint(3, 4))
        shapelet = dsp.breakpoint([ dsp.rand() for _ in range(num_points) ], shapelet_size)

        shape += shapelet

    return shape
Пример #25
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)
Пример #26
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)
Пример #27
0
def makeShape():
    shape = []

    num_shapelets = dsp.randint(3, 8)

    for _ in range(num_shapelets):
        shapelet_size = dsp.randint(20, 100)
        num_points = dsp.randint(4, shapelet_size / dsp.randint(3, 4))
        shapelet = dsp.breakpoint([dsp.rand() for _ in range(num_points)],
                                  shapelet_size)

        shape += shapelet

    return shape
Пример #28
0
def makeBloop(length, i, bfreqs):
    bfreq = dsp.randchoose(bfreqs)

    if dsp.rand() > 0.5:
        blength = length if length <= dsp.mstf(80) else dsp.mstf(dsp.rand(40, 80))
    else:
        blength = length

    wf = dsp.breakpoint([0] + [ dsp.rand(-1,1) for _ in range(dsp.randint(8, 20)) ] + [0], 512)

    bloop = dsp.mix([ keys.pulsar(bf, blength, wf=wf, amp=dsp.rand(0.1, 0.5)) for bf in [ bfreq, bfreq / 2, bfreq * 2 ] ])
    bloop = dsp.env(bloop, 'phasor')

    bloop = dsp.fill(bloop, length, silence=True)

    return bloop
Пример #29
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
Пример #30
0
    def stream(length, numsegments, freq):

        out = []
        seglength = dsp.randint(100, 300)
        points = [ dsp.rand(-1, 1) for _ in range(dsp.randint(10, 20)) ]

        for _ in range(numsegments):
            seglength = dsp.cap(seglength + dsp.randint(-5, 5), 1000, 100)
            points = [ dsp.cap(p + dsp.randint(-0.1, 0.1), 1, -1) for p in points ]

            out += dsp.breakpoint([0] + points + [0], seglength)

        print len(out), freq, length

        out = dsp.ctone(freq, dsp.stf(length), out, dsp.rand(0.1, 0.5))
        #out = dsp.env(out, 'random')

        return out
Пример #31
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
Пример #32
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
Пример #33
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
Пример #34
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
Пример #35
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
Пример #36
0
        minfloor = 5
        maxfloor = 200

    if canPlay('vary', bigoldsection):
        numpoints = dsp.randint(8, 100)
        numdests = numpoints / dsp.randint(2, 4)
        minvary = dsp.randint(1, 100)
        maxvary = dsp.randint(100, 300)
        minfloor = dsp.randint(10, 50)
        maxfloor = dsp.randint(50, 200)


    numpoints *= 3
    numdests *= 3

    lcurve = dsp.breakpoint([ dsp.rand() for l in range(numdests) ], numpoints)
    lvary = dsp.rand(minvary, maxvary)
    lfloor = dsp.rand(minfloor, maxfloor)
    lcurve = [ dsp.mstf(length * lvary + lfloor) for length in lcurve ]

# Break curve into variable size groups
    segments = []
    count = 0
    minseg = 1
    maxseg = 20
    while count < len(lcurve):
        segsize = dsp.randint(minseg, maxseg)
        seg = lcurve[count : count + segsize]
        segments += [ seg ]

        count += segsize
Пример #37
0
def makeRimshot(length, i):
    return dsp.fill(dsp.amp(rimshot, dsp.rand(4, 5)), length, silence=True)


nchords = 12
npulses = 200
nlayers = 3
sectionlength = dsp.stf(dsp.rand(10, 12))

for _ in range(nchords):
    layers = []

    for _ in range(nlayers):
        layer = ''
        highs = dsp.breakpoint(
            [dsp.rand(60, 15000) for _ in range(npulses / 50)], npulses)
        lows = [dsp.rand(20, freq) for freq in highs]
        amps = dsp.breakpoint(
            [dsp.rand(0.1, 0.3) for _ in range(npulses / 50)], npulses)
        pans = dsp.breakpoint([dsp.rand(0, 1) for _ in range(npulses / 10)],
                              npulses)
        lengths = [
            dsp.mstf(l) for l in dsp.breakpoint(
                [dsp.rand(1, 30) for _ in range(npulses / 10)], npulses)
        ]

        for high, low, amp, pan, length in zip(highs, lows, amps, pans,
                                               lengths):
            p = dsp.bln(length,
                        low,
                        high,
Пример #38
0
import orc.suiteguitar
import orc.rhodes
import orc.guitar
import orc.wes
import ctl

dsp.timer('start')

key = 'g'

out = ''
nsegs = 60

segs = ctl.tempoPath(nsegs)

kickprob = [0 for _ in range(20)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 30) + [0 for _ in range(10)]
snareprob = [0 for _ in range(20)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 30) + [0 for _ in range(10)]
hatprob = [0 for _ in range(10)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 20) + [0 for _ in range(10)]
suiteguitarprob = dsp.breakpoint([dsp.rand() for _ in range(8)], 15) + [
    0 for _ in range(nsegs - 30)
] + dsp.breakpoint([dsp.rand() for _ in range(8)], 15)
stabprob = [0 for _ in range(3)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 6) + [0 for _ in range(3)]
pulseprob = [0 for _ in range(3)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 6) + [0 for _ in range(3)]
longchordprob = [1 for _ in range(3)] + dsp.breakpoint(
    [dsp.rand() for _ in range(8)], nsegs - 6) + [1 for _ in range(3)]
guitarprob = [1 for _ in range(nsegs)]
glitchprob = [1 for _ in range(3)] + dsp.breakpoint(
Пример #39
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

    scale = [ dsp.randchoose([1, 3, 5, 6, 8]) for s in range(dsp.randint(2, 4)) ]
    #scale = [ dsp.randchoose([1, 2, 4, 6, 8]) for s in range(dsp.randint(2, 4)) ]

    freqs = tune.fromdegrees(scale, root='a', octave=dsp.randint(2,3), scale=tune.minor)
    freq = dsp.randchoose(freqs)

    pw = lpd.get(2, low=0.01, high=1, default=1)
    pw = dsp.rand(0.01, 1)
    modr = lpd.get(6, low=0.001, high=0.1)
    modr = dsp.rand(0.001, 0.05)
    #modr = dsp.rand(0.1, 10.5)
    #modr = dsp.rand(0.001, 0.01)
    modr = dsp.rand(0, modr)
    modf = dsp.rand(0.01, 0.05)
    amp = lpd.get(1, low=0, high=2, default=0)
    #amp = dsp.rand(0.1, 0.5)
    #amp = 0

    length = dsp.stf(lpd.get(5, low=0.5, high=14, default=1) * dsp.rand(0.75, 2))
    length = dsp.stf(dsp.rand(5.5, 24) * dsp.rand(0.75, 2))
    #length = dsp.stf(dsp.rand(0.5, 0.75) * dsp.rand(0.75, 2))

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

    layers = []

    harmonics = [1, 2, 3, 4]

    for harmonic in harmonics:
        f = freq * harmonic
        if harmonic > 4:
            a = dsp.rand(0.05, 0.1)
        else:
            a = amp * dsp.rand(0.1, 0.5)

        layer = dsp.pulsar(f, length, pw, wf, win, mod, modr, modf, a * 2)
        layer = dsp.env(layer, dsp.randchoose(['sine', 'tri', 'line', 'phasor']))
        layer = dsp.taper(layer)
        layer = dsp.pan(layer, dsp.rand())
        layer = dsp.mix([ dsp.drift(layer, dsp.rand(0.01, 0.03)), layer ])

        if dsp.rand() > 0.5:
            layer = dsp.vsplit(layer, dsp.mstf(50), dsp.mstf(500))
            bit = dsp.randchoose(layer)
            bit = bit * dsp.randint(1, 3)
            bit = dsp.transpose(bit, dsp.randchoose([1, 2, 4, 8]))
            layer = ''.join(layer)
            layer = dsp.insert_into(layer, bit, dsp.randint(0, dsp.flen(layer) - dsp.flen(bit)))

        layers += [ layer ]

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

    return out
Пример #40
0
from pippi import dsp
from hcj import data

numgrains = 1000
numsines = 100
length = dsp.mstf(100)

dist = data.Logistic(3.99, 0.5, numsines).data
dist = sorted(dist)

lows = dsp.breakpoint([ dsp.rand(10, 100) for _ in range(100) ], numgrains)
highs = dsp.breakpoint([ dsp.rand(100, 1000) for _ in range(100) ], numgrains)

out = ''
for lowfreq, highfreq in zip(lows, highs):
    layers = []

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

    out += dsp.taper(dsp.env(dsp.mix(layers), 'hann'), dsp.mstf(10))

dsp.write(out, 'shifty')
Пример #41
0
def mc(r, numpoints):
    numlands = dsp.randint(5, 20)
    return dsp.breakpoint([ dsp.rand(r[0], r[1]) for i in range(numlands) ], numpoints)
Пример #42
0
numevents = 100
numlayers = 3

layers = []

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

    for _ in range(numevents):
        slength = dsp.rand(0.1, 4)
        length = dsp.stf(slength)
        freq = (1.0 / slength) * dsp.rand(0.5, 10)
        amp = dsp.rand(0.1, 0.5)

        log = dsp.breakpoint(
            data.Logistic(dsp.rand(3.88, 3.99), 0.5, length / 10).data, length)
        mult = dsp.breakpoint(
            [0] + [dsp.rand(-1, 1) for _ in range(dsp.randint(50, 100))] + [0],
            length)

        wf = [m * l for m, l in zip(mult, log)]

        o = dsp.ctone(freq, length, wf, amp)
        o = dsp.env(o, 'random')
        o = dsp.pan(o, dsp.rand())
        o = dsp.taper(o, dsp.mstf(20))

        layer += o

    layers += [layer]
Пример #43
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]
Пример #44
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())
Пример #45
0
        maxvary = 800
        minfloor = 5
        maxfloor = 200

    if canPlay('vary', bigoldsection):
        numpoints = dsp.randint(8, 100)
        numdests = numpoints / dsp.randint(2, 4)
        minvary = dsp.randint(1, 100)
        maxvary = dsp.randint(100, 300)
        minfloor = dsp.randint(10, 50)
        maxfloor = dsp.randint(50, 200)

    numpoints *= 3
    numdests *= 3

    lcurve = dsp.breakpoint([dsp.rand() for l in range(numdests)], numpoints)
    lvary = dsp.rand(minvary, maxvary)
    lfloor = dsp.rand(minfloor, maxfloor)
    lcurve = [dsp.mstf(length * lvary + lfloor) for length in lcurve]

    # Break curve into variable size groups
    segments = []
    count = 0
    minseg = 1
    maxseg = 20
    while count < len(lcurve):
        segsize = dsp.randint(minseg, maxseg)
        seg = lcurve[count:count + segsize]
        segments += [seg]

        count += segsize
Пример #46
0
        while currentfreq <= maxfreq:
            currentfreq = root * mult
            if currentfreq <= maxfreq:
                partials += [currentfreq]
                mult += 1

    return sorted(set(partials).union())


partials = getPartials(roots)

maxpartial = max(partials)
minpartial = min(partials)
numgrains = 1000

b1 = dsp.breakpoint([dsp.rand(minpartial, maxpartial) for r in range(10)],
                    numgrains)
b2 = dsp.breakpoint([dsp.rand(minpartial, maxpartial) for r in range(10)],
                    numgrains)


def makeGrain(freq, length):
    grain = dsp.tone(length, freq, amp=dsp.rand(0.05, 0.1))
    grain = dsp.pan(grain, dsp.rand())
    return grain


out = []

for i in range(numgrains):
    grainlen = dsp.mstf(dsp.rand(30, 100))
Пример #47
0
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]):
            grain = dsp.cut(g, startpoint, l)
            grain = dsp.env(grain, 'phasor')
Пример #48
0
from pippi import dsp

freqs = [55, 220, 440, 770]
length = dsp.stf(90)

layers = []

for freq in freqs:
    amp = dsp.rand(0.05, 0.1)

    wf1 = dsp.breakpoint([ dsp.rand(-1, 1) for p in range(7) ], 512)
    wf2 = dsp.breakpoint([ dsp.rand(-1, 1) for p in range(4) ], 512)

    layer = dsp.subtract(dsp.ctone(freq * 0.999, length, wf1, amp), dsp.ctone(freq, length, wf2, amp))
    layer = dsp.pan(layer, dsp.rand())
    layer = dsp.env(layer, 'random')

    layers += [ layer ]

out = dsp.mix(layers)

dsp.write(out, 'retabler2')
Пример #49
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
Пример #50
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))
Пример #51
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
Пример #52
0
lens = tune.fromdegrees([1,2,3,4,5,6,8,9], 1, 'c')
lens = [ dsp.htf(ll) - 1 for ll in lens ]

w = dsp.split(wesley, 1)
w = [ ww for i, ww in enumerate(w) if i % 30 == 0 ]
w = [ dsp.pad(ww, 0, dsp.randchoose(lens) / dsp.randint(1, 3)) for ww in w ]
w = [ ww * dsp.randint(0, 10) for ww in w ]
w = [ dsp.pan(ww, dsp.rand()) for ww in w ]
w = [ dsp.amp(ww, dsp.rand(1, 30)) for ww in w ]
out = ''.join(w)

dsp.write(out, 'wesley_thirty_10')

## 11
out = ''
curves = [ dsp.breakpoint([ dsp.rand() for p in range(3) ], 30) for c in range(30) ]

for curve in curves:
    clen = dsp.mstf(30)
    s = dsp.randchoose(snds)
    t = [ dsp.cut(s, dsp.flen(s) * c - clen, clen) for c in curve ]
    t = [ dsp.env(tt, 'sine') for tt in t ]
    t = [ dsp.pan(t[i], curve[i]) for i, c in enumerate(curve) ]
    curve.reverse()
    t = [ dsp.transpose(t[i], (curve[i] * 0.5) + 0.75) for i, c in enumerate(curve) ]
    t = ''.join(t)
    out += t

dsp.write(out, 'wesley_thirty_11')

## 12
Пример #53
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))