aboutsummaryrefslogtreecommitdiff
path: root/monitors_midi_pianoroll.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-08 19:26:52 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-08 19:26:52 +0200
commitd05a4c4029f570c78b45cb23146546c466e5a6ec (patch)
tree0e8f2190a70483c61744de715549032fd2fc5f3e /monitors_midi_pianoroll.c
parent256d951fec898eadd004f5a5cc11e3ecd6a4a14b (diff)
downloadmonitors.lv2-d05a4c4029f570c78b45cb23146546c466e5a6ec.tar.xz
fix handling of midi channel in pianoroll.
Diffstat (limited to 'monitors_midi_pianoroll.c')
-rw-r--r--monitors_midi_pianoroll.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/monitors_midi_pianoroll.c b/monitors_midi_pianoroll.c
index c16423a..b72e3cf 100644
--- a/monitors_midi_pianoroll.c
+++ b/monitors_midi_pianoroll.c
@@ -56,7 +56,7 @@ struct _plugstate_t {
int32_t vflip;
float aspect_ratio;
uint8_t graph [MAX_GRAPH];
- int32_t midi_channel;
+ int32_t channel;
};
struct _plughandle_t {
@@ -110,6 +110,13 @@ _out_of_memory(plughandle_t *handle)
_craft_clear(&handle->notify);
}
+static inline void
+_clear_state(plughandle_t *handle)
+{
+ memset(handle->actives, 0x0, sizeof(handle->actives));
+ memset(handle->passives, 0x0, sizeof(handle->passives));
+}
+
static void
_render(plughandle_t *handle, int64_t frames)
{
@@ -252,13 +259,19 @@ _intercept_window(void *data, int64_t frames, props_impl_t *impl)
{
plughandle_t *handle = data;
- // clear note states
- memset(handle->actives, 0x0, sizeof(handle->actives));
- memset(handle->passives, 0x0, sizeof(handle->passives));
-
handle->range = 1e-3 * handle->sample_rate * handle->state.window;
handle->range_1 = 1.f / handle->range;
+ _clear_state(handle);
+ _render(handle, frames);
+}
+
+static void
+_intercept_channel(void *data, int64_t frames, props_impl_t *impl)
+{
+ plughandle_t *handle = data;
+
+ _clear_state(handle);
_render(handle, frames);
}
@@ -297,9 +310,10 @@ static const props_def_t defs [MAX_NPROPS] = {
.type = LV2_ATOM__Float
},
{
- .property = LV2_MIDI__channel,
- .offset = offsetof(plugstate_t, midi_channel),
- .type = LV2_ATOM__Int
+ .property = MONITORS__channel,
+ .offset = offsetof(plugstate_t, channel),
+ .type = LV2_ATOM__Int,
+ .event_cb = _intercept_channel
}
};
@@ -482,7 +496,7 @@ _handle_midi(plughandle_t *handle, int64_t frames, uint32_t size, const uint8_t
{
const uint8_t cha = msg[0] & 0x0f;
- if(cha == handle->state.midi_channel)
+ if(cha == handle->state.channel)
{
_note_on(handle, frames, msg[1], msg[2]);
}
@@ -492,7 +506,7 @@ _handle_midi(plughandle_t *handle, int64_t frames, uint32_t size, const uint8_t
{
const uint8_t cha = msg[0] & 0x0f;
- if(cha == handle->state.midi_channel)
+ if(cha == handle->state.channel)
{
_note_off(handle, frames, msg[1]);
}