aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-08-10 22:44:36 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-08-10 22:44:36 +0200
commit3ee28866cf4a3cd5f0c228bcd6eb1b50782f07ef (patch)
tree57e9c4f5a9138a1ce6415f4b0101d4157d5e8925
parenteaa81041f81195d2020d1190fa6b1d0fc7da6505 (diff)
downloadpatchmatrix-3ee28866cf4a3cd5f0c228bcd6eb1b50782f07ef.tar.xz
mixer: properly parse 14bit MIDI messages.
-rw-r--r--VERSION2
-rw-r--r--patchmatrix_mixer.c28
2 files changed, 19 insertions, 11 deletions
diff --git a/VERSION b/VERSION
index 4e8f395..83b4730 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.26.0
+0.27.1
diff --git a/patchmatrix_mixer.c b/patchmatrix_mixer.c
index 243062a..55cdd35 100644
--- a/patchmatrix_mixer.c
+++ b/patchmatrix_mixer.c
@@ -55,6 +55,21 @@ _jack_on_info_shutdown_cb(jack_status_t code, const char *reason, void *arg)
}
static inline void
+_midi_handle_data(mixer_app_t *mixer, uint8_t chn)
+{
+ const uint8_t nrpn_msb = mixer->nrpn[chn] >> 7;
+ const uint8_t nrpn_lsb = mixer->nrpn[chn] & 0x7f;
+ mixer_shm_t *shm = mixer->shm;
+
+ if( (nrpn_msb < shm->nsources) && (nrpn_lsb < shm->nsinks) )
+ {
+ const int32_t mBFS = (float)(mixer->data[chn] - 0x1fff)/0x2000 * 3600.f;
+
+ atomic_store_explicit(&shm->jgains[nrpn_msb][nrpn_lsb], mBFS, memory_order_relaxed);
+ }
+}
+
+static inline void
_midi_handle(mixer_app_t *mixer, jack_midi_event_t *ev)
{
const uint8_t cmd = ev->buffer[0] & 0xf0;
@@ -84,22 +99,15 @@ _midi_handle(mixer_app_t *mixer, jack_midi_event_t *ev)
{
mixer->data[chn] &= 0x3f80;
mixer->data[chn] |= val;
+
+ _midi_handle_data(mixer, chn);
} break;
case 0x06: // DATA_MSB
{
mixer->data[chn] &= 0x7f;
mixer->data[chn] |= (val << 7);
- const uint8_t nrpn_msb = mixer->nrpn[chn] >> 7;
- const uint8_t nrpn_lsb = mixer->nrpn[chn] & 0x7f;
- mixer_shm_t *shm = mixer->shm;
-
- if( (nrpn_msb < shm->nsources) && (nrpn_lsb < shm->nsinks) )
- {
- const int32_t mBFS = (float)(mixer->data[chn] - 0x1fff)/0x2000 * 3600.f;
-
- atomic_store_explicit(&shm->jgains[nrpn_msb][nrpn_lsb], mBFS, memory_order_relaxed);
- }
+ _midi_handle_data(mixer, chn);
} break;
}
}