cwInterface.cpp,cwScoreFollower.cpp : Initial non-realtime score follower.
This commit is contained in:
parent
ab40711eee
commit
47a5bbe06a
@ -58,15 +58,16 @@ namespace cw
|
|||||||
{
|
{
|
||||||
if( p != nullptr )
|
if( p != nullptr )
|
||||||
{
|
{
|
||||||
cmTsFinalize();
|
|
||||||
cmFsFinalize();
|
|
||||||
cmMdReport( kIgnoreNormalMmFl );
|
|
||||||
cmMdFinalize();
|
|
||||||
|
|
||||||
cmLHeapDestroy(&p->lhH);
|
cmLHeapDestroy(&p->lhH);
|
||||||
cmSymTblDestroy(&p->symTblH);
|
cmSymTblDestroy(&p->symTblH);
|
||||||
cmProcCtxFree(&p->procCtx);
|
cmProcCtxFree(&p->procCtx);
|
||||||
|
|
||||||
|
cmTsFinalize();
|
||||||
|
cmFsFinalize();
|
||||||
|
cmMdReport( kIgnoreNormalMmFl );
|
||||||
|
cmMdFinalize();
|
||||||
|
|
||||||
mem::release(p);
|
mem::release(p);
|
||||||
}
|
}
|
||||||
return kOkRC;
|
return kOkRC;
|
||||||
|
@ -95,9 +95,9 @@ namespace cw
|
|||||||
rc_t _destroy( score_follower_t* p)
|
rc_t _destroy( score_follower_t* p)
|
||||||
{
|
{
|
||||||
mem::release(p->score_csv_fname);
|
mem::release(p->score_csv_fname);
|
||||||
mem::release(p);
|
|
||||||
cmScMatcherFree(&p->matcher);
|
cmScMatcherFree(&p->matcher);
|
||||||
cmScoreFinalize(&p->cmScoreH);
|
cmScoreFinalize(&p->cmScoreH);
|
||||||
|
mem::release(p);
|
||||||
return kOkRC;
|
return kOkRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,24 +107,35 @@ namespace cw
|
|||||||
score_follower_t* p = (score_follower_t*)arg;
|
score_follower_t* p = (score_follower_t*)arg;
|
||||||
cmScoreEvt_t* cse;
|
cmScoreEvt_t* cse;
|
||||||
|
|
||||||
// get a pointer to the matched event
|
printf("%4i %4i %4i %3i %3i %4s : ", r->locIdx, r->mni, r->muid, r->flags, r->pitch, midi::midiToSciPitch( r->pitch, nullptr, 0 ));
|
||||||
if((cse = cmScoreEvt( p->cmScoreH, r->scEvtIdx )) == nullptr )
|
|
||||||
|
if( r->scEvtIdx == cmInvalidIdx )
|
||||||
{
|
{
|
||||||
cwLogError(kInvalidStateRC,"cm Score event index (%i) reported by the score follower is invalid.",r->scEvtIdx );
|
printf("MISS\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( p->match_id_curN >= p->match_id_allocN )
|
// get a pointer to the matched event
|
||||||
|
if((cse = cmScoreEvt( p->cmScoreH, r->scEvtIdx )) == nullptr )
|
||||||
{
|
{
|
||||||
cwLogError(kInvalidStateRC,"The score follower match id array is full.");
|
cwLogError(kInvalidStateRC,"cm Score event index (%i) reported by the score follower is invalid.",r->scEvtIdx );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// the csvEventId corresponds to the cwPianoScore location
|
if( p->match_id_curN >= p->match_id_allocN )
|
||||||
p->match_idA[ p->match_id_curN++ ] = cse->csvEventId;
|
{
|
||||||
|
cwLogError(kInvalidStateRC,"The score follower match id array is full.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// the csvEventId corresponds to the cwPianoScore location
|
||||||
|
p->match_idA[ p->match_id_curN++ ] = cse->csvEventId;
|
||||||
|
|
||||||
|
printf("%i MATCH\n",p->match_id_curN);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,8 +164,7 @@ cw::rc_t cw::score_follower::create( handle_t& hRef, const object_t* cfg, cm::ha
|
|||||||
cwLogError(kOpFailRC,"The score could not be initialized from '%s'. cmRC:%i.",p->score_csv_fname);
|
cwLogError(kOpFailRC,"The score could not be initialized from '%s'. cmRC:%i.",p->score_csv_fname);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if((p->matcher = cmScMatcherAlloc( cmProcCtx, // Program context.
|
if((p->matcher = cmScMatcherAlloc( cmProcCtx, // Program context.
|
||||||
nullptr, // Existing cmScMatcher to reallocate or NULL to allocate a new cmScMatcher.
|
nullptr, // Existing cmScMatcher to reallocate or NULL to allocate a new cmScMatcher.
|
||||||
srate, // System sample rate.
|
srate, // System sample rate.
|
||||||
@ -170,7 +180,7 @@ cw::rc_t cw::score_follower::create( handle_t& hRef, const object_t* cfg, cm::ha
|
|||||||
|
|
||||||
|
|
||||||
p->srate = srate;
|
p->srate = srate;
|
||||||
p->match_id_allocN = 128;
|
p->match_id_allocN = cmScoreEvtCount( p->cmScoreH )*2; // give plenty of extra space for the match_idA[]
|
||||||
p->match_idA = mem::allocZ<unsigned>(p->match_id_allocN);
|
p->match_idA = mem::allocZ<unsigned>(p->match_id_allocN);
|
||||||
|
|
||||||
hRef.set(p);
|
hRef.set(p);
|
||||||
@ -205,12 +215,17 @@ cw::rc_t cw::score_follower::destroy( handle_t& hRef )
|
|||||||
|
|
||||||
cw::rc_t cw::score_follower::reset( handle_t h, unsigned loc )
|
cw::rc_t cw::score_follower::reset( handle_t h, unsigned loc )
|
||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
//score_follower_t* p = _handleToPtr(h);
|
cmRC_t cmRC = cmOkRC;
|
||||||
|
score_follower_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
// cmRC_t cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx );
|
|
||||||
|
|
||||||
|
if((cmRC = cmScMatcherReset( p->matcher, loc )) != cmOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(kOpFailRC,"The score follower reset failed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
errLabel:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,6 +387,9 @@ cw::rc_t cw::score_follower::test( const object_t* cfg )
|
|||||||
if((rc = create( sfH, t.cfg, cmCtxH, t.srate )) != kOkRC )
|
if((rc = create( sfH, t.cfg, cmCtxH, t.srate )) != kOkRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
|
if((rc = reset( sfH, 0)) != kOkRC )
|
||||||
|
goto errLabel;
|
||||||
|
|
||||||
// open the midi file
|
// open the midi file
|
||||||
if((rc = midi::file::open( t.mfH, t.midi_fname )) != kOkRC )
|
if((rc = midi::file::open( t.mfH, t.midi_fname )) != kOkRC )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user