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
Exemple #2
0
def wild(snd, factor=1):
    snd = dsp.vsplit(snd, 41, 441)
    #snd = [ dsp.fnoise(l, dsp.rand(0, factor * 0.05)) for l in snd ]
    snd = [ dsp.amp(dsp.amp(l, dsp.rand(10, factor * 30 + 20)), 0.5) for l in snd ]
    snd = ''.join(snd)

    return snd
Exemple #3
0
def play(voice_id):
    tel = bot.getTel()

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

    octave = dsp.randint(1, 4)

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

    out = ''

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

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

        pulsewidth = dsp.rand(0.01, 1)

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

        modRange = dsp.rand(0.01, 100.08)

        modFreq = dsp.rand(0.0001, 5)

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

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

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

        t = dsp.alias(t)

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

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

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

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

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

        out += t


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

    return out
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
Exemple #5
0
def rhodes(total_time, freq=220.0, ampscale=0.5):
    partials = [
        # Multiple, amplitude, duration
        [1, 0.6, 1.0],
        [2, 0.25, 0.35],
        [3, 0.08, 0.15],
        [4, 0.005, 0.04],
    ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq,
                           length=total_time,
                           amp=plist[1] * ampscale)

        env_length = (total_time * plist[2] * 2) / 32
        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(total_time - len(wtable))])
        print env_length, len(wtable), dsp.flen(partial)

        partial = dsp.split(partial, 32)
        partial = [dsp.amp(partial[i], wtable[i]) for i in range(len(partial))]
        layer = ''.join(partial)

        layers += [layer]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

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

    return out
Exemple #6
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
Exemple #7
0
def rhodes(length=22050, freq=220.0, amp=0.5, wavetype='sine'):
    partials = [
            # Multiple, amplitude, duration
            [1, 0.6, 1.0], 
            [2, 0.25, 0.35], 
            [3, 0.08, 0.15],
            [4, 0.005, 0.04],
        ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq, length=length, amp=plist[1], wavetype=wavetype)

        env_length = (length * plist[2] * 2) / 32 
        if env_length <= 2:
            env_length = 4

        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(length - len(wtable))])
        
        partial = dsp.split(partial, 32)
        partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ]
        layer = ''.join(partial)

        layers += [ layer ]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

    out = dsp.mix([out, noise])
    out = dsp.amp(out, amp)

    return out
Exemple #8
0
def bell(length=22050, freq=220, amp=0.5):
    ding = dsp.read('/home/hecanjog/sounds/vibesc1.wav').data
    ding = dsp.amp(ding, dsp.rand(0.5, 0.8))

    bell = dsp.read('/home/hecanjog/sounds/tones/bellc.wav').data
    bell = dsp.amp(bell, dsp.rand(10, 50))
    bell = dsp.amp(bell, 0.3)

    rhodes = dsp.read('/home/hecanjog/sounds/tones/rhodes.wav').data
    rhodes = dsp.transpose(rhodes, 1.2)
    rhodes = dsp.pan(rhodes, dsp.rand())

    glade = dsp.read('/home/hecanjog/sounds/glade.wav').data
    numgs = dsp.randint(2, 6)

    gs = []
    for _ in range(numgs):
        g = dsp.rcut(glade, dsp.mstf(100, 500))
        g = dsp.amp(g, dsp.rand(0.2, 0.5))
        g = dsp.pan(g, dsp.rand())
        g = dsp.transpose(g, dsp.rand(0.15, 0.75))

        gs += [ g ]

    gs = dsp.mix(gs)
    gs = dsp.env(gs, 'phasor')

    clump = dsp.mix([ ding, gs, bell, rhodes ])

    clump = dsp.transpose(clump, freq / tune.ntf('c', octave=4))
    clump = dsp.fill(clump, length, silence=True)
    clump = dsp.env(clump, 'phasor')
    clump = dsp.amp(clump, amp)

    return clump
Exemple #9
0
def rhodes(total_time, freq=220.0, ampscale=0.5):
    partials = [
            # Multiple, amplitude, duration
            [1, 0.6, 1.0], 
            [2, 0.25, 0.35], 
            [3, 0.08, 0.15],
            [4, 0.005, 0.04],
        ]

    layers = []
    for plist in partials:
        partial = dsp.tone(freq=plist[0] * freq, length=total_time, amp=plist[1] * ampscale)

        env_length = (total_time * plist[2] * 2) / 32 
        wtable = dsp.wavetable('hann', int(env_length))
        wtable = wtable[int(env_length / 2):]
        wtable.extend([0 for i in range(total_time - len(wtable))])
        print env_length, len(wtable), dsp.flen(partial)
        
        partial = dsp.split(partial, 32)
        partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ]
        layer = ''.join(partial)

        layers += [ layer ]

    out = dsp.mix(layers)
    noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005)
    noise = dsp.fill(noise, dsp.flen(out))

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



    return out
Exemple #10
0
def play(voice_id):
    volume = P(voice_id, 'volume', 100.0)
    volume = volume / 100.0 # TODO: move into param filter
    volume = volume * 0.65
    length = P(voice_id, 'length', 40)
    env    = False
    wii    = False
#    wii    = True

    speed  = False
    
    numcycles = dsp.randint(1, 200)

    # Make breakpoint env with 2-10 vals between 0.1 and 1.0
    curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles)

    # Make wavetable with single cycle from given wave types
    curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse']
    curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles)

    # Make pan curve - always cosine
    pan = dsp.breakpoint([ dsp.rand() for i in range(dsp.randint(5, 50)) ], numcycles)
    amps = dsp.breakpoint([ dsp.rand(0.1, 0.75) for i in range(dsp.randint(5, 30)) ], numcycles)

    # Multiply breakpoint curve with simple wavetable
    wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ]

    # Scale to max frequency
    wtable = [ (f * 20000) + length for f in wtable ]

    # Possible osc wavetypes
    wtypes = ['sine2pi']
#    wtypes = ['tri', 'sine2pi', 'impulse']
#    wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary']

    if wii is True:
        out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ]
    else:
        wtype = dsp.randchoose(wtypes)
        out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ]

    out = [ dsp.amp(oo, amps[i]) for i, oo in enumerate(out) ]

    out = dsp.amp(''.join(out), volume)

    if speed != False and speed > 0.0:
        out = dsp.transpose(out, speed)

    if env != False:
        out = dsp.env(out, env)

    return out
Exemple #11
0
def makeLong(seg):
    g = dsp.randchoose(guitars)
    g = dsp.amp(g, 0.4)
    long_guitar = dsp.fill(g, sum(seg))

    fade_guitar = dsp.randchoose(guitars)
    fade_guitar = dsp.amp(fade_guitar, dsp.rand(0.1, 0.3))
    fade_guitar = fx.penv(fade_guitar)
    fade_guitar = dsp.fill(fade_guitar, sum(seg))

    out = dsp.mix([long_guitar, fade_guitar])

    return out
Exemple #12
0
def makeLong(seg):
    g = dsp.randchoose(guitars)
    g = dsp.amp(g, 0.4)
    long_guitar = dsp.fill(g, sum(seg))

    fade_guitar = dsp.randchoose(guitars)
    fade_guitar = dsp.amp(fade_guitar, dsp.rand(0.1, 0.3))
    fade_guitar = fx.penv(fade_guitar)
    fade_guitar = dsp.fill(fade_guitar, sum(seg))

    out = dsp.mix([ long_guitar, fade_guitar ])

    return out
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
Exemple #14
0
def makeSnare(length, i, amp):
    s = dsp.cut(snare, 0, dsp.randint(dsp.mstf(40), dsp.flen(snare)))
    s = dsp.alias(s, dsp.randint(4, 12))
    s = dsp.taper(s)
    s = dsp.fill(s, length, silence=True)
    s = dsp.amp(s, dsp.rand(2,4))
    return s
Exemple #15
0
def glitchStutter(snd):
    """ Basically a random gate """
    snd = dsp.vsplit(snd, dsp.mstf(1, 50), dsp.mstf(50, 200))

    for i, s in enumerate(snd):
        if dsp.rand() > dsp.rand(0.5, 0.9):
            s = dsp.amp(s, dsp.rand(0, 0.15))
            s = dsp.taper(s, 20)
            snd[i] = s
        else:
            s = dsp.amp(s, dsp.rand(0.85, 1))
            snd[i] = dsp.taper(s, 20)

    snd = ''.join(snd)

    return snd
Exemple #16
0
def makeSnare(length, i, amp):
    s = dsp.cut(snare, 0, dsp.randint(dsp.mstf(40), dsp.flen(snare)))
    s = dsp.alias(s, dsp.randint(4, 12))
    s = dsp.taper(s)
    s = dsp.fill(s, length, silence=True)
    s = dsp.amp(s, dsp.rand(2, 4))
    return s
Exemple #17
0
    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
Exemple #18
0
    def play(self, freq, length, amp=1):
        snd = dsp.transpose(self.snd, freq / self.freq)
        snd = dsp.taper(snd, 40)
        snd = dsp.amp(snd, amp)

        if self.direction == 'fw':
            snd = dsp.env(snd, self.env)
            snd = dsp.fill(snd, length, silence=True)

        if self.direction == 'fw-loop':
            snd = dsp.fill(snd, length, silence=False)
            snd = dsp.env(snd, self.env)

        if self.direction == 'fw-loop-rand':
            snd = dsp.env(snd, self.env)
            elapsed = 0
            sndout = ''
            while elapsed < length:
                sndout += dsp.pad(snd, 0, dsp.randint(0, dsp.flen(snd)))
                elapsed = dsp.flen(sndout)

            snd = dsp.fill(sndout, length, silence=False)

        if self.direction == 'fw-bw-loop':
            snd = dsp.fill(snd + dsp.reverse(snd), length, silence=False)
            snd = dsp.env(snd, self.env)

        if self.tails:
            snd = dsp.mix([ snd, self.makeTails(freq, length) ])

        return snd
Exemple #19
0
def play(ctl):
    param = ctl.get("param")

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

    lpd = ctl.get("midi").get("lpd")

    amp = pc.get(7)

    snds = ["sounds/melodica.wav", "sounds/rhodes.wav", "sounds/chime.wav", "sounds/bell.wav", "sounds/lap.wav"]
    # snds = ['sounds/rhodes.wav']
    m = dsp.read(dsp.randchoose(snds)).data
    m = dsp.transpose(m, 0.125)
    m = dsp.transpose(m, dsp.randchoose([1, 1.5, 2, 3]) * 2 ** dsp.randint(0, 3))
    m = dsp.fill(m, dsp.stf(pc.get(15, low=0.125, high=2)))

    reverse = dsp.randchoose([True, False])
    numlayers = dsp.randint(10, 20)
    numgrains = dsp.randint(pc.geti(8, low=3, high=10), pc.geti(8, low=10, high=20))
    minlen = dsp.rand(10, 100)
    # lenranges = (dsp.rand(10, 20), dsp.rand(50, 1000))
    lenranges = (pc.get(15, low=10, high=50), pc.get(15, low=50, high=500))
    env = dsp.randchoose(["sine", "hann", "tri", "vary"])

    # out = m
    out = fx.spider(m, numlayers, numgrains, minlen, lenranges, reverse)
    out = dsp.amp(out, amp)
    # out = dsp.env(out, 'sine')
    # out = dsp.alias(out)

    return out
Exemple #20
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
Exemple #21
0
def dsp_loop(out, buf, voice_id):
    os.nice(0)

    plays = int(settings.voice(voice_id, 'plays')) + 1
    settings.voice(voice_id, 'plays', plays)

    target_volume = settings.voice(voice_id, 'target_volume')
    post_volume   = settings.voice(voice_id, 'post_volume')

    buf = dsp.split(buf, 500)

    for chunk in buf:
        if target_volume != post_volume:
            if target_volume > post_volume:
                post_volume += 0.01
            elif post_volume > target_volume:
                post_volume -= 0.01

            chunk = dsp.amp(chunk, post_volume)

        out.write(chunk)

        if post_volume < 0.002:
            settings.voice(voice_id, 'loop', False)
            settings.voice(voice_id, 'post_volume', post_volume)
            break

    settings.voice(voice_id, 'post_volume', post_volume)
Exemple #22
0
def play(voice_id):
    tel = bot.getTel()

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

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

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

    blen = len(b)

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

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

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

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

    out = ''.join(b)

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

    return out
Exemple #23
0
def makeGrains():
    guitar = dsp.randchoose(guitars)
    guitar = dsp.transpose(guitar, dsp.randchoose([1, 2, 3, 4, 8]))

    max_grain_length = dsp.mstf(dsp.rand(10, 500))

    positions = [
        math.floor(pos * (dsp.flen(guitar) - max_grain_length))
        for pos in makeShape()
    ]
    lengths = [
        math.floor(length * (max_grain_length - 1) + 1)
        for length in makeShape()
    ]
    pans = makeShape()
    amps = [amp * dsp.rand(0, 10) for amp in makeShape()]

    num_grains = dsp.randint(500, 1000)

    grains = []

    for i in range(num_grains):
        grain = dsp.cut(guitar, positions[i % len(positions)],
                        lengths[i % len(lengths)])
        grain = dsp.pan(grain, pans[i % len(pans)])
        grain = dsp.amp(grain, amps[i % len(amps)])
        grain = dsp.taper(grain, 20)

        grains += [grain]

    return ''.join(grains)
Exemple #24
0
def ding(tone, tlength=88200, nlength=1000):

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

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

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

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

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

    tones = [ fade(tone) for tone in tones ]
    
    return dsp.amp(''.join(tones), 0.5)
Exemple #25
0
def makeHat(length, i):
    h = dsp.bln(length / 4, dsp.rand(6000, 8000), dsp.rand(9000, 16000))
    h = dsp.amp(h, dsp.rand(0.5, 1))
    h = dsp.env(h, 'phasor')
    h = dsp.fill(h, length, silence=True)

    return h
Exemple #26
0
def play(ctl):
    param = ctl.get("param")

    # lpd = ctl.get('midi').get('lpd')
    # pc = ctl.get('midi').get('pc')
    # pc.setOffset(111)

    # r = dsp.read('sounds/roll.wav').data
    r = dsp.read("sounds/pills.wav").data
    r = dsp.fill(r, dsp.stf(3))
    # tr = pc.get(10, low=0.125, high=4)
    tr = dsp.rand(0.125, 4)
    r = dsp.transpose(r, dsp.rand(tr * 0.25, tr * 2))
    # r = dsp.amp(r, pc.get(1, low=0, high=10))
    r = dsp.amp(r, dsp.rand(0, 10))

    reverse = dsp.randchoose([True, False])
    # numgrains = pc.geti(2, low=5, high=20)
    numgrains = dsp.randint(5, 20)
    # numlayers = pc.geti(3, low=5, high=50)
    numlayers = dsp.randint(5, 50)
    # minlen = lpd.get(9, low=10, high=100)
    minlen = dsp.rand(10, 100)
    # lenranges = (lpd.get(9, low=10, high=50), lpd.get(9, low=50, high=500))
    lenranges = (dsp.rand(10, 50), dsp.rand(50, 500))

    out = fx.spider(r, numlayers, numgrains, minlen, lenranges, reverse)
    # out = dsp.mix([out, dsp.env(r, 'sine')])

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

        return scale

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

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

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

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

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

    return dsp.amp(''.join(tones), 0.5)
Exemple #28
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)
    nlen = beat / dsp.randchoose([4,5,6,7,8,9,10])

    root = 340.0
    target = tune.ntf(key)

    n = dsp.read('sounds/mike.wav').data
    n = dsp.transpose(n, target / root)
    n = dsp.amp(n, 0.4)

    length = dsp.randint(16, 64) * beat
    ngrains = length / nlen

    n = dsp.transpose(n, dsp.randchoose([0.5, 1, 2, 2, 4, 4]))
    n = dsp.split(n, nlen)

    snd = dsp.randchoose(n)
    snd = dsp.env(snd, 'sine')

    grains = [ snd for i in range(ngrains) ]
    grains = [ dsp.pan(grain, dsp.rand()) for grain in grains ]

    out = ''.join(grains)
    out = dsp.env(out, 'sine')

#    out = dsp.pad(out, 0, dsp.stf(dsp.randint(0.5, 3)))

    return out
Exemple #29
0
    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
Exemple #30
0
def smear(input, mingrain=2205, maxgrain=4410, waveform='hann', spread=0.1, drift=0.05, minpan=0.0, maxpan=1.0, minamp=0.0, maxamp=1.0):
    out = dsp.vsplit(input, mingrain, maxgrain)
    out = [ dsp.amp(grain, dsp.rand(minamp, maxamp)) for grain in out ]
    out = [ dsp.env(grain, waveform) for grain in out ]
    out = [ dsp.pan(grain, dsp.rand(minpan, maxpan)) for grain in out ]
    drift_delta = drift / 2.0
    minspeed = 1.0 - drift_delta
    maxspeed = 1.0 + drift_delta

    out = [ dsp.transpose(grain, dsp.rand(minspeed, maxspeed)) for grain in out ]

    num_shuffled_grains = int(len(out) * spread)

    # Pull a random set of grains
    shuffled_grains = []
    for i in range(num_shuffled_grains):
        index = dsp.randint(0, len(out) - 1)
        shuffled_grains += [ out.pop(index) ] 

    # Insert them back into random positions
    for grain in shuffled_grains:
        index = dsp.randint(0, len(out) - 1)
        out.insert(index, grain)

    out = ''.join(out)

    return out
Exemple #31
0
def hihat(amp, length):
    if amp == 0:
        return dsp.pad('', 0, length)

    def hat(length):
        lowf = dsp.rand(600, 7000)
        highf = dsp.rand(7000, 19000)
        
        if dsp.randint(0, 6) == 0:
            out = dsp.bln(length, lowf, highf)
            out = dsp.env(out, 'line')
        else:
            out = dsp.bln(int(length * 0.05), lowf, highf)
            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)

    out = dsp.amp(out, amp)
    return out
Exemple #32
0
def play(args):
    length = dsp.stf(0.2)
    volume = 0.2 
    octave = 2 
    notes = ['d', 'a']
    quality = tune.major
    waveform = 'sine'
    ratios = tune.terry

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

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

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

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

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

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

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

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

    harm = range(1, 12)

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

        tones = []

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

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

    out = dsp.mix(layers)

    return dsp.amp(out, volume)
Exemple #33
0
    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
Exemple #34
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
Exemple #35
0
    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
Exemple #36
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')
    nk = ctl.get('midi').get('nk')

    amp = mpk.get(4, low=0, high=1, default=0)

    kick = dsp.read('/home/hecanjog/sounds/drums/Junglebd.wav').data
    klength = dsp.mstf(mpk.get(1, low=60, high=1500, default=100))
    k = dsp.fill(kick, klength, silence=True)
    kamp = nk.get(0, low=0, high=1, default=1)
    k = dsp.amp(k, kamp)
    kpitch = nk.get(16, low=0.25, high=1, default=1)
    k = dsp.transpose(k, kpitch)

    snare = dsp.read('/home/hecanjog/sounds/drums/Hipclap1.wav').data
    slength = dsp.mstf(mpk.get(2, low=60, high=500, default=100))
    s = dsp.fill(snare, slength, silence=True)
    soffset = dsp.mstf(mpk.get(6, low=0, high=500, default=0))
    s = dsp.pad(s, soffset, 0)
    samp = nk.get(1, low=0, high=1, default=1)
    s = dsp.amp(s, samp)
    spitch = nk.get(17, low=0.25, high=2, default=1)
    s = dsp.transpose(s, spitch)

    hat = dsp.read('/home/hecanjog/sounds/drums/78ch.wav').data
    hlength = dsp.mstf(mpk.get(3, low=60, high=500, default=100))
    h = dsp.fill(hat, hlength, silence=True)
    hoffset = dsp.mstf(mpk.get(7, low=0, high=500, default=0))
    h = dsp.pad(h, hoffset, 0)
    hamp = nk.get(2, low=0, high=1, default=1)
    h = dsp.amp(h, hamp)
    hpitch = nk.get(18, low=0.25, high=2, default=1)
    h = dsp.transpose(h, hpitch)

    longest = max([dsp.flen(k), dsp.flen(h), dsp.flen(s)])

    k = dsp.fill(k, longest)
    h = dsp.fill(h, longest)
    s = dsp.fill(s, longest)

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

    out = dsp.amp(out, amp)

    return out
Exemple #37
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')
    nk = ctl.get('midi').get('nk')

    amp = mpk.get(4, low=0, high=1, default=0)

    kick = dsp.read('/home/hecanjog/sounds/drums/Junglebd.wav').data
    klength = dsp.mstf(mpk.get(1, low=60, high=1500, default=100))
    k = dsp.fill(kick, klength, silence=True)
    kamp = nk.get(0, low=0, high=1, default=1)
    k = dsp.amp(k, kamp)
    kpitch = nk.get(16, low=0.25, high=1, default=1)
    k = dsp.transpose(k, kpitch)

    snare = dsp.read('/home/hecanjog/sounds/drums/Hipclap1.wav').data
    slength = dsp.mstf(mpk.get(2, low=60, high=500, default=100))
    s = dsp.fill(snare, slength, silence=True)
    soffset = dsp.mstf(mpk.get(6, low=0, high=500, default=0))
    s = dsp.pad(s, soffset, 0)
    samp = nk.get(1, low=0, high=1, default=1)
    s = dsp.amp(s, samp)
    spitch = nk.get(17, low=0.25, high=2, default=1)
    s = dsp.transpose(s, spitch)

    hat = dsp.read('/home/hecanjog/sounds/drums/78ch.wav').data
    hlength = dsp.mstf(mpk.get(3, low=60, high=500, default=100))
    h = dsp.fill(hat, hlength, silence=True)
    hoffset = dsp.mstf(mpk.get(7, low=0, high=500, default=0))
    h = dsp.pad(h, hoffset, 0)
    hamp = nk.get(2, low=0, high=1, default=1)
    h = dsp.amp(h, hamp)
    hpitch = nk.get(18, low=0.25, high=2, default=1)
    h = dsp.transpose(h, hpitch)

    longest = max([ dsp.flen(k), dsp.flen(h), dsp.flen(s) ])

    k = dsp.fill(k, longest)
    h = dsp.fill(h, longest)
    s = dsp.fill(s, longest)

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

    out = dsp.amp(out, amp)

    return out
Exemple #38
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
Exemple #39
0
    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
Exemple #40
0
    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
Exemple #41
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
Exemple #42
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
Exemple #43
0
    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
Exemple #44
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
Exemple #45
0
    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
Exemple #46
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
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
Exemple #48
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
Exemple #49
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
Exemple #50
0
def makeRimshot(length, i):
    return dsp.fill(dsp.amp(rimshot, dsp.rand(4, 5)), length, silence=True)
Exemple #51
0
def makeKick(length, i):
    k = kickcym if i == 0 else kick
    return dsp.fill(dsp.amp(k, dsp.rand(1, 5)), length, silence=True)
Exemple #52
0
        pans = dsp.breakpoint([dsp.rand(0, 1) for _ in range(npulses / 10)],
                              npulses)
        lengths = [
            dsp.mstf(l) for l in dsp.breakpoint(
                [dsp.rand(1, 30) for _ in range(npulses / 10)], npulses)
        ]

        for high, low, amp, pan, length in zip(highs, lows, amps, pans,
                                               lengths):
            p = dsp.bln(length,
                        low,
                        high,
                        wform=dsp.randchoose(['hann', 'sine2pi', 'tri']))
            p = dsp.env(p, 'hann')
            p = dsp.taper(p, 20)
            p = dsp.amp(p, amp)
            p = dsp.pan(p, pan)

            layer += p

        layers += [layer]

    freqs = tune.fromdegrees([dsp.randint(1, 9) for _ in range(nlayers)],
                             octave=1,
                             root='a')

    for i, freq in enumerate(freqs):
        layers[i] = dsp.pine(layer, dsp.flen(layer) * 10, freq)

    section = dsp.fill(dsp.mix(layers), sectionlength)
Exemple #53
0
    for i in range(num_grains):
        grain = dsp.cut(guitar, positions[i % len(positions)],
                        lengths[i % len(lengths)])
        grain = dsp.pan(grain, pans[i % len(pans)])
        grain = dsp.amp(grain, amps[i % len(amps)])
        grain = dsp.taper(grain, 20)

        grains += [grain]

    return ''.join(grains)


wes = fx.spider(orc.wes.fetch())

intro = dsp.mix([
    dsp.amp(makeGrains(), dsp.rand(0.01, 0.2))
    for _ in range(dsp.randint(5, 10))
])
intro = wes + dsp.env(intro, 'phasor')

# Buildup
##########

layers = []
nlayers = 3
length = dsp.stf(120)

for _ in range(nlayers):
    frags = []
    elapsed = 0
Exemple #54
0
    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)

    out += dsp.mix([ bar, dsp.fill(rhodes, dsp.flen(bar)) ])
    #out += bar
Exemple #55
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
Exemple #56
0
 def makeLSnare(length, i, amp):
     s = dsp.fill(lssnd, length, silence=True)
     return dsp.amp(s, 2)
Exemple #57
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

    pc = ctl.get('midi').get('pc')
    #pc.setOffset(111)

    gamut = {
        'high': [
            (10000, 15000),
            (5000, 15000),
            (5000, 10000),
        ],

        'mid': [
            (1000, 5000),
            (1000, 2000),
        ],

        'pitch': [
            tuple([ dsp.rand(500, 2000) for p in range(2) ]),
            tuple([ dsp.rand(100, 1000) for p in range(2) ]),
            tuple([ dsp.rand(1000, 5000) for p in range(2) ]),
        ],

        'low': [
            (20, 5000),
            (30, 10000),
            (40, 10000),
        ]
    }

    area = param.get('wash-area', default='high')
    area = dsp.randchoose(['high', 'mid', 'pitch', 'low'])
    area = 'pitch'

    dsp.log(area)

    freqs = dsp.randchoose(gamut[area])

    freqscale = pc.get(16, low=0.125, high=2, default=1)
    #freqscale = dsp.rand(0.125, 2)

    low = freqs[0] * freqscale
    high = freqs[1] * freqscale

    wform = dsp.randchoose(['sine2pi', 'tri', 'vary', 'square'])

    timescale = pc.get(17, low=1, high=4, default=1)
    #timescale = dsp.rand(1, 4)
    lengthscale = pc.get(18, low=0.125, high=2.5)
    #lengthscale = dsp.rand(0.125, 2.5)

    amp = pc.get(0, low=0, high=0.5, default=0.5)
    #amp = dsp.rand(0, 0.5)

    if area == 'high':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.3) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'phasor')

        if dsp.rand() > 10.5:
            beep = dsp.tone(dsp.flen(out), high * 2, amp=dsp.rand(0.5, 1))
            out = dsp.mix([out, beep])

        out = dsp.pad(out, 0, dsp.mstf(dsp.rand(1, 400) * timescale))
        out = out * dsp.randint(1, 3)
        out = dsp.drift(out, dsp.rand(0, 1))

    elif area == 'mid':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')

        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    elif area == 'pitch':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')

        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    elif area == 'low':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.2, 2) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')
        out = dsp.mix([out, dsp.tone(length, low)])

        if dsp.rand() > 0.5:
            beep = dsp.tone(dsp.flen(out), high, amp=dsp.rand(0.015, 0.1), wavetype=dsp.randchoose(['hann', 'impulse', 'square', 'vary', 'sine']))
            out = dsp.mix([out, beep])


        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    if dsp.rand() > pc.get(19, low=0, high=1, default=0.75):
        plength = length * dsp.randint(2, 6)
        freq = tune.ntf(param.get('key', default='c'), octave=dsp.randint(0, 4))
        out = dsp.mix([ dsp.pine(out, plength, freq), dsp.pine(out, plength, freq * 1.25) ])
        out = dsp.fill(out, length)

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

    return out
Exemple #58
0
 def makeKick(length, i, amp):
     k = dsp.fill(ksnd, length, silence=True)
     return dsp.amp(k, 3)