cwMiidi.h,cwMidiFile.h/cpp,cwPianoScore.cpp : cwMidi.isNoteOn() now takes the message velocity value as well as the status.
This commit is contained in:
parent
9d704cf77a
commit
15e60b429e
5
cwMidi.h
5
cwMidi.h
@ -87,8 +87,9 @@ namespace cw
|
|||||||
template< typename T> bool isStatus( T s ) { return (kNoteOffMdId <= (s) /*&& ((unsigned)(s)) <= kSysRtResetMdId*/ ); }
|
template< typename T> bool isStatus( T s ) { return (kNoteOffMdId <= (s) /*&& ((unsigned)(s)) <= kSysRtResetMdId*/ ); }
|
||||||
template< typename T> bool isChStatus( T s ) { return (kNoteOffMdId <= (s) && (s) < kSysExMdId); }
|
template< typename T> bool isChStatus( T s ) { return (kNoteOffMdId <= (s) && (s) < kSysExMdId); }
|
||||||
|
|
||||||
template< typename T> bool isNoteOn( T s ) { return ( kNoteOnMdId <= (s) && (s) <= (kNoteOnMdId + kMidiChCnt) ); }
|
template< typename T> bool isNoteOnStatus( T s ) { return ( kNoteOnMdId <= (s) && (s) <= (kNoteOnMdId + kMidiChCnt) ); }
|
||||||
template< typename T> bool isNoteOff( T s, T d1 ) { return ( (isNoteOn(s) && (d1)==0) || (kNoteOffMdId <= (s) && (s) <= (kNoteOffMdId + kMidiChCnt)) ); }
|
template< typename T> bool isNoteOn( T s, T d1 ) { return ( (isNoteOnStatus(s) && (d1)!=0) ); }
|
||||||
|
template< typename T> bool isNoteOff( T s, T d1 ) { return ( (isNoteOnStatus(s) && (d1)==0) || (kNoteOffMdId <= (s) && (s) <= (kNoteOffMdId + kMidiChCnt)) ); }
|
||||||
template< typename T> bool isCtl( T s ) { return ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) ); }
|
template< typename T> bool isCtl( T s ) { return ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) ); }
|
||||||
|
|
||||||
template< typename T> bool isSustainPedal( T s, T d0 ) { return ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) && (d0)== kSustainCtlMdId ); }
|
template< typename T> bool isSustainPedal( T s, T d0 ) { return ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) && (d0)== kSustainCtlMdId ); }
|
||||||
|
@ -1437,7 +1437,7 @@ cw::rc_t cw::midi::file::setVelocity( handle_t h, unsigned uid, uint8_t vel )
|
|||||||
if((r = _uidToMsg(mfp,uid)) == NULL )
|
if((r = _uidToMsg(mfp,uid)) == NULL )
|
||||||
return cwLogError(kInvalidArgRC,"The MIDI file uid %i could not be found.",uid);
|
return cwLogError(kInvalidArgRC,"The MIDI file uid %i could not be found.",uid);
|
||||||
|
|
||||||
if( midi::isNoteOn(r->status) == false && midi::isNoteOff(r->status,(uint8_t)0)==false )
|
if( midi::isNoteOnStatus(r->status) == false && midi::isNoteOff(r->status,(uint8_t)0)==false )
|
||||||
return cwLogError(kInvalidArgRC,"Cannot set velocity on a non-Note-On/Off msg.");
|
return cwLogError(kInvalidArgRC,"Cannot set velocity on a non-Note-On/Off msg.");
|
||||||
|
|
||||||
chMsg_t* chm = (chMsg_t*)r->u.chMsgPtr;
|
chMsg_t* chm = (chMsg_t*)r->u.chMsgPtr;
|
||||||
@ -2033,7 +2033,7 @@ namespace cw
|
|||||||
tmp->u.chMsgPtr->d1);
|
tmp->u.chMsgPtr->d1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( midi::isChStatus(tmp->status) && midi::isNoteOn(tmp->status) && (tmp->u.chMsgPtr->d1>0) )
|
if( midi::isChStatus(tmp->status) && midi::isNoteOn(tmp->status,tmp->u.chMsgPtr->d1) )
|
||||||
cwLogPrintH(logH," %4s ",midi::midiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0));
|
cwLogPrintH(logH," %4s ",midi::midiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0));
|
||||||
|
|
||||||
|
|
||||||
@ -2082,7 +2082,7 @@ namespace cw
|
|||||||
m->u.chMsgPtr->d1);
|
m->u.chMsgPtr->d1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fl = midi::isChStatus(m->status) && midi::isNoteOn(m->status) && (m->u.chMsgPtr->d1>0);
|
bool fl = midi::isChStatus(m->status) && midi::isNoteOn(m->status,m->u.chMsgPtr->d1);
|
||||||
cw::file::printf(fH,",%4s",fl ? midi::midiToSciPitch(m->u.chMsgPtr->d0,NULL,0) : "");
|
cw::file::printf(fH,",%4s",fl ? midi::midiToSciPitch(m->u.chMsgPtr->d0,NULL,0) : "");
|
||||||
|
|
||||||
|
|
||||||
@ -2195,7 +2195,7 @@ cw::rc_t cw::midi::file::genPlotFile( const char* midiFn, const char* outFn )
|
|||||||
return cwLogError(rc,"Unable to create the file '%s'.",cwStringNullGuard(outFn));
|
return cwLogError(rc,"Unable to create the file '%s'.",cwStringNullGuard(outFn));
|
||||||
|
|
||||||
for(i=0; i<mN; ++i)
|
for(i=0; i<mN; ++i)
|
||||||
if( (m[i]!=NULL) && midi::isChStatus(m[i]->status) && midi::isNoteOn(m[i]->status) && (m[i]->u.chMsgPtr->d1>0) )
|
if( (m[i]!=NULL) && midi::isChStatus(m[i]->status) && midi::isNoteOn(m[i]->status,m[i]->u.chMsgPtr->d1) )
|
||||||
cw::file::printf(fH,"n %f %f %i %s\n",m[i]->amicro/1000000.0,m[i]->u.chMsgPtr->durMicros/1000000.0,m[i]->uid,midi::midiToSciPitch(m[i]->u.chMsgPtr->d0,NULL,0));
|
cw::file::printf(fH,"n %f %f %i %s\n",m[i]->amicro/1000000.0,m[i]->u.chMsgPtr->durMicros/1000000.0,m[i]->uid,midi::midiToSciPitch(m[i]->u.chMsgPtr->d0,NULL,0));
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
|
@ -96,7 +96,7 @@ namespace cw
|
|||||||
} u;
|
} u;
|
||||||
} trackMsg_t;
|
} trackMsg_t;
|
||||||
|
|
||||||
inline bool isNoteOn(const trackMsg_t* m) { return midi::isNoteOn(m->status) && (m->u.chMsgPtr->d1>0); }
|
inline bool isNoteOn(const trackMsg_t* m) { return midi::isNoteOn( m->status,m->u.chMsgPtr->d1); }
|
||||||
inline bool isNoteOff(const trackMsg_t* m) { return midi::isNoteOff(m->status,m->u.chMsgPtr->d1); }
|
inline bool isNoteOff(const trackMsg_t* m) { return midi::isNoteOff(m->status,m->u.chMsgPtr->d1); }
|
||||||
|
|
||||||
inline bool isPedalUp(const trackMsg_t* m) { return midi::isPedalUp( m->status, m->u.chMsgPtr->d0, m->u.chMsgPtr->d1); }
|
inline bool isPedalUp(const trackMsg_t* m) { return midi::isPedalUp( m->status, m->u.chMsgPtr->d0, m->u.chMsgPtr->d1); }
|
||||||
|
@ -239,9 +239,9 @@ namespace cw
|
|||||||
rc_t _parse_event_list( score_t* p, const object_t* cfg )
|
rc_t _parse_event_list( score_t* p, const object_t* cfg )
|
||||||
{
|
{
|
||||||
rc_t rc;
|
rc_t rc;
|
||||||
const object_t* eventL;
|
const object_t* eventL = nullptr;
|
||||||
|
|
||||||
if((rc = cfg->getv( "evtL", eventL )) != kOkRC || eventL->is_list()==false )
|
if((rc = cfg->getv( "evtL", eventL )) != kOkRC || eventL==nullptr || eventL->is_list()==false )
|
||||||
rc = cwLogError( rc, "Unable to locate the 'evtL' configuration tag.");
|
rc = cwLogError( rc, "Unable to locate the 'evtL' configuration tag.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -494,7 +494,7 @@ unsigned cw::score::loc_to_next_note_on_measure( handle_t h, unsigned locId )
|
|||||||
const event_t* e = _loc_to_event(p,locId);
|
const event_t* e = _loc_to_event(p,locId);
|
||||||
|
|
||||||
while( e != nullptr )
|
while( e != nullptr )
|
||||||
if( midi::isNoteOn(e->status))
|
if( midi::isNoteOn(e->status,e->d1))
|
||||||
return e->meas;
|
return e->meas;
|
||||||
|
|
||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
|
Loading…
Reference in New Issue
Block a user