Plugin Remembering the Configured MIDI Channel

I’ve written a plugin which processes MIDI data, but at present it accepts all MIDI Channels. I’d like to be able to configure the MIDI Channel to be used by the plugin and have that channel ‘remembered’ after power cycles of the ModDwarf.

I have mod-plugin-builder installed and have tried to get submodules with ```
git submodule update --init

But the submodules seems to have pulled in a lot of TTL and not much CPP/C so I can't find an example which does this MIDI channel configuration. I assume that when the ModDwarf is powered up the environment will have to pass the previously configured MIDI Channel into the plugin?

Oops just noticed that the format of this message got a bit chewed up.

Just in case it needs clarification, I’m trying to set a MIDI channel on a plugin when the ModDwarf power cycles I want to plugin to come back with the correct configured MIDI Channel.

Look into the MIDI utilities and you should find a MIDI Channel Filter plugin (sorry, can’t remember the exact name) that will allow to pass data only from a specific MIDI channel.

1 Like

Thank you Simon. Got that example and trying to make sense of it. It appears that there’s a CFG port defined which is initialised in the connect_port() method. That’s the high level have to work through it to see how to actually store and retrieve stuff from that config port.

Thanks again for you help

So this is for developing plugins…
The host takes care to save the value of control input ports, nothing you have to do from your side.

1 Like

I assume we’re talking about two different things there falkTX. When my plugin is first powered up let’s say it processes events on MIDI Channel zero. I’d like the user to be able to configure the MIDI Channel which the plugin actually changes, so maybe they set it to seven. So when the plugin is initiated by the ModDwarf system I’d like to say something like:

midi_channel = configured_midi_channel.

I think I can pull that out of the example plugin that Simon pointed me to, at first glance it looks something line an Audo Port, or MIDI Control port which is connected to when the plugin is started, but it’s like a config_memory port or something. So in this connect_port() the line I have to get to the bottom of is “LOOP_CFG(CFG_PORT)”. That might have been covered in an example in the LV2 plugin book, but if so I missed it. And maybe this is a peculiarity of a plugin in the ModDwarf, whereas maybe that configuration would not be something used on a PC. Not used plugins on a PC so wouldn’t know. Anyhow in this connect_port() it’s the line before the ‘default’ case. I think I have to trace that through to see the mechanics of it.

static void
connect_port(LV2_Handle    instance,
		uint32_t   port,
		void*      data)
	MidiFilter* self = (MidiFilter*)instance;

	switch (port) {
		case 0:
			self->midiin = (const LV2_Atom_Sequence*)data;
		case 1:
			self->midiout = (LV2_Atom_Sequence*)data;
		case 2:
			self->latency_port = (float*)data;

there is nothing on the MOD side that does this, so this is something in your plugin.

what you want is just a user-exposed parameter right? so a control input port will work for that.
set it on the ttl as integer with 1-16 range, and you can use that to set the midi channel I guess.