~hecanjog/pippi

f3342ef5d04b09fa6b98b1060ee8349841015860 — Erik Schoster 22 days ago cd9efbf main
Some garbage
5 files changed, 32 insertions(+), 14 deletions(-)

M banner.png
M libpippi/orc/ding.py
M libpippi/src/renderer.c
M pippi/midi.pyx
M pippi/mir.pyx
M banner.png => banner.png +0 -0
M libpippi/orc/ding.py => libpippi/orc/ding.py +14 -7
@@ 3,10 3,17 @@ from pippi import dsp, fx, oscs
LOOP = True

def play(ctx):
    #ctx.log('foo')
    #adc = ctx.adc(dsp.rand(0.15, 1), offset=dsp.rand(0, 0.1)) 
    #adc = fx.hpf(adc, dsp.rand(100, 5000))
    out = oscs.SineOsc(freq=dsp.rand(500, 2000)).play(1).env('pluckout') 
    out = out.taper(0.05).pan(dsp.rand())
    #out.dub(adc)
    yield out * 0.2
    ctx.log('foo')
    for _ in range(3):
        adc = ctx.adc(dsp.rand(4, 10), offset=dsp.rand(0, 1)) 
        #adc = fx.hpf(adc, dsp.rand(100, 5000))
        #adc = fx.crush(adc, bitdepth=dsp.rand(8000, 16000), samplerate=dsp.rand(8000, 48000))
        #adc = fx.fold(adc, dsp.rand(5, 10))
        adc = fx.norm(adc, dsp.rand(0.5, 0.85))
        #kkc = fx.bpf(adc, 500)
        adc = adc.speed(shapes('sine', 0.5, 3))
        #adc = adc.env('hann')
        #out = adc.taper(0.05).pan(dsp.rand())
        out = adc.pan(dsp.rand())
        #out = out * dsp.win('pluckout').taper(dsp.MS*30).repeated(dsp.randint(10,100))
        yield out * 0.3

M libpippi/src/renderer.c => libpippi/src/renderer.c +9 -2
@@ 30,18 30,23 @@ int wait_for_play_message() {
    play_cmd = calloc(cmd_size, sizeof(char));
    snprintf(play_cmd, cmd_size, "BLPOP astrid-play-%s 0", instrument_basename);

    printf("Waiting for plays...\n");
    redis_reply = redisCommand(redis_ctx, play_cmd);
    if(strncmp(redis_reply->element[1]->str, PLAY_MESSAGE, 1) == 0) {
        printf("Got PLAY\n");
        status = 1;
    } else if(strncmp(redis_reply->element[1]->str, STOP_MESSAGE, 1) == 0) {
        printf("Got STOP\n");
        status = 0;
    } else if(strncmp(redis_reply->element[1]->str, SHUTDOWN_MESSAGE, 1) == 0) {
        printf("Got SHUTDOWN\n");
        status = 0;
        astrid_is_running = 0;
    } else {
        status = 0;
        fprintf(stderr, "Bad play message: %s\n", redis_reply->element[1]->str);
    }
    printf("play_status %d astrid_is_running %d\n", (int)status, (int)astrid_is_running);

    freeReplyObject(redis_reply);
    free(play_cmd);


@@ 168,7 173,10 @@ int main() {

        /* Wait until a play message arrives on the queue */
        play_status = wait_for_play_message();
        if(play_status == 0) continue;
        if(play_status == 0) {
            printf("play_status == 0, continue\n");
            continue;
        }

        /* Prompt the cyrenderer to check for redis messages and 
         * pass them along to the python instrument module */


@@ 189,7 197,6 @@ int main() {

lprender_thread_cleanup:
    Py_Finalize();
    pthread_exit(0);
    return 0;
}


M pippi/midi.pyx => pippi/midi.pyx +5 -3
@@ 26,8 26,9 @@ def play(list events, int device_index=0):
    for event in events:
        n = int(round(ftom(event.freq)))
        v = int(round(event.amp * 127))
        midi_events += [(event.onset, 'note_on', n, v)]
        midi_events += [(event.onset+event.length, 'note_off', n, 0)]
        c = event.channel or 0
        midi_events += [(event.onset, 'note_on', n, v, c)]
        midi_events += [(event.onset+event.length, 'note_off', n, 0, c)]

    midi_events = sorted(midi_events, key=lambda e: e[0])
    start_time = time.clock_gettime(time.CLOCK_MONOTONIC_RAW)


@@ 45,7 46,8 @@ def play(list events, int device_index=0):
            event = queued

        if elapsed >= event[0]:
            device.send(mido.Message(event[1], note=event[2], velocity=event[3]))
            m = mido.Message(event[1], note=event[2], velocity=event[3], channel=event[4])
            device.send(m)
            queued = None
        else:
            queued = event

M pippi/mir.pyx => pippi/mir.pyx +4 -2
@@ 82,14 82,16 @@ cpdef Wavetable pitch(SoundBuffer snd, double tolerance=0.8, str method=None, in

    cdef lpfloat_t s
    cdef lpfloat_t last_p = -1
    cdef lpfloat_t p = 0
    cdef lpfloat_t p = fallback

    for s in src:
        p = LPPitchTracker.yin_process(yin, s);
        if(p > 0 and p != last_p):
            last_p = p
            pitches += [ p ]

        pitches += [ p ]
    if len(pitches) == 0:
        return None

    return Wavetable(pitches)