main process: provisional decoding of midi messages
This commit is contained in:
parent
847af03dc7
commit
804e1cb738
2 changed files with 31 additions and 9 deletions
2
delay.c
2
delay.c
|
@ -8,7 +8,7 @@ void delay_init(
|
||||||
struct delay * delay
|
struct delay * delay
|
||||||
) {
|
) {
|
||||||
delay->mix = 0.8;
|
delay->mix = 0.8;
|
||||||
delay->feedback = 0.6;
|
delay->feedback = 0.8;
|
||||||
delay->duration = 0;
|
delay->duration = 0;
|
||||||
delay->buf_idx = 0;
|
delay->buf_idx = 0;
|
||||||
delay->buf_capacity = 0;
|
delay->buf_capacity = 0;
|
||||||
|
|
30
guitfx.c
30
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);
|
char * midi_data = SPA_POD_BODY(&c->value);
|
||||||
unsigned size = SPA_POD_BODY_SIZE(&c->value);
|
unsigned size = SPA_POD_BODY_SIZE(&c->value);
|
||||||
|
|
||||||
|
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 cur_tap = frame + c->offset;
|
||||||
uint64_t duration = cur_tap - data->last_tap;
|
uint64_t duration = cur_tap - data->last_tap;
|
||||||
data->last_tap = cur_tap;
|
data->last_tap = cur_tap;
|
||||||
|
|
||||||
printf("duration = %lu\n", duration);
|
|
||||||
if( duration < (4*position->clock.rate.denom) ) {
|
if( duration < (4*position->clock.rate.denom) ) {
|
||||||
delay_set_time( &data->delay, duration );
|
delay_set_time( &data->delay, duration/4 );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xc0:
|
||||||
|
// program change
|
||||||
|
printf("program change: %u\n", midi_data[1]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
printf("[%d] MIDI message (%d bytes) : %x, %x, %x\n", sec, size, midi_data[0], midi_data[1], midi_data[2]);
|
|
||||||
} else {
|
} else {
|
||||||
printf("on_process(): non midi-control\n");
|
printf("on_process(): non midi-control\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue