diff --git a/cwIo.cpp b/cwIo.cpp index 515a9c6..024f215 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -9,7 +9,7 @@ #include "cwIo.h" #include "cwMidi.h" -#include "cwMidiPort.h" +#include "cwMidiDevice.h" #include "cwObject.h" @@ -609,7 +609,7 @@ namespace cw msg_t m; midi_msg_t mm; const midi::packet_t* pkt = pktArray + i; - io_t* p = reinterpret_cast(pkt->cbDataPtr); + io_t* p = reinterpret_cast(pkt->cbArg); rc_t rc = kOkRC; @@ -633,7 +633,6 @@ namespace cw rc_t _midiPortCreate( io_t* p, const object_t* c ) { rc_t rc = kOkRC; - unsigned parserBufByteN = 1024; const object_t* cfg = nullptr; // get the MIDI port cfg @@ -643,14 +642,12 @@ namespace cw return kOkRC; } - if((rc = cfg->getv("parserBufByteN", parserBufByteN, - "asyncFl", p->midiAsyncFl )) != kOkRC ) + if((rc = cfg->getv("asyncFl", p->midiAsyncFl )) != kOkRC ) { rc = cwLogError(kSyntaxErrorRC,"MIDI configuration parse failed."); } - // initialie the MIDI system - if((rc = create(p->midiH, _midiCallback, p, parserBufByteN, "app")) != kOkRC ) + if((rc = create(p->midiH, _midiCallback, p, cfg)) != kOkRC ) return rc; @@ -3807,7 +3804,7 @@ void cw::io::latency_measure_setup(handle_t h) p->latency_meas_result.audio_out_rms_max = 0; if( p->midiH.isValid() ) - latency_measure_setup(p->midiH); + latency_measure_reset(p->midiH); } cw::io::latency_meas_result_t cw::io::latency_measure_result(handle_t h) @@ -3816,10 +3813,10 @@ cw::io::latency_meas_result_t cw::io::latency_measure_result(handle_t h) if( p->midiH.isValid() ) { - midi::device::latency_meas_result_t r = latency_measure_result(p->midiH); + midi::device::latency_meas_combined_result_t r = latency_measure_result(p->midiH); - p->latency_meas_result.note_on_input_ts = r.note_on_input_ts; - p->latency_meas_result.note_on_output_ts = r.note_on_output_ts; + p->latency_meas_result.note_on_input_ts = r.alsa_dev.note_on_input_ts; + p->latency_meas_result.note_on_output_ts = r.alsa_dev.note_on_output_ts; } return p->latency_meas_result; diff --git a/cwIoAudioMidi.cpp b/cwIoAudioMidi.cpp index 96324a3..b7ebc07 100644 --- a/cwIoAudioMidi.cpp +++ b/cwIoAudioMidi.cpp @@ -870,8 +870,8 @@ namespace cw am->devIdx = pkt->devIdx; am->portIdx = pkt->portIdx; am->timestamp = mm->timeStamp; - am->ch = mm->status & 0x0f; - am->status = mm->status & 0xf0; + am->ch = mm->ch; + am->status = mm->status; am->d0 = mm->d0; am->d1 = mm->d1; diff --git a/cwIoMidiRecordPlay.cpp b/cwIoMidiRecordPlay.cpp index 228ca2e..bdaa225 100644 --- a/cwIoMidiRecordPlay.cpp +++ b/cwIoMidiRecordPlay.cpp @@ -1355,7 +1355,7 @@ namespace cw { //printf("R:%i %i %i\n",mm->status, mm->d0, mm->d1); - const am_midi_msg_t* am = _midi_store( p, pkt->devIdx, pkt->portIdx, mm->timeStamp, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 ); + const am_midi_msg_t* am = _midi_store( p, pkt->devIdx, pkt->portIdx, mm->timeStamp, mm->ch, mm->status, mm->d0, mm->d1 ); if( p->thruFl && am != nullptr ) _transmit_msg( p, am, false ); diff --git a/cwIoPresetSelApp.cpp b/cwIoPresetSelApp.cpp index 8f630e3..c38c9b7 100644 --- a/cwIoPresetSelApp.cpp +++ b/cwIoPresetSelApp.cpp @@ -1142,8 +1142,8 @@ namespace cw if( midi::isChStatus(mm->status) ) { - if(midi_record_play::send_midi_msg( app->mrpH, midi_record_play::kSampler_MRP_DevIdx, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 ) == kOkRC ) - _midi_play_callback( app, midi_record_play::kMidiEventActionId, id, timestamp, loc, nullptr, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 ); + if(midi_record_play::send_midi_msg( app->mrpH, midi_record_play::kSampler_MRP_DevIdx, mm->ch, mm->status, mm->d0, mm->d1 ) == kOkRC ) + _midi_play_callback( app, midi_record_play::kMidiEventActionId, id, timestamp, loc, nullptr, mm->ch, mm->status, mm->d0, mm->d1 ); } } diff --git a/cwMidiDecls.h b/cwMidiDecls.h index 9e456fb..9746385 100644 --- a/cwMidiDecls.h +++ b/cwMidiDecls.h @@ -8,21 +8,25 @@ namespace cw typedef struct msg_str { time::spec_t timeStamp; - uint8_t status; // midi status byte - uint8_t d0; // midi data byte 0 - uint8_t d1; // midi data byte 1 - uint8_t pad; + unsigned uid; // application specified id + uint8_t ch; // midi channel + uint8_t status; // midi status byte (channel has been removed) + uint8_t d0; // midi data byte 0 + uint8_t d1; // midi data byte 1 } msg_t; typedef struct packet_str { - void* cbDataPtr; // Application supplied reference value + void* cbArg; // Application supplied reference value unsigned devIdx; // The device the msg originated from unsigned portIdx; // The port index on the source device msg_t* msgArray; // Pointer to an array of 'msgCnt' mdMsg records or NULL if sysExMsg is non-NULL uint8_t* sysExMsg; // Pointer to a sys-ex msg or NULL if msgArray is non-NULL (see note below) unsigned msgCnt; // Count of mdMsg records or sys-ex bytes } packet_t; + + typedef void (*cbFunc_t)( const packet_t* pktArray, unsigned pktCnt ); + } } #endif diff --git a/cwMidiPort.cpp b/cwMidiDevice.cpp similarity index 100% rename from cwMidiPort.cpp rename to cwMidiDevice.cpp diff --git a/cwMidiPort.h b/cwMidiDevice.h similarity index 100% rename from cwMidiPort.h rename to cwMidiDevice.h