예제 #1
0
파일: jbutler.py 프로젝트: hecanjog/jbutler
def fracture(snd):
    numpoints = dsp.randint(3, 20)
    poscurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    poscurve = [ p * (dsp.flen(snd) - dsp.mstf(210)) for p in poscurve ]

    lencurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    lencurve = [ l * dsp.mstf(200) + dsp.mstf(10) for l in lencurve ]

    pancurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)

    prepadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    prepadcurve = [ int(p * dsp.mstf(20)) for p in prepadcurve ]

    postpadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0], numpoints)
    postpadcurve = [ int(p * dsp.mstf(20)) for p in postpadcurve ]

    speeds = [1.0, 2.0, 0.5, 0.75]

    grains = [ dsp.cut(snd, poscurve[i], lencurve[i]) for i in range(numpoints) ]
    grains = [ dsp.pan(grains[i], pancurve[i]) for i in range(numpoints) ]
    grains = [ dsp.env(grain, 'gauss', True) for grain in grains ]
    grains = [ dsp.transpose(grain, dsp.randchoose(speeds)) for grain in grains ]
    grains = [ dsp.pad(grains[i], prepadcurve[i], postpadcurve[i]) for i in range(numpoints) ]

    for i in range(numpoints):
        if dsp.randint(0, 3) == 0:
            grains[i] = slurp(grains[i])

    etypes = ['line', 'phasor', 'tri', 'sine', 'gauss']

    snd = dsp.env(''.join(grains), dsp.randchoose(etypes))
    snd = dsp.pad(snd, 0, dsp.mstf(dsp.rand(100, 400)))

    return snd
예제 #2
0
파일: orc.py 프로젝트: hecanjog/o-ou
def snare(amp, length):
    if amp == 0:
        return dsp.pad('', 0, length)

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

    out = dsp.amp(out, amp)
    return out
예제 #3
0
    def clap1(beat):
        c = dsp.read('sounds/mikeclap.wav').data
        c = dsp.transpose(c, dsp.rand(1, 2.5))
        c = dsp.fill(c, dsp.mstf(dsp.rand(10, 100)))
        c = dsp.env(c, 'phasor')
        c = dsp.amp(c, dsp.rand(1, 3))
        c = dsp.pad(c, 0, beat - dsp.flen(c))

        blen = beat / dsp.randchoose([1, 2])
        c = dsp.pad(c, blen, 0)

        c *= 4

        return c
예제 #4
0
def snare(amp, length):
    if amp == 0:
        return dsp.pad('', 0, 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
예제 #5
0
def clap(amp, length):
    if amp == 0:
        return dsp.pad('', 0, 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
예제 #6
0
    def clap1(beat):
        c = dsp.read('sounds/mikeclap.wav').data
        c = dsp.transpose(c, dsp.rand(1, 2.5))
        c = dsp.fill(c, dsp.mstf(dsp.rand(10, 100)))
        c = dsp.env(c, 'phasor')
        c = dsp.amp(c, dsp.rand(1, 3))
        c = dsp.pad(c, 0, beat - dsp.flen(c))

        blen = beat / dsp.randchoose([1,2])
        c = dsp.pad(c, blen, 0)

        c *= 4

        return c
예제 #7
0
파일: orc.py 프로젝트: hecanjog/o-ou
def clap(amp, length):
    if amp == 0:
        return dsp.pad('', 0, length)

    # Two layers of noise: lowmid and high
    lowlow, lowhigh = dsp.rand(300, 600), dsp.rand(700, 1200)
    highlow, highhigh = dsp.rand(3000, 7000), dsp.rand(7000, 9000)
    out = dsp.mix([ dsp.bln(int(length * 0.2), lowlow, lowhigh), dsp.bln(int(length * 0.2), 7000, 9000) ])
    
    out = dsp.env(out, 'phasor')
    out = dsp.pad(out, 0, length - dsp.flen(out))
    out = dsp.amp(out, amp)

    return out
예제 #8
0
파일: __init__.py 프로젝트: hecanjog/hcj.py
    def play(self, freq, length, amp=1):
        snd = dsp.transpose(self.snd, freq / self.freq)
        snd = dsp.taper(snd, 40)
        snd = dsp.amp(snd, amp)

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

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

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

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

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

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

        return snd
예제 #9
0
    def clap2(beat):
        nlens = [
            beat * 2,
            beat,
            beat / 2,
        ]

        # length of pattern (in beats)
        nbeats = dsp.randint(10, 15)

        # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
        blens = [dsp.randchoose(nlens) for b in range(nbeats)]

        out = ''

        # synthesize the tones
        for i in range(nbeats):
            beat = dsp.transpose(dsp.randchoose([c1, c2]),
                                 dsp.rand(0.25, 40.0))
            beat = dsp.pad(beat, 0, blens[i] - dsp.flen(beat))
            beat = dsp.amp(beat, dsp.rand(1, 4))

            # add it to the output
            out += beat

        return out
예제 #10
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

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

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

    chord = dsp.mix(chord)

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

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

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

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

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

    groot = tune.ntf('c') 

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

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

    out = ''

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

    maxbend = 2
    maxbend = 0.02

    layers = []

    for nlen in lens:
        layer = ''

        nlen /= 2

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

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

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

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

            layer += b

#        layer = dsp.fill(layer, bar)

        layers += [ layer ]

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

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

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

    octave = dsp.randint(1, 4)

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

    out = ''

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

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

        pulsewidth = dsp.rand(0.01, 1)

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

        modRange = dsp.rand(0.01, 100.08)

        modFreq = dsp.rand(0.0001, 5)

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

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

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

        t = dsp.alias(t)

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

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

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

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

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

        out += t


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

    return out
예제 #13
0
def make_pulse(snd):
    snd_len = dsp.flen(snd)
    blip = dsp.cut(snd, 0, dsp.mstf(10))
    blip = dsp.env(blip, 'sine')
    blip = dsp.pad(blip, 0, snd_len - dsp.flen(blip))

    return blip
예제 #14
0
파일: orc.py 프로젝트: hecanjog/o-ou
def hihat(amp, length):
    if amp == 0:
        return dsp.pad('', 0, length)

    def hat(length):
        lowf = dsp.rand(600, 7000)
        highf = dsp.rand(7000, 19000)
        
        if dsp.randint(0, 6) == 0:
            out = dsp.bln(length, lowf, highf)
            out = dsp.env(out, 'line')
        else:
            out = dsp.bln(int(length * 0.05), lowf, highf)
            out = dsp.env(out, 'phasor')
            out = dsp.pad(out, 0, length - dsp.flen(out))

        return out

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

    out = dsp.amp(out, amp)
    return out
예제 #15
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
예제 #16
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
예제 #17
0
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

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

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

    chord = dsp.mix(chord)

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

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

    return chord
예제 #18
0
    def clap2(beat):
        nlens = [
            beat * 2,
            beat,
            beat / 2,
        ]

        # length of pattern (in beats)
        nbeats = dsp.randint(10, 15)

        # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
        blens = [ dsp.randchoose(nlens) for b in range(nbeats) ]

        out = ''
     
        # synthesize the tones
        for i in range(nbeats):
            beat = dsp.transpose(dsp.randchoose([c1,c2]), dsp.rand(0.25, 40.0))
            beat = dsp.pad(beat, 0, blens[i] - dsp.flen(beat))
            beat = dsp.amp(beat, dsp.rand(1, 4))

            # add it to the output
            out += beat

        return out
예제 #19
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
예제 #20
0
    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
예제 #21
0
 def make(length, freq):
     freq *= dsp.rand(1 - (bendfactor / 2.0), 1 + (bendfactor / 2.0))
     out = keys.chippy(length=int(length * dsp.rand(0.01, 0.4)),
                       freq=freq,
                       amp=0.7)
     out = dsp.env(out, 'phasor')
     out = dsp.pad(out, 0, length - dsp.flen(out))
     return out
예제 #22
0
    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
예제 #23
0
파일: cuts.py 프로젝트: hecanjog/geodes.py
def play(ctl):
    mpk = ctl.get('midi').get('mpk')
    nk = ctl.get('midi').get('nk')

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

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

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

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

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

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

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

    out = dsp.amp(out, amp)

    return out
예제 #24
0
def play(ctl):
    mpk = ctl.get('midi').get('mpk')
    nk = ctl.get('midi').get('nk')

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

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

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

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

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

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

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

    out = dsp.amp(out, amp)

    return out
예제 #25
0
파일: slew.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    beat = dsp.mstf(dsp.rand(100, 300))
    out = dsp.pad('', 0, beat)
    m = pygame.midi.Output(2)

    #m.write([ [[0xFA], time.time()] ])
    m.write([ [[0xF8], time.time()] ])

    return out
예제 #26
0
        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
예제 #27
0
def fracture(snd):
    numpoints = dsp.randint(3, 20)
    poscurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)
    poscurve = [p * (dsp.flen(snd) - dsp.mstf(210)) for p in poscurve]

    lencurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)
    lencurve = [l * dsp.mstf(200) + dsp.mstf(10) for l in lencurve]

    pancurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                              numpoints)

    prepadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                                 numpoints)
    prepadcurve = [int(p * dsp.mstf(20)) for p in prepadcurve]

    postpadcurve = dsp.breakpoint([0] + [dsp.rand() for i in range(4)] + [0],
                                  numpoints)
    postpadcurve = [int(p * dsp.mstf(20)) for p in postpadcurve]

    speeds = [1.0, 2.0, 0.5, 0.75]

    grains = [dsp.cut(snd, poscurve[i], lencurve[i]) for i in range(numpoints)]
    grains = [dsp.pan(grains[i], pancurve[i]) for i in range(numpoints)]
    grains = [dsp.env(grain, 'gauss', True) for grain in grains]
    grains = [dsp.transpose(grain, dsp.randchoose(speeds)) for grain in grains]
    grains = [
        dsp.pad(grains[i], prepadcurve[i], postpadcurve[i])
        for i in range(numpoints)
    ]

    for i in range(numpoints):
        if dsp.randint(0, 3) == 0:
            grains[i] = slurp(grains[i])

    etypes = ['line', 'phasor', 'tri', 'sine', 'gauss']

    snd = dsp.env(''.join(grains), dsp.randchoose(etypes))
    snd = dsp.pad(snd, 0, dsp.mstf(dsp.rand(100, 400)))

    return snd
예제 #28
0
파일: drums.py 프로젝트: hecanjog/hcj.py
def parsebeat(pattern, division, beat, length, callback, swing=0):
    subbeat = (beat * 4) / division
    nbeats = length / subbeat

    pattern = [ pattern[ i % len(pattern)] for i in range(nbeats) ]

    beats = []
    elapsed = 0

    for i, glyph in enumerate(pattern):
        elapsed += subbeat

        if glyph == 'x' or glyph == '-':
            glyph_type = 1
        else:
            glyph_type = 0

        next = None
        if i < len(pattern) - 1:
            next = pattern[i + 1]

        transition = ((glyph == 'x' or glyph == '-') and (next == ' ' or next == 'x')) or (glyph == ' ' and next == 'x')

        if transition or next is None:
            beats += [ (glyph_type, elapsed) ]
            elapsed = 0

    out = ''
    for i, (amp, beat_length) in enumerate(beats):
        if amp > 0:
            if i % 2 == 1 and swing > 0:
                swing_percent = (swing / 100.0) * 0.75 # actual range is 0 - 75%
                delay_length = int(beat_length * swing_percent)
                o = callback(beat_length - delay_length, i=i, amp=amp)
                o = dsp.pad(o, delay_length, 0)
                out += o
            else:
                out += callback(beat_length, i=i, amp=amp)
        else:
            out += dsp.pad('', 0, beat_length)

    return out
예제 #29
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
예제 #30
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
예제 #31
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 ]}})
예제 #32
0
파일: orc.py 프로젝트: hecanjog/o-ou
    def hat(length):
        lowf = dsp.rand(600, 7000)
        highf = dsp.rand(7000, 19000)
        
        if dsp.randint(0, 6) == 0:
            out = dsp.bln(length, lowf, highf)
            out = dsp.env(out, 'line')
        else:
            out = dsp.bln(int(length * 0.05), lowf, highf)
            out = dsp.env(out, 'phasor')
            out = dsp.pad(out, 0, length - dsp.flen(out))

        return out
예제 #33
0
def makeRhodes(length, beat, freqs, maxbend=0.05):
    backup = Sampler(snds.load('tones/nycrhodes01.wav'), tune.ntf('c'), direction='fw-bw-loop', tails=False)
    chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.7)) for freq in freqs ]
    chord = dsp.randshuffle(chord)
    chord = [ dsp.mix([ dsp.env(fx.penv(backup.play(freq * 2**dsp.randint(0,2), length, dsp.rand(0.4, 0.6))), 'line'), c ]) for freq, c in zip(freqs, chord) ]
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        c = fx.bend(c, [ dsp.rand() for _ in range(dsp.randint(5, 10)) ], dsp.rand(0, maxbend))
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    return dsp.mix(chord)
예제 #34
0
    def hat(length):
        lowf = dsp.rand(6000, 11000)
        highf = dsp.rand(11000, 17000)

        if dsp.randint(0, 6) == 0:
            out = bln(length, lowf, highf)
            out = dsp.env(out, 'line')
        else:
            out = bln(int(length * 0.05), lowf, highf)
            out = dsp.env(out, 'phasor')
            out = dsp.pad(out, 0, length - dsp.flen(out))

        return out
예제 #35
0
        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))

            out = bln(int(length * dsp.rand(0.01, 0.05)), 90, 6000)
            out = dsp.env(out, 'phasor')
            out = dsp.pad(out, 0, length - dsp.flen(out))

            return out
예제 #36
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
예제 #37
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
예제 #38
0
def makeBeat(pattern, lengths, callback):
    out = ''

    for i, length in enumerate(lengths):
        # Silence or beat?
        amp = pattern[i % len(pattern)]

        if amp > 0:
            out += callback(length, i)
        else:
            out += dsp.pad('', 0, length)

    assert dsp.flen(out) == sum(lengths)

    return out
예제 #39
0
파일: beats.py 프로젝트: hecanjog/hcj.py
    def makeHat(length, i, amp):
        """
        h = dsp.tone(dsp.mstf(dsp.rand(1, 3)), dsp.rand(11900, 12000))
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))
        h = dsp.amp(h, amp * 0.25)
        """

        #h = dsp.cut(hsnd, 0, dsp.mstf(dsp.rand(3, 10)))
        h = hsnd
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))
        #h = dsp.amp(h, amp * 0.75)

        return h
예제 #40
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
예제 #41
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
예제 #42
0
    def hat(beat):
        length = beat * 4
        nbeats = 16
        blen = length / nbeats

        out = ''

        for b in range(nbeats):
            h = dsp.transpose(tape1, 9)
            h = dsp.fill(h, dsp.mstf(dsp.rand(1, 20)))
            h = dsp.env(h, 'phasor')
            h = dsp.amp(h, dsp.rand(0, 0.8))
            h = dsp.pad(h, 0, blen - dsp.flen(h))

            out += h

        out *= 8

        return out
예제 #43
0
def makeBeat(pattern, lengths, callback, args=None):
    out = ''

    for i, length in enumerate(lengths):
        # Silence or beat?
        amp = pattern[i % len(pattern)]

        if amp > 0:
            if args is not None:
                out += callback(length, i, args)
            else:
                out += callback(length, i)
        else:
            out += dsp.pad('', 0, length)

    try:
        assert dsp.flen(out) == sum(lengths)
    except AssertionError:
        print 'doh', dsp.flen(out), sum(lengths), pattern

    return out
예제 #44
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
예제 #45
0
def play(ctl):
    lpd = ctl.get('midi').get('lpd')
    param = ctl.get('param')
    #pc.setOffset(111)

    chord_index = param.get('chord_index', default=0)

    if lpd.get(36, default=1) < 1:
        dsp.log(lpd.get(36)) 
        param.set('chord_index', chord_index + 1)

    areas = ['high', 'pitch', 'mid', 'low']
    area = lpd.geti(23, low=0, high=len(areas), default=len(areas))
    if area == len(areas):
        area = dsp.randchoose(areas)
    else:
        area = areas[area]

    param.set('wash-area', area, throttle=1)
    param.set('wash-area', 'high', throttle=1)

    return dsp.pad('', 0, dsp.mstf(100))
예제 #46
0
def hihat(amp, length):
    if amp == 0:
        return dsp.pad('', 0, length)

    def hat(length):
        lowf = dsp.rand(6000, 11000)
        highf = dsp.rand(11000, 17000)

        if dsp.randint(0, 6) == 0:
            out = bln(length, lowf, highf)
            out = dsp.env(out, 'line')
        else:
            out = bln(int(length * 0.05), lowf, highf)
            out = dsp.env(out, 'phasor')
            out = dsp.pad(out, 0, length - dsp.flen(out))

        return out

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

    return out
예제 #47
0
def kick(amp, length):
    if amp == 0:
        return dsp.pad('', 0, 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')
예제 #48
0
파일: basic.py 프로젝트: hecanjog/algotalk
def play(ctl):
    p = ctl.get('param')
    key = p.get('key', 'c')
    mpk = ctl.get('midi').get('mpk')
    bpm = p.get('bpm', 100)
    beat = dsp.bpm2frames(bpm)
    length = beat * 2 * mpk.geti(6, low=1, high=6)

    gamut = mpk.geti(20)
    poly = mpk.geti(21)
    logistic = mpk.geti(22)
    layered = mpk.geti(23)
    fixed = mpk.get(24)
    perc = mpk.get(25)
    wobble = mpk.get(26)

    min_octave = mpk.geti(4, low=1, high=4)
    max_octave = mpk.geti(4, low=3, high=7)
    octave = dsp.randint(min_octave, max_octave)

    k = dsp.randchoose(snds.search('mc303/*kick*'))
    h = dsp.randchoose(snds.search('mc303/*hat*'))
    c = dsp.randchoose(snds.search('mc303/*clap*'))

    pointer = p.get('pointer', default=0)
    log = data.Logistic(r=dsp.rand(3.9, 3.99),
                        x=0.5,
                        size=1024,
                        pointer=pointer)

    if fixed:
        seed = mpk.get(5)
    else:
        seed = time.time()

    dsp.seed(str(seed))

    def makeOnsets(length, wobble, div, num_beats, offset=False):
        if offset:
            offset = dsp.randint(0, 3)
        else:
            offset = 0

        pattern = dsp.eu(num_beats, dsp.randint(1, num_beats / div), offset)
        dsp.log(pattern)

        if wobble:
            points = [dsp.mstf(100, 500) for _ in range(dsp.randint(2, 8))]
            plength = sum(points)
            mult = length / float(plength)
            onsets = curves.bezier(points, num_beats)
            onsets = [int(o * mult) for o in onsets]

        else:
            beat = float(length) / num_beats
            num_beats = length / beat
            beat = int(round(beat))
            onsets = [beat * i for i in range(int(round(num_beats)))]

        return onsets

    def makeKicks(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 4, True)
        kick = dsp.taper(k, 20)
        kick = dsp.transpose(kick, dsp.rand(1, 2))

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

        out = out.mix()

        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    def makeHats(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 1, 16, True)

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

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    def makeClaps(length, wobble):
        out = Tracks()
        onsets = makeOnsets(length, wobble, 2, 8, True)

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

        out = out.mix()
        out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4]))
        out = [dsp.taper(o, 20) for o in out]
        out = dsp.randshuffle(out)
        out = ''.join(out)
        out = dsp.fill(out, length, silence=False)
        return dsp.taper(out, 40)

    if mpk.get(8) == 0:
        return dsp.pad('', 0, dsp.mstf(100))

    def randomScale():
        scale = [1, 2, 3, 4, 5, 6, 7, 8]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    def gamutScale():
        num_notes = dsp.randint(3, 6)
        scale = [
            dsp.randchoose([1, 2, 3, 4, 5, 6, 7, 8]) for _ in range(num_notes)
        ]
        freqs = tune.fromdegrees(scale, octave=octave, root=key)
        return freqs

    if gamut:
        freqs = gamutScale()
    else:
        freqs = randomScale()

    if layered:
        num_layers = dsp.randint(2, 4)
    else:
        num_layers = 1

    layers = []

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

        elapsed = 0
        while elapsed < length:
            if poly:
                num_poly = dsp.randint(1, 3)
            else:
                num_poly = 1

            note_length = beat / dsp.randchoose([1, 2, 3, 4])

            notes = []
            for _ in range(num_poly):
                freq = dsp.randchoose(freqs)

                if logistic:
                    pulsewidth = log.get(low=0.05, high=1)

                    if log.get() > 0.5:
                        wf = log.choose(['sine', 'tri', 'saw'])
                        wf = dsp.wavetable(wf, 512)
                    else:
                        points = [
                            log.get(-1, 1) for _ in range(log.geti(4, 20))
                        ]
                        wf = dsp.breakpoint(points, 512)
                else:
                    pulsewidth = 1
                    wf = dsp.wavetable('sine', 512)

                note = keys.pulsar(length=note_length,
                                   freq=freq,
                                   wf=wf,
                                   env='phasor',
                                   pulsewidth=pulsewidth)
                notes += [note]

            notes = dsp.mix(notes)
            layer += notes

            elapsed += dsp.flen(notes)

        layers += [layer]

    out = dsp.mix(layers)
    out = dsp.amp(out, 0.75)
    out = dsp.fill(out, length)

    #out = dsp.pad(out, 0, int(dsp.stf(0.5, 1) * mpk.get(7)))

    p.set('pointer', log.pointer)

    if perc:
        kicks = makeKicks(length, wobble)
        hats = makeHats(length, wobble)
        claps = makeClaps(length, wobble)
        out = dsp.mix([out, kicks, hats, claps])

    out = dsp.amp(out, mpk.get(8))

    return out
예제 #49
0
파일: beats.py 프로젝트: hecanjog/geodes.py
    def makeHat(length, i, amp):
        h = hsnd
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))

        return h
예제 #50
0
파일: beats.py 프로젝트: hecanjog/geodes.py
def play(ctl):
    mpk = ctl.get('midi').get('mpk')

    ccs = [i + 48 for i in range(24)]
    notes = []
    for cc in ccs:
        if mpk.get(cc) < 1:

            notes += [cc]

    ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data
    ssnd = dsp.read('jesssnare.wav').data
    hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data
    ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data
    #ksnd = dsp.read('jesskick.wav').data

    beat = dsp.bpm2frames(90)
    #beat = dsp.mstf(290 * 2)
    length = beat * 4

    hat = 'xxx '
    kick = 'x       '
    snare = '  x '

    #snare =  '  x  xx'
    #snare =  '    '

    def makeHat(length, i, amp):
        h = hsnd
        h = dsp.env(h, 'phasor')
        h = dsp.pad(h, 0, length - dsp.flen(h))

        return h

    def makeKick(length, i, amp):
        k = dsp.mix([ksnd, drums.sinekick(length, i, amp)])
        #k = dsp.env(ksnd, 'phasor')

        k = dsp.fill(k, length, silence=True)
        k = dsp.amp(k, 1)

        return k

    def makeSnare(length, i, amp):
        s = ssnd
        s = dsp.amp(s, 1.2)
        s = dsp.transpose(s, dsp.rand(1.5, 3))
        s = dsp.fill(s, length, silence=True)
        #ss = dsp.drift(s, dsp.rand(0.001, 0.1))
        #s = dsp.mix([s, ss])

        return s

    #hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25)
    hats = drums.parsebeat(hat, 16, beat, length, makeHat, 0)
    kicks = drums.parsebeat(kick, 16, beat, length, makeKick, 0)
    snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0)

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

    shuf = True
    shuf = False

    if shuf:
        out = dsp.split(out, beat)
        out = dsp.randshuffle(out)
        out = ''.join(out)

    out = dsp.amp(out, 2)

    cuts = True if dsp.rand() > 0.5 else False
    cuts = True
    #cuts = False

    if cuts:
        o = dsp.split(out, beat / 2)
        o = dsp.randshuffle(o)
        o = [dsp.amp(oo, dsp.rand(0, 2.5)) for oo in o]
        o = [dsp.env(oo, 'random') for oo in o]

        out = dsp.mix([''.join(o), out])

    dsp.log(notes)

    synthy = False
    #synthy = True

    if synthy == True:
        s = ''
        for ii in range(dsp.flen(out) / (beat / 2)):
            layers = []

            if len(notes) > 0:
                scale = [n - 47 for n in notes]
                scale = [1, 5, 8, 12]
                scale = tune.fromdegrees(scale, octave=3, root='d')
                p = ''.join([
                    keys.pulsar(scale[ii % len(scale)],
                                pulsewidth=dsp.rand(0.1, 1),
                                amp=0.5,
                                length=(beat / 2) / 3) for _ in range(3)
                ])
                layers += [p]
            else:
                layers += [dsp.pad('', beat / 2, 0)]

            s += dsp.mix(layers)

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

    #out = dsp.alias(out)

    #out = dsp.drift(out, dsp.rand(0.5, 2))

    return out
예제 #51
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
예제 #52
0
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)]


def canPlay(section_name='none', index=0):
예제 #53
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')
예제 #54
0
def play(voice_id):
    bpm = config('bpm')
    root = config('key')
    quality = getattr(tune, config('quality'))
    ratios = getattr(tune, config('tune'))

    beat = dsp.bpm2frames(bpm)

    amp = dsp.rand(0.1, 0.65)

    nlens = [
        beat * 4,
        beat * 3,
        beat * 2,
        beat + (beat / 2),
        beat,
        beat / 2,
        beat / 4,
    ]

    scale = [2, 4, 6, 9]
    scale = [1, 4, 6, 8]
    #    scale = [1,3,4,5,6,8,9]
    #    scale = [1,2,3,5,6,8,9]
    #    scale = [1,5,8]
    freqs = tune.fromdegrees(scale,
                             root=root,
                             octave=dsp.randint(2, 4),
                             ratios=ratios,
                             scale=quality)

    # length of pattern (in beats)
    elen = 0
    tlen = beat * dsp.randint(2, 8)

    # beat lengths (from a set of bpm-derived note lengths defined in the nlens list)
    blens = []
    while elen < tlen:
        l = dsp.randchoose(nlens)
        blens += [l]
        elen += l

    # beat pulsewidths
    bpws = [dsp.rand(0.1, 1) for pw in range(len(blens))]

    out = ''

    # choose a pitch from the scale
    freq = dsp.randchoose(freqs)

    # synthesize the tones
    for i in range(len(blens)):
        # find the length of the pulse
        blen = int(round(blens[i] * bpws[i]))

        # find the length of the rest
        brest = blens[i] - blen

        # make a rhodes tone with a random amplitude
        #beat = keys.rhodes(length=blen, freq=freq, amp=dsp.rand(0.3, 0.5))
        beat = keys.rhodes(length=blen, freq=freq, amp=amp)

        # pan the tone to a random position
        beat = dsp.pan(beat, dsp.rand())

        # bitcrush the tone a random amount
        #        beat = dsp.alias(beat)

        # pad the tone with silence
        beat = dsp.pad(beat, 0, brest)

        # add it to the output
        out += beat

    out *= dsp.randint(1, 2)

    if dsp.rand() > 0.75:
        out = dsp.split(out, dsp.bpm2frames(bpm) / dsp.randchoose([1, 2, 4]))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
예제 #55
0
 def kick(beat):
     out = drums.sinekick(length=beat, amp=dsp.rand(0.8, 1))
     out = dsp.pad(out, 0, beat * dsp.randint(1, 2))
     out *= 2
     return out