// // Programmer: Craig Stuart Sapp // Creation Date: Wed May 16 14:14:47 PDT 2001 // Last Modified: Wed May 16 14:14:50 PDT 2001 // Filename: ...sig/examples/all/scrub.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/scrub.cpp // Syntax: C++; museinfo // // Description: Remove chordal/non-chordal tones from input music. // // Things to do: Allow for pickup beats. // #include "humdrum.h" #include "ctype.h" #include "string.h" // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); void processFile (HumdrumFile& infile); int getDegree (int note, int root); void erasenote (HumdrumFile& infile, NoteList& note); // command line options: Options options; // database for command-line arguments int debugQ = 0; // for debugging Array filter(10); // notes to keep/remove. double timebase = 1.0; // duration of each chord /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { HumdrumFile infile; // input Humdrum Format file // process the command-line options checkOptions(options, argc, argv); // figure out the number of input files to process int numinputs = options.getArgCount(); for (int i=0; i scores(40); Array roots(infile.getNumLines()*10); Array starttimes(infile.getNumLines()*10); roots.setGrowth(infile.getNumLines()*10); starttimes.setGrowth(infile.getNumLines()*10); roots.setSize(0); starttimes.setSize(0); roots.allowGrowth(1); starttimes.allowGrowth(1); int root; Array p(3); p[0] = 0.573; p[1] = -4.0; p[2] = -3.0; while (beatstart+timebase-0.01 < infile.getTotalDuration()) { root = infile.measureChordRoot(scores, p, beatstart, beatstart+timebase-0.01, 0); starttimes.append(beatstart); roots.append(root); beatstart += timebase; } NoteListArray notelist; infile.generateNoteList(notelist, 0, infile.getNumLines() - 1); char buffer[128] = {0}; int i; int degree; int k = 0; for (i=0; i= starttimes[k]) { if (debugQ) { cout << "beat " << starttimes[k] << "\troot = " << Convert::base40ToKern(buffer, 2+roots[k]+3*40) << endl; } k++; } if(debugQ) { cout << "\t" << Convert::base40ToKern(buffer, notelist[i].getPitch()); } degree = getDegree(notelist[i].getPitch(), roots[k-1]+2); if (debugQ) { cout << "\t=\tdegree " << degree; } if (degree >= 0 && filter[degree] == 0) { if (debugQ) { cout << " (remove)"; } notelist[i].setPitch(-1); } if (debugQ) { cout << endl; } } // list removed notes for (i=0; i