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

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

            arps = ''

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

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

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

                arps += arp_one + arp_two
                arp_count += 2

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

            return arps
예제 #2
0
def make_vary(length, freq):

    if dsp.rand(0, 100) > 50:
        return make_pulse(dsp.tone(length, freq, amp=dsp.rand()))

    minlen = dsp.mstf(1)

    pulsewidth = int(dsp.rand(minlen, length / 2))
    
    snd = dsp.tone(pulsewidth, freq, amp=dsp.rand(0, 0.2))
    snd = dsp.env(snd, dsp.randchoose(['sine', 'tri', 'hann']))

    snd = dsp.pad(snd, 0, length - pulsewidth)

    return snd
예제 #3
0
def play(voice_id):
    """ Every generator script must define a play() function, which 
        accepts a voice_id integer (so you can read and write params 
        for each voice) and returns a sound.
        
        The shortname and name metadata above are optional, if you 
        don't include them the name will be drawn from the filename 
        and the shortname will be the first two characters of that name.
    """

    # Get the current bpm set in our session
    bpm = C('bpm')

    # Convert it to a length in frames
    beat = dsp.bpm2frames(bpm)

    # Read per-instance param, with a default value
    volume = P(voice_id, 'volume', default=1.0)

    # Get a frequency for the beep
    freq = tune.ntf('a', octave=2)

    # Beep for a beat
    out = dsp.tone(length=beat, freq=freq, wavetype='sine2pi', amp=volume)

    # Be silent for a beat after the beep
    out = dsp.pad(out, 0, beat)

    # Log the length of the computed buffer. 
    # I like to tail -f pippi.log during performance.
    dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))

    # Pass along the final buffer for playback
    return out
예제 #4
0
파일: keys.py 프로젝트: hecanjog/hcj.py
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
예제 #5
0
파일: orc.py 프로젝트: 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
예제 #6
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
예제 #7
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
예제 #8
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)
예제 #9
0
파일: test_synths.py 프로젝트: shnend/pippi
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)
예제 #10
0
                def bass(amp, length, oct=2):
                    if amp == 0:
                        return dsp.pad('', 0, length)

                    #bass_note = ['d', 'g', 'a', 'b'][ bassPlay % 4 ]
                    bass_note = ['e', 'a', 'b', 'c#'][ bassPlay % 4 ]

                    out = dsp.tone(length, wavetype='square', freq=tune.ntf(bass_note, oct), amp=amp*0.2)
                    out = dsp.env(out, 'random')

                    return out
예제 #11
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 ]}})
예제 #12
0
def make_vary(index, length, freq):
    def i(index, offset):
        return ((index + offset) % nump) / float(nump) 

    pulsewidth = int(pnoise1(i(index, 100), 2) * (length / 2))
    
    snd = dsp.tone(pulsewidth, freq, amp=pnoise1(i(index, 99), 3) * 0.5)
    snd = dsp.env(snd, 'sine')

    snd = dsp.pad(snd, 0, length - pulsewidth)

    return snd
예제 #13
0
파일: index.py 프로젝트: hecanjog/pippi.daw
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
예제 #14
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
예제 #15
0
파일: __init__.py 프로젝트: hecanjog/hcj.py
    def makeTails(self, freq, length):
        freq *= 0.5
        harmonics = [ dsp.randint(1, 8) for _ in range(2, 4) ]
        layers = []
        for harmonic in harmonics:
            layer = dsp.tone(length, freq * harmonic, amp=dsp.rand(0.1, 0.3))
            layer = fx.penv(layer)
            layer = dsp.env(layer, 'sine')
            layers += [ layer ]

        layers = dsp.mix(layers)
        layers = dsp.amp(layers, dsp.rand(0.25, 1))

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

    freqs = tune.fromdegrees([ dsp.randchoose([1, 2, 3, 5, 6, 8]) for f in range(dsp.randint(2, 5)) ], root='c', octave=dsp.randint(1, 3), ratios=tune.just)

    out = ''

    for freq in freqs:
        waveform = dsp.randchoose(['tri', 'sine2pi'])
        length = dsp.randint(dsp.mstf(10), dsp.mstf(300))
        #length = dsp.mstf(150)
        pulsewidth = dsp.rand()

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

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

        volume = dsp.rand(0.2, 0.3)

        if dsp.rand(0, 100) > 50:
            t = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
        else:
            t = dsp.tone(length, freq, waveform)

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

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

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

        t = dsp.pad(t, 0, dsp.randint(dsp.mstf(1), dsp.mstf(500)))
        #t = dsp.pad(t, 0, dsp.mstf(100))
        t = dsp.amp(t, dsp.rand(0.5, 0.75))

        #out += dsp.env(t, 'sine')
        out += t

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

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

    return out
예제 #17
0
                def bass(amp, length, oct=2):
                    if amp == 0:
                        return dsp.pad('', 0, length)

                    #bass_note = ['d', 'g', 'a', 'b'][ bassPlay % 4 ]
                    bass_note = ['e', 'a', 'b', 'c#'][bassPlay % 4]

                    out = dsp.tone(length,
                                   wavetype='square',
                                   freq=tune.ntf(bass_note, oct),
                                   amp=amp * 0.2)
                    out = dsp.env(out, 'random')

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

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

            arps = ''

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

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

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

                arps += arp_one + arp_two
                arp_count += 2

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

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

    freqs = [25, 55, 109, 222, 440, 550, 660, 770, 880]
    freqs = [55, 110, 440, 220, 880]
    length = dsp.mstf(dsp.rand(100, 2000))
    length = dsp.mstf(3000)

    layers = []
    for freq in freqs:
        freq = freq * 4 + dsp.rand(0.1, 1.5)

        if freq < 100:
            amp = 0.3
        else:
            amp = 0.01

        layer = dsp.mix([ dsp.tone(length, freq, amp=amp), dsp.tone(length, freq + dsp.rand(1, 10), amp=amp) ])
        layers += [ layer ]

    out = dsp.mix(layers)

    return out
예제 #20
0
def make_layer(freq):
    out = dsp.tone(length, freq, amp=0.2)

    out = dsp.vsplit(out, dsp.mstf(10), dsp.mstf(2500))

    for i, o in enumerate(out):
        if dsp.randint(0, 100) > 50:
            out[i] = make_pulse(o)
        else:
            out[i] = make_vary(o)

    out = [ dsp.amp(o, dsp.rand(0, 1)) for o in out ]

    out = ''.join(out)

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

    freqs = [
        (10000, 15000),
        (5000, 15000),
        (5000, 10000),
    ]

    low = dsp.rand(50, 100) 
    high = dsp.rand(80, 120)

    low = 80
    high = 120

    wform = 'sine2pi'

    amp = lpd.get(5, low=0, high=1, default=0)

    low = dsp.rand(low * 0.9, low)
    high = dsp.rand(high, high * 1.1)

    length = dsp.mstf(lpd.get(1, low=10, high=900)) 

    if dsp.rand() > 10.5:
        length = length / 2

    pulselength = lpd.geti(2, low=dsp.mstf(10), high=length, default=length)

    out = dsp.bln(pulselength, low, high, wform)
    out = dsp.env(out, 'phasor')

    if dsp.rand() > 10.1:
        beep = dsp.tone(dsp.flen(out), dsp.rand(12000, 12000), amp=dsp.rand(0.5, 1))
        out = dsp.mix([out, beep])

    out = dsp.drift(out, dsp.rand(0, 1))
    out = dsp.pad(out, 0, length - dsp.flen(out))

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

    return out
예제 #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 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')    
예제 #24
0
파일: wash.py 프로젝트: hecanjog/geodes.py
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
예제 #25
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)
예제 #26
0
def play(params):

    length    = params.get('length', dsp.stf(20))
    volume    = params.get('volume', 0.3)
    octave    = params.get('octave', 6)
    note      = params.get('note', 'c')
    quality   = params.get('quality', tune.major)
    multiple  = params.get('multiple', 1)
    width     = params.get('width', 0)
    waveform  = params.get('waveform', 'vary')
    chirp     = params.get('chirp', False)
    harmonics = params.get('harmonics', [1, 2])
    scale     = params.get('scale', [1, 4, 6, 5, 8])
    wavetypes = params.get('wavetypes', ['sine', 'phasor', 'line', 'saw'])
    ratios    = params.get('ratios', tune.terry)
    glitch    = params.get('glitch', False)

    def chirp(s):
        length = dsp.flen(s)

        #chirps = [ dsp.chirp(dsp.randint(10, 10000), 60, 5000, dsp.randint(1,100)) for c in range(100) ]
        chirps = [ dsp.chirp(
                        numcycles=dsp.randint(50, 1000), 
                        lfreq=dsp.rand(9000, 12000), 
                        hfreq=dsp.rand(14000, 20000), 
                        length=441 + (i * 41),
                        etype=dsp.randchoose(['gauss', 'sine', 'line', 'phasor']),
                        wform=dsp.randchoose(['sine', 'tri', 'phasor', 'line'])) 
                    for i in range(100) ]
        chirps = [ dsp.pan(c, dsp.rand()) for c in chirps ]

        chirps = ''.join(chirps)

        return dsp.fill(chirps, length)

    tones = []
    multiple *= 1.0
    freqs = tune.fromdegrees(dsp.randshuffle(scale), octave, note[0])
    for i in range(dsp.randint(2,4)):
        #freq = tune.step(i, note, octave, dsp.randshuffle(scale), quality, ratios)
        freq = freqs[i % len(freqs)]

        snds = [ dsp.tone(length, freq * h, waveform) for h in harmonics ]
        for snd in snds:
            snd = dsp.vsplit(snd, dsp.mstf(10 * multiple), dsp.mstf(100 * multiple))
            if width != 0:
                for ii, s in enumerate(snd):
                    if width > dsp.mstf(5):
                        owidth = int(width * dsp.rand(0.5, 2.0))
                    else:
                        owidth = width

                    olen = dsp.flen(s)
                    s = dsp.cut(s, 0, owidth)
                    s = dsp.pad(s, 0, olen - dsp.flen(s)) 
                    snd[ii] = s

            snd = [ dsp.env(s, dsp.randchoose(wavetypes)) for s in snd ]
            snd = [ dsp.pan(s, dsp.rand()) for s in snd ]
            snd = [ dsp.amp(s, dsp.rand()) for s in snd ]
                
            if chirp == True:
                snd = [ chirp(s) for s in snd ]

            snd = ''.join(snd)

            tones += [ snd ]

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

    return dsp.amp(out, volume)
예제 #27
0
                    return out

                if bassPlay % 5 == 0:
                    basses = bass(0.5, tlen, 1)
                else:
                    basses = drums.make(bass, dsp.rotate(single, vary=True), seg)

                bassPlay += 1
                layers += [ basses ]

            if dsp.randint(0,1) == 0 or canPlay('jam', bigoldsection):
                # Lead synth
                #lead_note = ['d', 'g', 'a', 'b'][ leadPlay % 4 ]
                lead_note = ['e', 'a', 'b', 'c#'][ leadPlay % 4 ]

                lead = dsp.tone(tlen / 2, wavetype='tri', freq=tune.ntf(lead_note, 4), amp=0.2)
                lead = dsp.env(lead, 'phasor')

                leadPlay += 1
                layers += [ lead ]

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

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

            arps = ''
예제 #28
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
예제 #29
0
def play(args):
    length = dsp.stf(30)
    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, 30)
    layers = []
    for note in notes:
        tones = []
        freq = tune.ntf(note, octave, ratios) 

        for i in range(30):
            angles = dsp.breakpoint([freq * dsp.randchoose(harm) for f in range(dsp.randint(3, 50))], dsp.randint(350, 500))
            alen = int(length / len(angles)) * 2

            angles = [ dsp.env(dsp.tone(alen, a, 'random'), 'sine') for a in angles ]

            # Each overtone blip should overlap by about 50% with its neighbor...
            lowangles = ''.join([ angle for i, angle in enumerate(angles) if i % 2 == 0 ])

            highangles = [ angle for i, angle in enumerate(angles) if i % 2 != 0 ]
            highangles[0] = dsp.cut(highangles[0], dsp.flen(highangles[0]) / 2, dsp.flen(highangles[0]) / 2)
            highangles = ''.join(highangles)

            tones += [ dsp.benv(dsp.amp(dsp.mix([lowangles, highangles]), 0.9), [dsp.rand(0.1, 0.9) for i in range(dsp.randint(5, 30))]) ]

        tones = dsp.mix(tones)
        #tonic = dsp.env(dsp.amp(dsp.tone(int(length * 0.6), freq, 'sine2pi'), 0.1), 'flat')

        #layers += [ dsp.mix([tones, tonic], False) ]
        layers += [ tones ]

    out = dsp.mix(layers)

    return dsp.amp(out, volume)
예제 #30
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)
예제 #31
0
    return blip

def make_vary(index, length, freq):
    def i(index, offset):
        return ((index + offset) % nump) / float(nump) 

    pulsewidth = int(pnoise1(i(index, 100), 2) * (length / 2))
    
    snd = dsp.tone(pulsewidth, freq, amp=pnoise1(i(index, 99), 3) * 0.5)
    snd = dsp.env(snd, 'sine')

    snd = dsp.pad(snd, 0, length - pulsewidth)

    return snd

p = 'XxxXxxxXxXxxXxxxxXx'

beats = seq.toFrames(p, beat) * 100

layers = []

for l in range(2):
    beats = dsp.rotate(beats, dsp.randint(50, 100))
    layers += [ ''.join([ make_pulse(dsp.tone(length, freqs[i % len(freqs)], amp=dsp.rand(0.1, 0.5))) for i, length in enumerate(beats) ]) ]

out = dsp.mix(layers)

dsp.write(out, 'buchla-perlin')

예제 #32
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)
예제 #33
0
from pippi import dsp
from hcj import data

numgrains = 1000
numsines = 100
length = dsp.mstf(100)

dist = data.Logistic(3.99, 0.5, numsines).data
dist = sorted(dist)

lows = dsp.breakpoint([ dsp.rand(10, 100) for _ in range(100) ], numgrains)
highs = dsp.breakpoint([ dsp.rand(100, 1000) for _ in range(100) ], numgrains)

out = ''
for lowfreq, highfreq in zip(lows, highs):
    layers = []

    for freq in dist:
        r = highfreq - lowfreq
        layers += [ dsp.pan(dsp.tone(length, freq * r + lowfreq, amp=0.05), dsp.rand()) ]

    out += dsp.taper(dsp.env(dsp.mix(layers), 'hann'), dsp.mstf(10))

dsp.write(out, 'shifty')
예제 #34
0
from pippi import dsp

dist = dsp.wavetable('hann', 1200)[:600]

lowfreq = 200
highfreq = 1000
length = dsp.stf(60)

layers = []

for freq in dist:
    r = highfreq - lowfreq
    layers += [dsp.tone(length, freq * r + lowfreq, amp=0.01)]

out = dsp.mix(layers)

dsp.write(out, 'basics')
예제 #35
0
def makeGrain(freq, length):
    grain = dsp.tone(length, freq, amp=dsp.rand(0.05, 0.1))
    grain = dsp.pan(grain, dsp.rand())
    return grain
예제 #36
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)
예제 #37
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)
예제 #38
0
layers = []

for layer in range(10):
    beats_steady = [beat for b in range(numbeats / 10)]
    beats_div = dsp.breakpoint([dsp.rand(1, 200) for b in range(10)],
                               numbeats - len(beats_steady))
    ramp = dsp.wavetable('line', len(beats_div))

    beats_div = [beat + dsp.mstf(d * r) for d, r in zip(beats_div, ramp)]

    beats = beats_steady + beats_div
    freqs = dsp.wavetable(dsp.randchoose(['line', 'phasor', 'tri', 'hann']),
                          len(beats))
    freqs = [freq + (100 * f) for f in freqs]

    layer = ''

    for b, f in zip(beats, freqs):
        blip = dsp.tone(length=b, freq=f, amp=dsp.rand(0.01, 0.2))
        blip = dsp.env(blip, 'phasor')
        blip = dsp.taper(blip, dsp.mstf(5))
        blip = dsp.pan(blip, dsp.rand())

        layer += blip

    layers += [layer]

out = dsp.mix(layers)

dsp.write(out, 'blipspray')
예제 #39
0
from pippi import dsp

length = dsp.stf(30)

freq = 100
highfreq = 200

count = 0
layers = []
while freq < highfreq:
    layer = dsp.tone(length, freq, amp=0.001)
    layer = dsp.pan(layer, dsp.rand())
    freq += dsp.rand(0.05, 0.1)

    layers += [layer]
    count += 1

print count
out = dsp.mix(layers)

dsp.write(out, 'sineclump')
예제 #40
0
파일: sine.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    out = dsp.tone(dsp.stf(6), freq=80, amp=1)
    out = dsp.env(out, 'phasor')

    return out
예제 #41
0
        frags += [g]

    # concat all frags
    layer = ''.join(frags)

    # add frags to layers
    layers += [layer]

# mix down frag layers
out = dsp.mix(layers)

# Add sine buildup

sines = []

lowfreq = tune.ntf('g', octave=2)

sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq, amp=0.4)]
sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.067, amp=0.4)]
sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.667, amp=0.25)]

sines = [dsp.mix([fx.penv(s), s]) for s in sines]

sines = dsp.mix(sines)
sines = dsp.env(sines, 'line')
sines = dsp.pad(sines, dsp.flen(out) - dsp.flen(sines), 0)

out = dsp.mix([intro, out, sines])

dsp.write(out, '01-friction_i')
예제 #42
0
        frags += [ g ]

    # concat all frags
    layer = ''.join(frags)

    # add frags to layers
    layers += [ layer ]

# mix down frag layers
out = dsp.mix(layers)

# Add sine buildup

sines = []

lowfreq = tune.ntf('g', octave=2)

sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq, amp=0.4) ]
sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.067, amp=0.4) ]
sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.667, amp=0.25) ]

sines = [ dsp.mix([ fx.penv(s), s ]) for s in sines ]

sines = dsp.mix(sines)
sines = dsp.env(sines, 'line')
sines = dsp.pad(sines, dsp.flen(out) - dsp.flen(sines), 0)

out = dsp.mix([ intro, out, sines ])

dsp.write(out, '01-friction_i')
예제 #43
0
                if bassPlay % 5 == 0:
                    basses = bass(0.5, tlen, 1)
                else:
                    basses = drums.make(bass, dsp.rotate(single, vary=True),
                                        seg)

                bassPlay += 1
                layers += [basses]

            if dsp.randint(0, 1) == 0 or canPlay('jam', bigoldsection):
                # Lead synth
                #lead_note = ['d', 'g', 'a', 'b'][ leadPlay % 4 ]
                lead_note = ['e', 'a', 'b', 'c#'][leadPlay % 4]

                lead = dsp.tone(tlen / 2,
                                wavetype='tri',
                                freq=tune.ntf(lead_note, 4),
                                amp=0.2)
                lead = dsp.env(lead, 'phasor')

                leadPlay += 1
                layers += [lead]

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

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

            arps = ''