diff --git a/bank.h b/bank.h index 73f4d63..28d0361 100644 --- a/bank.h +++ b/bank.h @@ -13,7 +13,7 @@ typedef struct { typedef struct { U8 oevent_type; - U8 channel, octave, note, velocity, bar_divisor; + U8 channel, octave, note, velocity, duration; } Oevent_midi; enum { Oevent_osc_int_count = 16 }; diff --git a/sim.c b/sim.c index d540d11..779552a 100644 --- a/sim.c +++ b/sim.c @@ -321,7 +321,7 @@ BEGIN_OPERATOR(midi) oe->octave = octave_num; oe->note = note_num; oe->velocity = (U8)vel_num; - oe->bar_divisor = (U8)(index_of(length_g) + 1); + oe->duration = (U8)(index_of(length_g)); END_OPERATOR BEGIN_OPERATOR(udp) diff --git a/tui_main.c b/tui_main.c index 2ebb5b0..3e96223 100644 --- a/tui_main.c +++ b/tui_main.c @@ -631,7 +631,7 @@ void draw_oevent_list(WINDOW *win, Oevent_list const *oevent_list) { wprintw(win, "MIDI\tchannel %d\toctave %d\tnote %d\tvelocity %d\tlength %d", (int)em->channel, (int)em->octave, (int)em->note, - (int)em->velocity, (int)em->bar_divisor); + (int)em->velocity, (int)em->duration); break; } case Oevent_type_osc_ints: { @@ -1026,7 +1026,7 @@ void send_output_events(Oosc_dev *oosc_dev, Midi_mode const *midi_mode, Usz bpm, Susnote_list *susnote_list, Oevent const *events, Usz count) { Midi_mode_type midi_mode_type = midi_mode->any.type; - double bar_secs = 60.0 / (double)bpm * 4.0; + double frame_secs = 60.0 / (double)bpm / 4.0; enum { Midi_on_capacity = 512 }; typedef struct { @@ -1049,15 +1049,14 @@ void send_output_events(Oosc_dev *oosc_dev, Midi_mode const *midi_mode, Usz bpm, if (note_number > 127) note_number = 127; Usz channel = em->channel; - Usz bar_div = em->bar_divisor; + Usz duration = em->duration; midi_note_ons[midi_note_count] = (Midi_note_on){.channel = (U8)channel, .note_number = (U8)note_number, .velocity = em->velocity}; - new_susnotes[midi_note_count] = (Susnote){ - .remaining = - bar_div == 0 ? 0.0f : (float)(bar_secs / (double)bar_div), - .chan_note = (U16)((channel << 8u) | note_number)}; + new_susnotes[midi_note_count] = + (Susnote){.remaining = (float)(frame_secs * (double)duration), + .chan_note = (U16)((channel << 8u) | note_number)}; #if 0 fprintf(stderr, "bar div: %d, time: %f\n", (int)bar_div, new_susnotes[midi_note_count].remaining);