コード例 #1
0
ファイル: tiefix.cpp プロジェクト: craigsapp/humextra
void printTieCorrection(ostream& out, HumdrumRecord& line, int tiecorrection, int index) {
	int i;
	for (i=0; i<line.getFieldCount(); i++) {
		if (i != index) {
			// not processing anything but the specified spine.
			out << line[i];
			if (i < line.getFieldCount() - 1) {
				out << "\t";
			}
			continue;
		}

		// need to print the corrected spine
		if (tiecorrection < 0) {
			printStringWithoutTie(out, line[index]);
		} else if (tiecorrection > 0) {
			printStringWithTie(out, line[index], tiecorrection);
		} else {
			out << line[index];
		}
		if (i < line.getFieldCount() - 1) {
			out << "\t";
		}
	}
	out << "\n";
}
コード例 #2
0
ファイル: tsroot.cpp プロジェクト: craigsapp/humextra
void printRomanKey(HumdrumFile& romananalysis, vector<int>& romanlines, 
   int target, HumdrumRecord& aRecord) {

   int i;
   int j;
   for (i=0; i<(int)romanlines.size(); i++) {
      if (romananalysis[i].getType() != E_humrec_interpretation) {
         continue;
      }
      if (target < romanlines[i]) {
         return;
      }
      if (target > romanlines[i]) {
         continue;
      }

      // target == romanlines[i]: assume first column contains data

      if (strchr(romananalysis[i][0], ':') == NULL) {
         continue;
      }

      // found a key interpretation which should be printed

      if (prependQ) {
         cout << romananalysis[i][0] << "\t";
         cout << romananalysis[i][0] << "\t";
      }

      if (prependQ || appendQ) {
         for (j=0; j<aRecord.getFieldCount(); j++) {
            cout << "*";
            if (j < aRecord.getFieldCount() - 1) {
               cout << "\t";
            } 
         }
      } else {
         if (harmonyQ) {
            cout << romananalysis[i][0] << "\t";
         }
         cout << romananalysis[i][0];

      }

      if (appendQ) {
         cout << "\t" << romananalysis[i][0];
         cout << "\t" << romananalysis[i][0];
      }

      cout << "\n";

      romanlines[i] = -1;  // make sure the that key will not be printed again

      break;
   }

}
コード例 #3
0
void printWithBarNumbers(HumdrumRecord& humrecord, int measurenum) {
   int i;
   for (i=0; i<humrecord.getFieldCount(); i++) {
       printSingleBarNumber(humrecord[i], measurenum);
       if (i < humrecord.getFieldCount() -1) {
          cout << "\t";
       }
   }
   cout << "\n";
}
コード例 #4
0
ファイル: humplay.cpp プロジェクト: craigsapp/humextra
int hasLayout(HumdrumRecord& record) {
	int i;
	for (i=0; i<record.getFieldCount(); i++) {
		if ((i == 0) && (strncmp(record[i], "!!LO:", 5) == 0)) {
			return 1;
		} else if (strncmp(record[i], "!LO:", 4) == 0) {
			return 1;
		}
	}
	return 0;
}
コード例 #5
0
void printWithoutBarNumbers(HumdrumRecord& humrecord) {
   int i;
   int j;
   int length;

   for (i=0; i<humrecord.getFieldCount(); i++) {
      if (humrecord[i][0] != '=') {
         cout << humrecord[i];
      } else {
         length = strlen(humrecord[i]);
         for (j=0; j<length; j++) {
            if (!std::isdigit(humrecord[i][j])) {
               cout << humrecord[i][j];
            }
         }
      }
      if (i < humrecord.getFieldCount()-1) {
         cout << "\t";
      }
   }
   cout << "\n";
}
コード例 #6
0
ファイル: HumdrumFileBasic.cpp プロジェクト: mdsmus/humdrum
int HumdrumFileBasic::predictNewSpineCount(HumdrumRecord& aRecord) {
   int output = 0;
   int spinecount = aRecord.getFieldCount();
   int subcount;
   int i;
   int j;
   for (i=0; i<spinecount; i++) {
      if (strcmp("*^", aRecord[i]) == 0) {
         output += 2;
      } else if (strcmp("*-", aRecord[i]) == 0) {
         output = output;
      } else if (strcmp("*+", aRecord[i]) == 0) {
         output += 2;
      } else if (strcmp("*x", aRecord[i]) == 0) {
         output++;
      } else if (strcmp("*v", aRecord[i]) == 0) {
         subcount = 1;
         for (j=i+1; j<spinecount; j++) {
            if (strcmp("*v", aRecord[j]) == 0) {
               subcount++;
            } else {
               break;
            }
         }
         if (subcount == 1) {
            cout << "Error: single *v pathindicator on line: " 
                 << aRecord.getLineNum() << "\n"
                 << aRecord.getLine()
                 << endl;
            exit(1);
         }
         output++;
         i = j-1;
      } else {
         output++;
      }
   }

   return output;
}
コード例 #7
0
ファイル: humplay.cpp プロジェクト: craigsapp/humextra
void processNotes(HumdrumRecord& record) {
	NoteEvent note;
	int pitch = 0;
	double duration = 0.0;
	int staccatoQ = 0;
	int accentQ = 0;
	int sforzandoQ = 0;
	int i, j;
	int notecount = 0;
	char buffer[128] = {0};
	for (i=0; i<record.getFieldCount(); i++) {
		if ((record.getPrimaryTrack(i) < (int)trackmute.size())
				&& trackmute[record.getPrimaryTrack(i)]) {
			continue;
		}
		if (record.getExInterpNum(i) == E_KERN_EXINT) {
			notecount = record.getTokenCount(i);
			if (strcmp(record[i], ".") == 0) {
				continue;
			}
			for (j=0; j<notecount; j++) {
				record.getToken(buffer, i, j);
				if (strchr(buffer, '[')) {
					// total tied note durations
					duration = data.getTiedDuration(linenum, i, j);
				} else {
					duration = Convert::kernToDuration(buffer);
				}
				pitch = Convert::kernToMidiNoteNumber(buffer);
				// skip rests
				if (pitch < 0) {
					continue;
				}
				pitch += transpose;
				// don't play note which is transposed too extremely
				if (pitch < 0)   { continue; }
				if (pitch > 127) { continue; }

				// skip tied notes
				if (strchr(buffer, '_') || strchr(buffer, ']')) {
					continue;
				}

				accentQ    = strchr(buffer, '^')  == NULL? 0 : 1;
				sforzandoQ = strchr(buffer, 'z')  == NULL? 0 : 1;
				staccatoQ  = strchr(buffer, '\'') == NULL? 0 : 1;
				note.setChannel(0);
				note.setKey(pitch);
				note.setOnTime(t_time);
				duration = duration * 60000 / tempo / tempoScale;
				if (shortenQ) {
					duration -= shortenamount;
					if (duration < mine) {
						duration = mine;
					}
				}
				note.setDur((int)duration);
				if (staccatoQ) {
					note.setDur((int)(0.5 * note.getDur()));
				}
				note.setKey(pitch);
				if (accentQ) {
					velocity *= 1.3;
				}
				if (sforzandoQ) {
					velocity *= 1.5;
				}
				if (velocity > 127) {
					velocity = 127;
				}
				note.setVelocity(velocity);

				note.activate();
				note.action(eventBuffer);
				eventBuffer.insert(note);
			}
		}
	}
}
コード例 #8
0
ファイル: HumdrumFileBasic.cpp プロジェクト: mdsmus/humdrum
void HumdrumFileBasic::makeNewSpineInfo(SigCollection<char*>&spineinfo, 
   HumdrumRecord& aRecord, int newsize, int& spineid,
   SigCollection<int>& ex) {

   SigCollection<char*> newinfo;
   newinfo.setSize(newsize);
   int i, j;
   for (i=0; i<newsize; i++) {
      newinfo[i] = new char[1024];
      newinfo[i][0] = '\0';
   }

   int spinecount = aRecord.getFieldCount();
   int subcount;
   int inindex = 0;
   int outindex = 0;

   for (inindex=0; inindex<spinecount; inindex++) {
      if (strcmp("*^", aRecord[inindex]) == 0) {
         strcpy(newinfo[outindex], "(");
         strcat(newinfo[outindex], spineinfo[inindex]);
         strcat(newinfo[outindex], ")a");
         outindex++;
         strcpy(newinfo[outindex], "(");
         strcat(newinfo[outindex], spineinfo[inindex]);
         strcat(newinfo[outindex], ")b");
         outindex++;
      } else if (strcmp("*-", aRecord[inindex]) == 0) {
         // don't increment outindex
      } else if (strcmp("*+", aRecord[inindex]) == 0) {
         strcpy(newinfo[outindex], spineinfo[inindex]);
         outindex++;
         spineid++;
         sprintf(newinfo[outindex], "%d", spineid);
         outindex++;
      } else if (strcmp("*x", aRecord[inindex]) == 0) {
         strcpy(newinfo[outindex], spineinfo[inindex+1]);
         outindex++;
         strcpy(newinfo[outindex], spineinfo[inindex]);
         outindex++;
         inindex++;
      } else if (strcmp("*v", aRecord[inindex]) == 0) {
         subcount = 1;
         strcpy(newinfo[outindex], spineinfo[inindex]);
         for (j=inindex+1; j<spinecount; j++) {
            if (strcmp("*v", aRecord[j]) == 0) {
               subcount++;
               if (subcount > 1) {
                  strcat(newinfo[outindex], " ");
                  strcat(newinfo[outindex], spineinfo[inindex+subcount-1]);
                  simplifySpineString(newinfo[outindex]);
               } 
            } else {
               break;
            }
         }
         if (subcount == 1) {
            cout << "Error: single *v path indicator on line: " 
                 << aRecord.getLineNum() << "\n"
                 << aRecord.getLine()
                 << endl;
            exit(1);
         } else {
            inindex += subcount-1;   
         }
         // check to see if the spine info can be simplified:
         simplifySpineInfo(newinfo, outindex);    

         outindex++;
      } else if (strncmp("**", aRecord[inindex], 2) == 0) {
         int value;
         value = Convert::exint.getValue(aRecord[inindex]);
         if (spineid != ex.getSize()) {
            cout << "Error in exclusive interpretation allocation" 
                 << endl;
            exit(1);
         }
         if (value == E_unknown) {
            value = Convert::exint.add(aRecord[inindex]);
            ex.append(value);
         } else {
            ex.append(value);
         }
         strcpy(newinfo[outindex], spineinfo[inindex]);
         outindex++;
      } else {
         strcpy(newinfo[outindex], spineinfo[inindex]);
         outindex++;
      }
   }

   if (outindex != newinfo.getSize()) {
      cout << "Error in HumdrumFileBasic path parsing" << endl;
      exit(1);
   }

   if (inindex != spineinfo.getSize()) {
      cout << "Error in HumdrumFileBasic path parsing" << endl;
      exit(1);
   }

   // delete the old information:
   for (i=0; i<spineinfo.getSize(); i++) {
      if (spineinfo[i] != NULL) {
         delete [] spineinfo[i];
         spineinfo[i] = NULL;
      }
   }
   spineinfo.setSize(newinfo.getSize());

   // copy the new spine path indicators
   int length;
   for (i=0; i<spineinfo.getSize(); i++) {
      length = strlen(newinfo[i]);
      spineinfo[i] = new char[length + 1];
      strcpy(spineinfo[i], newinfo[i]);
      delete [] newinfo[i];
      newinfo[i] = NULL;
   }

   newinfo.setSize(0);
}
コード例 #9
0
ファイル: HumdrumFileBasic.cpp プロジェクト: mdsmus/humdrum
void HumdrumFileBasic::readjustDotArrays(Array<int>& lastline, 
      Array<int>& lastspine, HumdrumRecord& record, int newsize) {

   Array<int> newline;
   Array<int> newspine;
   newline.setSize(newsize);
   newspine.setSize(newsize);
   newline.allowGrowth(0);
   newspine.allowGrowth(0);

   int i, j;
   for (i=0; i<newsize; i++) {
      newline[i] = -1;
      newspine[i] = -1;
   }

   int spinecount = record.getFieldCount();
   int subcount;
   int inindex = 0;
   int outindex = 0;

   for (inindex=0; inindex<spinecount; inindex++) {
      if (strcmp("*^", record[inindex]) == 0) {
         newline[outindex] = lastline[inindex];
         newspine[outindex] = lastspine[inindex];
         outindex++;
         newline[outindex] = lastline[inindex];
         newspine[outindex] = lastspine[inindex];
         outindex++;
      } else if (strcmp("*-", record[inindex]) == 0) {
         // don't increment outindex
      } else if (strcmp("*+", record[inindex]) == 0) {
         newline[outindex] = lastline[inindex];
         newspine[outindex] = lastline[inindex];
         outindex++;
         newline[outindex] = -1;
         newspine[outindex] = -1;
         outindex++;
      } else if (strcmp("*x", record[inindex]) == 0) {
         newline[outindex] = lastline[inindex+1];
         newspine[outindex] = lastspine[inindex+1];
         newline[outindex+1] = lastline[inindex];
         newspine[outindex+1] = lastspine[inindex];
         outindex+=2;
         inindex++;
      } else if (strcmp("*v", record[inindex]) == 0) {
         subcount = 1;
         newline[outindex] = lastline[outindex];
         newspine[outindex] = lastspine[outindex];
         for (j=inindex+1; j<spinecount; j++) {
            if (strcmp("*v", record[j]) == 0) {
               subcount++;
               if (subcount > 1) {
                  newline[outindex] = lastline[inindex+subcount-1];
                  newspine[outindex] = lastspine[inindex+subcount-1];
               } 
            } else {
               break;
            }
         }
         if (subcount == 1) {
            cout << "Error: single *v path indicator on line: " 
                 << record.getLineNum() << "\n"
                 << record.getLine()
                 << endl;
            exit(1);
         } else {
            inindex += subcount-1;   
         }
         outindex++;
      } else if (strncmp("**", record[inindex], 2) == 0) {
         newline[outindex] = -1;
         newspine[outindex] = -1;
         outindex++;
      } else {
         newline[outindex] = lastline[inindex];
         newspine[outindex] = lastspine[inindex];
         outindex++;
      }
   }

   if (outindex != newline.getSize()) {
      cout << "Error in HumdrumFileBasic path parsing" << endl;
      exit(1);
   }

   if (inindex != lastline.getSize()) {
      cout << "Error in HumdrumFileBasic path parsing" << endl;
      exit(1);
   }

   // copy the new information
   lastline.setSize(newline.getSize());
   lastspine.setSize(newspine.getSize());
   for (i=0; i<newline.getSize(); i++) {
      lastline[i] = newline[i];
      lastspine[i] = newspine[i];
   }

}