shithub: orca

Download patch

ref: f11a1911dc769ff6353bf3ac4ab1a9ec13471bb4
parent: af326b6e9ae14448d73326c0e6740e605000597e
author: cancel <cancel@cancel.fm>
date: Sun Dec 30 14:26:12 EST 2018

Add working midi out with fixed timings

--- a/osc_out.c
+++ b/osc_out.c
@@ -216,7 +216,7 @@
   for (Usz i = 0; i < count;) {
     Susnote sn = buffer[i];
     sn.remaining -= delta_float;
-    if (sn.remaining > 0) {
+    if (sn.remaining > 0.001) {
       if (sn.remaining < soonest)
         soonest = sn.remaining;
       buffer[i].remaining = sn.remaining;
--- a/sim.c
+++ b/sim.c
@@ -365,7 +365,7 @@
   oe->octave = (U8)usz_clamp(octave_num, 1, 9);
   oe->note = note_num;
   oe->velocity = midi_velocity_of(velocity_g);
-  oe->bar_divisor = (U8)usz_clamp(index_of(length_g), 1, Glyphs_index_count);
+  oe->bar_divisor = (U8)(index_of(length_g) + 1);
 END_OPERATOR
 
 BEGIN_OPERATOR(osc)
--- a/tui_main.c
+++ b/tui_main.c
@@ -896,7 +896,7 @@
                         Susnote_list* susnote_list, Oevent const* events,
                         Usz count) {
   Midi_mode_type midi_mode_type = midi_mode->any.type;
-  double bar_secs = (double)bpm / 60.0;
+  double bar_secs = 60.0 / (double)bpm * 4.0;
 
   enum { Midi_on_capacity = 512 };
   typedef struct {
@@ -1028,8 +1028,6 @@
   double secs = stm_sec(stm_since(a->clock));
   a->meter_level -= (float)secs;
   a->meter_level = float_clamp(a->meter_level, 0.0f, 1.0f);
-  apply_time_to_sustained_notes(oosc_dev, midi_mode, secs, &a->susnote_list,
-                                &a->time_to_next_note_off);
   if (!a->is_playing)
     return;
   bool do_play = false;
@@ -1068,6 +1066,8 @@
   }
 #endif
   if (do_play) {
+    apply_time_to_sustained_notes(oosc_dev, midi_mode, secs_span,
+                                  &a->susnote_list, &a->time_to_next_note_off);
     orca_run(a->field.buffer, a->markmap_r.buffer, a->field.height,
              a->field.width, a->tick_num, &a->oevent_list, a->piano_bits);
     ++a->tick_num;