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

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

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

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

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

    return out
예제 #2
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
예제 #3
0
파일: squee.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    dpc = ctl.get('midi').get('dpc')
    lpd = ctl.get('midi').get('lpd')

    print lpd.get(1)

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

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

    freq = dsp.randchoose(scale)

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

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

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

    return out
예제 #4
0
파일: keys.py 프로젝트: hecanjog/hcj.py
def chippy(length=22050, freq=220, amp=0.5):
    wfrm = dsp.wavetable('sine2pi', 512)
    wndw = dsp.wavetable('tri', 512)
    modw = [ 1 for u in range(256) ] + [ 0 for d in range(256) ]
    modr = 1
    modf = dsp.rand(10, 20)
    pw = dsp.rand()

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

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

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

    return layer
예제 #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
예제 #7
0
def that(li):
    print 'layer', li

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

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

    layers = []

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

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

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

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

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

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

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

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

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

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

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

        layer = ''.join(layer)

        layers += [ layer ]

    out = dsp.mix(layers)

    return out
예제 #8
0
파일: pulse.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

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

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

    length = int(length / div)

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

    layers = []

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

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

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

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

        layers += [ layer ]

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

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

    #out = out * 4

    return out
예제 #9
0
def play(voice_id):
    tel = bot.getTel()

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

    octave = dsp.randint(1, 4)

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

    out = ''

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

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

        pulsewidth = dsp.rand(0.5, 1)

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

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

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

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

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

        out += t

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

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

    return out
예제 #10
0
파일: keys.py 프로젝트: hecanjog/hcj.py
def pulsar(freq, length=22050, drift=0.01, speed=0.5, amp=0.1, pulsewidth=None, env='flat', wf=None, mod=None):
    if wf is None:
        waveform = dsp.wavetable('sine2pi')
    else:
        waveform = wf

    window = dsp.wavetable('sine')

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

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

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

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

    return out
예제 #11
0
파일: drums.py 프로젝트: hecanjog/hcj.py
def clap(length=22050, i=0, amp=0.5, root=3000.0, pw=None):
    wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(50) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

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

    amp = dsp.rand(0.75, 1.0)

    mFreq = 1.0 / dsp.fts(klen)

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

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

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

    return k
예제 #12
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
예제 #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
예제 #14
0
파일: drums.py 프로젝트: hecanjog/hcj.py
def kick(length=22050, i=0, amp=0.5):
    wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(20) ] + [0], 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

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

    amp = dsp.rand(0.5, 1.0)

    mFreq = 1.0 / dsp.fts(klen)

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

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

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

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

    return k
예제 #15
0
파일: keys.py 프로젝트: hecanjog/hcj.py
def yourlove(length=22050, i=0, bar=5, amp=0.5, chords=None, root='a', octave=3, maxdiv=4, mindiv=1):
    """ Inspired by Terre """
    wav = dsp.wavetable('sine2pi', 512)
    win = dsp.wavetable('sine', 512)
    mod = dsp.wavetable('phasor', 512)

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

    pw = dsp.rand(0.1, 1)

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

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

    amp = dsp.rand(0.3, 0.5)

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

    layers = []

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

        layers += [ k ]

    out = dsp.mix(layers)

    return out
예제 #16
0
파일: snippet.py 프로젝트: szabo92/gistable
def play(ctl):
    midi = ctl.get('midi')
    midi.setOffset(111)
    pw = midi.get(1, low=0.01, high=1)

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

    freq = dsp.randchoose(scale)

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

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

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

    return out
예제 #17
0
파일: tam.py 프로젝트: hecanjog/geodes.py
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

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

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

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

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

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

    layers = []

    harmonics = [1, 2, 3, 4]

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

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

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

        layers += [ layer ]

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

    return out
예제 #18
0
numpoints = 7

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

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

out = []

for wf, mod, modf, modr, pw in zip(wfs, mods, modfs, modrs, pws):
    layers = []
    for freq in chord:
        layer = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, 0.1)
        layers += [layer]

    out += [dsp.mix(layers)]

out = [dsp.taper(o, dsp.mstf(10)) for o in out]
out = ''.join(out)

dsp.write(out, 'truckidle')
예제 #19
0
파일: pulsar.py 프로젝트: hecanjog/solos1
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
예제 #20
0
def play(params):
    volume      = params.get('volume', dsp.rand(70.0, 100.0)) / 100.0

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

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

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

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

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

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

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

    pulsewidth = 1.0


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

    tune.a0 = float(root)

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

    layers = []

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

    out = dsp.mix(layers)

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

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

        out = ''.join(out)

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

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

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

    bits = []

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

    for bit in layer:
        if dsp.rand() > 0.75:
            bit = ''.join([
                dsp.pan(dsp.amp(bit, dsp.rand(0.1, 10)), dsp.rand())
                for _ in range(dsp.randint(2, 10))
            ])

        bits += [bit]
예제 #22
0
boids = [[dsp.rand(0, 1) for _ in range(numpoints + 1)]
         for b in range(numboids)]

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

    center = center / float(numboids)

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

out = []

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

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

out = dsp.mix(out)

dsp.write(out, 'boids')
예제 #23
0
slen = dsp.rand(5, dsp.rand(15, 100))

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

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

    bits = []

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

    for bit in layer:
        if dsp.rand() > 0.75:
            bit = ''.join([ dsp.pan(dsp.amp(bit, dsp.rand(0.1, 10)), dsp.rand()) for _ in range(dsp.randint(2, 10)) ])

        bits += [ bit ]

    layer = ''.join(bits)

    layers += [ layer ]
예제 #24
0
    def makecurve(length):
        # freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, amp

        wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024)
        win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024)
        mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(4, 8))) ], 1024)

        smaxamp = dsp.rand(0.65, 0.95)
        amp = dsp.rand(0.01, smaxamp)

        pw = dsp.rand(0.1, 1.0)

        if 'upbeat' in tel['name']:
            wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024)
            win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024)
            mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, 80))) ], 1024)


            pw = 1.0

        if 'ballsout' in tel['name']:
            wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(10, 40))) ] + [0], 1024)
            win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(10) ] + [0], 1024)
            mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(20, 100))) ], 1024)


        if 'sparse' in tel['name']:
            amp = dsp.rand(0.7, 3)

        freq = tel['register'] * tel['roughness'] * (tel['density'] * tel['pace'] * 0.25)
        #if dsp.rand(0, 100) > 50:
            #freq = dsp.rand(2, 20)

        modR = tel['harmonicity']
        modF= tel['pace'] / 10.0

        c = dsp.pulsar(freq, length, pw, wf, win, mod, modR, modF, amp)

        ngrains = len(c)
        pans = dsp.breakpoint([ dsp.rand(0,1) for i in range(100) ], ngrains)

        maxPad = dsp.randint(2000, 4000)

        if 'sparse' in tel['name']:
            c = dsp.vsplit(c, dsp.mstf(0.5), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace']))
            c = [ dsp.randchoose(c) for i in range(int(dsp.rand(3, 10))) ]

        elif 'ballsout' in tel['name']:
            c = dsp.vsplit(c, dsp.mstf(0.1), dsp.mstf(400))
            c = dsp.packet_shuffle(c, dsp.randint(5, 10))

            speeds = dsp.breakpoint([ dsp.rand(tel['register'] * 0.1 + 0.2, tel['register'] + 0.2) for i in range(100) ], ngrains)

            #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ]
            #c = [ dsp.amp(cg, dsp.rand(0.25, 1.25)) for i, cg in enumerate(c) ]

            for ic, cc in enumerate(c):
                if dsp.rand(0, 100) > 70:
                    c[ic] = dsp.tone(dsp.flen(cc), 11000, amp=0.5)

        elif 'upbeat' in tel['name']:
            beat = dsp.bpm2frames(bpm)
            c = dsp.split(c, beat)

            maxPad = 0

            c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, beat / 4))) for i, cg in enumerate(c) ]

        else:
            c = dsp.vsplit(c, dsp.mstf(10), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace'] * dsp.rand(1, 10)))

        c = [ dsp.pan(cg, pans[i]) for i, cg in enumerate(c) ]
        c = [ dsp.env(cg, 'sine') for i, cg in enumerate(c) ]

        if 'sparse' in tel['name'] or 'ballsout' in tel['name']:
            speeds = dsp.breakpoint([ dsp.rand(0.5, 1.99) for i in range(100) ], ngrains)
            
            for ic, cc in enumerate(c):
                if dsp.flen(cc) < dsp.mstf(100):
                    c[ic] = cc + ''.join([ dsp.amp(cc, dsp.rand(0.1, 1.0)) for buh in range(dsp.randint(1, int(tel['density']))) ])

            #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ]
            c = [ dsp.pan(cg, dsp.rand(0.0, 1.0)) for i, cg in enumerate(c) ]

        if 'ballsout' not in tel['name']:
            c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, maxPad))) for i, cg in enumerate(c) ]

        out = ''.join(c)

        return out
예제 #25
0
파일: arp.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    param = ctl.get("param")

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

    key = "g"

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

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

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

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

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

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

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

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

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

        modf = dsp.rand(0.5, 2)

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

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

        rep = rep + 1

        out += o

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

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

    return out