shithub: orca

Download patch

ref: e94e3c9f064b0b152679009a3673a3e6c07331b2
parent: 54983e79f525cb86636d43ac1d6b729c9177b393
author: cancel <cancel@cancel.fm>
date: Thu Dec 20 22:07:05 EST 2018

Add osc operator '='

--- a/bank.h
+++ b/bank.h
@@ -50,11 +50,13 @@
   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 {
--- a/sim.c
+++ b/sim.c
@@ -383,7 +383,8 @@
   _('!', keys)                                                                 \
   _('#', comment)                                                              \
   _('*', bang)                                                                 \
-  _(':', midi)
+  _(':', midi)                                                                 \
+  _('=', osc)
 
 #define ORCA_DUAL_OPERATORS(_)                                                 \
   _('A', 'a', add)                                                             \
@@ -502,6 +503,40 @@
   oe->note = note_num;
   oe->velocity = midi_velocity_of(velocity_g);
   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)
--- a/tui_main.c
+++ b/tui_main.c
@@ -70,6 +70,7 @@
     return Glyph_class_movement;
   case '!':
   case ':':
+  case '=':
     return Glyph_class_lowercase;
   case '*':
     return Glyph_class_bang;
@@ -96,6 +97,7 @@
   case '*':
   case ':':
   case ';':
+  case '=':
   case '#':
     return true;
   }
@@ -540,8 +542,9 @@
     } 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]);
       }