mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-MIDI IO class error checking
This commit is contained in:
parent
7f96d72d77
commit
f700c2bd4e
2 changed files with 28 additions and 11 deletions
|
@ -26,7 +26,8 @@ extern Jack* jack;
|
||||||
|
|
||||||
MidiIO::MidiIO() :
|
MidiIO::MidiIO() :
|
||||||
jackInputPort(0),
|
jackInputPort(0),
|
||||||
jackOutputPort(0)
|
jackOutputPort(0),
|
||||||
|
portsRegistered(false)
|
||||||
{
|
{
|
||||||
//LUPPP_NOTE("MidiIO %i",this);
|
//LUPPP_NOTE("MidiIO %i",this);
|
||||||
}
|
}
|
||||||
|
@ -62,25 +63,34 @@ void MidiIO::writeMidi( unsigned char* data )
|
||||||
|
|
||||||
int MidiIO::registerMidiPorts(std::string name)
|
int MidiIO::registerMidiPorts(std::string name)
|
||||||
{
|
{
|
||||||
|
if( !jack )
|
||||||
|
{
|
||||||
|
LUPPP_ERROR("Attempted register of controller, JACK not instantiated yet!");
|
||||||
|
return LUPPP_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
jack_client_t* c = jack->getJackClientPointer();
|
||||||
|
|
||||||
// register the JACK MIDI ports
|
// register the JACK MIDI ports
|
||||||
stringstream i;
|
stringstream i;
|
||||||
i << name << " in";
|
i << name << " in";
|
||||||
jackInputPort = jack_port_register( jack->getJackClientPointer(),
|
jackInputPort = jack_port_register( c,
|
||||||
i.str().c_str(),
|
i.str().c_str(),
|
||||||
JACK_DEFAULT_MIDI_TYPE,
|
JACK_DEFAULT_MIDI_TYPE,
|
||||||
JackPortIsInput,
|
JackPortIsInput,
|
||||||
0 );
|
0 );
|
||||||
stringstream o;
|
stringstream o;
|
||||||
o << name << " out";
|
o << name << " out";
|
||||||
jackOutputPort = jack_port_register( jack->getJackClientPointer(),
|
jackOutputPort = jack_port_register( c,
|
||||||
o.str().c_str(),
|
o.str().c_str(),
|
||||||
JACK_DEFAULT_MIDI_TYPE,
|
JACK_DEFAULT_MIDI_TYPE,
|
||||||
JackPortIsOutput,
|
JackPortIsOutput,
|
||||||
0 );
|
0 );
|
||||||
|
|
||||||
if ( jackInputPort && jackOutputPort )
|
if ( jackInputPort && jackOutputPort )
|
||||||
{
|
{
|
||||||
//LUPPP_NOTE("%i, %i", jackInputPort, jackOutputPort );
|
//LUPPP_NOTE("%i, %i", jackInputPort, jackOutputPort );
|
||||||
|
portsRegistered = true;
|
||||||
return LUPPP_RETURN_OK;
|
return LUPPP_RETURN_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -93,6 +103,9 @@ int MidiIO::registerMidiPorts(std::string name)
|
||||||
|
|
||||||
void MidiIO::initBuffers(int nframes)
|
void MidiIO::initBuffers(int nframes)
|
||||||
{
|
{
|
||||||
|
if ( !portsRegistered )
|
||||||
|
return;
|
||||||
|
|
||||||
// clear the output buffer
|
// clear the output buffer
|
||||||
void* outputBuffer= (void*) jack_port_get_buffer( jackOutputPort, nframes );
|
void* outputBuffer= (void*) jack_port_get_buffer( jackOutputPort, nframes );
|
||||||
jack_midi_clear_buffer( outputBuffer );
|
jack_midi_clear_buffer( outputBuffer );
|
||||||
|
@ -100,6 +113,9 @@ void MidiIO::initBuffers(int nframes)
|
||||||
|
|
||||||
void MidiIO::process(int nframes)
|
void MidiIO::process(int nframes)
|
||||||
{
|
{
|
||||||
|
if ( !portsRegistered )
|
||||||
|
return;
|
||||||
|
|
||||||
// get port buffers and setup
|
// get port buffers and setup
|
||||||
void* inputBuffer = (void*) jack_port_get_buffer( jackInputPort, nframes );
|
void* inputBuffer = (void*) jack_port_get_buffer( jackInputPort, nframes );
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ class MidiIO
|
||||||
void writeMidi( unsigned char* /*data*/ );
|
void writeMidi( unsigned char* /*data*/ );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool portsRegistered;
|
||||||
// there are jack_port_t* registered ports
|
// there are jack_port_t* registered ports
|
||||||
jack_port_t* jackInputPort;
|
jack_port_t* jackInputPort;
|
||||||
jack_port_t* jackOutputPort;
|
jack_port_t* jackOutputPort;
|
||||||
|
|
Loading…
Add table
Reference in a new issue