コード例 #1
0
int CMuseDataNoteRecord::parseFromRecord(char *line)
{
	//information retrievalble from  col 13-43

	//1.Parse the sound-information from colums 1 to 9
	//1.1. normal notes or chords
	if(isCharInString(line[0],"ABCDEFGr ")){
		//set note-type
		rdNoteType=nt_normal;
		//chord or not??
		if(line[0]==' '){rdFlagChord=1;} else {rdFlagChord=0;}
		//parse pitch
		if(parsePitchInformation(&line[rdFlagChord],&rdPitchName,&rdPitchChromatic,&rdPitchOctave)){
			MUSEERROR(err_ParsePitch,idLineNumber,rdFlagChord);
		}
		//parse duration
		if(parseDurationInformation(&line[5],&rdDuration)){
			if( (rdFlagChord) && (parseParameters.lastNoteDuration!=-1) && (isBlanks(line+5,3)) ){
				rdDuration=parseParameters.lastNoteDuration;
			} else {
				MUSEERROR(err_ParseDuration,idLineNumber,6);
			}
		}
		parseParameters.lastNoteDuration=rdDuration;
		//parse tie-flag
		if(!isCharInString(line[8],"- ")){
			MUSEERROR(err_ParseTieFlag,idLineNumber,9)
		}
		if(line[8]=='-'){rdFlagTied=1;}
	} 
コード例 #2
0
ファイル: MuseDataHeader.cpp プロジェクト: EQ4/guido-engine
int CMuseDataHeader::parseMusicalAttributes(char*line,int lineNr)
{
	attributesRead=1;
	if(line[1]!=' '){
		MUSEERROR(err_EditorialLevelNotSupported,lineNr,2);
	}
	if(line[2]!=' '){
		MUSEERROR(err_FootnoteNotSupported,lineNr,3);
	}

	if(line[1]==0){return 0;}
	if(line[2]==0){return 0;}

	int col=3;
	while(line[col]!=0){
		int rv=0;
		switch(line[col]){
		//single-integer-attributes:
		case 'K':rv=parseAttribute(&line[col+1],&rdKey);break;
		case 'Q':rv=parseAttribute(&line[col+1],&rdDivisionsPerQuarter);break;
		case 'X':rv=parseAttribute(&line[col+1],&rdTransposingPart);break;
		case 'S':rv=parseAttribute(&line[col+1],&rdNumberOfStaves);break;
		case 'I':rv=parseAttribute(&line[col+1],&rdNumberOfInstruments);break;
		//clefs:
		case 'C':
			if(line[col+1]==':'){rv=parseAttribute(&line[col+1],&rdClef[0]);break;}
			if(line[col+1]=='1'){rv=parseAttribute(&line[col+2],&rdClef[0]);break;}
			if(line[col+1]=='2'){rv=parseAttribute(&line[col+2],&rdClef[1]);break;}
			rv=-1;break;
		//directives:
		case 'D':
			if(line[col+1]==':'){strncpy(rdDirective[0],&line[col+2],80);break;}
			if(line[col+1]=='1'){
				if(line[col+2]==':') {strncpy(rdDirective[0],&line[col+3],80);break;}
				else {rv=-1;break;}
			}
			if(line[col+1]=='2'){
				if(line[col+2]==':') {strncpy(rdDirective[1],&line[col+3],80);break;}
				else {rv=-1;break;}
			}
		}

		if(rv){
			MUSEERROR(err_ParseAttribute,lineNr,col);
		}

		//find next blank
		while( (line[col]!=0) && (line[col]!=' ') ){col++;}
		if(line[col]==' '){col++;}
	}
	return 0;
}
コード例 #3
0
ファイル: MuseDataFile.cpp プロジェクト: anttirt/guidolib
int CMuseDataFile::parseLoop(FILE * f)
{
	char line[81];
	while(!feof(f)){
		//read one line from file
		parseLineNumber++;
		if(fgets(line,80,f)==NULL){
			if(feof(f)){
				continue;
			} else {
				MUSEERROR(err_ReadInputFile,parseLineNumber,0);
			}
		}

		//beautify read line: fill end with blanks and remove eol-sign
		for(int i=0;i<80;i++){
			if( (line[i]=='\n') || (line[i]==0) ){
				for(i;i<80;i++){line[i]=' ';}
			}
		}
		line[80]=0;
		//parse the line
		if(parseLine(line)!=0){return -1;}
	}
	return 0;
}
コード例 #4
0
ファイル: MuseDataFile.cpp プロジェクト: anttirt/guidolib
int CMuseDataFile::readFromFile(char *filename)
{
	FILE * file=fopen(filename,"rt");
	if(file==NULL){
		MUSEERROR(err_OpenInputFile,0,0);
		return -1;
	}
	if(parseInit()!=0){
		fclose(file);
		MUSEERROR(err_ParsingAbborted,0,0);
		return -1;
	} else {
		if(parseLoop(file)!=0){
			fclose(file);
			MUSEERROR(err_ParsingAbborted,0,0);
			return -1;
		}
	}
	fclose(file);
	MUSEERROR(err_ParsingCompleted,0,0);
	return 0;
}
コード例 #5
0
int CMuseDataEndRecord::parseFromRecord(char *line)
{
	if(strncmp(line,"/FINE",5)){
		rdEndRecordType=ert_fine;
	} else {
		if(strncmp(line,"/END",4)){
			rdEndRecordType=ert_end;
		} else {
			MUSEERROR(err_UnknownRecordType,idLineNumber,0);
		}
	}
	return 0;
}
コード例 #6
0
int CConversionOptions::parseCommandLine(int argc, char **argv)
{
	if(argc<2){
		MUSEERROR(err_NoInputFile,0,0)
	}

	//Last option is sourcefile!
	sourceFile=argv[argc-1];

	//parse the other options
	for(int i=1;i<argc-1;i++){
		parseOption(argv[i]);	
	}
	return 0;
}
コード例 #7
0
ファイル: MuseDataFile.cpp プロジェクト: anttirt/guidolib
int CMuseDataFile::parseDataRecord(char * line)
{
	CMuseDataDataRecord* newRecord=NULL;

	switch(line[0]){
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'r':
	case ' ':
	case 'c':
	case 'g':
		newRecord=new CMuseDataNoteRecord();break;
	case 'f':
		MUSEERROR(err_UnsupportedRecord,parseLineNumber,0);
		return 0;
	case 'b':
	case 'i':
		newRecord=new CMuseDataCombineDivideRecord();break;
	case 'm':
		newRecord=new CMuseDataMeasureLineRecord(); break;
	case '*':
		MUSEERROR(err_UnsupportedRecord,parseLineNumber,0);
		return 0;
	//case '@':break; //handled in parseLine
	//case '&':break; //handled in parseLine
	case '/':
		newRecord=new CMuseDataEndRecord();break;
	case 'P':
		//for printing-suggestions we can't simply create a new record,
		//instead we send them to the last read record, if there was any
		if(parseLastParsedDataRecord==NULL){
			MUSEERROR(err_PrintSuggestion,parseLineNumber,0);
			return 0; //no record before, sniff
		} else {
			return parseLastParsedDataRecord->parsePrintSuggestionRecord(line);
		}
		break;
	case 'a':
		//Append-Records are handled like P-records!
		if(parseLastParsedDataRecord==NULL){
			MUSEERROR(err_PrintSuggestion,parseLineNumber,0);
			return 0; //no record before
		} else {
			return parseLastParsedDataRecord->parseAppendRecord(line);
		}

		break;
	case 'S':
		MUSEERROR(err_UnsupportedRecord,parseLineNumber,0);
		return 0;
	case '$':
		newRecord=new CMuseDataMusicalAttributesRecord();
		break;
	default:
		MUSEERROR(err_UnknownRecordType,parseLineNumber,0);
		return 0;
	}

	if(newRecord==NULL){
		MUSEERROR(err_InternalMemNoRecordObject,parseLineNumber,0);
		return 0;
	}

	//set new records line-number from file
	newRecord->setLineNumber(parseLineNumber);
	//parse the record
	int retVal=newRecord->parseFromRecord(line);
	if(retVal!=0){
		return -1;
	}

	//store new record
	recordList.appendRecord(newRecord);
	//maybe the next record is an Addition to this one, so we store it here
	parseLastParsedDataRecord=newRecord;
	return 0;
}