Пример #1
0
def chirp():
    r = dsp.rand(3.6, 3.99)
    numpoints = dsp.randint(10, 30)

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

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

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

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

    return out
Пример #2
0
    def worker(gens, tick):
        while time.time() < started + (60 * 15):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

            if dsp.rand(0, 100) > 50:
                if dsp.rand(0, 100) > 80:
                    voice_id, generator_name = settings.add_voice("pp re qu")
                    dsp.log("")
                    dsp.log("starting pulsar voice %s" % voice_id)
                elif dsp.rand(0, 100) > 50:
                    voice_id, generator_name = settings.add_voice("ch re qu")
                    dsp.log("")
                    dsp.log("starting chirp voice %s" % voice_id)
                else:
                    voice_id, generator_name = settings.add_voice("bo re qu")
                    dsp.log("")
                    dsp.log("starting boone voice %s" % voice_id)

                playback_process = mp.Process(name=voice_id, target=rt.out, args=(gens[generator_name], tick))
                playback_process.start()

                dsp.delay(dsp.stf(dsp.rand(6, 35)))

                dsp.log("")
                dsp.log("stopping voice %s" % voice_id)
                settings.voice(voice_id, "loop", 0)
Пример #3
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)
Пример #4
0
def test_tone():
    out = dsp.tone(length=dsp.stf(1),
                   freq=220,
                   wavetype='sine2pi',
                   amp=1,
                   phase=0,
                   offset=0)
    assert dsp.flen(out) == dsp.stf(1)
Пример #5
0
def make_tracks(numtracks):
    tracks = range(numtracks)

    g.db.execute('delete from `blocks`;')

    # Testing out display of rendered blocks
    for i, track in enumerate(tracks):
        blocks = range(dsp.randint(1, 5))

        # for each sound:
        for j, snd in enumerate(blocks):
            # render it.
            snd = dsp.tone(dsp.stf(dsp.rand(0.5, 5)))

            # filename is track_id-block_id.wav for now
            filename = "%i-%i-%i" % (i, j, 0)

            # write it to disk
            dsp.write(snd, 'static/sounds/%s' % filename)

            # Calc length in pixels from frames
            length = dsp.flen(snd)
            pxlength = "%ipx" % (length / 441,)
            slength = "%02fs" % dsp.fts(length)
            offset = dsp.stf(dsp.rand(0, 60))


            # save in the db
            block = ( 
                        0,
                        0,
                        i,
                        length,
                        length,
                        offset,
                        filename,
                    )
            g.db.execute('insert into `blocks` (version, generator_id, track_id, length, range, offset, filename) values (?, ?, ?, ?, ?, ?, ?)', 
                    block)

            c = g.db.cursor()
            block_id = c.lastrowid()

            # block is a tuple:
            #   (block index, filename, length in pixels, offset in pixels)
            blocks[j] = (block_id, filename, slength, ftpx(length), ftpx(offset))

        tracks[i] = blocks

    g.db.commit()

    return tracks
Пример #6
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
Пример #7
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
Пример #8
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
Пример #9
0
def play(ctl):
    freqs = tune.fromdegrees([1,3,6,8,9], octave=4, root='a')
    freq = dsp.randchoose(freqs)
    length = dsp.stf(dsp.rand(3, 5))
    out = keys.rhodes(length, freq)

    return out
Пример #10
0
def play(ctl):
    dpc = ctl.get('midi').get('dpc')
    lpd = ctl.get('midi').get('lpd')

    print lpd.get(1)

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

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

    freq = dsp.randchoose(scale)

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

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

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

    return out
Пример #11
0
def play(ctl):
    #out = snds.load('genie/piano.wav')

    lenrange = 300
    minlen = 1

    if dsp.rand() > 0.5:
        lengths = dsp.breakpoint([dsp.rand(0, 1) for _ in range(5)], 50)
    else:
        lengths = dsp.wavetable('sine', 50)

    lengths = [dsp.mstf(l * lenrange + minlen) for l in lengths]

    out = ''

    for length in lengths:
        freq = tune.ntf('f', octave=dsp.randint(2, 5))

        if dsp.rand() > 10.85:
            length = dsp.stf(dsp.rand(0.5, 3))
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

        out += keys.pulsar(freq=freq, length=length, env='phasor')

        if dsp.rand() > 10.75:
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

    return out
Пример #12
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
Пример #13
0
def play(ctl):
    snd = dsp.read('/home/hecanjog/sounds/guitarpluck.wav').data

    #out = fx.rb(snd, interval=dsp.randint(0, 8) * 2, length=dsp.stf(0.25), formant=False)
    snd = dsp.transpose(snd, 0.968)
    out = dsp.stretch(snd, length=dsp.stf(dsp.rand(12, 15)), grain_size=120)
    out = dsp.env(out, 'hann')

    return out
Пример #14
0
def play(voice_id):
    tel = bot.getTel()

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

    octave = dsp.randint(1, 5)

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

    out = ''

    for freq in freqs:
        length = dsp.randint(dsp.stf(4), dsp.stf(12))

        pulsewidth = dsp.rand(0.5, 1)

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

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

        volume = dsp.rand(0.6, 1)

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

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

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

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

        out += t


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

    return out
Пример #15
0
def play(params):
    length = params.get('length', dsp.stf(2))
    reps   = params.get('repeats', 4)

    out = ''
    stream = []
    for rep in range(reps):
        stream += [ ('/tick/6', 1, dsp.fts(length / 2)) ]
        stream += [ ('/tick/6', 0, dsp.fts(length / 2)) ]
        out += dsp.pad(dsp.amp(dsp.tone(length / 2), 0.1), 0, length/ 2)
    
    return (out, {'value': {'events': [ stream ]}})
Пример #16
0
def play(ctl):
    grains = dsp.randint(1, 100)

    o = ""
    for g in range(grains):
        length = dsp.stf(dsp.rand(0.001, 0.1))
        numpoints = dsp.randint(10, 30)
        points = [0] + [dsp.rand(-1, 1) for _ in range(numpoints)] + [0]

        out = dsp.bln(length, 330, 330, "tri")
        # out = dsp.am(out, dsp.tone(length, dsp.rand(10, 100)))
        out = dsp.env(out, "random")
        out = dsp.pan(out, dsp.rand())
        out = dsp.amp(out, dsp.rand(0.1, 0.9))

        o += out

    out = dsp.env(o, "random")
    out = dsp.pad(out, 0, dsp.stf(dsp.rand(0.1, 1)))

    return out
Пример #17
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
Пример #18
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
Пример #19
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
Пример #20
0
def arpeggiate(freq, phraseLen=8, even=True):
    """
    input: 
         freq: a number in hertz (just for fun) in the future, I will have a hertz to actual notes mapping table
         phraseLen: how long the length needs to be
         even: if the Phrases should evenly be subdivided
    output: 
          an array of notes
    """
    arr=[]
    if phraseLen < 2:
        print "this makes negative sense, please stop"
        return 
    if even == True:
        #say we have 8, that means our 'even' cases would be 4, 2
        # for 9 our case would be 3
        # for 10 it would be 5, 2
        # and so on.., essentially I need all factors of a number, then choose a random one, 
        #if it were in R, I would weigh higher probability on the lower number
        newPhraseLen=random.sample(factor(phraseLen),1)[0]
        print newPhraseLen
        #say we chose 8 and we have 4, then I want 4 phrases of 2
        for subdivided in range(newPhraseLen):
            for note in range(phraseLen/newPhraseLen):
                arr.append(dsp.tone(dsp.stf(255),freq* (note+1),'sine2pi', 0.2))
            
            
    else:
        #I would have to make random tree, by this I mean
        #for 8 It could not be 4,4
        #it could be 5,3 or 3,3,2 or 3,2,3 or 2,3,3 or 2,2,3,1 or..
        #calculate like 4 or 5 of them, then return one
        rs=randSubdivide(phraseLen)
        for number in rs:
            for subdivided in range(newPhraseLen):
                for note in range(phraseLen/newPhraseLen):
                    arr.append(dsp.tone(dsp.stf(5),freq,'sine2pi', 0.2))
    return arr
Пример #21
0
    def worker(gens, tick):
        while time.time() < started + (60 * 9):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

            if dsp.rand(0, 100) > 60:
                if dsp.rand(0, 100) > 60:
                    voice_id, generator_name = settings.add_voice('sh re qu')
                    dsp.log('')
                    dsp.log('starting shimmer voice %s' % voice_id)
                else:
                    voice_id, generator_name = settings.add_voice('dr re qu')
                    dsp.log('')
                    dsp.log('starting drone voice %s' % voice_id)


                playback_process = mp.Process(name=voice_id, target=rt.out, args=(gens[generator_name], tick))
                playback_process.start()

                dsp.delay(dsp.stf(dsp.rand(6, 35)))

                dsp.log('')
                dsp.log('stopping voice %s' % voice_id)
                settings.voice(voice_id, 'loop', 0)
Пример #22
0
def make_cycles(length):
    """ Well begun, half done """
    num_harmonics = dsp.randint(1, 6)
    val_harmonics = [1, 2, 3, dsp.randint(4, 7), dsp.randint(5, 9)]

    # Each collection of partials
    min_length = dsp.stf(10)
    max_length = dsp.stf(18)

    root = 40.0 # hz

    # Deviate
    root = root + dsp.rand()

    elapsed = 0
    cycles = []

    # Count off
    while elapsed < length:
        cycle_length = dsp.randint(min_length, max_length)

        harmonics = [ 
                dsp.tone(
                length=cycle_length, 
                freq=root * dsp.randchoose(val_harmonics), 
                amp=dsp.rand(0.1, 0.4),
                wavetype='impulse'
                ) 
            for h in range(num_harmonics) ]

        harmonics = [ dsp.pan(harmonic, dsp.rand()) for harmonic in harmonics ]
        harmonics = [ dsp.env(harmonic, 'gauss') for harmonic in harmonics ]

        cycles += [ dsp.mix(harmonics) ]
        elapsed += cycle_length

    return ''.join(cycles)
Пример #23
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
Пример #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
Пример #25
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
Пример #26
0
    def stream(length, numsegments, freq):

        out = []
        seglength = dsp.randint(100, 300)
        points = [ dsp.rand(-1, 1) for _ in range(dsp.randint(10, 20)) ]

        for _ in range(numsegments):
            seglength = dsp.cap(seglength + dsp.randint(-5, 5), 1000, 100)
            points = [ dsp.cap(p + dsp.randint(-0.1, 0.1), 1, -1) for p in points ]

            out += dsp.breakpoint([0] + points + [0], seglength)

        print len(out), freq, length

        out = dsp.ctone(freq, dsp.stf(length), out, dsp.rand(0.1, 0.5))
        #out = dsp.env(out, 'random')

        return out
Пример #27
0
def play(ctl):
    lpd = ctl.get('midi').get('lpd')

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

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

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

        return dsp.mix(layers)

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

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

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

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

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

    freq = dsp.randchoose(freqs) / 4.0

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

    out = rain(o, freqs)

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

    return out
Пример #28
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
Пример #29
0
def play(params):
    length      = params.get('length', dsp.stf(dsp.rand(0.1, 1)))
    volume      = params.get('volume', 100.0) / 100.0
    speed       = params.get('speed', dsp.rand(0.3, 0.5))
    octave      = params.get('octave', 2)
    note        = params.get('note', ['c'])[0]
    env         = params.get('envelope', False)
    pad         = params.get('padding', False)
    bend        = params.get('bend', False)
    wform       = params.get('waveform', False)
    instrument  = params.get('instrument', 'r')
    scale       = params.get('scale', [1,6,5,4,8])
    shuffle     = params.get('shuffle', False) # Reorganize input scale
    reps        = params.get('repeats', len(scale))
    alias       = params.get('alias', False)
    lyrics      = params.get('ww', '1-2-3-4-5-6-7-8-9-10').split('-')

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

    if shuffle:
        lyrics = dsp.randshuffle(lyrics)

    lyrics = ' '.join(lyrics)

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

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

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

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

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

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

    return out
Пример #30
0
def play(params):
    length = params.get("length", dsp.stf(3))

    def bln(length, low=3000.0, high=7100.0, wform="sine2pi"):
        wforms = ["tri", "sine2pi", "impulse", "cos2pi"]
        outlen = 0
        cycles = ""
        while outlen < length:
            cycle = dsp.cycle(dsp.rand(low, high), dsp.randchoose(wforms))
            outlen += len(cycle)
            cycles += cycle

        return cycles

    envs = ["phasor", "line", "sine"]

    hats = [bln(dsp.mstf(dsp.rand(100, 1000)), dsp.rand(200, 5000), dsp.rand(3000, 11000)) for i in range(32)]
    hats = [dsp.env(hat, dsp.randchoose(envs)) for hat in hats]
    hats = [dsp.pad(hat, 0, dsp.mstf(170)) for hat in hats]
    hats = "".join(hats)

    return hats
Пример #31
0
def play(ctl):
    pianos = ['sawvib', 'piano', 'pianooct1', 'harp', 'saw']
    pianos = ['sawvib', 'piano']
    piano = snds.load('genie/%s.wav' % dsp.randchoose(pianos))
    notes = [1,3,5]
    chord = tune.fromdegrees([ dsp.randchoose(notes) + (dsp.randchoose([0, 1]) * 8) for _ in range(dsp.randint(1, 3)) ], octave=0)
    length = dsp.stf(dsp.rand(1, 4))

    layers = []

    for freq in chord:
        p = dsp.transpose(piano, freq / 220.0)
        p = dsp.amp(p, 0.35)
        #p = dsp.pan(p, dsp.rand())
        p = dsp.fill(p, length)

        if dsp.rand() > 0.25:
            p = dsp.vsplit(p, dsp.mstf(100), dsp.mstf(500))
            p = [ dsp.pan(pp, dsp.rand()) for pp in p ]
            p = [ dsp.amp(pp, dsp.rand(0,2)) for pp in p ]
            p = [ dsp.transpose(pp, dsp.randchoose([1,2,4,8])) for pp in p ]
            p = [ dsp.taper(pp, 20) for pp in p ]
            p = [ dsp.pad(pp, 0, dsp.mstf(dsp.rand(0, 100))) for pp in p ]
            p = dsp.randshuffle(p)
            p = ''.join(p)

        if dsp.rand() > 0.75:
            p = dsp.alias(p)

        #p = dsp.env(p, 'phasor')

        layers += [ p ]

    out = dsp.mix(layers)

    return out
Пример #32
0
def play(ctl):
    midi = ctl.get('midi')
    midi.setOffset(111)
    pw = midi.get(1, low=0.01, high=1)

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

    freq = dsp.randchoose(scale)

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

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

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

    return out
Пример #33
0
def main():
    #since how this Library works it's a bit uncertain how to change channels in real time, for now just write a cut off, since an intterrupt won't work with the channels
    #out = [dsp.tone(dsp.stf(5),55*i , 'sine2pi',0.2) for i in range(1,5)]
    #dsp.write(out, 'helloagain')
    out=[]
    notes=0
    #start = time.time()
    #while time.time()-start < 100000:
    while notes<25:
    
        serialInput= ser.readline().split()
        #    print serialInput
        #    serialInput = serialInput.split()
        if len(serialInput) == 4:
            instrument=int(float(serialInput[0]))+1 # pin number
            amplitude=(int(float(serialInput[1]))%10)/10.0 #humidity
            freq=float(serialInput[2])*(instrument+1)*10 #temperature
            tempo=float(serialInput[3]) #tempo
        
        else:
            instrument=1 # pin number
            amplitude=0.2 #humidity
            freq=440 #temperature
            tempo=14 #tempo
            #print serialInput

            #print freq
        out.append(dsp.tone(dsp.stf(instrument),freq,'sine2pi', amplitude))
            #    print notes
        notes+=1

            #print out
            #out = [dsp.env(o , sine'])) for o in out]
    out = [dsp.env(o , dsp.randchoose(['hann', 'tri', 'sine'])) for o in out]
    out = dsp.mix(out)
    dsp.write(out, 'sample')    
Пример #34
0
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

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

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

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

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

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

    layers = []

    harmonics = [1, 2, 3, 4]

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

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

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

        layers += [ layer ]

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

    return out
Пример #35
0
        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

    while elapsed < length:
        # pick a fragment
        g = dsp.randchoose(guitars)

        # transpose to A
        g = dsp.transpose(g, 1.125)

        # rand octave or 5th transpose
        g = dsp.transpose(g, dsp.randchoose([1, 1.5, 2]))
Пример #36
0
from pippi import dsp

freqs = [55, 220, 440, 770]
length = dsp.stf(90)

layers = []

for freq in freqs:
    amp = dsp.rand(0.05, 0.1)

    wf1 = dsp.breakpoint([ dsp.rand(-1, 1) for p in range(7) ], 512)
    wf2 = dsp.breakpoint([ dsp.rand(-1, 1) for p in range(4) ], 512)

    layer = dsp.subtract(dsp.ctone(freq * 0.999, length, wf1, amp), dsp.ctone(freq, length, wf2, amp))
    layer = dsp.pan(layer, dsp.rand())
    layer = dsp.env(layer, 'random')

    layers += [ layer ]

out = dsp.mix(layers)

dsp.write(out, 'retabler2')
Пример #37
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
Пример #38
0
from pippi import dsp
from pippi import tune
import glob
import drums
import rhodes

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

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

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

out = ''

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

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

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

vary_sections = [dsp.randint(7, 12) for vs in range(2)]
Пример #39
0
from pippi import dsp
from hcj import fx
from datetime import datetime
import subprocess
import tweepy
import os

slen = dsp.rand(5, dsp.rand(15, 100))

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

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

    bits = []
Пример #40
0
rimshot = dsp.read('samples/jess/rimshot.wav').data


def makeKick(length, i):
    k = kickcym if i == 0 else kick
    return dsp.fill(dsp.amp(k, dsp.rand(1, 5)), length, silence=True)


def makeRimshot(length, i):
    return dsp.fill(dsp.amp(rimshot, dsp.rand(4, 5)), length, silence=True)


nchords = 12
npulses = 200
nlayers = 3
sectionlength = dsp.stf(dsp.rand(10, 12))

for _ in range(nchords):
    layers = []

    for _ in range(nlayers):
        layer = ''
        highs = dsp.breakpoint(
            [dsp.rand(60, 15000) for _ in range(npulses / 50)], npulses)
        lows = [dsp.rand(20, freq) for freq in highs]
        amps = dsp.breakpoint(
            [dsp.rand(0.1, 0.3) for _ in range(npulses / 50)], npulses)
        pans = dsp.breakpoint([dsp.rand(0, 1) for _ in range(npulses / 10)],
                              npulses)
        lengths = [
            dsp.mstf(l) for l in dsp.breakpoint(
Пример #41
0
ssnd = dsp.read('samples/jess/snare.wav').data
lssnd = dsp.read('samples/jess/rimshot.wav').data
hsnd = dsp.read('samples/jess/tamb_rattle.wav').data
ohsnd = dsp.read('samples/jess/skitter.wav').data
ksnd = dsp.read('samples/jess/kickshuffle.wav').data
bksnd = dsp.read('samples/jess/kickcym.wav').data
bksnd = dsp.mix([ bksnd, dsp.read('samples/jess/smash.wav').data ])

beat = dsp.bpm2frames(166)
key = 'b'

out = ''
elapsed = 0
count = 0

tlength = dsp.stf(120)

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)
Пример #42
0
#!/usr/bin/env python
"""
pip install pippi
"""
import sys
from pippi import dsp
out = dsp.tone(dsp.stf(5), freq=220, amp=0.2)
out = dsp.env(out, 'hann')
#dsp.write(out, 'hello')
#'hello.wav'
dsp.write(sys.stdout)
Пример #43
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', 'h.c')

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

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

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

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

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

    if bbend == True:
        bend = True

    tune.a0 = float(root)

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

    if hertz is not False:
        notes = hertz

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

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

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

            if bend is not False:

                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose([
                            'impulse', 'sine', 'line', 'phasor', 'cos',
                            'impulse'
                        ])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        #                        lowbend = 0.75
                        highbend = 1.01
#                        highbend = 1.5

                    out = dsp.split(out, 441)

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

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

                    out = [
                        dsp.transpose(out[i], freqs[i])
                        for i in range(len(out))
                    ]
                    return ''.join(out)

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

            tones += [dsp.mix(snds)]

        layer = dsp.mix(tones)

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

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

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

        layer = dsp.env(layer, env)

        layers += [layer]

    out = dsp.mix(layers) * reps

    return dsp.amp(out, volume)
Пример #44
0
boids = [[dsp.rand(0, 1) for _ in range(numpoints + 1)]
         for b in range(numboids)]

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

    center = center / float(numboids)

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

out = []

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

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

out = dsp.mix(out)

dsp.write(out, 'boids')
Пример #45
0
from pippi import dsp
from pippi import tune

chord = tune.chord('I', octave=2, key='a', ratios=tune.terry)

numsegs = 2222
length = dsp.stf(60) / numsegs
numpoints = 7

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

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

out = []

for wf, mod, modf, modr, pw in zip(wfs, mods, modfs, modrs, pws):
    layers = []
    for freq in chord:
        layer = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, 0.1)
        layers += [layer]
Пример #46
0
from pippi import dsp
from pippi import tune
from hcj import keys

chords = tune.chords(['i', 'vi9', 'iii7', 'v'],
                     'a',
                     octave=3,
                     ratios=tune.terry)

out = ''

for chord in chords * 4:
    layers = []
    length = dsp.stf(dsp.rand(3, 4))
    for freq in chord:
        layer = keys.rhodes(length, freq, dsp.rand(0.1, 0.2))
        layer = dsp.pan(layer, dsp.rand())
        layer = dsp.drift(layer, dsp.rand(0, 0.01))

        layers += [layer]

    chord = dsp.mix(layers)
    chord = dsp.drift(chord, dsp.rand(0, 0.01))

    out += chord

dsp.write(out, 'chordsweep')
Пример #47
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')
Пример #48
0
from matplotlib import pyplot as pp
from pippi import dsp
from hcj import data

length = dsp.stf(3)

curves = tuple(
    [data.Logistic(dsp.rand(3.8, 4), 0.1, length).data for _ in range(3)])
y = [(a * b * c) / 3.0 for a, b, c in zip(*curves)]

freq = (1.0 / 3) / 200.0
amp = 0.5

out = dsp.ctone(freq, length, y, amp)
dsp.write(out, 'plot')

#x = range(len(y))
#pp.plot(x, y)
#pp.grid(True)
#pp.show()
Пример #49
0
from pippi import dsp
from hcj import data

numevents = 100
numlayers = 3

layers = []

for _ in range(numlayers):
    layer = ''

    for _ in range(numevents):
        slength = dsp.rand(0.1, 4)
        length = dsp.stf(slength)
        freq = (1.0 / slength) * dsp.rand(0.5, 10)
        amp = dsp.rand(0.1, 0.5)

        log = dsp.breakpoint(
            data.Logistic(dsp.rand(3.88, 3.99), 0.5, length / 10).data, length)
        mult = dsp.breakpoint(
            [0] + [dsp.rand(-1, 1) for _ in range(dsp.randint(50, 100))] + [0],
            length)

        wf = [m * l for m, l in zip(mult, log)]

        o = dsp.ctone(freq, length, wf, amp)
        o = dsp.env(o, 'random')
        o = dsp.pan(o, dsp.rand())
        o = dsp.taper(o, dsp.mstf(20))

        layer += o
Пример #50
0
from pippi import dsp, tune
from hcj import keys, fx, drums

kick = dsp.read('../../sounds/organkick.wav').data
hat = dsp.read('../../sounds/mc303shake.wav').data
snare = dsp.read('../../sounds/organsnare.wav').data

bpm = 100
target_length = dsp.stf(60 * 2)
beat = dsp.bpm2frames(bpm)

out = ''

chord = [dsp.randint(1, 15) for _ in range(4)]


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

        last[last.index(deg)] = newdeg

    return last


kickp = 'x   '
Пример #51
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))


out = ''

sparks = dsp.mix(
    [''.join([fracture(cathedral.data) for i in range(20)]) for i in range(3)])

smears = dsp.mix([smear(cathedral.data) for i in range(10)])

tlen = dsp.stf(20)

dings = ''
for seg in range(20):
    nlen = dsp.mstf(dsp.randint(4130, 6300))
    dings += dsp.mix([ding(tone, tlen, nlen) for i in range(2)])

#out = dsp.mix([dsp.amp(dings, 0.8), smears, sparks])
out = sparks

dsp.write(out, 'sparks', False)

dsp.timer('stop')
Пример #52
0
from pippi import dsp
from pippi import tune

length = dsp.stf(45)

freqs = [ dsp.rand(20, 200) for f in range(10) ]

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

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

    return layer

layers = [ makeLayer(freq) for freq in freqs ]

out = dsp.mix(layers)

dsp.write(out, 'fuzzlo')
Пример #53
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)
Пример #54
0
out = ''
t = dsp.split(thirty, dsp.mstf(40))
t = [ dsp.env(tt, 'sine') for tt in t ]
t = [ tt * 4 for tt in t ]

out = ''.join(t)

dsp.write(out, 'wesley_thirty_02')

## 03
out = ''

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

out = dsp.mix(layers)

dsp.write(out, 'wesley_thirty_03')

## 04
out = ''

for count in range(5):
    t = dsp.randchoose(snds)
    t = dsp.vsplit(t, 1, dsp.mstf(20))
    for i, g in enumerate(t):
        if dsp.randint(0,5) == 0:
Пример #55
0
        subseg = ctl.splitSeg(seg, 2)
        orc.rhodes.long_chord = long_chord
        glitches = ctl.makeBeat([1, 1], subseg, orc.rhodes.makeGlitch)

        layers += [glitches]

    if dsp.rand() < wesprob[segi]:
        voices = orc.wes.make(sum(seg))
        layers += [voices]

    if len(layers) > 0:
        section = dsp.mix(layers)

        out += section

out += dsp.env(
    dsp.mix([orc.guitar.makeLong([dsp.stf(dsp.rand(4, 8))])
             for _ in range(2)]), 'phasor')
out += dsp.env(
    dsp.mix(
        [orc.guitar.makeLong([dsp.stf(dsp.rand(4, 10))]) for _ in range(2)]),
    'phasor')
out += dsp.env(
    dsp.mix(
        [orc.guitar.makeLong([dsp.stf(dsp.rand(6, 12))]) for _ in range(3)]),
    'phasor')

dsp.write(out, '02-friction_ii')

print dsp.timer('stop')