Ejemplo n.º 1
0
def makeSnare(length, i, amp):
    s = dsp.cut(snare, 0, dsp.randint(dsp.mstf(40), dsp.flen(snare)))
    s = dsp.alias(s, dsp.randint(4, 12))
    s = dsp.taper(s)
    s = dsp.fill(s, length, silence=True)
    s = dsp.amp(s, dsp.rand(2,4))
    return s
Ejemplo n.º 2
0
def makeGlitch(length, i):
    g = dsp.cut(long_chord, dsp.randint(0,
                                        dsp.flen(long_chord) - length), length)
    g = dsp.alias(g)
    g = dsp.fill(g, length)

    return g
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def makeSnare(length, i, amp):
    s = dsp.cut(snare, 0, dsp.randint(dsp.mstf(40), dsp.flen(snare)))
    s = dsp.alias(s, dsp.randint(4, 12))
    s = dsp.taper(s)
    s = dsp.fill(s, length, silence=True)
    s = dsp.amp(s, dsp.rand(2, 4))
    return s
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
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
Ejemplo n.º 7
0
def make(length, i):
    r = dsp.transpose(guitar, getRatio(scale[ i % len(scale)]))
    r = dsp.mix([ dsp.pan(r, dsp.rand()), dsp.drift(dsp.pan(r, dsp.rand()), dsp.rand(0.001, 0.02)) ])

    if dsp.rand() > 0.5:
        r = dsp.alias(r)

    if dsp.rand() > 0.5:
        r = dsp.split(r, dsp.flen(r) / dsp.randint(2,5))
        r = dsp.randshuffle(r)
        r = ''.join(r)

    r = dsp.amp(r, dsp.rand(0.1, 0.75))

    g = dsp.fill(r, length, silence=True)

    return g
Ejemplo n.º 8
0
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality'))
    ratios = getattr(tune, config('tune'))

    beat = dsp.bpm2frames(bpm)
    beat = beat / 4

    glitch = False
    alias = False
    nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16]))

    gs = ['gC1', 'gC2']
    g = dsp.randchoose(gs)
    n = dsp.read('sounds/%s.wav' % g).data

    #    speeds = [1, 1.25, 1.5, 1.666, 2, 4]
    speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16]

    root = tune.ntf('c')
    target = tune.ntf(key)

    n = dsp.transpose(n, target / root)
    n = dsp.fill(n, dsp.stf(20))
    n = dsp.transpose(n, dsp.randchoose(speeds))
    n = dsp.split(n, beat)
    n = dsp.randshuffle(n)
    n = n[:nbeats + 1]

    if alias:
        n = [dsp.alias(nn) for nn in n]

    n = [dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n]
    n = [dsp.pan(nn, dsp.rand()) for nn in n]

    n = ''.join(n)

    out = n

    if glitch:
        out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
Ejemplo n.º 9
0
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    beat = dsp.bpm2frames(bpm)
    beat = beat / 4

    glitch = False
    alias = False
    nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16]))

    gs = ['gC1', 'gC2']
    g = dsp.randchoose(gs)
    n = dsp.read('sounds/%s.wav' % g).data

#    speeds = [1, 1.25, 1.5, 1.666, 2, 4]
    speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16]

    root = tune.ntf('c')
    target = tune.ntf(key)

    n = dsp.transpose(n, target / root)
    n = dsp.fill(n, dsp.stf(20))
    n = dsp.transpose(n, dsp.randchoose(speeds))
    n = dsp.split(n, beat)
    n = dsp.randshuffle(n)
    n = n[:nbeats + 1]

    if alias:
        n = [ dsp.alias(nn) for nn in n ]

    n = [ dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n ]
    n = [ dsp.pan(nn, dsp.rand()) for nn in n ]

    n = ''.join(n)

    out = n

    if glitch:
        out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
Ejemplo n.º 10
0
def make(length, i):
    r = dsp.transpose(guitar, getRatio(scale[i % len(scale)]))
    r = dsp.mix([
        dsp.pan(r, dsp.rand()),
        dsp.drift(dsp.pan(r, dsp.rand()), dsp.rand(0.001, 0.02))
    ])

    if dsp.rand() > 0.5:
        r = dsp.alias(r)

    if dsp.rand() > 0.5:
        r = dsp.split(r, dsp.flen(r) / dsp.randint(2, 5))
        r = dsp.randshuffle(r)
        r = ''.join(r)

    r = dsp.amp(r, dsp.rand(0.1, 0.75))

    g = dsp.fill(r, length, silence=True)

    return g
Ejemplo n.º 11
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
Ejemplo n.º 12
0
def play(params):
    bpm = params.get('bpm', 80)

    # Choose sound from gamut
    s = dsp.randchoose(gamut)

    beat = dsp.mstf(dsp.bpm2ms(bpm * 2))

    # Choose num beats
    numbeats = dsp.randint(1, 7)

    out = ''

    # for each beat:
    for b in range(numbeats):
        b = dsp.transpose(s, 2**dsp.randint(0, 6))

        # Cut to beat length
        b = dsp.fill(b, beat)

        # Envelope it
        b = dsp.env(b, 'phasor')

        # Pan it
        b = dsp.pan(b, dsp.rand())

        # Alias it
        if dsp.randint(0,1) == 0:
            b = dsp.alias(b)

        # Amp it
        b = dsp.amp(b, dsp.rand(0.5, 1.0))

        # Pinecone it
        #b = dsp.pine(b, dsp.flen(b) * 4, 245.27 * (2**dsp.randint(0,4)))

        out += b

    return out
Ejemplo n.º 13
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
Ejemplo n.º 14
0
def play(ctl):
    pianos = ['sawvib', 'piano', 'pianooct1', 'harp', 'saw']
    pianos = ['sawvib', 'piano']
    piano = snds.load('genie/%s.wav' % dsp.randchoose(pianos))
    notes = [1,3,5]
    chord = tune.fromdegrees([ dsp.randchoose(notes) + (dsp.randchoose([0, 1]) * 8) for _ in range(dsp.randint(1, 3)) ], octave=0)
    length = dsp.stf(dsp.rand(1, 4))

    layers = []

    for freq in chord:
        p = dsp.transpose(piano, freq / 220.0)
        p = dsp.amp(p, 0.35)
        #p = dsp.pan(p, dsp.rand())
        p = dsp.fill(p, length)

        if dsp.rand() > 0.25:
            p = dsp.vsplit(p, dsp.mstf(100), dsp.mstf(500))
            p = [ dsp.pan(pp, dsp.rand()) for pp in p ]
            p = [ dsp.amp(pp, dsp.rand(0,2)) for pp in p ]
            p = [ dsp.transpose(pp, dsp.randchoose([1,2,4,8])) for pp in p ]
            p = [ dsp.taper(pp, 20) for pp in p ]
            p = [ dsp.pad(pp, 0, dsp.mstf(dsp.rand(0, 100))) for pp in p ]
            p = dsp.randshuffle(p)
            p = ''.join(p)

        if dsp.rand() > 0.75:
            p = dsp.alias(p)

        #p = dsp.env(p, 'phasor')

        layers += [ p ]

    out = dsp.mix(layers)

    return out
Ejemplo n.º 15
0
            if dsp.randint(0,1) == 0 or canPlay('jam', bigoldsection):
                # Blips
                blips = []

                the_blip = dsp.amp(dsp.transpose(notes[0], 2.0 * dsp.randint(1, 3)), 0.4)
                blip = dsp.mix([ the_blip, dsp.amp(dsp.transpose(notes[0], 1.5 * dsp.randint(1, 4)), 0.4) ])

                for length in seg:
                    ba = dsp.cut(blip, dsp.randint(0, dsp.flen(blip) / 4), length / 2)
                    bb = dsp.cut(blip, dsp.randint(0, dsp.flen(blip) / 4), length / 2)

                    b = dsp.mix([dsp.pan(ba, dsp.rand()), dsp.pan(bb, dsp.rand())])

                    blips += [ dsp.pad(b, 0, length / 2) ]

                blips = dsp.alias(''.join(blips))
                blips = mixdrift(blips)

                blipsPlay += 1
                layers += [ blips ]


        single = [1] + ([0] * (len(seg) - 1))

        if canPlay('jam', bigoldsection) or canPlay('breakdown', bigoldsection):
            # Hats
            if len(seg) >= 2:
                if bigoldsection > 11:
                    maxbeats = dsp.randint(len(seg) / 2, len(seg))
                    hatpat = drums.eu(len(seg), maxbeats)
                else:
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
        rimshots = ctl.makeBeat(pattern, [ beat for _ in range(numbeats) ], makeRimshot)
        if dsp.rand() > 0.75:
            rimshots = dsp.amp(drums.roll(rimshot, dsp.flen(bar), dsp.randint(2, 6)), dsp.rand(0.4, 1))

        layers += [ rimshots ]

    if canPlay('kicks', section):
        kickp = 'x.......'
        pattern = ctl.parseBeat(kickp)
        kicks = ctl.makeBeat(pattern, [ beat for _ in range(numbeats) ], makeKick)
        kicks = dsp.amp(kicks, dsp.rand(2,4))
        layers += [ kicks ]

    if canPlay('smashes', section):
        sm = dsp.fill(smash, dsp.flen(bar))
        sm = dsp.mix([ dsp.alias(sm), fx.penv(sm) ])
        sm = dsp.amp(sm, dsp.rand(0.5, 2))
        sk = dsp.fill(skitter, dsp.flen(bar))
        sk = fx.penv(sk)

        layers += [ sm, sk ]

    if count % 4 == 0:
        layers += [ dsp.pad(flam, dsp.flen(bar) - dsp.flen(flam), 0) ]

    if canPlay('bloops', section):
        bfreqs = tune.chord(cname, key, 2)
        bloopp = 'x.x.--------' if dsp.rand() > 0.5 else 'xxx.--------'
        bloopp = bloopp if dsp.rand() > 0.65 else 'xxx.----'
        pattern = ctl.parseBeat(bloopp)
        bloops = ctl.makeBeat(pattern, [ beat / 2 for _ in range(16) ], makeBloop, bfreqs)
Ejemplo n.º 18
0
    def makeGlitch(length, i):
        g = dsp.cut(long_chord, dsp.randint(0, dsp.flen(long_chord) - length), length)
        g = dsp.alias(g)
        g = dsp.fill(g, length)

        return g
Ejemplo n.º 19
0
from pippi import dsp

main = dsp.read('base_loop.wav').data
synth = dsp.read('synthloop.wav').data
beat = dsp.flen(main) / 128

freq = 430
s = dsp.pine(synth, dsp.flen(main) * 8, freq)
s = dsp.split(s, beat)
s = dsp.randshuffle(s)
s = [dsp.alias(ss) for ss in s]
s = [dsp.amp(ss, dsp.rand(0.5, 2)) for ss in s]
s = [dsp.pan(ss, dsp.rand(0, 1)) for ss in s]
s = ''.join(s)
s = dsp.fill(s, dsp.flen(synth))

s2 = dsp.split(synth, beat)
s2 = dsp.randshuffle(s2)
s2 = [dsp.transpose(ss, dsp.randchoose([1, 2, 4])) for ss in s2]
s2 = [dsp.fill(ss, beat) for ss in s2]
s2 = [dsp.env(ss, 'phasor') for ss in s2]
s2 = ''.join(s2)

synth = dsp.mix([s, s2])
synth = dsp.fill(synth, dsp.flen(main))

#synth = dsp.fill(synth, dsp.flen(main))

out = dsp.mix([main, synth])
#out = synth
Ejemplo n.º 20
0
                for length in seg:
                    ba = dsp.cut(blip, dsp.randint(0,
                                                   dsp.flen(blip) / 4),
                                 length / 2)
                    bb = dsp.cut(blip, dsp.randint(0,
                                                   dsp.flen(blip) / 4),
                                 length / 2)

                    b = dsp.mix(
                        [dsp.pan(ba, dsp.rand()),
                         dsp.pan(bb, dsp.rand())])

                    blips += [dsp.pad(b, 0, length / 2)]

                blips = dsp.alias(''.join(blips))
                blips = mixdrift(blips)

                blipsPlay += 1
                layers += [blips]

        single = [1] + ([0] * (len(seg) - 1))

        if canPlay('jam', bigoldsection) or canPlay('breakdown',
                                                    bigoldsection):
            # Hats
            if len(seg) >= 2:
                if bigoldsection > 11:
                    maxbeats = dsp.randint(len(seg) / 2, len(seg))
                    hatpat = drums.eu(len(seg), maxbeats)
                else:
Ejemplo n.º 21
0
from pippi import dsp

main = dsp.read('base_loop.wav').data
synth = dsp.read('synthloop.wav').data
beat = dsp.flen(main) / 128

freq = 430
s = dsp.pine(synth, dsp.flen(main) * 8, freq)
s = dsp.split(s, beat)
s = dsp.randshuffle(s)
s = [ dsp.alias(ss) for ss in s ]
s = [ dsp.amp(ss, dsp.rand(0.5, 2)) for ss in s ]
s = [ dsp.pan(ss, dsp.rand(0, 1)) for ss in s ]
s = ''.join(s)
s = dsp.fill(s, dsp.flen(synth))

s2 = dsp.split(synth, beat)
s2 = dsp.randshuffle(s2)
s2 = [ dsp.transpose(ss, dsp.randchoose([1,2,4])) for ss in s2 ]
s2 = [ dsp.fill(ss, beat) for ss in s2 ]
s2 = [ dsp.env(ss, 'phasor') for ss in s2 ]
s2 = ''.join(s2)

synth = dsp.mix([ s, s2 ])
synth = dsp.fill(synth, dsp.flen(main))

#synth = dsp.fill(synth, dsp.flen(main))

out = dsp.mix([ main, synth ])
#out = synth
Ejemplo n.º 22
0
def play(params):

    length = params.get('length', dsp.stf(2))
    volume = params.get('volume', 100.0)
    volume = volume / 100.0 # TODO: move into param filter
    width = params.get('width', 50)
    measures = params.get('multiple', 1)
    beats = params.get('repeats', 8)
    bpm = params.get('bpm', 75.0)
    glitch = params.get('glitch', False)
    alias = params.get('alias', False)
    skitter = params.get('skitter', False)
    bend = params.get('bend', False)
    tweet = params.get('tweet', False)
    pattern = params.get('pattern', True)
    playdrums = params.get('drum', ['k', 'h', 'c'])
    pinecone = params.get('pinecone', False)
    insamp = params.get('rec', False)
    roll = params.get('roll', False)
    pi = params.get('pi', False)

    def bln(length, low=3000.0, high=7100.0, wform='sine2pi'):
        """ Time-domain band-limited noise generator
        """
        outlen = 0
        cycles = ''
        while outlen < length:
            cycle = dsp.cycle(dsp.rand(low, high), wform)
            outlen += len(cycle)
            cycles += cycle

        return cycles

    def eu(length, numpulses):
        pulses = [ 1 for pulse in range(numpulses) ]
        pauses = [ 0 for pause in range(length - numpulses) ]

        position = 0
        while len(pauses) > 0:
            try:
                index = pulses.index(1, position)
                pulses.insert(index + 1, pauses.pop(0))
                position = index + 1
            except ValueError:
                position = 0

        return pulses

    def getevents(lenbeat, pattern):
        """ Takes pattern: [0, 1]
            Returns event list: [[0, 44100], [1, 44100]]
        """

        events = []
        count = 0
        value = None
        event = []

        for p in pattern:

            prev = value
            value = p

            # Null to zero always starts new zero
            if prev is None and value is 0:
                # Start zero, add to length
                event = [0, lenbeat]

            # Any transition to one always starts new one
            elif value is 1:
                # Add last event if not empty to events and start a new one
                if len(event) == 2:
                    events += [ event ]

                # Start one, add to length
                event = [1, lenbeat]

            # One to zero always adds to one
            # Zero to zero always adds to zero
            elif prev is 0 or prev is 1 and value is 0:
                # Add to length
                event[1] += lenbeat

        return events

    def clap(amp, length):
        # Two layers of noise: lowmid and high
        out = dsp.mix([ bln(int(length * 0.2), 600, 1200), bln(int(length * 0.2), 7000, 9000) ])
        
        out = dsp.env(out, 'phasor')
        out = dsp.pad(out, 0, length - dsp.flen(out))

        return out

    def hihat(amp, length):
        def hat(length):
            if dsp.randint(0, 6) == 0:
                out = bln(length, 9000, 14000)
                out = dsp.env(out, 'line')
            else:
                out = bln(int(length * 0.05), 9000, 14000)
                out = dsp.env(out, 'phasor')
                out = dsp.pad(out, 0, length - dsp.flen(out))

            return out

        if dsp.randint() == 0:
            out = ''.join([ hat(length / 2), hat(length / 2) ])
        else:
            out = hat(length)

        return out

    def snare(amp, length):
        # Two layers of noise: lowmid and high
        out = dsp.mix([ bln(int(length * 0.2), 700, 3200, 'impulse'), bln(int(length * 0.01), 7000, 9000) ])
        
        out = dsp.env(out, 'phasor')
        out = dsp.pad(out, 0, length - dsp.flen(out))

        return out

    def kick(amp, length):
        fhigh = 160.0
        flow = 60.0
        fdelta = fhigh - flow

        target = length
        pos = 0
        fpos = fhigh

        out = ''
        while pos < target:
            # Add single cycle
            # Decrease pitch by amount relative to cycle len
            cycle = dsp.cycle(fpos)
            #cycle = ''.join([ str(v) for v in dsp.curve(0, dsp.htf(fpos), math.pi * 2) ])
            pos += dsp.flen(cycle)
            #fpos = fpos - (fhigh * (length / dsp.htf(fpos)))
            fpos = fpos - 30.0
            out += cycle

        return dsp.env(out, 'phasor')

    beats = beats * measures

    drums = [{
        'name': 'clap',
        'shortname': 'c',
        'trigger_id': 5,
        'gen': clap,
        'pat': eu(beats, dsp.randint(1, beats / 3)),
        }, {
        'name': 'hihat',
        'shortname': 'h',
        'trigger_id': 3,
        'gen': hihat,
        'pat': eu(beats, dsp.randint(1, beats / 3)),
        }, {
        'name': 'snare',
        'shortname': 's',
        'trigger_id': 4,
        'gen': snare,
        'pat': eu(beats, dsp.randint(1, beats / 2)),
        }, {
        'name': 'kick',
        'shortname': 'k',
        'trigger_id': 2,
        'gen': kick,
        'pat': eu(beats, dsp.randint(1, beats / 3)),
        }]

    out = ''
    lenbeat = dsp.mstf(60000.0 / bpm) / 4
    layers = []
    streams = []

    for drum in drums:
        if drum['shortname'] in playdrums:
            events = getevents(lenbeat, drum['pat'])
            layers += [ ''.join([ drum['gen'](event[0], event[1]) for event in events ]) ]

            if drum['shortname'] == 's':
                osc_messages = [ ['/tick', dsp.fts(lenbeat), drum['trigger_id'], int(h)] for h in drum['pat'] ]
            #stream = []
            #for h in drum['pat']:
                #stream += [ ('/tick/' + str(drum['trigger_id']), int(h), dsp.fts(lenbeat)) ]

            #streams += [ stream ]

    out = dsp.mix(layers)

    if bend is True:
        out = dsp.drift(out, dsp.rand(0.1, 2))

    if alias is True:
        out = dsp.alias(out)


    if glitch == True:
        out = dsp.split(out, int(lenbeat * 0.5))
        out = ''.join(dsp.randshuffle(out))

    return dsp.amp(out, volume)
Ejemplo n.º 23
0
    #kicks = dsp.fill(kick, dsp.flen(layers), silence=True)

    hats = drums.parsebeat(hatp, 8, beat, dsp.flen(layers), makeHat, 12)
    kicks = drums.parsebeat(kickp, 4, beat, dsp.flen(layers), makeKick, 0)
    snares = drums.parsebeat(snarep, 8, beat, dsp.flen(layers), makeSnare, 0)

    #dr = dsp.mix([ hats, kicks, snares ])
    dr = dsp.mix([ kicks, snares ])
    d = dsp.split(dr, beat / 8)
    d = dsp.randshuffle(d)
    #print len(d)
    #d = dsp.packet_shuffle(d, dsp.randint(2, 4))
    #print len(d)
    d = [ dd * dsp.randint(1, 2) for dd in d ]
    d = ''.join(d)
    d = dsp.fill(dsp.mix([d, dr]), dsp.flen(layers))

    d = dsp.amp(d, 3)

    layers = dsp.mix([ layers, d, drone ])

    ost = keys.rhodes(beat, tune.ntf('c', octave=4), 0.6)
    ost = dsp.env(ost, 'phasor')
    numosts = dsp.flen(layers) / dsp.flen(ost)
    ost = ''.join([ dsp.alias(ost) for _ in range(numosts) ]) 
    layers = dsp.mix([ layers, ost ])

    out += layers

dsp.write(out, 'out')
Ejemplo n.º 24
0
dsp.write(out, 'wesley_thirty_13')

## 14
out = ''

for i in range(30):
    t = dsp.split(thirty, dsp.mstf(30))
    for i, tt in enumerate(t):
        if dsp.randint(0, 1) == 0 and i > 0:
            t.insert(i - 1, tt)

    if dsp.randint(0, 1) == 0:
        t.reverse()

    t = [ dsp.alias(tt) for tt in t ]

    out += ''.join(t)

dsp.write(out, 'wesley_thirty_14')

## 15
out = ''

freqs = tune.fromdegrees([1, 3, 5, 9], 3, 'c')

lens = [ 1, 1.25, 1.5, 2, 3, 5, 10, 20 ]
for plen in lens:
    layers = []
    for freq in freqs:
        l = dsp.pine(dsp.amp(thirty, 0.5), int(dsp.flen(thirty) * plen), freq)
Ejemplo n.º 25
0
    drone = dsp.randshuffle(drone)
    drone = ''.join(drone)

    hats = drums.parsebeat(hatp, 16, beat, dsp.flen(layers), makeHat, 12)
    kicks = drums.parsebeat(kickp, 4, beat, dsp.flen(layers), makeKick, 0)
    snares = drums.parsebeat(snarep, 8, beat, dsp.flen(layers), makeSnare, 0)

    dr = dsp.mix([kicks, snares])

    d = dsp.split(dr, beat / 8)
    d = dsp.randshuffle(d)
    d = [dd * dsp.randint(1, 2) for dd in d]
    d = ''.join(d)
    d = dsp.fill(dsp.mix([d, dr, dsp.env(hats, 'hann')]), dsp.flen(layers))

    d = dsp.amp(d, 3)

    layers = dsp.mix([layers, d, drone])

    ost = keys.rhodes(beat, tune.ntf('c', octave=4), 0.6)
    ost = dsp.env(ost, 'phasor')
    numosts = dsp.flen(layers) / dsp.flen(ost)
    ost = ''.join([dsp.alias(ost) for _ in range(numosts)])
    layers = dsp.mix([layers, ost])

    out += layers

    b += 1

dsp.write(out, 'climbing')