예제 #1
0
        def makeArps(seg, oct=3, reps=4):
            arp_degrees = [1,2,3,5,8,9,10]
            if dsp.randint(0,1) == 0:
                arp_degrees.reverse()

            arp_degrees = dsp.rotate(arp_degrees, vary=True)
            arp_notes = tune.fromdegrees(arp_degrees[:reps], oct, 'e')

            arps = ''

            arp_count = 0
            for arp_length in seg:
                arp_length /= 2
                arp_pair = arp_notes[ arp_count % len(arp_notes) ], arp_notes[ (arp_count + 1) % len(arp_notes) ]

                arp_one = dsp.tone(arp_length, wavetype='tri', freq=arp_pair[0], amp=0.075)
                arp_one = dsp.env(arp_one, 'random')

                arp_two = dsp.tone(arp_length, wavetype='tri', freq=arp_pair[1], amp=0.08)
                arp_two = dsp.env(arp_two, 'random')

                arps += arp_one + arp_two
                arp_count += 2

            arps = dsp.env(arps, 'random')
            arps = dsp.pan(arps, dsp.rand())

            return arps
예제 #2
0
def makeStab(length, i):
    chord = tune.fromdegrees([ dsp.randchoose([1,4,5,8]) for _ in range(dsp.randint(2,4)) ], octave=3, root=key)
    stab = rhodesChord(length, chord, dsp.rand(0.5, 0.75))
    stab = dsp.taper(stab, 40)
    stab = dsp.fill(stab, length, silence=True)

    return stab
예제 #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
def makeStab(length, i):
    freqs = tune.fromdegrees([ dsp.randchoose([1,2,3,4,5,6,8]) for _ in range(dsp.randint(2,4)) ], octave=3, root=key)
    stab = chord(length, freqs, dsp.rand(0.25, 0.75))
    stab = dsp.taper(stab, 40)
    stab = dsp.fill(stab, length, silence=True)

    return stab
예제 #5
0
파일: home.py 프로젝트: hecanjog/geodes.py
def play(ctl):
    freqs = tune.fromdegrees([1,3,6,8,9], octave=4, root='a')
    freq = dsp.randchoose(freqs)
    length = dsp.stf(dsp.rand(3, 5))
    out = keys.rhodes(length, freq)

    return out
예제 #6
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)

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

    bar = beat * dsp.randchoose([8, 16, 32])

    groot = tune.ntf('c') 

    scale = tune.fromdegrees([1,3,5,6,8,9], root=root, octave=2, ratios=ratios)

    v = dsp.read('sounds/vibesc1.wav').data

    out = ''

#    lens = [ bar / 5, bar / 8, bar / 12 ]
    lens = [ bar / 6, bar / 8, bar / 16 ]

    maxbend = 2
    maxbend = 0.02

    layers = []

    for nlen in lens:
        layer = ''

        nlen /= 2

        note = dsp.transpose(v, (dsp.randchoose(scale) * 2**dsp.randint(0, 3)) / groot)
        note = dsp.fill(note, nlen)
        note = dsp.env(note, 'phasor')
        note = dsp.amp(note, 0.125)

        nbeats = bar / nlen
        for b in range(nbeats):
            b = dsp.pan(note, dsp.rand())
            b = dsp.drift(b, dsp.rand(0, dsp.rand(0.01, maxbend)))

            if dsp.flen(b) < nlen:
                b = dsp.pad(b, 0, nlen - dsp.flen(b))

#            if dsp.rand() > 0.5:
#                b = dsp.vsplit(b, dsp.flen(b) / 3, dsp.flen(b) / 2)
#                b = dsp.randshuffle(b)
#                b = [ dsp.amp(bb, dsp.rand(0.5, 2)) for bb in b ]
#                b = ''.join(b)

            layer += b

#        layer = dsp.fill(layer, bar)

        layers += [ layer ]

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

    return out
예제 #7
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
예제 #8
0
def makePulse(length, i):
    freqs = tune.fromdegrees([ dsp.randchoose([1,2,3,4,5,6,8]) for _ in range(dsp.randint(2,4)) ], octave=2, root=key)
    pulse = chord(length, freqs, dsp.rand(0.5, 0.75)) 
    pulse = dsp.taper(pulse, 40)
    pulse = dsp.amp(pulse, dsp.rand(0.5, 1))
    pulse = dsp.fill(pulse, length, silence=True)

    return pulse
예제 #9
0
파일: jbutler.py 프로젝트: hecanjog/jbutler
 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
예제 #10
0
def makeLongChord(seg):
    degrees = [dsp.randint(1, 9) for _ in range(dsp.randint(2, 4))]
    long_chord = chord(sum(seg), [
        freq * 2**dsp.randint(0, 5)
        for freq in tune.fromdegrees(degrees, octave=1, root=key)
    ], dsp.rand(0.15, 0.35))
    long_chord = dsp.fill(long_chord, sum(seg))

    return long_chord
예제 #11
0
def makePulse(length, i):
    chord = tune.fromdegrees([ dsp.randchoose([1,4,5,8]) for _ in range(dsp.randint(2,4)) ], octave=2, root=key)
    pulse = rhodesChord(length, chord, dsp.rand(0.5, 0.75)) 
    #pulse = dsp.mix([ pulse, kick ])
    pulse = dsp.taper(pulse, 40)
    pulse = dsp.amp(pulse, dsp.rand(0.9, 1.5))
    pulse = dsp.fill(pulse, length, silence=True)

    return pulse
예제 #12
0
def makeStab(length, i):
    freqs = tune.fromdegrees([
        dsp.randchoose([1, 2, 3, 4, 5, 6, 8]) for _ in range(dsp.randint(2, 4))
    ],
                             octave=3,
                             root=key)
    stab = chord(length, freqs, dsp.rand(0.25, 0.75))
    stab = dsp.taper(stab, 40)
    stab = dsp.fill(stab, length, silence=True)

    return stab
예제 #13
0
def singit(lyrics, mult):
    words = text2wave(lyrics)

    pitches = [ dsp.randint(1, 10) for i in range(dsp.randint(2, 4)) ]
    pitches = tune.fromdegrees(pitches, octave=dsp.randint(1, 4), root='a')

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

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

    return sings
예제 #14
0
def makePulse(length, i):
    freqs = tune.fromdegrees([
        dsp.randchoose([1, 2, 3, 4, 5, 6, 8]) for _ in range(dsp.randint(2, 4))
    ],
                             octave=2,
                             root=key)
    pulse = chord(length, freqs, dsp.rand(0.5, 0.75))
    pulse = dsp.taper(pulse, 40)
    pulse = dsp.amp(pulse, dsp.rand(0.5, 1))
    pulse = dsp.fill(pulse, length, silence=True)

    return pulse
예제 #15
0
def make_chords():
    roots = []
    lastroot = 1
    for root in range(6):
        roots += [ lastroot ]
        nextroot = choose_interval(lastroot)
        lastroot = nextroot

    print roots

    freqs = [ tune.fromdegrees([ cr - 1 for cr in chords[root]], 3, 'c', scale=range(12)) for root in roots ]

    return freqs
예제 #16
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
예제 #17
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
예제 #18
0
파일: thirty.py 프로젝트: hecanjog/w30
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)
예제 #19
0
def play(voice_id):
    bpm = config('bpm')
    root = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    bendfactor = 0.05
#    bendfactor = 0 

    bdiv = 4
    bdiv *= dsp.randchoose([16, 24, 32]) 
    loctave = 1
    hoctave = 4

    si = 32 * dsp.randint(1, 2)
    beat = dsp.bpm2frames(bpm) / bdiv

    y = [ easeOutQuad(float(i), 0, 1, si) for i in range(si) ]
    z = [ easeOutQuad(float(i), 0, 1, si) for i in reversed(range(si)) ]

    freqs = tune.fromdegrees([1,2,3,4,5,6,7,8], root=root, octave=dsp.randint(loctave, hoctave), ratios=ratios, scale=quality)
    freqs = freqs[:dsp.randint(1, len(freqs))]
    if dsp.rand() > 0.5:
        freqs = [ f for f in reversed(freqs) ]
    freqs = dsp.rotate(freqs, dsp.randint(0, len(freqs)))

    y = y + z

    y = [ dsp.mstf(v * beat) + dsp.mstf(2) for v in y ]

    x = range(len(y))

    def make(length, freq):
        freq *= dsp.rand(1 - (bendfactor / 2.0), 1 + (bendfactor / 2.0))
        out = keys.chippy(length=int(length*dsp.rand(0.01, 0.4)), freq=freq, amp=0.7)
        out = dsp.env(out, 'phasor')
        out = dsp.pad(out, 0, length - dsp.flen(out))
        return out

    out = [ make(v, freqs[i % len(freqs)]) for i,v in enumerate(y) ]
    out = ''.join(out)

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

    return out
예제 #20
0
def singit(lyrics, mult):
    words = text2wave(lyrics)

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

    pitches = [ dsp.randint(1, 9) for i in range(dsp.randint(2, 4)) ]
    pitches = tune.fromdegrees(pitches, octave=dsp.randint(1, 4), root=root, ratios=ratios, scale=quality)

    return words

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

#    sings = sox("sox %s %s tempo 1.0", sings)

    return sings
예제 #21
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
예제 #22
0
파일: sweep.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    lpd = ctl.get('midi').get('lpd')

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

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

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

        return dsp.mix(layers)

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

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

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

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

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

    freq = dsp.randchoose(freqs) / 4.0

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

    out = rain(o, freqs)

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

    return out
예제 #23
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
예제 #24
0
def play(voice_id):
    reload(keys)

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

    scale = [1,5,8]

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

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

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

    out = ''

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

        b = dsp.split(b, 100)

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

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

        out += b

    return out
예제 #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
예제 #26
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
예제 #27
0
        def makeArps(seg, oct=3, reps=4):
            arp_degrees = [1, 2, 3, 5, 8, 9, 10]
            if dsp.randint(0, 1) == 0:
                arp_degrees.reverse()

            arp_degrees = dsp.rotate(arp_degrees, vary=True)
            arp_notes = tune.fromdegrees(arp_degrees[:reps], oct, 'e')

            arps = ''

            arp_count = 0
            for arp_length in seg:
                arp_length /= 2
                arp_pair = arp_notes[arp_count %
                                     len(arp_notes)], arp_notes[(arp_count + 1)
                                                                %
                                                                len(arp_notes)]

                arp_one = dsp.tone(arp_length,
                                   wavetype='tri',
                                   freq=arp_pair[0],
                                   amp=0.075)
                arp_one = dsp.env(arp_one, 'random')

                arp_two = dsp.tone(arp_length,
                                   wavetype='tri',
                                   freq=arp_pair[1],
                                   amp=0.08)
                arp_two = dsp.env(arp_two, 'random')

                arps += arp_one + arp_two
                arp_count += 2

            arps = dsp.env(arps, 'random')
            arps = dsp.pan(arps, dsp.rand())

            return arps
예제 #28
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
예제 #29
0
파일: genie.py 프로젝트: hecanjog/hcj.py
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
예제 #30
0
b = 0
while dsp.flen(out) <= target_length:
    print 'Rendering bar %s' % (b + 1)

    #bpm = bpm + dsp.randint(-5, 5)
    #beat = dsp.bpm2frames(bpm)

    if b % 4 == 0:
        chord = [dsp.randint(1, 15) for _ in range(4)]

    layers = []

    #length = beat * dsp.randchoose([2, 3, 4, 6])
    length = beat * 4

    for freq in tune.fromdegrees(chord, octave=2, root='c'):
        amp = dsp.rand(0.25, 0.5)
        layer = keys.rhodes(length, freq, amp)
        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=dsp.rand(0.01, 0.1))
        for _ in range(4)
    ])

    chord = nextChord(chord)

    if b % 2 == 0:
예제 #31
0
파일: thirty.py 프로젝트: hecanjog/w30
dsp.write(out, 'wesley_thirty_01')

## 02
out = ''
t = dsp.split(thirty, dsp.mstf(40))
t = [ dsp.env(tt, 'sine') for tt in t ]
t = [ tt * 4 for tt in t ]

out = ''.join(t)

dsp.write(out, 'wesley_thirty_02')

## 03
out = ''

freqs = tune.fromdegrees([1, 3, 5, 9], 3, 'c')
layers = []
for i in range(30):
    l = dsp.pine(dsp.amp(thirty, 0.1), dsp.stf(30), dsp.randchoose(freqs))
    l = dsp.pan(l, dsp.rand())
    layers += [ l ]

out = dsp.mix(layers)

dsp.write(out, 'wesley_thirty_03')

## 04
out = ''

for count in range(5):
    t = dsp.randchoose(snds)
예제 #32
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
예제 #33
0
from pippi import dsp
from pippi import tune
import glob
import drums
import rhodes

speeds = [ 1.0, 1.5, 2.0 ]
scale = tune.fromdegrees([1, 4, 5, 3, 6, 8, 9], octave=2, root='e')
envs = ['line', 'tri', 'hann', 'phasor', 'impulse']
wforms = ['tri', 'saw', 'impulse', 'square']

notes = [ rhodes.rhodes(dsp.stf(dsp.rand(4, 7)), freq, 0.3) for freq in scale ]

layer = [ dsp.randchoose(notes) for i in range(40) ]
layer = [ dsp.pan(note, dsp.rand()) for note in layer ]
layer = [ dsp.amp(note, dsp.rand(0.1, 0.7)) for note in layer ]
layer = [ dsp.transpose(note, dsp.randchoose(speeds)) for note in layer ]
layer = [ dsp.pad(note, 0, dsp.mstf(dsp.rand(500, 2000))) for note in layer ]
layer = ''.join(layer)

out = ''

themes = [ [ dsp.transpose(note, dsp.randchoose(speeds)) for note in notes * 2 ] for theme in range(8) ]

arpsPlay, leadPlay, hatsPlay, blipsPlay, foldsPlay, kicksPlay, clapsPlay, bassPlay, themePlay = 0,0,0, 0,0,0, 0,0,0

intro_drone_pad_length, intro_drone_length, outro_drone_pad_length, outro_drone_length = 0,0,0,0


vary_sections = [ dsp.randint(7, 12) for vs in range(2) ]
예제 #34
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)
예제 #35
0
from pippi import dsp
from pippi import tune
import glob
import drums
import rhodes

speeds = [1.0, 1.5, 2.0]
scale = tune.fromdegrees([1, 4, 5, 3, 6, 8, 9], octave=2, root='e')
envs = ['line', 'tri', 'hann', 'phasor', 'impulse']
wforms = ['tri', 'saw', 'impulse', 'square']

notes = [rhodes.rhodes(dsp.stf(dsp.rand(4, 7)), freq, 0.3) for freq in scale]

layer = [dsp.randchoose(notes) for i in range(40)]
layer = [dsp.pan(note, dsp.rand()) for note in layer]
layer = [dsp.amp(note, dsp.rand(0.1, 0.7)) for note in layer]
layer = [dsp.transpose(note, dsp.randchoose(speeds)) for note in layer]
layer = [dsp.pad(note, 0, dsp.mstf(dsp.rand(500, 2000))) for note in layer]
layer = ''.join(layer)

out = ''

themes = [[dsp.transpose(note, dsp.randchoose(speeds)) for note in notes * 2]
          for theme in range(8)]

arpsPlay, leadPlay, hatsPlay, blipsPlay, foldsPlay, kicksPlay, clapsPlay, bassPlay, themePlay = 0, 0, 0, 0, 0, 0, 0, 0, 0

intro_drone_pad_length, intro_drone_length, outro_drone_pad_length, outro_drone_length = 0, 0, 0, 0

vary_sections = [dsp.randint(7, 12) for vs in range(2)]
예제 #36
0
    bar_length = dsp.randint(4, 13)
    num_pulses = dsp.randint(1, bar_length)
    pattern = dsp.eu(bar_length, num_pulses)
    pattern = dsp.rotate(pattern, vary=True)
    subseg = splitSeg(seg, 3)

    stabs = makeBeat(pattern, subseg, makeStab)
    
    # pulses
    pattern = parseBeat(pulsep)
    pulses = makeBeat(pattern, seg, makePulse)

    section = dsp.mix([ kicks, snares, stabs, hats, pulses ])

    chord = [ dsp.randint(1, 9) for _ in range(dsp.randint(2,4)) ]
    long_chord = rhodesChord(sum(seg), tune.fromdegrees(chord, octave=dsp.randint(2,4), root=key), dsp.rand(0.6, 0.75))
    long_chord = dsp.fill(long_chord, sum(seg))

    def makeGlitch(length, i):
        g = dsp.cut(long_chord, dsp.randint(0, dsp.flen(long_chord) - length), length)
        g = dsp.alias(g)
        g = dsp.fill(g, length)

        return g

    subseg = splitSeg(seg, 2)
    glitches = makeBeat([1,1], subseg, makeGlitch)

    changeindex = changeindex + 1

    section = dsp.mix([ section, long_chord, glitches ])