// // Programmer: Craig Stuart Sapp // Creation Date: Fri May 4 17:04:43 PDT 2001 // Last Modified: Fri May 4 17:04:48 PDT 2001 // Filename: ...sig/examples/all/kern2cmn.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/kern2cmn.cpp // Syntax: C++; museinfo // Reference: http://www-ccrma.stanford.edu/CCRMA/Software/cmn/cmn-manual/cmn.html // // Description: Converts kern data into the format used in CMN, // a LISP program that genrates PostScript musical scores. // // Note: Not completed // #include "humdrum.h" #include #include #include #include #include // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void convertToCMN(HumdrumFile& infile); void processTrack(HumdrumFile& infile, int track); void convertKernNoteToDM(HumdrumFile& infile, int line, int spine, int track); void printNote(int base40); void printRest(double duration); void printCMNDuration(double duration); int parseInterpretation(HumdrumFile& infile, int line, int track); void printPitchClass(int note); void getNoteArray(Array& notes, HumdrumFile& infile, int line, int spine); // user interface variables Options options; // database for command-line arguments int debugQ = 0; // used with --debug option // other variables: int key = -1; // for storing the key (base 40 number) int nameinit = 0; char name[128] = {0}; int bar = 0; // bar number int mode = -1; // for storing the mode (0 = major, 1 = minor) float metronome = -1.0; int start = -1; int terminus = -1; /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); Array absbeat; Array pitch; Array testset; Array duration; Array level; Array coef; for (int i=0; i= 0; i--) { // set global state variables to uninitialized key = -1; nameinit = 0; name[0] = '\0'; mode = -1; metronome = -1; bar = 0; processTrack(infile, i+1); } } ////////////////////////////// // // processTrack -- print out the specified track // void processTrack(HumdrumFile& infile, int track) { int status; int i, j; for (i=0; i i && track != infile.getMaxTracks()) { // skip over global comments after the first time: i = start; } if (terminus < i && terminus != -1 && track != 1) { // skip over global comments after the first time: break; } switch (infile[i].getType()) { case E_humrec_data: for (j=0; j notes; if (strcmp(element, ".") == 0) { return; } if (infile[line].getExInterpNum(spine) != E_KERN_EXINT) { return; } // if (infile[line].getBeat() == 1.0) { // bar++; // cout << "\n (bar " << bar << ") "; // } duration = Convert::kernToDuration(infile[line][spine]); if (strchr(element, 'r') != NULL) { cout << " "; printRest(duration); return; } getNoteArray(notes, infile, line, spine); int notecount = notes.getSize(); cout << " ("; for (int i=0; i& notes, HumdrumFile& infile, int line, int spine){ int notecount = infile[line].getTokenCount(spine); char buffer[128] = {0}; notes.setSize(0); int note; notes.allowGrowth(1); for (int i=0; i