// // Copyright 1998-2001 by Craig Stuart Sapp, All Rights Reserved. // Programmer: Craig Stuart Sapp // Creation Date: Mon May 18 13:43:47 PDT 1998 // Last Modified: Mon Oct 16 18:04:47 PDT 2000 Revised for spines and rhythm // Last Modified: Tue Nov 28 11:35:23 PST 2000 Rebuilt deleted include // Last Modified: Sat Dec 2 11:53:10 PST 2000 Added basic assemble command // Last Modified: Wed Dec 6 13:22:08 PST 2000 Added analyzeMetricLevel() // Last Modified: Wed Dec 13 13:52:07 PST 2000 Added analyzeTempoMarkings() // Last Modified: Sat Dec 16 13:37:19 PST 2000 Added analyzeDataIndex() // Last Modified: Sat Dec 16 14:41:14 PST 2000 Added analyzeCliche() // Last Modified: Mon May 14 18:21:37 PDT 2001 Moved chord functions // Last Modified: Mon Nov 5 17:55:54 PST 2001 Added getNextDatum/getLastDatum // Last Modified: Wed Jan 1 16:23:10 PST 2003 Removed Maxwell functions // Last Modified: Thu Aug 21 20:13:10 PDT 2003 Add *free, *strict markers // Last Modified: Wed Jun 16 21:15:06 PDT 2004 Indep. tracks in analyzeKeyKS // Last Modified: Mon Jun 5 06:59:27 PDT 2006 Add fixIrritatingPickupProblem // Last Modified: Fri Jun 12 22:58:34 PDT 2009 Renamed SigCollection class // Last Modified: Sat Sep 5 22:03:28 PDT 2009 ArrayInt to Array // Last Modified: Sun Jun 20 13:42:12 PDT 2010 Added rhythm list) // Last Modified: Mon Sep 16 20:26:17 PDT 2013 Added getMeasureNumber() // Filename: ...sig/include/sigInfo/HumdrumFile.h // Web Address: http://sig.sapp.org/include/sigInfo/HumdrumFile.h // Syntax: C++ // // Description: Higher-level functions for processing Humdrum files. // Inherits HumdrumFileBasic and adds rhythmic and other // types of analyses to the HumdrumFile class. // #ifndef _HUMDRUMFILE_H_INCLUDED #define _HUMDRUMFILE_H_INCLUDED #include #include #include "HumdrumFileBasic.h" #include "NoteList.h" #include "ChordQuality.h" using namespace std; ////////////////////////////// // // HumdrumFile::getNoteList defines // #define NL_NORESTS (0<<0) /* don't include rests in list */ #define NL_RESTS (1<<0) /* include rests */ #define NL_NOFILL (0<<1) /* ignore null tokens */ #define NL_FILL (1<<1) /* expand null token meanings */ #define NL_NOMIDI (0<<2) /* pitch list output in Base-40 note numbers */ #define NL_MIDI (1<<2) /* pitch list output in MIDI note numbers */ #define NL_NOPC (0<<3) /* output pitches with octave information */ #define NL_PC (1<<3) /* output pitch class values */ #define NL_NOSORT (0<<4) /* don't sort pitches from lowest to highest */ #define NL_SORT (1<<4) /* sort pitches from lowest to highest */ #define NL_NOUNIQ (0<<5) /* don't remove redundant pitches */ #define NL_UNIQ (1<<5) /* remove redundant pitches */ #define NL_TIED (0<<6) /* don't remove tied notes */ #define NL_NOTIED (1<<6) /* remove tied notes */ // // HumdrumFile analysis* flag settings // #define DEBUG_BIT 0 #define COMPOUND_METER_BIT 1 #define PITCH_BASE_BIT 2 #define AFLAG_NODEBUG (0<& notes, int line, int flag); int getNoteList (vector& notes, int line, int flag); void getNoteArray (Array& absbeat, Array& pitches, Array& durations, Array& levels, int startLine = 0, int endLine = 0, int tracknum = -1); void getNoteArray2 (Array& absbeat, Array& pitches, Array& durations, Array& levels, Array >& lastpitches, Array >& nextpitches, int startLine = 0, int endLine = 0); double getTiedDuration (int linenum, int field, int token = 0); RationalNumber getTiedDurationR (int linenum, int field, int token = 0); RationalNumber getTotalTiedDurationR(int linenum, int field, int token); double getTiedStartBeat (int linenum, int field, int token = 0); void getTiedStartLocation(int linenum, int field, int token, int& tline, int& tcol, int& ttok); RationalNumber getTiedStartBeatR(int linenum, int field, int token = 0); double getTotalDuration (void); RationalNumber getTotalDurationR(void); HumdrumFile& operator= (const HumdrumFile& aFile); void read (const char* filename); void read (const string& filename); void read (istream& inStream); // analyses that generate internal data void analyzeRhythm (const char* base = "", int debug = 0); void spaceEmptyLines (void); int getMinTimeBase (void); RationalNumber getMinTimeBaseR (void); int rhythmQ (void); void getRhythms (Array& rhys); // // analyses that generate external data // // serialisms void getIntervalVector (Array& iv, int line, int attackQ = 0); const char* getForteSetName (int line); void getNormalForm (Array& norm, int line, int attackQ = 0); void getTnNormalForm (Array& tnorm, int line, int attackQ = 0); void getBase12PitchList (Array& list, int line, int attackQ = 0); const char* getTnSetName (int line, int attackQ = 0); void getTnSetNameAllSubsets(Array& list, int line, int attackQ = 0); void getIntervalVector (vector& iv, int line, int attackQ = 0); string getForteSetNameString (int line); void getNormalForm (vector& norm, int line, int attackQ = 0); void getTnNormalForm (vector& tnorm, int line, int attackQ = 0); void getBase12PitchList (vector& list, int line, int attackQ = 0); string getTnSetNameString (int line, int attackQ = 0); void getTnSetNameAllSubsets(vector& list, int line, int attackQ = 0); void analyzeDataIndex(Array& indices, int segment = -1); // form analyses int analyzeCliche(Array& cliche, double duration, int minimumcount, double start = -1.0, double stop = -1.0); // metrical analyses void analyzeTempoMarkings(Array& tempo, double tdefault = 60.0); void analyzeTempoMarkings(vector& tempo, double tdefault = 60.0); void analyzeMeter(Array& top, Array& bottom, int flag = AFLAG_NOCOMPOUND_METER); void analyzeBeatDuration(Array& beatdur, int flag = AFLAG_COMPOUND_METER); void analyzeAttackAccentuation(Array& atakcent); void analyzeMetricLevel(Array& metlev); void analyzeMetricLevel(vector& metlev); // sonority harmonic analyses void analyzeSonorityQuality(Array& cq); void analyzeSonorityQuality(vector& cq); void analyzeSonorityRoot(Array& roots, int flag = AFLAG_BASE40_PITCH); // Krumhansl-Schmuckler key-finding algorithms int analyzeKeyKS(Array& scores, int startindex, int stopindex, int rhythmQ = 1, int binaryQ = 0, int tracknum = -1); int analyzeKeyKS2(Array& scores, int startindex, int stopindex, double* majorprofile, double* minorprofile, int rhythmQ = 1, int binaryQ = 0, int tracknum = -1); protected: int rhythmcheck; // 1 = rhythm analysis has been done int minrhythm; // the least common multiple of all rhythms RationalNumber minrhythmR; // the least common multiple of all rhythms Array localrhythms; // used with rhythmanalysis RationalNumber pickupdur; // duration of a pickup measure private: int ispoweroftwo (int value); RationalNumber getMinimumRationalRhythm(Array& rhythms); static int intcompare(const void* a, const void* b); void convertKernStringToArray(Array& array, const char* string); // spine analysis functions: void privateSpineAnalysis(void); int predictNewSpineCount(HumdrumRecord& aRecord); void makeNewSpineInfo(SigCollection&spineinfo, HumdrumRecord& aRecord, int newsize, int& spineid, SigCollection& ex); void simplifySpineInfo(SigCollection& info, int index); // rhythm analysis functions: void privateRhythmAnalysis(const char* base = "", int debug = 0); RationalNumber determineDurationR(HumdrumRecord& aRecord, int& init, SigCollection& lastdurations, SigCollection& runningstatus, Array& rhythms, Array& ignore); RationalNumber determineDurationR2(HumdrumRecord& aRecord, int& init, SigCollection& lastdurations, SigCollection& runningstatus, Array& rhythms, Array& ignore); void adjustForSpinePaths(HumdrumRecord& aRecord, SigCollection& lastdurations, SigCollection& runningstatus, int& init, int& datastart, Array& ignore); void adjustForRhythmMarker(HumdrumRecord& aRecord, int state, int spine, SigCollection& lastdurations, SigCollection& runningstatus, int& init, int& datastart, Array& ignore); void fixIncompleteBarMeter(SigCollection& meterbeats, SigCollection& timebase); void fixIncompleteBarMeterR( SigCollection& meterbeats, SigCollection& timebase, const char* base); void fixIrritatingPickupProblem(void); void initializeTracers(SigCollection& lastduration, SigCollection& runningstatus, HumdrumRecord& currRecord); int GCD (int a, int b); int findlcm (Array& rhythms); // determining the meaning of dots (null records) void privateDotAnalysis(void); void readjustDotArrays(Array& lastline, Array& lastspine, HumdrumRecord& record, int newsize); // for use with assemble() static int processLinesForCombine(HumdrumFile& output, HumdrumFile& A, HumdrumFile& B, int debug = 0); static ostream& printConstantTokenFields(ostream& out, HumdrumRecord& aRecord, const char* token); // private function for analyzeCliche: int attemptMatch(Array >& allnotes, Array& di, int starti, int i, int j, double duration); /////////////////////////////////////////////////////////////////////// // // functions defined in HumdrumFile-chord.cpp // public: int measureChordRoot (Array& scores, Array& parameters, double startbeat, double stopbeat, int algorithmno = 0, int debug = 0); int measureChordRoot (Array& scores, Array& parameters, int startindex, int stopindex, int algorithmno = 0, int debug = 0); int measureChordRoot0 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot1 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot2 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot3 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot4 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot5 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot6 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot7 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot8 (Array& scores, Array& parameters, NoteListArray& notelist); int measureChordRoot9 (Array& scores, Array& parameters, NoteListArray& notelist); void generateNoteList (NoteListArray& notelist, int startLinst, int endLine); // old functions which should not be used: int analyzeChordProbabilityDurNorm(Array& coef, double startbeat, double stopbeat, Array& scorelevels, double empirical1, double empirical2, double sx, double sy); int analyzeChordProbabilityDur(Array& coef, double startbeat, double stopbeat, Array& scorelevels, double empirical1, double empirical2, double sx, double sy); int analyzeChordProbability(Array& coef, int start, int stop, Array& scorelevels, double empirical1, double empirical2, double sx, double sy); }; #endif /* _HUMDRUMFILE_H_INCLUDED */ // md5sum: 8e155fdb7b2d0af7bbfa1d92cd7ccd85 HumdrumFile.h [20050403]