Browse Source

Add start of osc operator

master
cancel 6 years ago
parent
commit
54983e79f5
  1. 9
      bank.h
  2. 38
      tui_main.c

9
bank.h

@ -34,6 +34,7 @@ Usz bank_read(char const* restrict bank_data, Usz bank_size,
typedef enum {
Oevent_type_midi,
Oevent_type_osc_ints,
} Oevent_types;
typedef struct {
@ -49,9 +50,17 @@ typedef struct {
U8 bar_divisor;
} Oevent_midi;
typedef struct {
U8 oevent_type;
Glyph glyph;
U8 count;
U8 numbers[4];
} Oevent_osc_ints;
typedef union {
Oevent_any any;
Oevent_midi midi;
Oevent_osc_ints osc_ints;
} Oevent;
typedef struct {

38
tui_main.c

@ -532,13 +532,21 @@ void draw_oevent_list(WINDOW* win, Oevent_list const* oevent_list) {
Oevent_types evt = ev->any.oevent_type;
switch (evt) {
case Oevent_type_midi: {
Oevent_midi const* em = (Oevent_midi const*)ev;
Oevent_midi const* em = &ev->midi;
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);
break;
}
} break;
case Oevent_type_osc_ints: {
Oevent_osc_ints const* eo = &ev->osc_ints;
wprintw(win, "OSC Ints\tname %c\tcount %d", eo->glyph, eo->count,
eo->count);
for (Usz i = 0; i < eo->count; ++i) {
wprintw(win, " %d", eo->numbers[i]);
}
(void)eo;
} break;
}
}
}
@ -819,7 +827,7 @@ void send_output_events(Oosc_dev* oosc_dev, Midi_mode const* midi_mode, Usz bpm,
Oevent const* e = events + i;
switch ((Oevent_types)e->any.oevent_type) {
case Oevent_type_midi: {
Oevent_midi const* em = (Oevent_midi const*)&e->midi;
Oevent_midi const* em = &e->midi;
Usz note_number = (Usz)(12u * em->octave + em->note);
Usz channel = em->channel;
Usz bar_div = em->bar_divisor;
@ -837,12 +845,23 @@ void send_output_events(Oosc_dev* oosc_dev, Midi_mode const* midi_mode, Usz bpm,
#endif
++midi_note_count;
} break;
case Oevent_type_osc_ints: {
Oevent_osc_ints const* eo = &e->osc_ints;
char path_buff[3];
path_buff[0] = '/';
path_buff[1] = eo->glyph;
path_buff[2] = 0;
I32 ints[ORCA_ARRAY_COUNTOF(eo->numbers)];
Usz nnum = eo->count;
for (Usz inum = 0; inum < nnum; ++inum) {
ints[inum] = eo->numbers[inum];
}
oosc_send_int32s(oosc_dev, path_buff, ints, nnum);
} break;
}
}
if (midi_note_count == 0)
return;
if (midi_note_count > 0 && midi_mode) {
Usz start_note_offs, end_note_offs;
susnote_list_add_notes(susnote_list, new_susnotes, midi_note_count,
&start_note_offs, &end_note_offs);
@ -866,6 +885,7 @@ void send_output_events(Oosc_dev* oosc_dev, Midi_mode const* midi_mode, Usz bpm,
} break;
}
}
}
}
double ged_secs_to_deadline(Ged const* a) {
@ -923,12 +943,10 @@ void ged_do_stuff(Ged* a) {
a->is_draw_dirty = true;
Usz count = a->oevent_list.count;
if (oosc_dev && midi_mode) {
if (count > 0) {
if (oosc_dev && count > 0) {
send_output_events(oosc_dev, midi_mode, a->bpm, &a->susnote_list,
a->oevent_list.buffer, count);
}
}
a->meter_level += (float)count * 0.2f;
a->meter_level = float_clamp(a->meter_level, 0.0f, 1.0f);
// note for future: sustained note deadlines may have changed due to note

Loading…
Cancel
Save