int main(int argc, char** argv) {
	FILE* in;
	noteList notes;
	key pieceKey;
	timeSig pieceTime;
	int i;

	if(argc == 1){
		printf("\nNot enough arguments!\nUsage ./AnalyzeMidi title.midi\n");
		printf("(Second argument must be path from local directory)\n\n");
		exit(1);
	}

	// Read Midi File
	initializeFile(argv, &in);
	readMidi(in, &pieceKey, &pieceTime, &notes); 

	// Sort notes by start time (quicksort: requires first and last index)
	quickSortNotes(&notes, 0, notes.length-1);

	// For testing: print out all notes to .txt file
	printAll(notes, pieceKey, pieceTime, argv[1]);

	free(notes.notes);

	return 0;
}
Exemple #2
0
void verifyFile(fileDescriptor FD, int size) {
   initializeFile(FD, size);

   int ndx;
   char byte;
   for (ndx = 0; ndx < size; ++ndx) {
      REQUIRE_EQ(tfs_readByte(FD, &byte), TFS_SUCCESS);
      REQUIRE_EQ(byte, '0' + (ndx % 7));
   }
}
Exemple #3
0
	// will be called after all data has been collected
	void Metrics::writeResults()
	{
		ifstream resultsMetricsFile ("resultsMetrics.csv");
		if(!resultsMetricsFile)
			initializeFile();

		ofstream outResultsMetricsFile;
		outResultsMetricsFile.open("resultsMetrics.csv", std::fstream::app);
		outResultsMetricsFile << goalsOwn << ";" << goalsOpp << ";" << goalDifference << ";" << cumMetricsBallAt_t << ";";
		outResultsMetricsFile << endl;
		outResultsMetricsFile.close();
	 }
Exemple #4
0
int main(int argc, char *argv[]) {
  std::fstream f {};

  if (argc == 4 ) {
    std::string command {argv[1]};
    index_file = argv[2];
    next_id_file = index_file + ".next"; 
    initializeFile(f, index_file);
    bool create = command == "add";

    FileID fid = addWord(argv[3], f, create);
    seekRW(f, 0, f.end);
    f.close();
    std::cout << fid << std::endl;

  }
  return 0;
}
//opens the databasee
FILE * openFile(int argc, const char * argv[]) {
    
    //checks for command-line argmunets
    if (argc == 1) {
        printf("Please enter filename as a command-line argument.\n");
        return NULL;
    }
    
    FILE* tempfptr;
    //opens to append mode, ensures that file exists
    tempfptr = fopen(argv[1], "a+b");
    
   
    if (tempfptr == NULL) {
        fprintf(stderr, "Input file could not be opened.");
        return NULL;
    }
    
    initializeFile(tempfptr);
    
    //closes pointer for append mode
    fclose(tempfptr);
    
    FILE *fptr;
    //file must exist after append mode, opens pointer to r+ mode
    fptr = fopen(argv[1], "r+b");
    
    if (fptr == NULL) {
        fprintf(stderr, "Input file could not be opened.");
        return NULL;
    }
    
    return fptr;

    
}