cwIoMidiRecordPlay.cpp : _stop() now checks p->startedFl before executing stop actions.
This prevents multiple kPlayerStoppedActionId's from being sent to app. seek() now calls _midi_state_clear() instead of _stop(). This fixes problem which prevented preset sequencing in app.
This commit is contained in:
parent
3e4230bf5d
commit
141bd8da73
@ -20,7 +20,7 @@ namespace cw
|
||||
namespace midi_record_play
|
||||
{
|
||||
enum {
|
||||
kStoppedMidiStateId,
|
||||
kStoppedMidiStateId = 0,
|
||||
kPlayingMidiStateId,
|
||||
kStoppingMidiStateId
|
||||
};
|
||||
@ -194,7 +194,6 @@ namespace cw
|
||||
// initialze the midi state to all-notes-off and all controllers=0
|
||||
void _midi_state_clear( midi_record_play_t* p)
|
||||
{
|
||||
|
||||
for(unsigned i=0; i<p->midiDevN; ++i)
|
||||
{
|
||||
for(unsigned j=0; j<midi::kMidiNoteCnt; ++j)
|
||||
@ -205,7 +204,6 @@ namespace cw
|
||||
|
||||
p->midiDevA[i].midi_state.state = kPlayingMidiStateId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void _midi_state_set_state( midi_record_play_t* p, unsigned stateId )
|
||||
@ -1148,6 +1146,8 @@ namespace cw
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
||||
if( p->startedFl )
|
||||
{
|
||||
p->startedFl = false;
|
||||
|
||||
time::spec_t t1;
|
||||
@ -1185,11 +1185,11 @@ namespace cw
|
||||
|
||||
}
|
||||
|
||||
_midi_state_clear(p);
|
||||
|
||||
if( p->cb != nullptr )
|
||||
p->cb( p->cb_arg, kPlayerStoppedActionId, kInvalidId, t1, kInvalidId, 0, 0, 0, 0 );
|
||||
|
||||
|
||||
_midi_state_clear(p);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1561,68 +1561,13 @@ cw::rc_t cw::midi_record_play::load( handle_t h, const midi_msg_t* msg, unsigned
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
cw::rc_t cw::midi_record_play::seek( handle_t h, time::spec_t seek_timestamp )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
bool damp_down_fl = false; // TODO: track pedals on all channels
|
||||
bool sost_down_fl = false;
|
||||
bool soft_down_fl = false;
|
||||
|
||||
midi_record_play_t* p = _handleToPtr(h);
|
||||
|
||||
for(unsigned i=0; i<p->msgArrayInIdx; ++i)
|
||||
{
|
||||
am_midi_msg_t* mm = p->msgArray + i;
|
||||
|
||||
if( time::isLTE(seek_timestamp,mm->timestamp) )
|
||||
{
|
||||
p->msgArrayOutIdx = i;
|
||||
|
||||
_transmit_pedal( p, mm->ch, midi::kSustainCtlMdId, damp_down_fl, 0 );
|
||||
_transmit_pedal( p, mm->ch, midi::kSostenutoCtlMdId, sost_down_fl, 0 );
|
||||
_transmit_pedal( p, mm->ch, midi::kSoftPedalCtlMdId, soft_down_fl, 0 );
|
||||
|
||||
//cwLogInfo("damper: %s.", damp_down_fl ? "down" : "up");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if( mm->status == midi::kCtlMdId )
|
||||
{
|
||||
switch( mm->d0 )
|
||||
{
|
||||
case midi::kSustainCtlMdId:
|
||||
damp_down_fl = mm->d1 > 64;
|
||||
break;
|
||||
|
||||
case midi::kSostenutoCtlMdId:
|
||||
sost_down_fl = mm->d1 > 64;
|
||||
break;
|
||||
|
||||
case midi::kSoftPedalCtlMdId:
|
||||
soft_down_fl = mm->d1 > 64;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
cw::rc_t cw::midi_record_play::seek( handle_t h, time::spec_t seek_timestamp )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
midi_record_play_t* p = _handleToPtr(h);
|
||||
|
||||
// stop and clear the MIDI state
|
||||
_stop(p);
|
||||
// clear the MIDI state
|
||||
_midi_state_clear(p);
|
||||
|
||||
// supress MIDI transmission during the seek
|
||||
p->supressMidiXmitFl = true;
|
||||
@ -1729,7 +1674,7 @@ void cw::midi_record_play::enable_device( handle_t h, unsigned devIdx, bool enab
|
||||
else
|
||||
{
|
||||
p->midiDevA[devIdx].enableFl = enableFl;
|
||||
printf("Enable: %i = %i\n",devIdx,enableFl);
|
||||
//printf("Enable: %i = %i\n",devIdx,enableFl);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user