cwPianoScore.h/cpp : Added loc_to_measure() and loc_to_next_note_on_measure()
This commit is contained in:
parent
6a9351b043
commit
b680d46487
@ -325,6 +325,17 @@ namespace cw
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const event_t* _loc_to_event( score_t* p, unsigned loc )
|
||||||
|
{
|
||||||
|
const event_t* e = p->base;
|
||||||
|
for(; e!=nullptr; e=e->link)
|
||||||
|
if( e->loc == loc )
|
||||||
|
return e;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,10 +478,31 @@ bool cw::score::is_loc_valid( handle_t h, unsigned locId )
|
|||||||
return locId < p->maxLocId;
|
return locId < p->maxLocId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned cw::score::loc_to_measure( handle_t h, unsigned locId )
|
||||||
|
{
|
||||||
|
score_t* p = _handleToPtr(h);
|
||||||
|
const event_t* e;
|
||||||
|
if((e = _loc_to_event(p,locId)) == nullptr )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return kInvalidId;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned cw::score::loc_to_next_note_on_measure( handle_t h, unsigned locId )
|
||||||
|
{
|
||||||
|
score_t* p = _handleToPtr(h);
|
||||||
|
const event_t* e = _loc_to_event(p,locId);
|
||||||
|
|
||||||
|
while( e != nullptr )
|
||||||
|
if( midi::isNoteOn(e->status))
|
||||||
|
return e->meas;
|
||||||
|
|
||||||
|
return kInvalidId;
|
||||||
|
}
|
||||||
|
|
||||||
const cw::score::event_t* cw::score::uid_to_event( handle_t h, unsigned uid )
|
const cw::score::event_t* cw::score::uid_to_event( handle_t h, unsigned uid )
|
||||||
{
|
{
|
||||||
|
//hscore_t* p = _handleToPtr(h);
|
||||||
score_t* p = _handleToPtr(h);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +39,12 @@ namespace cw
|
|||||||
|
|
||||||
unsigned loc_count( handle_t h );
|
unsigned loc_count( handle_t h );
|
||||||
bool is_loc_valid( handle_t h, unsigned locId );
|
bool is_loc_valid( handle_t h, unsigned locId );
|
||||||
|
unsigned loc_to_measure( handle_t h, unsigned locId );
|
||||||
|
unsigned loc_to_next_note_on_measure( handle_t h, unsigned locId );
|
||||||
|
|
||||||
const event_t* uid_to_event( handle_t h, unsigned uid );
|
const event_t* uid_to_event( handle_t h, unsigned uid );
|
||||||
|
|
||||||
|
|
||||||
// Format the event as a string for printing.
|
// Format the event as a string for printing.
|
||||||
rc_t event_to_string( handle_t h, unsigned uid, char* buf, unsigned buf_byte_cnt );
|
rc_t event_to_string( handle_t h, unsigned uid, char* buf, unsigned buf_byte_cnt );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user