cwScoreFollow2.h/cpp,cwScoreFollow2Test.cpp : on_new_note() now returns score velocity.
This commit is contained in:
parent
4558a2fcd7
commit
c292c009e9
@ -239,7 +239,7 @@ namespace cw
|
||||
|
||||
}
|
||||
|
||||
rc_t _trkr_on_new_note( trkr_t* trk, double sec, unsigned pitch, unsigned vel, bool rpt_fl, unsigned& matched_loc_id_ref )
|
||||
rc_t _trkr_on_new_note( trkr_t* trk, double sec, unsigned pitch, unsigned vel, bool rpt_fl, unsigned& matched_loc_id_ref, unsigned& score_vel_ref )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
double d_corr_sec = 0.0;
|
||||
@ -257,6 +257,7 @@ namespace cw
|
||||
unsigned match_ni = kInvalidIdx;
|
||||
double match_val = 0;
|
||||
|
||||
score_vel_ref = -1;
|
||||
matched_loc_id_ref = kInvalidId;
|
||||
|
||||
assert( trk->exp_loc_idx != kInvalidIdx && trk->exp_loc_idx < trk->sf->locN );
|
||||
@ -362,6 +363,7 @@ namespace cw
|
||||
trk->loc_match_cntA[ match_loc_idx ] += 1;
|
||||
trk->note_match_cntA[ match_ni ] += 1;
|
||||
|
||||
score_vel_ref = trk->sf->noteA[ match_ni ].vel;
|
||||
matched_loc_id_ref = match_loc_id;
|
||||
|
||||
// notice if we arrived at the end of the score tracking range
|
||||
@ -805,7 +807,7 @@ errLabel:
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::score_follow_2::create( handle_t& hRef, const args_t& args )
|
||||
cw::rc_t cw::score_follow_2::create( handle_t& hRef, const args_t& args, perf_score::handle_t scoreH )
|
||||
{
|
||||
rc_t rc;
|
||||
if((rc = destroy(hRef)) != kOkRC )
|
||||
@ -813,10 +815,10 @@ cw::rc_t cw::score_follow_2::create( handle_t& hRef, const args_t& args )
|
||||
|
||||
sf_t* p = mem::allocZ<sf_t>();
|
||||
|
||||
if((rc = _get_loc_and_note_count( p, args.scoreH )) != kOkRC )
|
||||
if((rc = _get_loc_and_note_count( p, scoreH )) != kOkRC )
|
||||
goto errLabel;
|
||||
|
||||
if((rc = _alloc_fill_loc_and_note_arrays( p, args.scoreH )) != kOkRC )
|
||||
if((rc = _alloc_fill_loc_and_note_arrays( p, scoreH )) != kOkRC )
|
||||
goto errLabel;
|
||||
|
||||
if((rc = _alloc_and_fill_loc_note_arrays( p )) != kOkRC )
|
||||
@ -894,18 +896,19 @@ cw::rc_t cw::score_follow_2::reset( handle_t h, unsigned beg_loc_id, unsigned en
|
||||
|
||||
_trkr_reset(p->trk,beg_loc_id);
|
||||
|
||||
cwLogInfo("SF2 reset: %i %i",beg_loc_id,end_loc_id);
|
||||
|
||||
errLabel:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::score_follow_2::on_new_note( handle_t h, unsigned uid, double sec, uint8_t pitch, uint8_t vel, unsigned& loc_id )
|
||||
cw::rc_t cw::score_follow_2::on_new_note( handle_t h, unsigned uid, double sec, uint8_t pitch, uint8_t vel, unsigned& matched_loc_id_ref, unsigned& score_vel_ref )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
sf_t* p = _handleToPtr(h);
|
||||
unsigned matched_loc_id = kInvalidId;
|
||||
|
||||
_trkr_on_new_note(p->trk,sec,pitch,vel, p->args.rpt_fl, matched_loc_id);
|
||||
_trkr_on_new_note(p->trk,sec,pitch,vel, p->args.rpt_fl, matched_loc_id_ref, score_vel_ref);
|
||||
|
||||
if( p->resultN < p->resultAllocN )
|
||||
{
|
||||
@ -913,7 +916,7 @@ cw::rc_t cw::score_follow_2::on_new_note( handle_t h, unsigned uid, double sec,
|
||||
r->perf_uid = uid;
|
||||
r->perf_pitch = pitch;
|
||||
r->perf_vel = vel;
|
||||
r->match_loc_id = matched_loc_id;
|
||||
r->match_loc_id = matched_loc_id_ref;
|
||||
p->resultN += 1;
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,20 @@ namespace cw
|
||||
typedef handle< struct sf_str > handle_t;
|
||||
|
||||
typedef struct args_str
|
||||
{
|
||||
perf_score::handle_t scoreH;
|
||||
|
||||
{
|
||||
double pre_affinity_sec; // 1.0 look back affinity duration
|
||||
double post_affinity_sec; // 3.0 look forward affinity duration
|
||||
double pre_wnd_sec; // 2.0 look back search window
|
||||
double post_wnd_sec; // 5.0 look forward search window
|
||||
|
||||
double decay_coeff; // 0.995affinity decay coeff
|
||||
double decay_coeff; // 0.995 affinity decay coeff
|
||||
|
||||
double d_sec_err_thresh_lo; // 0.4 reject if d_loc > d_loc_thresh_lod and d_time > d_time_thresh_lo
|
||||
int d_loc_thresh_lo; // 3
|
||||
int d_loc_thresh_lo; // 3
|
||||
|
||||
double d_sec_err_thresh_hi; // 1.5 reject if d_loc != 0 and d_time > d_time_thresh_hi
|
||||
int d_loc_thresh_hi; // 4 reject if d_loc > d_loc_thresh_hi
|
||||
int d_loc_stats_thresh; // 3 reject for time stats updates if d_loc > d_loc_stats_thresh
|
||||
int d_loc_thresh_hi; // 4 reject if d_loc > d_loc_thresh_hi
|
||||
int d_loc_stats_thresh; // 3 reject for time stats updates if d_loc > d_loc_stats_thresh
|
||||
|
||||
bool rpt_fl; // set to turn on debug reporting
|
||||
|
||||
@ -29,13 +27,13 @@ namespace cw
|
||||
|
||||
rc_t parse_args( const object_t* cfg, args_t& args );
|
||||
|
||||
rc_t create( handle_t& hRef, const args_t& args );
|
||||
rc_t create( handle_t& hRef, const args_t& args, perf_score::handle_t scoreH );
|
||||
|
||||
rc_t destroy( handle_t& hRef );
|
||||
|
||||
rc_t reset( handle_t h, unsigned beg_loc_id, unsigned end_loc_id );
|
||||
|
||||
rc_t on_new_note( handle_t h, unsigned uid, double sec, uint8_t pitch, uint8_t vel, unsigned& loc_id );
|
||||
rc_t on_new_note( handle_t h, unsigned uid, double sec, uint8_t pitch, uint8_t vel, unsigned& loc_id_ref, unsigned& score_vel_ref );
|
||||
|
||||
// Decay the affinity window and if necessary trigger a cycle of async background processing
|
||||
rc_t do_exec( handle_t h );
|
||||
|
@ -138,10 +138,8 @@ namespace cw
|
||||
|
||||
//cwLogInfo("Following: (%i notes found) sample count:%i %s.",mf.evtN,mf.sampleN,midi_csv_fname);
|
||||
|
||||
sf_args.scoreH = scoreH;
|
||||
|
||||
// create the score-follower
|
||||
if((rc = score_follow_2::create(sfH,sf_args)) != kOkRC )
|
||||
if((rc = score_follow_2::create(sfH,sf_args,scoreH)) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(rc,"Score follower create failed.");
|
||||
goto errLabel;
|
||||
@ -159,11 +157,12 @@ namespace cw
|
||||
while( smp_idx <= mf.evtA[midi_evt_idx].sample_idx && mf.evtA[midi_evt_idx].sample_idx < smp_idx + smp_per_cycle )
|
||||
{
|
||||
const midi_evt_t* e = mf.evtA + midi_evt_idx++;
|
||||
unsigned loc_id;
|
||||
|
||||
unsigned loc_id = kInvalidId;
|
||||
unsigned score_vel = -1;
|
||||
|
||||
//printf("%f pitch:%i vel:%i\n",e->sec,e->pitch,e->vel);
|
||||
|
||||
if((rc = on_new_note( sfH, e->uid, e->sec, e->pitch, e->vel, loc_id )) != kOkRC )
|
||||
if((rc = on_new_note( sfH, e->uid, e->sec, e->pitch, e->vel, loc_id, score_vel )) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(rc,"SF2 note processing failed on note UID:%i.",e->uid);
|
||||
goto errLabel;
|
||||
|
Loading…
Reference in New Issue
Block a user