Esempio n. 1
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
Esempio n. 2
0
def ping(maxlen=44100, freqs=None):
    out = ''

    if freqs is None:
        freqs = [ dsp.rand(20,10000) for i in range(4) ]

    tlen = dsp.randint(10, maxlen)

    tones = [ dsp.tone(length=tlen, freq=freq, amp=0.1, wavetype='random') 
            for freq in freqs ]

    tones = [ dsp.split(tone, 64) for tone in tones ]

    pcurves = [ dsp.breakpoint([ dsp.rand() for t in range(len(tones[i]) / 20) ],
            len(tones[i])) for i in range(len(tones)) ]

    tones = [ [ dsp.pan(t, pcurves[i][ti]) for ti, t in enumerate(tones[i]) ] 
            for i in range(len(tones)) ]

    fcurves = [ dsp.breakpoint([ dsp.rand(0.0, 0.1) + 0.9 for t in range(len(tones[i]) / 20) ],
            len(tones[i])) for i in range(len(tones)) ]

    tones = [ [ dsp.transpose(t, fcurves[i][ti] + 0.1) for ti, t in enumerate(tones[i]) ] 
            for i in range(len(tones)) ]

    out = dsp.mix([ dsp.env(''.join(tone), 'random') for tone in tones ])
    out = dsp.env(out, 'random')
    out = dsp.pad(out, 0, dsp.randint(0, maxlen * 3))

    return out
Esempio n. 3
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
Esempio n. 4
0
File: orc.py Progetto: hecanjog/o-ou
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
Esempio n. 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
Esempio n. 6
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

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

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

    chord = dsp.mix(chord)

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

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

    return chord
Esempio n. 7
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)
Esempio n. 8
0
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    beat = dsp.bpm2frames(bpm)
    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
Esempio n. 9
0
def smear(snd):
    snd = dsp.split(snd, dsp.mstf(dsp.rand(5000, 10000)))
    snd = dsp.randshuffle(snd)
    snd = [dsp.env(s) for s in snd]
    snd = [s * dsp.randint(1, 8) for s in snd]

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

    return dsp.drift(''.join(snd), dsp.rand(0.01, 0.1))
Esempio n. 11
0
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose([
                            'impulse', 'sine', 'line', 'phasor', 'cos',
                            'impulse'
                        ])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        #                        lowbend = 0.75
                        highbend = 1.01
#                        highbend = 1.5

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [
                        math.fabs(f) * (highbend - lowbend) + lowbend
                        for f in freqs
                    ]

                    out = [
                        dsp.transpose(out[i], freqs[i])
                        for i in range(len(out))
                    ]
                    return ''.join(out)
Esempio n. 12
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

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

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

    chord = dsp.mix(chord)

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

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

    return chord
Esempio n. 13
0
def penv(snd, low=4, high=20):
    packets = dsp.split(snd, dsp.dsp_grain)

    ptable = dsp.breakpoint([ dsp.rand() for _ in range(dsp.randint(low, high)) ], len(packets))
    etable = dsp.breakpoint([0] + [ dsp.rand() for _ in range(dsp.randint(low, high)) ] + [0], len(packets))

    packets = [ dsp.pan(p, ptable[i], etable[i]) for i, p in enumerate(packets) ]

    return ''.join(packets)
Esempio n. 14
0
def make_vary(snd):
    numpoints = dsp.flen(snd) / 40
    curve = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(dsp.randint(5, numpoints / 100)) ] + [0], numpoints)
    
    snd = dsp.split(snd, 40)

    snd = [ dsp.amp(snd[i], curve[i]) for i in range(numpoints) ]

    snd = ''.join(snd)

    return snd
Esempio n. 15
0
def slurp(snd):
    snd = dsp.split(snd, dsp.flen(snd) / 100)
    numcycles = len(snd)
    curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles)
    curve_b = dsp.wavetable('cos', numcycles)
    wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ]
    wtable = [ math.fabs((f * 5) + 0.75) for f in wtable ]

    snd = [ dsp.transpose(snd[i], wtable[i]) for i in range(numcycles) ]

    return ''.join(snd)
Esempio n. 16
0
def slurp(snd):
    snd = dsp.split(snd, dsp.flen(snd) / 100)
    numcycles = len(snd)
    curve_a = dsp.breakpoint(
        [1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0],
        numcycles)
    curve_b = dsp.wavetable('cos', numcycles)
    wtable = [curve_a[i] * curve_b[i] for i in range(numcycles)]
    wtable = [math.fabs((f * 5) + 0.75) for f in wtable]

    snd = [dsp.transpose(snd[i], wtable[i]) for i in range(numcycles)]

    return ''.join(snd)
Esempio n. 17
0
    def makeHats(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 1, 16, True)

        for onset in onsets:
            out.add(h, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)
Esempio n. 18
0
    def makeHats(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 1, 16, True)

        for onset in onsets:
            out.add(h, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)
Esempio n. 19
0
def bend(snd, freqs=None, amount=0.02):
    out = dsp.split(snd, 441)

    if freqs is None:
        freqs = dsp.wavetable('sine', len(out))
    else:
        freqs = dsp.breakpoint(freqs, len(out))

    freqs = [ freq * amount + (1 - (amount * 0.5)) for freq in freqs ]

    out = [ dsp.transpose(grain, freq) for grain, freq in zip(out, freqs) ]

    return ''.join(out)
Esempio n. 20
0
    def makeClaps(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 8, True)

        for onset in onsets:
            clap = dsp.stretch(c, int(dsp.flen(c) * log.get(1, 10)), grain_size=dsp.randint(20, 120))
            out.add(clap, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = [ dsp.taper(o, 20) for o in out ]
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)
Esempio n. 21
0
def glitchPulse(snd):
    """ 2 to 3 overlapping streams of enveloped grains at regular but phasing intervals. """

    numlayers = dsp.randint(2,3)

    layers = []
    for _ in range(numlayers):
        grains = dsp.split(snd, dsp.mstf(1, 100))
        grains = [ dsp.taper(g, 50) for g in grains ]
        grains = ''.join(grains)
        grains = penv(grains)

        layers += [ grains ]

    return dsp.mix(layers)
Esempio n. 22
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
Esempio n. 23
0
def make_pulses(degrees, bpm):
    freqs = tune.fromdegrees(degrees, 3, 'c')

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

    t = dsp.mix(layers)

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

    t = dsp.randshuffle(t)

    return ''.join(t)
Esempio n. 24
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
Esempio n. 25
0
    def makeClaps(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 8, True)

        for onset in onsets:
            clap = dsp.stretch(c,
                               int(dsp.flen(c) * log.get(1, 10)),
                               grain_size=dsp.randint(20, 120))
            out.add(clap, onset)

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = [dsp.taper(o, 20) for o in out]
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)
Esempio n. 26
0
def make(length, i):
    r = dsp.transpose(guitar, getRatio(scale[ i % len(scale)]))
    r = dsp.mix([ dsp.pan(r, dsp.rand()), dsp.drift(dsp.pan(r, dsp.rand()), dsp.rand(0.001, 0.02)) ])

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

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

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

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

    return g
Esempio n. 27
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
Esempio n. 28
0
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse'])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        highbend = 1.01

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ]

                    out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
                    return ''.join(out)
Esempio n. 29
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
Esempio n. 30
0
def make(length, i):
    r = dsp.transpose(guitar, getRatio(scale[i % len(scale)]))
    r = dsp.mix([
        dsp.pan(r, dsp.rand()),
        dsp.drift(dsp.pan(r, dsp.rand()), dsp.rand(0.001, 0.02))
    ])

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

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

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

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

    return g
Esempio n. 31
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

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

    out = ''

    for i in range(32):

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

        bar = dsp.flen(b) / 2

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

            blayers += [ blayer ]

        b = dsp.mix(blayers)

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

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

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

    return out
Esempio n. 32
0
from pippi import dsp

g = dsp.read('sounds/seneca3bars.wav').data
beat = dsp.flen(g) / (12 * 13)
g = dsp.split(g, beat)

modulos = [3, 5, 7, 11]
numgrains = dsp.stf(20) / beat

streams = []
for mod in modulos:
    stream = []

    for i, s in enumerate(g):
        if i % mod == 0:
            stream += [s]

    stream = [stream[i % len(stream)] for i in range(numgrains)]

    streams += [stream]

out = []

for grain in range(numgrains):
    for stream in streams:
        out += stream[grain]

out = ''.join(out)

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

    chord = nextChord(chord)

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

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

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

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

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

    d = dsp.split(dr, beat / 8)
    d = dsp.randshuffle(d)
Esempio n. 34
0
snds = [thirty, wesley]

## 01
out = ''
t = thirty * 30
t = dsp.pan(t, 0)

tt = dsp.cut(thirty, 0, dsp.flen(thirty) - dsp.mstf(30)) * 30
tt = dsp.pan(tt, 1)

out = dsp.mix([ t, tt ])
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())
Esempio n. 35
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
Esempio n. 36
0
    def makecurve(length):
        # freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, amp

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

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

        pw = dsp.rand(0.1, 1.0)

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


            pw = 1.0

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


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

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

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

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

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

        maxPad = dsp.randint(2000, 4000)

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

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

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

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

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

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

            maxPad = 0

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

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

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

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

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

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

        out = ''.join(c)

        return out
Esempio n. 37
0
    if section == 'float':
        numbeats = 16 * dsp.randint(2, 20)

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

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

    bar_length = beat * numbeats

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

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

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

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

    if canPlay('swells', section):
Esempio n. 38
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
Esempio n. 39
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    return out
Esempio n. 40
0
    def makeSnare(length, i, amp):
        s = dsp.fill(ssnd, length, silence=True)
        return dsp.amp(s, 3)

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

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

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

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

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

    progression = 'ii6 ii69'.split(' ')
    cname = progression[ count % len(progression) ]
    rfreqs = tune.chord(cname, key, 2)
    rhodes = makeRhodes(dsp.flen(bar), beat / 8, rfreqs)
Esempio n. 41
0
from pippi import dsp

snd = dsp.read('sounds/seneca3bars.wav').data
snd = dsp.split(snd, 0, 1)
snd = dsp.packet_shuffle(snd, 3)
snd = [s * dsp.randint(1, 10) for s in snd]

out = ''.join(snd)

dsp.write(out, 'seero')
Esempio n. 42
0
from pippi import dsp, tune
from hcj import keys, fx, drums

kick = dsp.read('snds/kick.wav').data
bigkick = dsp.read('snds/kick606.wav').data
snare = dsp.read('snds/snare.wav').data
snare = dsp.amp(snare, 6)
snare = dsp.env(snare, 'phasor')

snarex = dsp.split(snare, 0, 1)

key = 'a'

hatp =   'xxxx'
snarep = '..x...x...'
kickp =  'x...-.....x..x...'
pulsep = 'x..'

# tempo path
def tempoPath(nsegs):
    maxms = dsp.rand(100, 400)
    minms = dsp.rand(1, 100)
    wavetypes = ['hann', 'sine', 'vary']

    out = []

    for _ in range(nsegs):
        seglen = dsp.randint(20, 200)
        seg = dsp.wavetable(dsp.randchoose(wavetypes), seglen)

        # pull out a randomly selected subsegment of the curve
Esempio n. 43
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
Esempio n. 44
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)
Esempio n. 45
0
from pippi import dsp

g = dsp.read('sounds/seneca3bars.wav').data
beat = dsp.bpm2frames(112)

g = dsp.split(g, dsp.flen(g) / 48)

out = ''

osts = [dsp.randchoose(g) for a in range(3)]

for p in range(32):
    alts = [dsp.randchoose(g) for a in range(4)]

    for b in range(dsp.randint(4, 12)):
        out += osts[p % len(osts)]
        out += alts[b % len(alts)]

dsp.write(out, 'pulsechord')
Esempio n. 46
0
def play(params):

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

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

        return cycles

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

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

        return pulses

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

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

        for p in pattern:

            prev = value
            value = p

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

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

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

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

        return events

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

        return out

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

            return out

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

        return out

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

        return out

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

        target = length
        pos = 0
        fpos = fhigh

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

        return dsp.env(out, 'phasor')

    beats = beats * measures

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

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

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

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

            #streams += [ stream ]

    out = dsp.mix(layers)

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

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


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

    return dsp.amp(out, volume)
Esempio n. 47
0
from pippi import dsp
from hcj import snds

snare = snds.load('mc303/snare1.wav')
snare = dsp.amp(snare, 3)
#snare = dsp.read('snds/snare.wav').data
#snare = dsp.env(snare, 'phasor')
snarex = dsp.split(snare, 0, 1)


def make(length, i):
    #burst = dsp.bln(length, dsp.rand(400, 800), dsp.rand(8000, 10000))
    #burst = dsp.env(burst, 'phasor')
    #s = dsp.mix([snare, burst])
    s = snare
    s = dsp.transpose(s, dsp.rand(0.9, 1.1))

    s = dsp.fill(s, length, silence=True)

    return dsp.taper(s, 40)
Esempio n. 48
0
from pippi import dsp

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

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

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

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

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

out = dsp.mix([main, synth])
#out = synth
Esempio n. 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