Browse Source

Add osc operator '='

master
cancel 6 years ago
parent
commit
e94e3c9f06
  1. 4
      bank.h
  2. 37
      sim.c
  3. 5
      tui_main.c

4
bank.h

@ -50,11 +50,13 @@ typedef struct {
U8 bar_divisor;
} Oevent_midi;
enum { Oevent_osc_int_count = 4 };
typedef struct {
U8 oevent_type;
Glyph glyph;
U8 count;
U8 numbers[4];
U8 numbers[Oevent_osc_int_count];
} Oevent_osc_ints;
typedef union {

37
sim.c

@ -383,7 +383,8 @@ Usz usz_clamp(Usz val, Usz min, Usz max) {
_('!', keys) \
_('#', comment) \
_('*', bang) \
_(':', midi)
_(':', midi) \
_('=', osc)
#define ORCA_DUAL_OPERATORS(_) \
_('A', 'a', add) \
@ -504,6 +505,40 @@ BEGIN_SOLO_PHASE_1(midi)
oe->bar_divisor = (U8)usz_clamp(index_of(length_g), 1, Glyphs_index_max);
END_PHASE
BEGIN_SOLO_PHASE_0(osc)
BEGIN_ACTIVE_PORTS
PORT(0, -2, IN | HASTE);
PORT(0, -1, IN | HASTE);
Usz len = index_of(PEEK(0, -1)) + 1;
if (len > Oevent_osc_int_count)
len = Oevent_osc_int_count;
for (Usz i = 0; i < len; ++i) {
PORT(0, (Isz)i + 1, IN);
}
END_PORTS
END_PHASE
BEGIN_SOLO_PHASE_1(osc)
STOP_IF_NOT_BANGED;
Glyph g = PEEK(0, -2);
if (g != '.') {
Usz len = index_of(PEEK(0, -1)) + 1;
if (len > Oevent_osc_int_count)
len = Oevent_osc_int_count;
U8 buff[Oevent_osc_int_count];
for (Usz i = 0; i < len; ++i) {
buff[i] = (U8)index_of(PEEK(0, (Isz)i + 1));
}
Oevent_osc_ints* oe =
&oevent_list_alloc_item(extra_params->oevent_list)->osc_ints;
oe->oevent_type = (U8)Oevent_type_osc_ints;
oe->glyph = g;
oe->count = (U8)len;
for (Usz i = 0; i < len; ++i) {
oe->numbers[i] = buff[i];
}
}
END_PHASE
BEGIN_DUAL_PHASE_0(add)
REALIZE_DUAL;
BEGIN_DUAL_PORTS

5
tui_main.c

@ -70,6 +70,7 @@ static Glyph_class glyph_class_of(Glyph glyph) {
return Glyph_class_movement;
case '!':
case ':':
case '=':
return Glyph_class_lowercase;
case '*':
return Glyph_class_bang;
@ -96,6 +97,7 @@ static bool is_valid_glyph(Glyph c) {
case '*':
case ':':
case ';':
case '=':
case '#':
return true;
}
@ -540,8 +542,9 @@ void draw_oevent_list(WINDOW* win, Oevent_list const* oevent_list) {
} 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,
wprintw(win, "OSC\t%c\tcount: %d ", eo->glyph, eo->count,
eo->count);
waddch(win, ACS_VLINE);
for (Usz i = 0; i < eo->count; ++i) {
wprintw(win, " %d", eo->numbers[i]);
}

Loading…
Cancel
Save