cwScoreParse,cwScoreTest,Makefile : Iniital commit.
This commit is contained in:
parent
5e3130503d
commit
1572e23910
13
Makefile.am
13
Makefile.am
@ -67,15 +67,20 @@ libcwSRC += src/libcw/cwIoMidiRecordPlay.cpp src/libcw/cwIoAudioRecordPlay.cpp
|
|||||||
libcwHDR += src/libcw/cwIoPresetSelApp.h src/libcw/cwPianoScore.h src/libcw/cwPresetSel.h src/libcw/cwVelTableTuner.h
|
libcwHDR += src/libcw/cwIoPresetSelApp.h src/libcw/cwPianoScore.h src/libcw/cwPresetSel.h src/libcw/cwVelTableTuner.h
|
||||||
libcwSRC += src/libcw/cwIoPresetSelApp.cpp src/libcw/cwPianoScore.cpp src/libcw/cwPresetSel.cpp src/libcw/cwVelTableTuner.cpp
|
libcwSRC += src/libcw/cwIoPresetSelApp.cpp src/libcw/cwPianoScore.cpp src/libcw/cwPresetSel.cpp src/libcw/cwVelTableTuner.cpp
|
||||||
|
|
||||||
libcwHDR += src/libcw/cwCmInterface.h src/libcw/cwScoreFollower.h
|
libcwHDR += src/libcw/cwScoreFollower.h
|
||||||
libcwSRC += src/libcw/cwCmInterface.cpp src/libcw/cwScoreFollower.cpp
|
libcwSRC += src/libcw/cwScoreFollower.cpp
|
||||||
|
|
||||||
libcwHDR += src/libcw/cwSfScoreParser.h src/libcw/cwSfScore.h src/libcw/cwSfMatch.h src/libcw/cwSfTrack.h
|
libcwHDR += src/libcw/cwDynRefTbl.h src/libcw/cwScoreParse.h src/libcw/cwSfScore.h src/libcw/cwSfMatch.h src/libcw/cwScoreTest.h
|
||||||
libcwSRC += src/libcw/cwSfScoreParser.cpp src/libcw/cwSfScore.cpp src/libcw/cwSfMatch.cpp src/libcw/cwSfTrack.cpp
|
libcwSRC += src/libcw/cwDynRefTbl.cpp src/libcw/cwScoreParse.cpp src/libcw/cwSfScore.cpp src/libcw/cwSfMatch.cpp src/libcw/cwScoreTest.cpp
|
||||||
|
|
||||||
|
libcwHDR += src/libcw/cwSfTrack.h
|
||||||
|
libcwSRC += src/libcw/cwSfTrack.cpp
|
||||||
|
|
||||||
libcwHDR += src/libcw/cwScoreFollowerPerf.h src/libcw/cwMidiState.h src/libcw/cwSvgMidi.h src/libcw/cwSvgScoreFollow.h
|
libcwHDR += src/libcw/cwScoreFollowerPerf.h src/libcw/cwMidiState.h src/libcw/cwSvgMidi.h src/libcw/cwSvgScoreFollow.h
|
||||||
libcwSRC += src/libcw/cwMidiState.cpp src/libcw/cwSvgMidi.cpp src/libcw/cwSvgScoreFollow.cpp
|
libcwSRC += src/libcw/cwMidiState.cpp src/libcw/cwSvgMidi.cpp src/libcw/cwSvgScoreFollow.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
1114
cwScoreParse.cpp
Normal file
1114
cwScoreParse.cpp
Normal file
File diff suppressed because it is too large
Load Diff
147
cwScoreParse.h
Normal file
147
cwScoreParse.h
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
namespace cw
|
||||||
|
{
|
||||||
|
namespace score_parse
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
kInvalidTId,
|
||||||
|
kBarTId,
|
||||||
|
kSectionTId,
|
||||||
|
kBpmTId,
|
||||||
|
kNoteOnTId,
|
||||||
|
kNoteOffTId,
|
||||||
|
kPedalTId,
|
||||||
|
kRestTId,
|
||||||
|
kCtlTId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* opcode_id_to_label( unsigned opId );
|
||||||
|
unsigned opcode_label_to_id( const char* label );
|
||||||
|
|
||||||
|
const char* dyn_ref_id_to_label( unsigned dynId );
|
||||||
|
unsigned dyn_ref_label_to_id( const char* label );
|
||||||
|
|
||||||
|
unsigned attr_char_to_flags( const char* label );
|
||||||
|
const char* attr_flags_to_char( unsigned flag );
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kDynVarFl = 0x0001,
|
||||||
|
kEvenVarFl = 0x0002,
|
||||||
|
kTempoVarFl = 0x0004,
|
||||||
|
kSetEndVarFl = 0x0008,
|
||||||
|
kGraceFl = 0x0010,
|
||||||
|
kTieBegFl = 0x0020,
|
||||||
|
kTieContinueFl = 0x0040,
|
||||||
|
kTieEndFl = 0x0080,
|
||||||
|
kOnsetFl = 0x0100
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kMinVarIdx = 0,
|
||||||
|
kDynVarIdx = kMinVarIdx,
|
||||||
|
kEvenVarIdx,
|
||||||
|
kTempoVarIdx,
|
||||||
|
kVarCnt
|
||||||
|
};
|
||||||
|
|
||||||
|
struct set_str;
|
||||||
|
struct event_str;
|
||||||
|
typedef struct section_str
|
||||||
|
{
|
||||||
|
char* label;
|
||||||
|
unsigned csvRowNumb; // score CSV row number where this section starts
|
||||||
|
unsigned setN;
|
||||||
|
struct set_str** setA;
|
||||||
|
struct event_str* begEvent;
|
||||||
|
struct event_str* endEvent;
|
||||||
|
struct section_str* link;
|
||||||
|
} section_t;
|
||||||
|
|
||||||
|
struct event_str;
|
||||||
|
|
||||||
|
typedef struct set_str
|
||||||
|
{
|
||||||
|
unsigned id;
|
||||||
|
unsigned varTypeId;
|
||||||
|
unsigned eventN;
|
||||||
|
struct event_str** eventA;
|
||||||
|
section_t* targetSection;
|
||||||
|
unsigned sectionSetIdx; // index of this set in the section
|
||||||
|
struct set_str* link;
|
||||||
|
} set_t;
|
||||||
|
|
||||||
|
typedef struct event_var_str
|
||||||
|
{
|
||||||
|
unsigned flags; // var flags
|
||||||
|
set_t* set; // set this event belongs to
|
||||||
|
unsigned setNoteIdx; // the index of this event in it's owner set
|
||||||
|
section_t* target_section; // the target section of this set - if this is the last event in the set
|
||||||
|
} event_var_t;
|
||||||
|
|
||||||
|
typedef struct event_str
|
||||||
|
{
|
||||||
|
unsigned csvRowNumb; // CSV row number this event was derived from
|
||||||
|
unsigned opId; // event type
|
||||||
|
unsigned csvId; // CSV 'index' column
|
||||||
|
section_t* section; // section that this event belongs to
|
||||||
|
unsigned barNumb; //
|
||||||
|
unsigned barEvtIdx; // index of this event in this bar
|
||||||
|
unsigned barPitchIdx; // count of this pitch in this bar
|
||||||
|
unsigned voice;
|
||||||
|
unsigned tick;
|
||||||
|
double sec;
|
||||||
|
double rval;
|
||||||
|
unsigned dotCnt;
|
||||||
|
unsigned dynLevel; // dynamic level based on marker
|
||||||
|
unsigned hash; // [ op_id:4 bar:12 pitch:8 bar_pitch_n:8 ]
|
||||||
|
unsigned loc;
|
||||||
|
unsigned loctn;
|
||||||
|
unsigned oloc;
|
||||||
|
unsigned bpm;
|
||||||
|
unsigned flags;
|
||||||
|
midi::byte_t status;
|
||||||
|
midi::byte_t d0;
|
||||||
|
midi::byte_t d1;
|
||||||
|
char* sciPitch;
|
||||||
|
event_var_t varA[ kVarCnt ];
|
||||||
|
|
||||||
|
} event_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef handle<struct score_parse_str> handle_t;
|
||||||
|
|
||||||
|
const char* opcode_id_to_label( unsigned opId );
|
||||||
|
unsigned opcode_label_to_id( const char* label );
|
||||||
|
|
||||||
|
unsigned var_char_to_flags( const char* label );
|
||||||
|
const char* var_flags_to_char( unsigned flags );
|
||||||
|
const char* var_index_to_char( unsigned var_idx );
|
||||||
|
|
||||||
|
const char* dyn_ref_level_to_label( handle_t h, unsigned vel );
|
||||||
|
unsigned dyn_ref_label_to_level( handle_t h, const char* label );
|
||||||
|
|
||||||
|
unsigned form_hash( unsigned op_id, unsigned bar, uint8_t midi_pitch, unsigned barPitchIdx );
|
||||||
|
void parse_hash( unsigned hash, unsigned& op_idRef, unsigned& barRef, uint8_t& midi_pitchRef, unsigned& barPitchIdxRef );
|
||||||
|
|
||||||
|
rc_t create( handle_t& hRef, const char* fname, double srate, dyn_ref_tbl::handle_t dynRefH );
|
||||||
|
rc_t destroy( handle_t& hRef );
|
||||||
|
|
||||||
|
double sample_rate( handle_t h );
|
||||||
|
|
||||||
|
unsigned event_count( handle_t h );
|
||||||
|
const event_t* event_array( handle_t h );
|
||||||
|
|
||||||
|
unsigned section_count( handle_t h );
|
||||||
|
// Returns a linked list of section records in time order.
|
||||||
|
const section_t* section_list( handle_t h );
|
||||||
|
|
||||||
|
unsigned set_count( handle_t h );
|
||||||
|
// Returns a linked list of sets.
|
||||||
|
const set_t* set_list( handle_t h );
|
||||||
|
|
||||||
|
|
||||||
|
void report( handle_t h );
|
||||||
|
|
||||||
|
// see score_test::test() for testing this object
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
113
cwScoreTest.cpp
Normal file
113
cwScoreTest.cpp
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#include "cwCommon.h"
|
||||||
|
#include "cwLog.h"
|
||||||
|
#include "cwCommonImpl.h"
|
||||||
|
#include "cwMem.h"
|
||||||
|
#include "cwText.h"
|
||||||
|
#include "cwObject.h"
|
||||||
|
#include "cwMidi.h"
|
||||||
|
#include "cwFileSys.h"
|
||||||
|
#include "cwDynRefTbl.h"
|
||||||
|
#include "cwScoreParse.h"
|
||||||
|
#include "cwSfScore.h"
|
||||||
|
#include "cwSfMatch.h"
|
||||||
|
#include "cwSfTrack.h"
|
||||||
|
#include "cwScoreTest.h"
|
||||||
|
|
||||||
|
cw::rc_t cw::score_test::test( const object_t* cfg )
|
||||||
|
{
|
||||||
|
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
const char* cm_score_fname = nullptr;
|
||||||
|
const object_t* dynArrayNode = nullptr;
|
||||||
|
const object_t* sfmatchNode = nullptr;
|
||||||
|
const object_t* sftrackNode = nullptr;
|
||||||
|
bool parse_fl = false;
|
||||||
|
bool parse_report_fl = false;
|
||||||
|
bool score_fl = false;
|
||||||
|
bool score_report_fl = false;
|
||||||
|
bool match_fl = false;
|
||||||
|
bool track_fl = false;
|
||||||
|
double srate = 0;
|
||||||
|
dyn_ref_tbl::handle_t dynRefH;
|
||||||
|
sfscore::handle_t scoreH;
|
||||||
|
score_parse::handle_t spH;
|
||||||
|
|
||||||
|
|
||||||
|
// parse the test cfg
|
||||||
|
if((rc = cfg->getv( "score_fname", cm_score_fname,
|
||||||
|
"srate", srate,
|
||||||
|
"dyn_ref", dynArrayNode,
|
||||||
|
"sfmatch", sfmatchNode,
|
||||||
|
"sftrack", sftrackNode,
|
||||||
|
"parse_fl", parse_fl,
|
||||||
|
"parse_report_fl", parse_report_fl,
|
||||||
|
"score_fl", score_fl,
|
||||||
|
"score_report_fl", score_report_fl,
|
||||||
|
"match_fl", match_fl,
|
||||||
|
"track_fl", track_fl)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"sfscore test parse params failed on.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse the dynamics reference array
|
||||||
|
if((rc = dyn_ref_tbl::create(dynRefH,dynArrayNode)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"The reference dynamics array parse failed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if parsing was requested
|
||||||
|
if( parse_fl )
|
||||||
|
{
|
||||||
|
// create the score_parse object
|
||||||
|
if((rc = score_parse::create(spH,cm_score_fname,srate,dynRefH)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"Score parse failed on '%s'.",cwStringNullGuard(cm_score_fname));
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( parse_report_fl )
|
||||||
|
report(spH);
|
||||||
|
|
||||||
|
// if score processing was requested
|
||||||
|
if( score_fl )
|
||||||
|
{
|
||||||
|
if((rc = create(scoreH,spH)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"Score test create failed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( score_report_fl )
|
||||||
|
report(scoreH,nullptr);
|
||||||
|
|
||||||
|
if( match_fl )
|
||||||
|
{
|
||||||
|
if((rc = sfmatch::test(sfmatchNode,scoreH)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"Score match test failed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( track_fl )
|
||||||
|
{
|
||||||
|
if((rc = sftrack::test(sftrackNode,scoreH)) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"Score track test failed.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
errLabel:
|
||||||
|
destroy(scoreH);
|
||||||
|
destroy(spH);
|
||||||
|
destroy(dynRefH);
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
8
cwScoreTest.h
Normal file
8
cwScoreTest.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace cw
|
||||||
|
{
|
||||||
|
namespace score_test
|
||||||
|
{
|
||||||
|
|
||||||
|
rc_t test( const object_t* cfg );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user