Ejemplo n.º 1
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

    for i, freq in enumerate(freqs):
        if freq > root * 2.5:
            freqs[i] = freq * 0.5

    chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs ]
    chord = dsp.randshuffle(chord)
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    chord = dsp.mix(chord)

    chord = dsp.split(chord, dsp.flen(chord) / 16)
    chord = dsp.randshuffle(chord)
    chord = [ dsp.env(ch, 'phasor') for ch in chord ]

    chord = [ dsp.mix([ dsp.amp(dsp.pan(grain, dsp.rand()), dsp.rand(0.1, 0.8)), dsp.amp(dsp.pan(dsp.randchoose(chord), dsp.rand()), dsp.rand(0.1, 0.8)) ]) for grain in chord ]
    chord = ''.join(chord)

    return chord
Ejemplo n.º 2
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

    for i, freq in enumerate(freqs):
        if freq > root * 2.5:
            freqs[i] = freq * 0.5

    chord = [keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs]
    chord = dsp.randshuffle(chord)
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    chord = dsp.mix(chord)

    chord = dsp.split(chord, dsp.flen(chord) / 16)
    chord = dsp.randshuffle(chord)
    chord = [dsp.env(ch, "phasor") for ch in chord]

    chord = [
        dsp.mix(
            [
                dsp.amp(dsp.pan(grain, dsp.rand()), dsp.rand(0.1, 0.8)),
                dsp.amp(dsp.pan(dsp.randchoose(chord), dsp.rand()), dsp.rand(0.1, 0.8)),
            ]
        )
        for grain in chord
    ]
    chord = "".join(chord)

    return chord
Ejemplo n.º 3
0
def play(ctl):
    freq = tune.ntf(dsp.randchoose(['eb']), octave=dsp.randint(0,2))

    synth = keys.rhodes(dsp.stf(4), freq)

    s = dsp.vsplit(synth, dsp.mstf(50), dsp.mstf(2000))
    s = dsp.randshuffle(s)
    #s = [ dsp.alias(ss) for ss in s ]
    s = [ dsp.amp(ss, dsp.rand(0.5, 0.75)) 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.vsplit(synth, dsp.mstf(150), dsp.mstf(1500))
    s2 = dsp.randshuffle(s2)
    s2 = [ dsp.transpose(ss, dsp.randchoose([1,1.5,2,3,4,8])) for ss in s2 ]
    s2 = [ dsp.env(ss, 'phasor') for ss in s2 ]
    s2 = ''.join(s2)


    out = dsp.mix([ s, s2 ])

    out = dsp.amp(out, 1.5)

    out = dsp.transpose(out, 1.01) 
#synth = dsp.fill(synth, dsp.flen(main))

#out = synth

    return out
Ejemplo n.º 4
0
def smear(snd):
    snd = dsp.split(snd, dsp.mstf(dsp.rand(5000, 10000)))
    snd = dsp.randshuffle(snd)
    snd = [dsp.env(s) for s in snd]
    snd = [s * dsp.randint(1, 8) for s in snd]

    return dsp.drift(''.join(snd), dsp.rand(0.01, 0.1))
Ejemplo n.º 5
0
def smear(snd):
    snd = dsp.split(snd, dsp.mstf(dsp.rand(5000, 10000)))
    snd = dsp.randshuffle(snd)
    snd = [ dsp.env(s) for s in snd ]
    snd = [ s * dsp.randint(1, 8) for s in snd ]

    return dsp.drift(''.join(snd), dsp.rand(0.01, 0.1))
Ejemplo n.º 6
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.º 7
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.º 8
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

    crinkle = dsp.read('sounds/s/crinkle.wav').data
    glass1 = dsp.read('sounds/s/glass1.wav').data
    glass2 = dsp.read('sounds/s/glass2.wav').data
    toys = dsp.read('sounds/s/rolling.wav').data

    c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3))
    c = dsp.randshuffle(c)
    c = c[:40]
    c = [dsp.pan(cc, dsp.rand()) for cc in c]
    c = [dsp.env(cc, 'sine') for cc in c]
    c = [dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c]

    t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1))
    t = dsp.randshuffle(t)
    t = t[:40]
    t = [dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t]
    t = [dsp.pan(tt, dsp.rand(0, 1)) for tt in t]
    t = [dsp.env(tt, 'sine') for tt in t]
    t = [dsp.transpose(tt, 0.5) for tt in t]

    g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100))
    g = dsp.randshuffle(g)
    g = g[:40]
    g = [dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g]
    g = [dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g]
    g = [gg * dsp.randint(1, 8) for gg in g]

    things = [c, t, g]

    out = [
        dsp.mix([
            dsp.randchoose(dsp.randchoose(things))
            for l in range(dsp.randint(2, 4))
        ]) for i in range(4)
    ]
    out = ''.join(out)

    dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))

    return out
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
def nextChord(last):
    degs = dsp.randshuffle(last)[:dsp.randint(1, 2)]
    for deg in degs:
        newdeg = deg + dsp.randchoose([-1, 1])
        if newdeg == 0:
            newdeg = 1
        elif newdeg > 15:
            newdeg = 15

        last[last.index(deg)] = newdeg

    return last
Ejemplo n.º 12
0
        def makeGrains(out, length=None, env=None):
            envs = ['tri', 'line', 'flat', 'sine', 'hann']
            out = dsp.vsplit(out, dsp.mstf(20), dsp.mstf(90))

            out = [dsp.env(grain, 'hann') for grain in out]
            out = [dsp.pan(grain, dsp.rand()) for grain in out]

            out = dsp.randshuffle(out)
            out = ''.join(out)
            out = dsp.env(out, dsp.randchoose(envs))

            return out
Ejemplo n.º 13
0
        def makeGrains(out, length=None, env=None):
            envs = ['tri', 'line', 'flat', 'sine', 'hann']
            out = dsp.vsplit(out, dsp.mstf(20), dsp.mstf(90))

            out = [ dsp.env(grain, 'hann') for grain in out ]
            out = [ dsp.pan(grain, dsp.rand()) for grain in out ]

            out = dsp.randshuffle(out)
            out = ''.join(out)
            out = dsp.env(out, dsp.randchoose(envs))

            return out
Ejemplo n.º 14
0
def nextChord(last):
    degs = dsp.randshuffle(last)[:dsp.randint(1,2)]
    for deg in degs:
        newdeg = deg + dsp.randchoose([-1,1])
        if newdeg == 0:
            newdeg = 1
        #elif newdeg > 15:
        #    newdeg = 15

        last[last.index(deg)] = newdeg

    return last
Ejemplo n.º 15
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

    crinkle = dsp.read('sounds/s/crinkle.wav').data
    glass1 = dsp.read('sounds/s/glass1.wav').data
    glass2 = dsp.read('sounds/s/glass2.wav').data
    toys = dsp.read('sounds/s/rolling.wav').data

    c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3))
    c = dsp.randshuffle(c)
    c = c[:40]
    c = [ dsp.pan(cc, dsp.rand()) for cc in c ]
    c = [ dsp.env(cc, 'sine') for cc in c ]
    c = [ dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c ]

    t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1))
    t = dsp.randshuffle(t)
    t = t[:40]
    t = [ dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t ]
    t = [ dsp.pan(tt, dsp.rand(0, 1)) for tt in t ]
    t = [ dsp.env(tt, 'sine') for tt in t ]
    t = [ dsp.transpose(tt, 0.5) for tt in t ]

    g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100))
    g = dsp.randshuffle(g)
    g = g[:40]
    g = [ dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g ]
    g = [ dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g ]
    g = [ gg * dsp.randint(1, 8) for gg in g ]

    things = [c,t,g]

    out = [ dsp.mix([ dsp.randchoose(dsp.randchoose(things)) for l in range(dsp.randint(2, 4)) ]) for i in range(4) ]
    out = ''.join(out)

    dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))

    return out
Ejemplo n.º 16
0
def makeRhodes(length, beat, freqs, maxbend=0.05):
    backup = Sampler(snds.load('tones/nycrhodes01.wav'), tune.ntf('c'), direction='fw-bw-loop', tails=False)
    chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.7)) for freq in freqs ]
    chord = dsp.randshuffle(chord)
    chord = [ dsp.mix([ dsp.env(fx.penv(backup.play(freq * 2**dsp.randint(0,2), length, dsp.rand(0.4, 0.6))), 'line'), c ]) for freq, c in zip(freqs, chord) ]
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        c = fx.bend(c, [ dsp.rand() for _ in range(dsp.randint(5, 10)) ], dsp.rand(0, maxbend))
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    return dsp.mix(chord)
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
    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)
Ejemplo n.º 20
0
def make_pulses(degrees, bpm):
    freqs = tune.fromdegrees(degrees, 3, 'c')

    layers = []
    for freq in freqs:
        l = dsp.pine(dsp.amp(thirty, 0.5), int(dsp.flen(thirty) * 20), freq)
        l = dsp.pan(l, dsp.rand())
        layers += [ l ]

    t = dsp.mix(layers)

    t = dsp.split(t, dsp.mstf(dsp.bpm2ms(bpm)))

    t = dsp.randshuffle(t)

    return ''.join(t)
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
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.º 23
0
def makeArps(length, beat, cname):
    freqs = tune.chord(cname, key, dsp.randint(1,4))
    tone = Sampler(snds.load('tones/nick.wav'), direction='fw-bw-loop', tails=False)
    freqs = dsp.randshuffle(freqs)

    beat = int((beat * 2) / dsp.randchoose([0.5, 1, 2, 3, 1.5]))

    numbeats = length / beat

    out = ''

    for i in range(numbeats):
        out += tone.play(freqs[i % len(freqs)], beat) 

    out = dsp.fill(out, length)
    out = fx.penv(out)

    return out
Ejemplo n.º 24
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.º 25
0
def play(params):
    length      = params.get('length', dsp.stf(dsp.rand(0.1, 1)))
    volume      = params.get('volume', 100.0) / 100.0
    speed       = params.get('speed', dsp.rand(0.3, 0.5))
    octave      = params.get('octave', 2)
    note        = params.get('note', ['c'])[0]
    env         = params.get('envelope', False)
    pad         = params.get('padding', False)
    bend        = params.get('bend', 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)
    lyrics      = params.get('ww', '1-2-3-4-5-6-7-8-9-10').split('-')

    bpm = params.get('bpm', 100)

    if shuffle:
        lyrics = dsp.randshuffle(lyrics)

    lyrics = ' '.join(lyrics)

    words = text2wave(lyrics)
    words = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", words)
    words = dsp.transpose(words, speed)

    pitches = tune.fromdegrees(scale, octave=octave, root=note)

    length = dsp.flen(words) * dsp.randint(30, 32)

    sings = [ dsp.pine(words, length, pitch) for pitch in pitches ]
    sings = dsp.mix(sings)

    sings = sox("sox %s %s tempo 6.0", sings)

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

    return out
Ejemplo n.º 26
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

    chord = dsp.read('sounds/sag1.wav').data
    bass = dsp.read('sounds/sag2.wav').data    

    out = ''

    for i in range(32):

        b = dsp.amp(bass, 0.5)
        b = dsp.transpose(b, 2)
        b *= 2

        bar = dsp.flen(b) / 2

        blayers = []
        for blayer in range(3):
            blayer = dsp.split(b, bar / dsp.randchoose([6, 12]))
            blayer = dsp.randshuffle(blayer)
            blayer = blayer[:2]
            blayer = ''.join(blayer)
            blayer = dsp.pan(blayer, dsp.rand())
#            blayer *= dsp.randint(2, 8)

            blayers += [ blayer ]

        b = dsp.mix(blayers)

        c = dsp.amp(chord, 0.5)
        c = dsp.fill(c, bar / dsp.randchoose([8, 16, 12, 24]))
        c = dsp.fill(c, dsp.flen(b))

        out += dsp.mix([ b, c ])

    dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))

    return out
Ejemplo n.º 27
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.º 28
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.º 29
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.º 30
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', '["c","k","h"]')
    dsp.log(dsl)
    dsl = json.loads(dsl)

    def hat(beat):
        length = beat * 4
        nbeats = 16
        blen = length / nbeats

        out = ''

        for b in range(nbeats):
            h = dsp.transpose(tape1, 9)
            h = dsp.fill(h, dsp.mstf(dsp.rand(1, 20)))
            h = dsp.env(h, 'phasor')
            h = dsp.amp(h, dsp.rand(0, 0.8))
            h = dsp.pad(h, 0, blen - dsp.flen(h))

            out += h

        out *= 8

        return out

    def kick(beat):
        out = drums.sinekick(length=beat, amp=dsp.rand(0.8, 1))
        out = dsp.pad(out, 0, beat * dsp.randint(1, 2))
        out *= 2
        return out

    def clap1(beat):
        c = dsp.read('sounds/mikeclap.wav').data
        c = dsp.transpose(c, dsp.rand(1, 2.5))
        c = dsp.fill(c, dsp.mstf(dsp.rand(10, 100)))
        c = dsp.env(c, 'phasor')
        c = dsp.amp(c, dsp.rand(1, 3))
        c = dsp.pad(c, 0, beat - dsp.flen(c))

        blen = beat / dsp.randchoose([1, 2])
        c = dsp.pad(c, blen, 0)

        c *= 4

        return c

    def clap2(beat):
        nlens = [
            beat * 2,
            beat,
            beat / 2,
        ]

        # length of pattern (in beats)
        nbeats = dsp.randint(10, 15)

        # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
        blens = [dsp.randchoose(nlens) for b in range(nbeats)]

        out = ''

        # synthesize the tones
        for i in range(nbeats):
            beat = dsp.transpose(dsp.randchoose([c1, c2]),
                                 dsp.rand(0.25, 40.0))
            beat = dsp.pad(beat, 0, blens[i] - dsp.flen(beat))
            beat = dsp.amp(beat, dsp.rand(1, 4))

            # add it to the output
            out += beat

        return out

    all = []

    if 'c' in dsl:
        clapper = dsp.randchoose([clap1, clap2])
        all += [clapper(beat)]

    if 'k' in dsl:
        all += [kick(beat)]

    if 'h' in dsl:
        all += [hat(beat)]

    out = dsp.mix(all)

    #    out = dsp.vsplit(out, dsp.mstf(dsp.rand(8, 140)), dsp.mstf(500))
    #    out = dsp.randshuffle(out)
    #    out = ''.join(out)

    out = dsp.vsplit(out, 10, 1000)
    out = [dsp.amp(o, dsp.rand(0, 4)) for o in out]
    out = [dsp.env(o, 'random') for o in out]
    out = [dsp.transpose(o, dsp.rand(0.25, 1)) for o in out]
    out = dsp.randshuffle(out)
    out = ''.join(out)

    out = dsp.pine(out, int(dsp.flen(out) * dsp.rand(1.5, 4)),
                   dsp.rand(10, 2000), dsp.randint(0, 2), dsp.rand(1, 3),
                   dsp.randint(0, 2), dsp.rand(1, 3))
    out = dsp.amp(out, 0.65)

    glass = dsp.read('sounds/s/glass2.wav').data

    glass = dsp.vsplit(glass, dsp.mstf(1), dsp.mstf(100))
    glass = dsp.randshuffle(glass)
    #    glass = [ dsp.pad(g, 0, dsp.randint(10, 1000)) for g in glass ]
    #    glass = [ dsp.transpose(g, dsp.rand(0.5, 1.5)) * dsp.randint(1, 3) for g in glass ]
    glass = ''.join(glass)

    glass = dsp.fill(glass, dsp.flen(out))

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

    return out
Ejemplo n.º 31
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', 'h.c')

    length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12))))
    volume = P(voice_id, 'volume', 70.0) 
    volume = volume / 100.0 # TODO move into param filter

    octave = P(voice_id, 'octave', 3)
    notes = P(voice_id, 'note', '["%s"]' % config('key'))
    notes = json.loads(notes)
    
    hertz = P(voice_id, 'hertz', False)
    alias = P(voice_id, 'alias', False)
    alias = True
    bend = P(voice_id, 'bend', False)
    env = P(voice_id, 'envelope', 'gauss')
    harmonics = P(voice_id, 'harmonic', '[1,2,3,4]')
    harmonics = json.loads(harmonics)
    reps      = P(voice_id, 'repeats', 1)
    waveform = P(voice_id, 'waveform', 'sine2pi')

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

    glitch = False
    #glitch = True
    root = 27.5
    pinecone = False
    bbend = False
    wild = False

    if bbend == True:
        bend = True

    tune.a0 = float(root)

    # These are amplitude envelopes for each partial,
    # randomly selected for each. Not to be confused with 
    # the master 'env' param which is the amplit
    wtypes = ['sine', 'phasor', 'line', 'saw']    
    layers = []

    if hertz is not False:
        notes = hertz

    for note in notes:
        tones = []
        for i in range(dsp.randint(2,4)):
            if hertz is not False:
                freq = float(note)

                if octave > 1:
                    freq *= octave
            else:
                freq = tune.ntf(note, octave)

            snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ]
            snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6)) for s in snds ]
            snds = [ dsp.pan(s, dsp.rand()) for s in snds ]

            if bend is not False:
                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)

                snds = [ bendit(snd) for snd in snds ]

            tones += [ dsp.mix(snds) ]

        layer = dsp.mix(tones)

        if wild != False:
            layer = dsp.vsplit(layer, 41, 4410)
            layer = [ dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer ]
            layer = ''.join(layer)
        
        if pinecone != False:
            layer = dsp.pine(layer, length, freq, 4)

        if glitch == True:
            layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4)
            layer = dsp.randshuffle(layer)
            layer = ''.join(layer)

        layer = dsp.env(layer, env)

        layers += [ layer ]

    out = dsp.mix(layers) * reps

    return dsp.amp(out, volume)
Ejemplo n.º 32
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

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

    freqs = tune.fromdegrees(scale, root='eb', octave=dsp.randint(0, 2))
    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.005)
    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.5, 0.8)

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

    wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for w in range(5) ] + [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]

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

        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 ])

        layer = dsp.vsplit(layer, dsp.mstf(5), dsp.mstf(1500))
        layer = dsp.randshuffle(layer)
        layer = ''.join(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.taper(out)
    #out = dsp.env(out, 'random')

    return out
Ejemplo n.º 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)

    amp = dsp.rand(0.1, 0.65)

    nlens = [
        beat * 4,
        beat * 3,
        beat * 2,
        beat + (beat / 2),
        beat,
        beat / 2,
        beat / 4,
    ]

    scale = [2, 4, 6, 9]
    scale = [1, 4, 6, 8]
    #    scale = [1,3,4,5,6,8,9]
    #    scale = [1,2,3,5,6,8,9]
    #    scale = [1,5,8]
    freqs = tune.fromdegrees(scale,
                             root=root,
                             octave=dsp.randint(2, 4),
                             ratios=ratios,
                             scale=quality)

    # length of pattern (in beats)
    elen = 0
    tlen = beat * dsp.randint(2, 8)

    # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
    blens = []
    while elen < tlen:
        l = dsp.randchoose(nlens)
        blens += [l]
        elen += l

    # beat pulsewidths
    bpws = [dsp.rand(0.1, 1) for pw in range(len(blens))]

    out = ''

    # choose a pitch from the scale
    freq = dsp.randchoose(freqs)

    # synthesize the tones
    for i in range(len(blens)):
        # find the length of the pulse
        blen = int(round(blens[i] * bpws[i]))

        # find the length of the rest
        brest = blens[i] - blen

        # make a rhodes tone with a random amplitude
        #beat = keys.rhodes(length=blen, freq=freq, amp=dsp.rand(0.3, 0.5))
        beat = keys.rhodes(length=blen, freq=freq, amp=amp)

        # pan the tone to a random position
        beat = dsp.pan(beat, dsp.rand())

        # bitcrush the tone a random amount
        #        beat = dsp.alias(beat)

        # pad the tone with silence
        beat = dsp.pad(beat, 0, brest)

        # add it to the output
        out += beat

    out *= dsp.randint(1, 2)

    if dsp.rand() > 0.75:
        out = dsp.split(out, dsp.bpm2frames(bpm) / dsp.randchoose([1, 2, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
Ejemplo n.º 34
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')

    ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data
    lssnd = dsp.read('jesssnare.wav').data
    hsnd = dsp.read('/home/hecanjog/sounds/drums/78ch.wav').data
    ohsnd = dsp.read('/home/hecanjog/sounds/drums/78oh.wav').data
    ksnd = dsp.read('jesskick.wav').data

    beat = dsp.bpm2frames(166)
    length = beat * 8

    if dsp.rand() > 0.5:
        kick =   'x--x-x-x--------'
    else:
        kick =   'x----x----------'

    hat =    'x-x-x-x-xx-x-x-x'
    ohat =   'x------x--------'
    lsnare = '---------x--x---'

    if dsp.rand() > 0.5:
        lsnare = '---------x--x---'
    else:
        lsnare = '--x--x--x--x--x-'

    snare =  '--x--x--x--x--x-'

    def makeOHat(length, i, amp):
        return dsp.fill(hsnd, length, silence=True)

    def makeHat(length, i, amp):
        return dsp.fill(ohsnd, length, silence=True)

    def makeKick(length, i, amp):
        k = dsp.fill(ksnd, length, silence=True)
        return dsp.amp(k, 3)

    def makeSnare(length, i, amp):
        s = dsp.fill(ssnd, length, silence=True)
        return dsp.amp(s, 2)

    def makeLSnare(length, i, amp):
        s = dsp.fill(lssnd, length, silence=True)
        return dsp.amp(s, 1)

    hats = drums.parsebeat(hat, 8, beat, length, makeHat, 5)
    ohats = drums.parsebeat(ohat, 8, beat, length, makeOHat, 0)
    kicks = drums.parsebeat(kick, 8, beat, length, makeKick, 0)
    snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0)
    lsnares = drums.parsebeat(lsnare, 8, beat, length, makeLSnare, 0)

    snaresnstuff = dsp.mix([ohats,snares])
    snaresnstuff= dsp.split(snaresnstuff, dsp.flen(snaresnstuff) / 32)
    snaresnstuff = dsp.randshuffle(snaresnstuff)
    snaresnstuff = ''.join(snaresnstuff)
    snaresnstuff = dsp.amp(snaresnstuff, 0.35)

    out = dsp.mix([kicks,lsnares,snares,hats,ohats,snaresnstuff])

    return out
Ejemplo n.º 35
0
        numbeats = 16 * dsp.randint(2, 20)

    if section == 'ending':
        numbeats = dsp.randint(16, 40)

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

    bar_length = beat * numbeats

    bar = dsp.pad('', 0, bar_length)

    if canPlay('choppy', section):
        dl = ''.join([ dsp.mix([ dsp.randchoose([ dloop1, dloop2 ]), dsp.randchoose([ kickhard, kicksoft ]) ]) for _ in range(3) ])
        dl = dsp.split(dl, dsp.flen(dl) / 16)
        dl = dsp.randshuffle(dl)
        dl = [ dsp.env(dd, 'phasor') for dd in dl ]
        for i, b in enumerate(dl):
            if dsp.rand() > 0.75:
                dl[i] = dsp.pad('', 0, dsp.flen(b))
            elif dsp.rand() > 0.75:
                dl[i] = dsp.split(b, dsp.flen(b) / 2)[0] * 2

            dl[i] = dsp.amp(dl[i], dsp.rand(0.9, 2))
            dl[i] = dsp.fill(dl[i], beat, silence=True)

        dl = ''.join(dl)
        layers += [ dl ]

    if canPlay('swells', section):
        octave = 1 if section == 'float' else dsp.randint(2, 3)
Ejemplo n.º 36
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.º 37
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.º 38
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.º 39
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')

    ccs = [ i + 48 for i in range(24) ]
    notes = []
    for cc in ccs:
        if mpk.get(cc) < 1:

            notes += [ cc ]

    ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data
    ssnd = dsp.read('jesssnare.wav').data
    hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data
    ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data
    #ksnd = dsp.read('jesskick.wav').data

    beat = dsp.bpm2frames(90)
    #beat = dsp.mstf(290 * 2)
    length = beat * 4

    hat = 'xxx '
    kick =  'x       '
    snare =  '  x '
    #snare =  '  x  xx'
    #snare =  '    '

    def makeHat(length, i, amp):
        h = hsnd
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))

        return h

    def makeKick(length, i, amp):
        k = dsp.mix([ ksnd, drums.sinekick(length, i, amp) ])
        #k = dsp.env(ksnd, 'phasor')

        k = dsp.fill(k, length, silence=True)
        k = dsp.amp(k, 1)

        return k

    def makeSnare(length, i, amp):
        s = ssnd
        s = dsp.amp(s, 1.2)
        s = dsp.transpose(s, dsp.rand(1.5, 3))
        s = dsp.fill(s, length, silence=True)
        #ss = dsp.drift(s, dsp.rand(0.001, 0.1))
        #s = dsp.mix([s, ss])

        return s

    #hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25)
    hats = drums.parsebeat(hat, 16, beat, length, makeHat, 0)
    kicks = drums.parsebeat(kick, 16, beat, length, makeKick, 0)
    snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0)

    out = dsp.mix([hats,kicks,snares])

    shuf = True
    shuf = False

    if shuf:
        out = dsp.split(out, beat)
        out = dsp.randshuffle(out)
        out = ''.join(out)

    out = dsp.amp(out, 2)

    cuts = True if dsp.rand() > 0.5 else False
    cuts = True
    #cuts = False

    if cuts:
        o = dsp.split(out, beat / 2)
        o = dsp.randshuffle(o)
        o = [ dsp.amp(oo, dsp.rand(0, 2.5)) for oo in o ]
        o = [ dsp.env(oo, 'random') for oo in o ]

        out = dsp.mix([ ''.join(o), out ])

    dsp.log(notes)


    synthy = False
    #synthy = True

    if synthy == True:
        s = ''
        for ii in range(dsp.flen(out) / (beat/2)):
            layers = []

            if len(notes) > 0:
                scale = [ n - 47 for n in notes ]
                scale = [1,5,8,12]
                scale = tune.fromdegrees(scale, octave=3, root='d')
                p = ''.join([ keys.pulsar(scale[ii % len(scale)], pulsewidth=dsp.rand(0.1, 1), amp=0.5, length=(beat/2) / 3) for _ in range(3) ])
                layers += [ p ]
            else:
                layers += [ dsp.pad('', beat / 2, 0) ]

            s += dsp.mix(layers)

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

    #out = dsp.alias(out)

    #out = dsp.drift(out, dsp.rand(0.5, 2))

    return out
Ejemplo n.º 40
0
def play(params):
    length = params.get("length", dsp.mstf(10000))
    buffer_index = params.get("buffer_index", False)
    sample_index = params.get("sample_index", False)
    buffer_length = params.get("buffer_length", dsp.stf(5))
    volume = params.get("volume", 100.0) / 100.0
    scale = params.get("scale", [25, 50, 100, 200])
    octave = params.get("octave", 0)
    envelope = params.get("envelope", False)
    glitch = params.get("glitch", True)
    overdub = params.get("dub", False)
    pad = params.get("padding", False)
    pan = params.get("pan", False)

    if sample_index != False:
        out = dsp.read("samps/pre/buf-%s.wav" % str(sample_index)).data
    elif buffer_index != False:
        fname = "samps/buf-%s" % str(buffer_index)

        if not os.path.exists(fname + ".wav") or overdub == True:
            out = rt.capture(buffer_length, "T6_pair1", 1)
            out = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", out)
            out = dsp.transpose(out, 0.5)
        else:
            out = dsp.read("samps/buf-%s.wav" % str(buffer_index)).data
    else:
        out = rt.capture(buffer_length, "T6_pair1", 1)
        out = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", out)
        out = dsp.transpose(out, 0.5)

    speeds = [s / 100.0 for s in scale]
    # speeds = [ 0.25, 0.5, 1.0, 2.0 ]

    if glitch == True:
        grain_length = dsp.flen(out) / 4

        out = dsp.vsplit(out, int(grain_length * 0.5), grain_length)
        numgrains = (length / grain_length) * 2

        if len(out) < numgrains:
            for i in range(numgrains - len(out)):
                out += [dsp.randchoose(out)]

        layers = []

        for index in range(1, 20):
            layer = dsp.randshuffle(out)

            if pad is not False:
                layer = [dsp.pad(grain, 0, pad) for grain in layer]

            layer = [dsp.env(grain, "sine") for grain in layer]
            layer = [dsp.transpose(grain, dsp.randchoose(speeds) * 2 ** octave * 0.25) for grain in layer]
            layer = "".join(layer)

            layer = dsp.pad(layer, grain_length / index, 0)
            layers += [layer]

        out = dsp.mix(layers, True, 10)

    if envelope == True:
        out = dsp.env(out, envelope)

    if buffer_index:
        fname = "samps/buf-%s" % str(buffer_index)
        if os.path.exists(fname + ".wav") and overdub == False:
            pass
        else:
            dsp.write(out, fname)

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

    return out
Ejemplo n.º 41
0
        s = dsp.fill(ssnd, length, silence=True)
        return dsp.amp(s, 3)

    def makeLSnare(length, i, amp):
        s = dsp.fill(lssnd, length, silence=True)
        return dsp.amp(s, 2)

    hats = drums.parsebeat(hat, 8, beat, length, makeHat, 5)
    ohats = drums.parsebeat(ohat, 8, beat, length, makeOHat, 0)
    kicks = drums.parsebeat(kick, 8, beat, length, makeKick, 0)
    snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0)
    lsnares = drums.parsebeat(lsnare, 8, beat, length, makeLSnare, 0)

    snaresnstuff = dsp.mix([ohats,snares])
    snaresnstuff= dsp.split(snaresnstuff, dsp.flen(snaresnstuff) / 32)
    snaresnstuff = dsp.randshuffle(snaresnstuff)
    snaresnstuff = [ dsp.env(sns, 'phasor') for sns in snaresnstuff ]
    snaresnstuff = ''.join(snaresnstuff)
    snaresnstuff = dsp.amp(snaresnstuff, 0.5)

    bar = dsp.mix([kicks,lsnares,snares,hats,ohats,snaresnstuff])
    #bar = dsp.mix([hats,ohats])

    if count % 4 == 0:
        bar = dsp.mix([ bar, dsp.fill(bksnd, dsp.flen(bar), silence=True) ])

    progression = 'ii6 ii69'.split(' ')
    cname = progression[ count % len(progression) ]
    rfreqs = tune.chord(cname, key, 2)
    rhodes = makeRhodes(dsp.flen(bar), beat / 8, rfreqs)
Ejemplo n.º 42
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
Ejemplo n.º 43
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', 'h.c')

    length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12))))
    volume = P(voice_id, 'volume', 70.0)
    volume = volume / 100.0  # TODO move into param filter

    octave = P(voice_id, 'octave', 3)
    notes = P(voice_id, 'note', '["%s"]' % config('key'))
    notes = json.loads(notes)

    hertz = P(voice_id, 'hertz', False)
    alias = P(voice_id, 'alias', False)
    alias = True
    bend = P(voice_id, 'bend', False)
    env = P(voice_id, 'envelope', 'gauss')
    harmonics = P(voice_id, 'harmonic', '[1,2,3,4]')
    harmonics = json.loads(harmonics)
    reps = P(voice_id, 'repeats', 1)
    waveform = P(voice_id, 'waveform', 'sine2pi')

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

    glitch = False
    #glitch = True
    root = 27.5
    pinecone = False
    bbend = False
    wild = False

    if bbend == True:
        bend = True

    tune.a0 = float(root)

    # These are amplitude envelopes for each partial,
    # randomly selected for each. Not to be confused with
    # the master 'env' param which is the amplit
    wtypes = ['sine', 'phasor', 'line', 'saw']
    layers = []

    if hertz is not False:
        notes = hertz

    for note in notes:
        tones = []
        for i in range(dsp.randint(2, 4)):
            if hertz is not False:
                freq = float(note)

                if octave > 1:
                    freq *= octave
            else:
                freq = tune.ntf(note, octave)

            snds = [
                dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics
            ]
            snds = [
                dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6))
                for s in snds
            ]
            snds = [dsp.pan(s, dsp.rand()) for s in snds]

            if bend is not False:

                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)

                snds = [bendit(snd) for snd in snds]

            tones += [dsp.mix(snds)]

        layer = dsp.mix(tones)

        if wild != False:
            layer = dsp.vsplit(layer, 41, 4410)
            layer = [dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer]
            layer = ''.join(layer)

        if pinecone != False:
            layer = dsp.pine(layer, length, freq, 4)

        if glitch == True:
            layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4)
            layer = dsp.randshuffle(layer)
            layer = ''.join(layer)

        layer = dsp.env(layer, env)

        layers += [layer]

    out = dsp.mix(layers) * reps

    return dsp.amp(out, volume)
Ejemplo n.º 44
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')

    ccs = [i + 48 for i in range(24)]
    notes = []
    for cc in ccs:
        if mpk.get(cc) < 1:

            notes += [cc]

    ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data
    ssnd = dsp.read('jesssnare.wav').data
    hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data
    ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data
    #ksnd = dsp.read('jesskick.wav').data

    beat = dsp.bpm2frames(90)
    #beat = dsp.mstf(290 * 2)
    length = beat * 4

    hat = 'xxx '
    kick = 'x       '
    snare = '  x '

    #snare =  '  x  xx'
    #snare =  '    '

    def makeHat(length, i, amp):
        h = hsnd
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))

        return h

    def makeKick(length, i, amp):
        k = dsp.mix([ksnd, drums.sinekick(length, i, amp)])
        #k = dsp.env(ksnd, 'phasor')

        k = dsp.fill(k, length, silence=True)
        k = dsp.amp(k, 1)

        return k

    def makeSnare(length, i, amp):
        s = ssnd
        s = dsp.amp(s, 1.2)
        s = dsp.transpose(s, dsp.rand(1.5, 3))
        s = dsp.fill(s, length, silence=True)
        #ss = dsp.drift(s, dsp.rand(0.001, 0.1))
        #s = dsp.mix([s, ss])

        return s

    #hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25)
    hats = drums.parsebeat(hat, 16, beat, length, makeHat, 0)
    kicks = drums.parsebeat(kick, 16, beat, length, makeKick, 0)
    snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0)

    out = dsp.mix([hats, kicks, snares])

    shuf = True
    shuf = False

    if shuf:
        out = dsp.split(out, beat)
        out = dsp.randshuffle(out)
        out = ''.join(out)

    out = dsp.amp(out, 2)

    cuts = True if dsp.rand() > 0.5 else False
    cuts = True
    #cuts = False

    if cuts:
        o = dsp.split(out, beat / 2)
        o = dsp.randshuffle(o)
        o = [dsp.amp(oo, dsp.rand(0, 2.5)) for oo in o]
        o = [dsp.env(oo, 'random') for oo in o]

        out = dsp.mix([''.join(o), out])

    dsp.log(notes)

    synthy = False
    #synthy = True

    if synthy == True:
        s = ''
        for ii in range(dsp.flen(out) / (beat / 2)):
            layers = []

            if len(notes) > 0:
                scale = [n - 47 for n in notes]
                scale = [1, 5, 8, 12]
                scale = tune.fromdegrees(scale, octave=3, root='d')
                p = ''.join([
                    keys.pulsar(scale[ii % len(scale)],
                                pulsewidth=dsp.rand(0.1, 1),
                                amp=0.5,
                                length=(beat / 2) / 3) for _ in range(3)
                ])
                layers += [p]
            else:
                layers += [dsp.pad('', beat / 2, 0)]

            s += dsp.mix(layers)

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

    #out = dsp.alias(out)

    #out = dsp.drift(out, dsp.rand(0.5, 2))

    return out
Ejemplo n.º 45
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)

    amp = dsp.rand(0.1, 0.65)

    nlens = [
        beat * 4,
        beat * 3,
        beat * 2, 
        beat + (beat / 2),
        beat, 
        beat / 2,
        beat / 4,
    ]

    scale = [2,4,6,9]
    scale = [1,4,6,8]
#    scale = [1,3,4,5,6,8,9]
#    scale = [1,2,3,5,6,8,9]
#    scale = [1,5,8]
    freqs = tune.fromdegrees(scale, root=root, octave=dsp.randint(2,4), ratios=ratios, scale=quality)

    # length of pattern (in beats)
    elen = 0
    tlen = beat * dsp.randint(2, 8)

    # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
    blens = []
    while elen < tlen:
        l = dsp.randchoose(nlens)
        blens += [ l ]
        elen += l

    # beat pulsewidths
    bpws = [ dsp.rand(0.1, 1) for pw in range(len(blens)) ]

    out = ''

    # choose a pitch from the scale
    freq = dsp.randchoose(freqs)
 
    # synthesize the tones
    for i in range(len(blens)):
        # find the length of the pulse
        blen = int(round(blens[i] * bpws[i]))

        # find the length of the rest
        brest = blens[i] - blen

        # make a rhodes tone with a random amplitude
        #beat = keys.rhodes(length=blen, freq=freq, amp=dsp.rand(0.3, 0.5))
        beat = keys.rhodes(length=blen, freq=freq, amp=amp)

        # pan the tone to a random position
        beat = dsp.pan(beat, dsp.rand())

        # bitcrush the tone a random amount
#        beat = dsp.alias(beat)

        # pad the tone with silence
        beat = dsp.pad(beat, 0, brest)

        # add it to the output
        out += beat

    out *= dsp.randint(1, 2)

    if dsp.rand() > 0.75:
        out = dsp.split(out, dsp.bpm2frames(bpm) / dsp.randchoose([1,2,4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
Ejemplo n.º 46
0
    layers = dsp.mix(layers)
    ctf = tune.fromdegrees([commontone], octave=2, root='c')[0]
    drone = dsp.mix([
        keys.pulsar(ctf, dsp.flen(layers), amp=dsp.rand(0.01, 0.1))
        for _ in range(4)
    ])

    chord = nextChord(chord)

    if b % 2 == 0:
        commontone = commontone + dsp.randchoose([-1, 1])
        if commontone == 0:
            commontone = 1

    layers = dsp.split(layers, beat / 3)
    layers = dsp.randshuffle(layers)
    layers = ''.join(layers)

    drone = dsp.split(drone, beat)
    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]
Ejemplo n.º 47
0
        layer = dsp.pan(layer, dsp.rand())
        layers += [ layer ]

    layers = dsp.mix(layers)
    ctf = tune.fromdegrees([ commontone ], octave=2, root='c')[0]
    drone = dsp.mix([ keys.pulsar(ctf, dsp.flen(layers), amp=0.3) for _ in range(4) ])

    chord = nextChord(chord)

    if b % 2 == 0:
        commontone = commontone + dsp.randchoose([-1,1])
        if commontone == 0:
            commontone = 1

    layers = dsp.split(layers, beat / 3)
    layers = dsp.randshuffle(layers)
    layers = ''.join(layers)

    drone = dsp.split(drone, beat)
    drone = dsp.randshuffle(drone)
    drone = ''.join(drone)

    #hats = dsp.fill(dsp.fill(hat, beat / 4), dsp.flen(layers))
    #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 ])
Ejemplo n.º 48
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