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 ;
].
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;
}
}
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;
}
}
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