// // 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) // 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 "HumdrumFileBasic.h" #include "NoteList.h" #include "ChordQuality.h" #ifndef OLDCPP #include using namespace std; #else #include #endif typedef Array ArrayInt; ////////////////////////////// // // 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); 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); double getTiedStartBeat (int linenum, int field, int token = 0); double getTotalDuration (void); HumdrumFile& operator= (const HumdrumFile& aFile); void read (const char* filename); void read (istream& inStream); // analyses that generate internal data void analyzeRhythm (const char* base = "", int debug = 0); int getMinTimeBase (void); int rhythmQ (void); // // analyses that generate external data // 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 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); // sonority harmonic analyses void analyzeSonorityQuality(Array& 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 double pickupdur; // duration of a pickup measure private: 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(Collection&spineinfo, HumdrumRecord& aRecord, int newsize, int& spineid, Collection& ex); void simplifySpineInfo(Collection& info, int index); // rhythm analysis functions: void privateRhythmAnalysis(const char* base = "", int debug = 0); double determineDuration(HumdrumRecord& aRecord, int& init, Collection& lastdurations, Collection& runningstatus, Array& rhythms, Array& ignore); void adjustForSpinePaths(HumdrumRecord& aRecord, Collection& lastdurations, Collection& runningstatus, int& init, int& datastart, Array& ignore); void adjustForRhythmMarker(HumdrumRecord& aRecord, int state, int spine, Collection& lastdurations, Collection& runningstatus, int& init, int& datastart, Array& ignore); void fixIncompleteBarMeter(Collection& meterbeats, Collection& timebase); void fixIrritatingPickupProblem(void); void spaceEmptyLines(void); void initializeTracers(Collection& lastduration, Collection& 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); // 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]