diff --git a/delay.c b/delay.c index f9a6ea8..c99b818 100644 --- a/delay.c +++ b/delay.c @@ -8,7 +8,7 @@ void delay_init( struct delay * delay ) { delay->mix = 0.8; - delay->feedback = 0.6; + delay->feedback = 0.8; delay->duration = 0; delay->buf_idx = 0; delay->buf_capacity = 0; diff --git a/guitfx.c b/guitfx.c index 71bd06a..02f8a12 100644 --- a/guitfx.c +++ b/guitfx.c @@ -75,15 +75,37 @@ static void on_process(void *userdata, struct spa_io_position *position) char * midi_data = SPA_POD_BODY(&c->value); unsigned size = SPA_POD_BODY_SIZE(&c->value); - uint64_t cur_tap = frame + c->offset; - uint64_t duration = cur_tap - data->last_tap; - data->last_tap = cur_tap; - - printf("duration = %lu\n", duration); - if( duration < (4*position->clock.rate.denom) ) { - delay_set_time( &data->delay, duration ); - } printf("[%d] MIDI message (%d bytes) : %x, %x, %x\n", sec, size, midi_data[0], midi_data[1], midi_data[2]); + + switch( midi_data[0] & 0xff ) { + case 0xb0: + switch( midi_data[1] ) { + case 0x0b: + // expr pedal + float val_f = ((float)midi_data[2]) / 128.0; + printf("Expr Pedal %f\n", val_f); + + data->delay.mix = val_f; + break; + + case 0x42: + // sust pedal + + uint64_t cur_tap = frame + c->offset; + uint64_t duration = cur_tap - data->last_tap; + data->last_tap = cur_tap; + if( duration < (4*position->clock.rate.denom) ) { + delay_set_time( &data->delay, duration/4 ); + } + break; + } + break; + + case 0xc0: + // program change + printf("program change: %u\n", midi_data[1]); + break; + } } else { printf("on_process(): non midi-control\n"); }