Ardour does not connect MIDI in to my plug

All your LV2 and LADSPA goodness and more.

Moderators: MattKingUSA, khz

Post Reply
f00bar
Established Member
Posts: 83
Joined: Sun May 12, 2013 7:40 pm

Ardour does not connect MIDI in to my plug

Post by f00bar »

I have problems making my synth connect in Ardour3.5.380. It works fine in Carla 1.9.4. I see that CalfMonosynth (which should work) uses the deprecated lv2Event for MIDI. Should I use lv2event instead of atoms?

Code: Select all

@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix midi: <http://lv2plug.in/ns/ext/midi#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix urid: <http://lv2plug.in/ns/ext/urid#> .

<http://example.org/happychords>
	a lv2:Plugin;
	a lv2:InstrumentPlugin;
	lv2:binary <happychords.so>;
	doap:name "Happychords";
	doap:license <http://usefulinc.com/doap/licenses/gpl>;

lv2:port
	[
	a lv2:InputPort,atom:AtomPort;
	lv2:index 0;
	lv2:symbol "midi_in";
	lv2:name "MIDI in";
	],
	[
	a lv2:OutputPort,lv2:AudioPort;
	lv2:index 1;
	lv2:symbol "output_L";
	lv2:name "Output L";
	],
	[
	a lv2:OutputPort,lv2:AudioPort;
	lv2:index 2;
	lv2:symbol "output_R";
	lv2:name "Output R";
	],[
	a lv2:InputPort,lv2:ControlPort;
	lv2:index 3;
	lv2:symbol "choir_attack" ;
	lv2:name "Choir/Attack";
	lv2:default 0.0009765625 ;
	lv2:minimum 0.0009765625 ;
	lv2:maximum 1.0 ;
	]
	,[
	a lv2:InputPort,lv2:ControlPort;
	lv2:index 4;
	lv2:symbol "choir_decay" ;
	lv2:name "Choir/Decay";
	lv2:default 0.0009765625 ;
	lv2:minimum 0.0009765625 ;
	lv2:maximum 1.0 ;
	]
	,[
	a lv2:InputPort,lv2:ControlPort;
	lv2:index 5;
	lv2:symbol "choir_sustain" ;
	lv2:name "Choir/Sustain";
	lv2:default 0.5 ;
	lv2:minimum 0.0 ;
	lv2:maximum 1.0 ;
	]
	,[
	a lv2:InputPort,lv2:ControlPort;
	lv2:index 6;
	lv2:symbol "choir_release" ;
	lv2:name "Choir/Release";
	lv2:default 0.0009765625 ;
	lv2:minimum 0.0009765625 ;
	lv2:maximum 1.0 ;
	],[
	a lv2:InputPort,lv2:ControlPort;
	lv2:index 7;
	lv2:symbol "choir_detune" ;
	lv2:name "Choir/Detune";
	lv2:default 0.0009765625 ;
	lv2:minimum 0.0009765625 ;
	lv2:maximum 1.0 ;
	].
The connection code:

Code: Select all

void Happychords::Client::portConnect(uint32_t port,void* data)
	{
	switch(port)
		{
		case 0:
			midi_in=(const LV2_Atom_Sequence*)data;
			break;
		case 1:
			output_L=(float*)data;
			break;
		case 2:
			output_R=(float*)data;
			break;
		case 3:
			choir_attack=(const float*)data;
			break;
		case 4:
			choir_decay=(const float*)data;
			break;
		case 5:
			choir_sustain=(const float*)data;
			break;
		case 6:
			choir_release=(const float*)data;
			break;
		case 7:
			choir_detune=(const float*)data;
			break;			
		}
	}
Main processing loop:

Code: Select all

void Happychords::Client::process(uint32_t n_frames)
	{
	if(!midi_in || !output_L || !output_R || !choir_attack || !choir_decay
		|| !choir_sustain || !choir_release || !choir_detune)
		{
		/* eg. ARDOUR::LV2Plugin::latency_compute_run()
		* -> midi ports are not yet connected
		*/
		printf("Not connected!\n"
			"    midi_in: %p\n"
			"    output_L: %p\n"
			"    output_R: %p\n"
			"    choir_attack: %p\n"
			"    choir_decay: %p\n"
			"    choir_sustain: %p\n"
			"    choir_release: %p\n"
			"    choir_detune: %p\n"
			,midi_in,output_L,output_R,choir_attack,choir_decay
			,choir_sustain,choir_release,choir_detune);
		return;
		}
	
	parametersUpdate();

	/* process events on the midiin port */
	LV2_Atom_Event* ev = lv2_atom_sequence_begin(&(midi_in->body));

	while(!lv2_atom_sequence_is_end(&(midi_in->body)
		,midi_in->atom.size,ev))
		{
		printf("This is a message\n");
		if(ev->body.type==features.midi())
			{
			const uint8_t* const msg=(const uint8_t*)(ev + 1);
			switch(lv2_midi_message_type(msg))
				{
				case LV2_MIDI_MSG_NOTE_ON:
					noteStart(msg[1],msg[2]);
					break;
				case LV2_MIDI_MSG_NOTE_OFF:
					noteStop(msg[1]);
					break;
				default:
					break;
				}
			}
		/*
		else
		if(ev->body.type==_this->id_BLANK || ev->body.type==_this->id_OBJECT)
			{
			const LV2_Atom_Object* obj = (LV2_Atom_Object*)&ev->body;
			if (obj->body.otype == _this->id_POSITION)
				{
				update_position(self, obj);
				}
			}*/
		
		ev = lv2_atom_sequence_next(ev);
		}

	auto L=output_L;
	auto R=output_R;
	while(n_frames)
		{
		auto v=generatorsMix();
		*L=v.x;
		*R=v.y;
		++L;
		++R;
		--n_frames;
		}
	}
I get the following output:

Not connected!
midi_in: (nil)
output_L: 0xb590500
output_R: 0xb590680
choir_attack: 0xa7bafdc
choir_decay: 0xa7bafe0
choir_sustain: 0xa7bafe4
choir_release: 0xa7bafe8
choir_detune: 0xa7bafec
f00bar
Established Member
Posts: 83
Joined: Sun May 12, 2013 7:40 pm

Re: Ardour does not connect MIDI in to my plug

Post by f00bar »

falkTX wrote:your midi in port is missing a few things.

particularly:

Code: Select all

        atom:bufferType atom:Sequence ;
        atom:supports <http://lv2plug.in/ns/ext/midi#MidiEvent> ;
If the port accepts any other kind of message type (like timePos) add it as well, like this:

Code: Select all

        atom:supports <http://lv2plug.in/ns/ext/midi#MidiEvent> ,
                      <http://lv2plug.in/ns/ext/time#Position> ;
Now it works
ssj71
Established Member
Posts: 1294
Joined: Tue Sep 25, 2012 6:36 pm
Has thanked: 1 time

Re: Ardour does not connect MIDI in to my plug

Post by ssj71 »

foobar:

Just FYI, you can post these questions in the developers section of the forum rather than plugins and effects, just so its easier for people to reference in the future. :)
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
Post Reply