예제 #1
0
def show_telemetry(tel):
    output = []

    for k, v in tel.iteritems():
        if k == "register":
            color = "blue"

        elif k == "density":
            color = "red"

        elif k == "harmonicity":
            color = "green"

        elif k == "roughness":
            color = "cyan"

        elif k == "pace":
            color = "yellow"

        else:
            color = "white"

        if k == "name":
            output += [colored(" ".join(v), color)]
        else:
            output += [colored("%s: %.2f" % (k[:3], v), color)]

    output = " | ".join(output)
    dsp.log(output)
예제 #2
0
def run(gens, tick):
    dsp.log("telemetry up!")
    started = time.time()

    def worker(gens, tick):
        while time.time() < started + (60 * 15):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

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

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

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

                dsp.log("")
                dsp.log("stopping voice %s" % voice_id)
                settings.voice(voice_id, "loop", 0)

    for w in range(20):
        # Spawn worker
        worker_process = mp.Process(name="worker", target=worker, args=(gens, tick))
        worker_process.start()
예제 #3
0
def run(gens, tick):
    dsp.log('telemetry up!')
    started = time.time()

    def worker(gens, tick):
        while time.time() < started + (60 * 9):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

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


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

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

                dsp.log('')
                dsp.log('stopping voice %s' % voice_id)
                settings.voice(voice_id, 'loop', 0)

    for w in range(10):
        # Spawn worker
        worker_process = mp.Process(name='worker', target=worker, args=(gens, tick))
        worker_process.start()
예제 #4
0
def show_telemetry(tel):
    output = [] 

    for k, v in tel.iteritems():
        if k == 'register':
            color = 'blue'

        elif k == 'density':
            color = 'red'

        elif k == 'harmonicity':
            color = 'green'

        elif k == 'roughness':
            color = 'cyan'

        elif k == 'pace':
            color = 'yellow'

        else:
            color = 'white'

        if k == 'name':
            output += [ colored(' '.join(v), color) ]
        else:
            output += [ colored('%s: %.2f' % (k[:3], v), color) ]

    output = ' | '.join(output)
    dsp.log(output)
예제 #5
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
예제 #6
0
def automate(ctl):
    sh = ctl.get('midi').get('sh')
    i = ctl.get('iterations')
    
    sh.noteon(64)

    dsp.delay(dsp.mstf(dsp.rand(200, 500)))

    sh.noteoff(64)

    dsp.log(i)
예제 #7
0
파일: snds.py 프로젝트: hecanjog/hcj.py
def getMatches(inst, midi_note, wildcard=''):
    inst = inst.lower()
    path = os.path.join(snddir, 'iowa/%s/%s.%s.%s*.wav' % (inst, midi_note, inst, wildcard))
    dsp.log(path)
    files = glob.glob(path)

    if len(files) == 0 and midi_note > 120:
        raise ValueError('No matching pitch (%s) found for %s' % (midi_note, inst))
    elif len(files) == 0:
        midi_note += 12
        files = getMatches(inst, midi_note)

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

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

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

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

    blen = len(b)

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

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

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

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

    out = ''.join(b)

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

    return out
예제 #9
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

    crinkle = dsp.read('sounds/s/crinkle.wav').data
    glass1 = dsp.read('sounds/s/glass1.wav').data
    glass2 = dsp.read('sounds/s/glass2.wav').data
    toys = dsp.read('sounds/s/rolling.wav').data

    c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3))
    c = dsp.randshuffle(c)
    c = c[:40]
    c = [dsp.pan(cc, dsp.rand()) for cc in c]
    c = [dsp.env(cc, 'sine') for cc in c]
    c = [dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c]

    t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1))
    t = dsp.randshuffle(t)
    t = t[:40]
    t = [dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t]
    t = [dsp.pan(tt, dsp.rand(0, 1)) for tt in t]
    t = [dsp.env(tt, 'sine') for tt in t]
    t = [dsp.transpose(tt, 0.5) for tt in t]

    g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100))
    g = dsp.randshuffle(g)
    g = g[:40]
    g = [dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g]
    g = [dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g]
    g = [gg * dsp.randint(1, 8) for gg in g]

    things = [c, t, g]

    out = [
        dsp.mix([
            dsp.randchoose(dsp.randchoose(things))
            for l in range(dsp.randint(2, 4))
        ]) for i in range(4)
    ]
    out = ''.join(out)

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

    return out
예제 #10
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
예제 #11
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

    crinkle = dsp.read('sounds/s/crinkle.wav').data
    glass1 = dsp.read('sounds/s/glass1.wav').data
    glass2 = dsp.read('sounds/s/glass2.wav').data
    toys = dsp.read('sounds/s/rolling.wav').data

    c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3))
    c = dsp.randshuffle(c)
    c = c[:40]
    c = [ dsp.pan(cc, dsp.rand()) for cc in c ]
    c = [ dsp.env(cc, 'sine') for cc in c ]
    c = [ dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c ]

    t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1))
    t = dsp.randshuffle(t)
    t = t[:40]
    t = [ dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t ]
    t = [ dsp.pan(tt, dsp.rand(0, 1)) for tt in t ]
    t = [ dsp.env(tt, 'sine') for tt in t ]
    t = [ dsp.transpose(tt, 0.5) for tt in t ]

    g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100))
    g = dsp.randshuffle(g)
    g = g[:40]
    g = [ dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g ]
    g = [ dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g ]
    g = [ gg * dsp.randint(1, 8) for gg in g ]

    things = [c,t,g]

    out = [ dsp.mix([ dsp.randchoose(dsp.randchoose(things)) for l in range(dsp.randint(2, 4)) ]) for i in range(4) ]
    out = ''.join(out)

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

    return out
예제 #12
0
def play(voice_id):
    bpm = C('bpm')
    beat = dsp.bpm2frames(bpm)
    volume = P(voice_id, 'volume', default=1.0)

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

    out = ''

    for i in range(32):

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

        bar = dsp.flen(b) / 2

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

            blayers += [ blayer ]

        b = dsp.mix(blayers)

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

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

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

    return out
예제 #13
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))
예제 #14
0
파일: listen.py 프로젝트: hecanjog/hcj.py
def play(ctl):
    lpd = ctl.get('midi').get('pc')
    param = ctl.get('param')
    pc = ctl.get('midi').get('pc')
    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(6, 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)

    return dsp.pad('', 0, dsp.mstf(100))
예제 #15
0
파일: basic.py 프로젝트: hecanjog/algotalk
    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
예제 #16
0
파일: basic.py 프로젝트: hecanjog/algotalk
    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
예제 #17
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
예제 #18
0
def play(voice_id):
    tel = bot.getTel()

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

    octave = dsp.randint(1, 4)

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

    out = ''

    freq = dsp.randchoose(freqs)
    volume = dsp.rand(0.5, 0.8)
    length = dsp.randint(dsp.mstf(20), dsp.mstf(30))

    for p in range(dsp.randint(20, 100)):

        pulsewidth = dsp.rand(0.5, 1)

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

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

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

        t = dsp.pad(t, 0, length * 3)

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

        out += t

    out = dsp.env(out, 'sine')
    out = dsp.pan(out, dsp.rand(0, 1))

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

    return out
예제 #19
0
def make_telemetry():
    zones = [
        {
            "name": ["sparse"],
            "register": (7, 10),
            "density": (1, 2),
            "harmonicity": (1, 10),
            "roughness": (1, 5),
            "pace": (1, 3),
        },
        {
            "name": ["gentle"],
            "register": (3, 7),
            "density": (3, 8),
            "harmonicity": (8, 10),
            "roughness": (1, 2),
            "pace": (1, 3),
        },
        {
            "name": ["ballsout"],
            "register": (1, 10),
            "density": (2, 10),
            "harmonicity": (1, 10),
            "roughness": (4, 10),
            "pace": (3, 10),
        },
        {
            "name": ["upbeat"],
            "register": (5, 8),
            "density": (1, 8),
            "harmonicity": (8, 10),
            "roughness": (2, 4),
            "pace": (4, 7),
        },
        {
            "name": ["upbeat"],
            "register": (5, 8),
            "density": (1, 8),
            "harmonicity": (8, 10),
            "roughness": (2, 4),
            "pace": (4, 7),
        },
    ]

    dsp.log("generating telemetry...")

    numsections = dsp.randint(10, 20)
    sections = []

    for s in range(numsections):
        zone = dsp.randchoose(zones)
        section = make_section(zone)
        sections += section

        # Transition
        if dsp.rand(0, 100) > 20:
            next_zone = dsp.randchoose(zones)

            if next_zone["name"] != zone["name"]:
                next_section = make_section(next_zone)

                transition_zone = {
                    "name": ["transition", section[-1]["name"][0], next_section[0]["name"][0]],
                    "register": (section[-1]["register"], next_section[0]["register"]),
                    "density": (section[-1]["density"], next_section[0]["density"]),
                    "harmonicity": (section[-1]["harmonicity"], next_section[0]["harmonicity"]),
                    "roughness": (section[-1]["roughness"], next_section[0]["roughness"]),
                    "pace": (section[-1]["pace"], next_section[0]["pace"]),
                }

                transition_section = make_section(transition_zone)

                sections += transition_section
                sections += next_section

    dsp.log("telemetry generated")
    settings.shared("tel", sections)
예제 #20
0
from termcolor import colored
import multiprocessing as mp
import pulsar
import chirps
import json
import time

"""
register: low - high
density: thin - thick
harmonicity: aharmonic - harmonic
roughness: smooth - rough
pace: slow - fast
"""

dsp.log("loaded geodes bot")


def mc(r, numpoints):
    numlands = dsp.randint(5, 20)
    return dsp.breakpoint([dsp.rand(r[0], r[1]) for i in range(numlands)], numpoints)


def make_section(zone):
    numpoints = dsp.randint(20, 50)

    zone["register"] = mc(zone["register"], numpoints)
    zone["density"] = mc(zone["density"], numpoints)
    zone["harmonicity"] = mc(zone["harmonicity"], numpoints)
    zone["roughness"] = mc(zone["roughness"], numpoints)
    zone["pace"] = mc(zone["pace"], numpoints)
예제 #21
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', '["c","k","h"]')
    dsp.log(dsl)
    dsl = json.loads(dsl)

    def hat(beat):
        length = beat * 4
        nbeats = 16
        blen = length / nbeats

        out = ''

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

            out += h

        out *= 8

        return out

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

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

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

        c *= 4

        return c

    def clap2(beat):
        nlens = [
            beat * 2,
            beat,
            beat / 2,
        ]

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

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

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

            # add it to the output
            out += beat

        return out

    all = []

    if 'c' in dsl:
        clapper = dsp.randchoose([clap1,clap2])
        all += [ clapper(beat) ]

    if 'k' in dsl:
        all += [ kick(beat) ]

    if 'h' in dsl:
        all += [ hat(beat) ]

    out = dsp.mix(all)

#    out = dsp.vsplit(out, dsp.mstf(dsp.rand(8, 140)), dsp.mstf(500))
#    out = dsp.randshuffle(out)
#    out = ''.join(out)

    out = dsp.vsplit(out, 10, 1000)
    out = [ dsp.amp(o, dsp.rand(0, 4)) for o in out ]
    out = [ dsp.env(o, 'random') for o in out ]
    out = [ dsp.transpose(o, dsp.rand(0.25, 1)) for o in out ]
    out = dsp.randshuffle(out)
    out = ''.join(out)

    out = dsp.pine(out, int(dsp.flen(out) * dsp.rand(1.5, 4)), dsp.rand(10, 2000), dsp.randint(0, 2), dsp.rand(1, 3), dsp.randint(0, 2), dsp.rand(1, 3)) 
    out = dsp.amp(out, 0.65)

    glass = dsp.read('sounds/s/glass2.wav').data

    glass = dsp.vsplit(glass, dsp.mstf(1), dsp.mstf(100))
    glass = dsp.randshuffle(glass)
#    glass = [ dsp.pad(g, 0, dsp.randint(10, 1000)) for g in glass ]
#    glass = [ dsp.transpose(g, dsp.rand(0.5, 1.5)) * dsp.randint(1, 3) for g in glass ]
    glass = ''.join(glass)

    glass = dsp.fill(glass, dsp.flen(out))

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

    return out
예제 #22
0
파일: solo1.py 프로젝트: hecanjog/solos1
from termcolor import colored
import multiprocessing as mp
import pulsar
import chirps
import json
import time

"""
register: low - high
density: thin - thick
harmonicity: aharmonic - harmonic
roughness: smooth - rough
pace: slow - fast
"""

dsp.log('loaded geodes bot')

def mc(r, numpoints):
    numlands = dsp.randint(5, 20)
    return dsp.breakpoint([ dsp.rand(r[0], r[1]) for i in range(numlands) ], numpoints)

def make_section(zone):
    numpoints = dsp.randint(20, 50)

    zone['register'] = mc(zone['register'], numpoints)
    zone['density'] = mc(zone['density'], numpoints)
    zone['harmonicity'] = mc(zone['harmonicity'], numpoints)
    zone['roughness'] = mc(zone['roughness'], numpoints)
    zone['pace'] = mc(zone['pace'], numpoints)

    return [ make_point(zone, i) for i in range(numpoints) ]
예제 #23
0
from pippic import settings
from pippic import rt
from termcolor import colored
import multiprocessing as mp
import json
import time

"""
register: low - high
density: thin - thick
harmonicity: aharmonic - harmonic
roughness: smooth - rough
pace: slow - fast
"""

dsp.log('loaded blue bot')

def mc(r, numpoints):
    numlands = dsp.randint(5, 20)
    return dsp.breakpoint([ dsp.rand(r[0], r[1]) for i in range(numlands) ], numpoints)

def make_section(zone):
    numpoints = dsp.randint(20, 50)

    zone['register'] = mc(zone['register'], numpoints)
    zone['density'] = mc(zone['density'], numpoints)
    zone['harmonicity'] = mc(zone['harmonicity'], numpoints)
    zone['roughness'] = mc(zone['roughness'], numpoints)
    zone['pace'] = mc(zone['pace'], numpoints)

    return [ make_point(zone, i) for i in range(numpoints) ]
예제 #24
0
파일: osc.py 프로젝트: bensteinberg/pippi
        def handler(self, path, args):
            if hasattr(self.ns, 'osc_log_active'):
                dsp.log('%s %s %s' % (self.port, path, args))

            setattr(self.ns, '%s%s' % (self.port, path), args)
예제 #25
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', '["c","k","h"]')
    dsp.log(dsl)
    dsl = json.loads(dsl)

    def hat(beat):
        length = beat * 4
        nbeats = 16
        blen = length / nbeats

        out = ''

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

            out += h

        out *= 8

        return out

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

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

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

        c *= 4

        return c

    def clap2(beat):
        nlens = [
            beat * 2,
            beat,
            beat / 2,
        ]

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

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

        out = ''

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

            # add it to the output
            out += beat

        return out

    all = []

    if 'c' in dsl:
        clapper = dsp.randchoose([clap1, clap2])
        all += [clapper(beat)]

    if 'k' in dsl:
        all += [kick(beat)]

    if 'h' in dsl:
        all += [hat(beat)]

    out = dsp.mix(all)

    #    out = dsp.vsplit(out, dsp.mstf(dsp.rand(8, 140)), dsp.mstf(500))
    #    out = dsp.randshuffle(out)
    #    out = ''.join(out)

    out = dsp.vsplit(out, 10, 1000)
    out = [dsp.amp(o, dsp.rand(0, 4)) for o in out]
    out = [dsp.env(o, 'random') for o in out]
    out = [dsp.transpose(o, dsp.rand(0.25, 1)) for o in out]
    out = dsp.randshuffle(out)
    out = ''.join(out)

    out = dsp.pine(out, int(dsp.flen(out) * dsp.rand(1.5, 4)),
                   dsp.rand(10, 2000), dsp.randint(0, 2), dsp.rand(1, 3),
                   dsp.randint(0, 2), dsp.rand(1, 3))
    out = dsp.amp(out, 0.65)

    glass = dsp.read('sounds/s/glass2.wav').data

    glass = dsp.vsplit(glass, dsp.mstf(1), dsp.mstf(100))
    glass = dsp.randshuffle(glass)
    #    glass = [ dsp.pad(g, 0, dsp.randint(10, 1000)) for g in glass ]
    #    glass = [ dsp.transpose(g, dsp.rand(0.5, 1.5)) * dsp.randint(1, 3) for g in glass ]
    glass = ''.join(glass)

    glass = dsp.fill(glass, dsp.flen(out))

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

    return out
예제 #26
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
예제 #27
0
from pippic import settings
from pippic import rt
from termcolor import colored
import multiprocessing as mp
import json
import time

"""
register: low - high
density: thin - thick
harmonicity: aharmonic - harmonic
roughness: smooth - rough
pace: slow - fast
"""

dsp.log("loaded orange bot")


def mc(r, numpoints):
    numlands = dsp.randint(5, 20)
    return dsp.breakpoint([dsp.rand(r[0], r[1]) for i in range(numlands)], numpoints)


def make_section(zone):
    numpoints = dsp.randint(20, 50)

    zone["register"] = mc(zone["register"], numpoints)
    zone["density"] = mc(zone["density"], numpoints)
    zone["harmonicity"] = mc(zone["harmonicity"], numpoints)
    zone["roughness"] = mc(zone["roughness"], numpoints)
    zone["pace"] = mc(zone["pace"], numpoints)
예제 #28
0
def out(generator, tick, bufs):
    """ Master playback process spawned by play()
        Manages render and playback processes  

        Params are collapsed to a key-value dict,
        where the value is translated to the target 
        data type, and the key is expanded to the param
        full name.
        """

    voice_id = str(mp.current_process().name)

    # Spawn a render process which will write generator output
    # into the buf for this voice
    r = mp.Process(name='r' + str(voice_id), target=render, args=(generator.play, voice_id, False, False, bufs))
    r.start()
    r.join()

    def openpcm(device):
        try:
            out = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, alsaaudio.PCM_NORMAL, device)
        except:
            print 'Could not open an ALSA connection.'
            return False

        out.setchannels(2)
        out.setrate(44100)
        out.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        out.setperiodsize(10)

        return out

    # Open a connection to an ALSA PCM device
    device = getattr(generator, 'device', 'default')
    out = openpcm(device)

    # On start of playback, check to see if we should be regenerating 
    # the sound. If so, spawn a new render thread.
    # If there is a fresher render available, use that instead.
    cooking             = False # Flag set to true if a render subprocess has been spawned
    volume              = 1.0
    next                = False

    buf = settings.buf(voice_id, bufs=bufs)
    while settings.voice(voice_id, 'loop') == True:
        regenerate    = settings.voice(voice_id, 'regenerate')
        once          = settings.voice(voice_id, 'once')
        uno           = settings.voice(voice_id, 'uno')
        quantize      = settings.voice(voice_id, 'quantize')
        target_volume = settings.voice(voice_id, 'target_volume')

        if uno == True:
            settings.voice(voice_id, 'loop', False)

        if regenerate == True or once == True:
            reload(generator)
            device = getattr(generator, 'device', 'default')
            out = openpcm(device)

            r = mp.Process(name='r' + str(voice_id), target=render, args=(generator.play, voice_id, False, False, bufs))
            try:
                r.start()
                r.join()
                buf = settings.buf(voice_id, bufs=bufs)
            except OSError:
                dsp.log('failed to regenerate voice %s' % voice_id)

        if quantize != False:
            tick.wait()

        dsp_loop(out, buf, voice_id)

    settings.remove_voice(voice_id)
예제 #29
0
    while foundtracks <= numtracks:
        track_id = dsp.randint(1, maxtrack_id)
        params = {'api_key': api_key, 'track_id': track_id}
        track = requests.get(endpoint, params=params)
        try:
            track = track.json()
            track_license = track['dataset'][0]['license_title']

            if len(track['errors']) == 0 and not 'Deriv' in track_license:

                track_url = track['dataset'][0]['track_url']
                track_name = track['dataset'][0]['track_title']
                track_artist = track['dataset'][0]['artist_name']

                dsp.log('%s by %s. %s' % (track_name, track_artist, track_license))

                track_page = requests.get(track_url)
                html = BeautifulSoup(track_page.text)
                track_url = html.find_all('a', class_='icn-arrow')[0].get('href')

                with open('%s.mp3' % track_id, 'wb') as track_data:
                    r = requests.get(track_url)

                    if r.ok:
                        track_data.write(r.content)

                cmd = 'sox %s.mp3 %s.wav trim 0 5' % (track_id, track_id)
                p = subprocess.Popen(cmd, shell=True)
                p.wait()
예제 #30
0
def play(voice_id):
    tel = bot.getTel()

    bpm = s.config('bpm')

    #if 'gentle' in tel['name'] or 'upbeat' in tel['name'] or 'full' in tel['name']:
        #dsp.log('')
        #dsp.log(voice_id + ' chirps silent')
        #return dsp.pad('', 0, dsp.stf(dsp.rand(1, 10)))

    length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(3))

    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

    out = makecurve(length)

    if dsp.flen(out) > dsp.mstf(100) and dsp.rand(0, 100) > 30:
        out = dsp.drift(out, (tel['harmonicity'] - 10.0) * -1 * 0.5, dsp.randint(41, 441))

    if dsp.flen(out) > dsp.stf(10):
        out = dsp.fill(out, dsp.stf(10))

    if dsp.rand(0, 100) > 50:
        out = dsp.vsplit(out, 41, 441)
        for ii, o in enumerate(out):
            if dsp.rand(0, 100) > 50:
                out[ii] = dsp.pad('', 0, dsp.flen(o))
            elif dsp.rand(0, 100) > 50:
                out[ii] = dsp.amp(o, dsp.rand(0.75, 3))

        out = [ dsp.pan(o, dsp.rand()) for o in out ]

        out = ''.join(out)

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

    return out
예제 #31
0
파일: pulsar.py 프로젝트: hecanjog/solos1
def play(voice_id):
    tel = bot.getTel()

    if 'sparse' in tel['name'] or 'ballsout' in tel['name'] and dsp.rand(0, 100) > 70:
        dsp.log('')
        dsp.log(voice_id + ' pulsar silent')
        bot.show_telemetry(tel)
        #return dsp.pad('', 0, dsp.stf(dsp.rand(1, 10)))

    #####################
    # PARAMS 
    ##################### 
    volume = dsp.rand(0.4, 0.7)

    melodies = [[dsp.randchoose([1, 5, 6])]]

    if tel['density'] >= 4:
        melodies += [ [ dsp.randchoose([1, 2, 9, 5, 6]) for i in range(2) ] for m in range(dsp.randint(2, 4)) ]

    if tel['density'] >= 6:
        melodies += [ [ dsp.randchoose([1, 2, 9, 3, 4, 5, 6, 7]) for i in range(dsp.randint(3, 6)) ] for m in range(dsp.randint(2, 5)) ]

    try:
        notes = dsp.randchoose(melodies)
    except IndexError:
        dsp.log(melodies)
        notes = [1]

    if tel['harmonicity'] <= 5:
        octave = (tel['register'] / 10.0) * dsp.randint(1, 3) + 1
    else:
        octave = int(round((tel['register'] / 10.0) * dsp.randint(1, 3) + 1))

    bpm         = p(voice_id, 'bpm', 80.0)

    if 'ballsout' in tel['name']:
        length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(3))
    else:
        length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(4)) + dsp.stf(dsp.rand(0.25, 1))

    # Cap voice length at 60 secs
    if length > dsp.stf(60):
        length = dsp.stf(60)

    env         = 'sine'

    mod         = p(voice_id, 'mod', 'random')
    modFreq     = p(voice_id, 'modfreq', dsp.rand(1.0, 2.5) / dsp.fts(length))

    modRange    = dsp.rand(0.01, 0.04)
    modRange    = dsp.rand(0, modRange)

    pulsewidth = 1.0 / (tel['roughness'] / 10.0)
    pulsewidth -= dsp.rand(0, 0.09)
    if pulsewidth < 0.1:
        pulsewidth = 0.1

    beat = dsp.bpm2frames(bpm)
 
    try:
        freqs   = tune.fromdegrees(notes, octave=octave, ratios=tune.just, root='c')
    except TypeError:
        print 'hm', notes, octave
        freqs = tune.fromdegrees([1,5], octave=octave, ratios=tune.just, root='c')

    #####################
    # NORMAL 
    ##################### 
    numgrains = int(dsp.rand(50, 500))

    if tel['roughness'] <= 2:
        window      = 'sine'
        waveform    = 'sine2pi'
        minplen     = dsp.ftms(length / 4)
        maxplen     = 30000

    elif tel['roughness'] <= 4:
        window      = 'sine'
        waveform    = 'sine2pi'
        minplen     = 10
        maxplen     = 350

    elif tel['roughness'] > 4:
        window      = 'tri'
        waveform    = 'tri'
        minplen     = 10 
        maxplen     = 120

    elif tel['roughness'] >= 7:
        window      = 'vary'
        waveform    = 'tri'
        minplen     = 5
        maxplen     = 80

    mod = dsp.wavetable(mod, 512)
    window = dsp.wavetable(window, 512)
    waveform = dsp.wavetable(waveform, 512)

    pc = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, numgrains))) ], numgrains)

    out = ''
    outlen = 0
    count = 0

    bar = dsp.randint(4, 8)

    dobeats = tel['density'] > 5 and dsp.rand(0, 100) > 20

    if dobeats:
        numbeats = bar * dsp.randint(3, 7)

    while outlen < length:
        layers = []

        if dobeats:
            plen = beat / dsp.randint(1, 10)
        else:
            plen = dsp.mstf(dsp.rand(minplen, maxplen))

        if tel['register'] >= 6 and tel['density'] >= 4:
            maxo = dsp.randint(2, 6)
        else:
            maxo = 1

        if dobeats:
            freqs = dsp.randshuffle(freqs)
            for b in range(numbeats):
                f = freqs[b % len(freqs)] 
                if dsp.rand(0, 100) > 70:
                    f *= 2**dsp.randint(0, maxo)

                b = dsp.pulsar(f, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume)
                b = dsp.pan(b, dsp.rand())

                out += b
                outlen += dsp.flen(b)

        else:
            for iff, freq in enumerate(freqs):
                if 'gentle' in tel['name']:
                    volume = dsp.rand(0.5, 0.6)
                elif 'sparse' in tel['name']:
                    volume = dsp.rand(0.3, 0.6)
                elif 'upbeat' in tel['name'] or 'ballsout' in tel['name']:
                    volume = dsp.rand(0.5, 0.6)
                else:
                    volume = dsp.rand(0.4, 0.6)

                if dsp.rand(0, 100) > 60:
                    freq *= 2**dsp.randint(0, maxo)

                layer = dsp.pulsar(freq, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume)

                layer = dsp.env(layer, 'sine')
                layer = dsp.pan(layer, dsp.rand())

                layers += [ layer ]

            layer = dsp.mix(layers)
            out += layer
            outlen += dsp.flen(layer)

            count += 1

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

    #if dsp.flen(out) > dsp.mstf(100) and dsp.rand(0, 100) > 50:
        #out = dsp.drift(out, (tel['harmonicity'] - 10.0) * -1 * 0.1, dsp.randint(4, 441))

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

    return out
예제 #32
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
예제 #33
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
예제 #34
0
파일: solo1.py 프로젝트: hecanjog/solos1
    def worker(gens, tick):
        while time.time() < started + (60 * 15):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

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

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

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

                dsp.log('')
                dsp.log('stopping voice %s' % voice_id)
                settings.voice(voice_id, 'loop', 0)
예제 #35
0
파일: osc.py 프로젝트: shnend/pippi
        def handler(self, path, args):
            if hasattr(self.ns, 'osc_log_active'):
                dsp.log('%s %s %s' % (self.port, path, args))

            setattr(self.ns, '%s%s' % (self.port, path), args)
예제 #36
0
def make_telemetry():
    zones = [
        {
            'name': ['sparse'],
            'register': (7, 10),
            'density': (1, 2),
            'harmonicity': (1, 10),
            'roughness': (1, 5),
            'pace': (1, 3)
        }, {
            'name': ['gentle'],
            'register': (3, 7),
            'density': (3, 8),
            'harmonicity': (8, 10),
            'roughness': (1, 2),
            'pace': (1, 3)
        }, {
            'name': ['ballsout'],
            'register': (1, 10),
            'density': (2, 10),
            'harmonicity': (1, 10),
            'roughness': (4, 10),
            'pace': (3, 10)
        }, {
            'name': ['upbeat'],
            'register': (5, 8),
            'density': (1, 8),
            'harmonicity': (8, 10),
            'roughness': (2, 4),
            'pace': (4, 7)
        }
    ]

    dsp.log('generating telemetry...')

    numsections = dsp.randint(10, 20)
    sections = []

    for s in range(numsections):
        zone = dsp.randchoose(zones)
        section = make_section(zone)
        sections += section

        # Transition
        if dsp.rand(0, 100) > 20:
            next_zone = dsp.randchoose(zones)

            if next_zone['name'] != zone['name']:
                next_section = make_section(next_zone)

                transition_zone = {
                    'name': ['transition', section[-1]['name'][0], next_section[0]['name'][0]],
                    'register': (section[-1]['register'], next_section[0]['register']),
                    'density': (section[-1]['density'], next_section[0]['density']),
                    'harmonicity': (section[-1]['harmonicity'], next_section[0]['harmonicity']),
                    'roughness': (section[-1]['roughness'], next_section[0]['roughness']),
                    'pace': (section[-1]['pace'], next_section[0]['pace']),
                }

                transition_section = make_section(transition_zone)

                sections += transition_section
                sections += next_section

    dsp.log('telemetry generated')
    settings.shared('tel', sections)
예제 #37
0
    def worker(gens, tick):
        while time.time() < started + (60 * 12.5):
            dsp.delay(dsp.stf(dsp.rand(2, 20)))

            if dsp.rand(0, 100) > 60:
                v = dsp.rand(0, 100)

                if v > 65:
                    voice_id, generator_name = settings.add_voice("ch re qu")
                    dsp.log("")
                    dsp.log("starting chirp voice %s" % voice_id)
                elif v > 35:
                    voice_id, generator_name = settings.add_voice("bi re qu")
                    dsp.log("")
                    dsp.log("starting bird voice %s" % voice_id)
                else:
                    voice_id, generator_name = settings.add_voice("bo re qu")
                    dsp.log("")
                    dsp.log("starting boone voice %s" % voice_id)

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

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

                dsp.log("")
                dsp.log("stopping voice %s" % voice_id)
                settings.voice(voice_id, "loop", 0)