parse MIDI even if not connected

This commit is contained in:
Volker Fischer 2019-09-27 18:15:22 +02:00
parent d19bd6fc36
commit 4407c8805a

View file

@ -254,35 +254,6 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
} }
} }
// akt on MIDI data if MIDI is enabled
if ( pSound->input_port_midi != NULL )
{
void* in_midi = jack_port_get_buffer (
pSound->input_port_midi, nframes );
if ( in_midi != 0 )
{
jack_nframes_t event_count = jack_midi_get_event_count ( in_midi );
for ( jack_nframes_t j = 0; j < event_count; j++ )
{
jack_midi_event_t in_event;
jack_midi_event_get ( &in_event, in_midi, j );
// copy packet and send it to the MIDI parser
// TODO do not call malloc in real-time callback
CVector<uint8_t> vMIDIPaketBytes ( in_event.size );
for ( i = 0; i < static_cast<int> ( in_event.size ); i++ )
{
vMIDIPaketBytes[i] = static_cast<uint8_t> ( in_event.buffer[i] );
}
pSound->ParseMIDIMessage ( vMIDIPaketBytes );
}
}
}
// call processing callback function // call processing callback function
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo ); pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
@ -332,6 +303,34 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
} }
} }
// akt on MIDI data if MIDI is enabled
if ( pSound->input_port_midi != NULL )
{
void* in_midi = jack_port_get_buffer ( pSound->input_port_midi, nframes );
if ( in_midi != 0 )
{
jack_nframes_t event_count = jack_midi_get_event_count ( in_midi );
for ( jack_nframes_t j = 0; j < event_count; j++ )
{
jack_midi_event_t in_event;
jack_midi_event_get ( &in_event, in_midi, j );
// copy packet and send it to the MIDI parser
// TODO do not call malloc in real-time callback
CVector<uint8_t> vMIDIPaketBytes ( in_event.size );
for ( i = 0; i < static_cast<int> ( in_event.size ); i++ )
{
vMIDIPaketBytes[i] = static_cast<uint8_t> ( in_event.buffer[i] );
}
pSound->ParseMIDIMessage ( vMIDIPaketBytes );
}
}
}
return 0; // zero on success, non-zero on error return 0; // zero on success, non-zero on error
} }