cwScoreFollower.h/cpp : Added cw_loc_range(),is_loc_in_range() and has_stored_performance().

This commit is contained in:
kevin 2023-05-21 12:41:50 -04:00
parent 54bcfeac53
commit 9f58e34f87
2 changed files with 46 additions and 0 deletions

View File

@ -422,6 +422,46 @@ void cw::score_follower::clear_match_id_array( handle_t h )
p->match_id_curN = 0; p->match_id_curN = 0;
} }
cw::rc_t cw::score_follower::cw_loc_range( handle_t h, unsigned& minLocRef, unsigned& maxLocRef )
{
rc_t rc = kOkRC;
score_follower_t* p = _handleToPtr(h);
minLocRef = kInvalidId;
maxLocRef = kInvalidId;
if( p->cwLocToCmLocA==nullptr || p->cwLocToCmLocN == 0 )
{
rc = cwLogError(kInvalidStateRC,"The cw location range is not yet set.");
goto errLabel;
}
minLocRef = 1;
maxLocRef = p->cwLocToCmLocN-1;
errLabel:
return rc;
}
bool cw::score_follower::is_loc_in_range( handle_t h, unsigned loc )
{
rc_t rc;
unsigned minLoc = 0;
unsigned maxLoc = 0;
if((rc = cw_loc_range(h,minLoc,maxLoc)) != kOkRC )
return false;
return minLoc <= loc && loc <= maxLoc;
}
unsigned cw::score_follower::has_stored_performance( handle_t h )
{
score_follower_t* p = _handleToPtr(h);
return p->perf_idx > 0;
}
cw::rc_t cw::score_follower::write_svg_file( handle_t h, const char* out_fname, bool show_muid_fl ) cw::rc_t cw::score_follower::write_svg_file( handle_t h, const char* out_fname, bool show_muid_fl )
{ {
score_follower_t* p = _handleToPtr(h); score_follower_t* p = _handleToPtr(h);

View File

@ -24,6 +24,12 @@ namespace cw
// Clear the match id array. This should be done to empty the current_match_id_array() // Clear the match id array. This should be done to empty the current_match_id_array()
void clear_match_id_array( handle_t h ); void clear_match_id_array( handle_t h );
rc_t cw_loc_range( handle_t h, unsigned& minLocRef, unsigned& maxLocRef );
bool is_loc_in_range( handle_t h, unsigned loc );
unsigned has_stored_performance( handle_t h );
// Write an SVG file containing a graphic view of the score following results since the last call to reset(). // Write an SVG file containing a graphic view of the score following results since the last call to reset().
// Set show_muid_fl to true to display the 'muid' of the performed notes in the // Set show_muid_fl to true to display the 'muid' of the performed notes in the
// SVG rendering, otherwise the performed note sequence (order of arrival) id is shown. // SVG rendering, otherwise the performed note sequence (order of arrival) id is shown.