// // Programmer: Craig Stuart Sapp // Creation Date: Mon Jan 8 23:44:16 PST 2018 // Last Modified: Mon Jan 8 23:44:22 PST 2018 // Filename: tool/retick.cpp // URL: https://github.com/craigsapp/midifile/blob/master/tools/retick.cpp // Syntax: C++11 // vim: ts=3 // // Description: Change TPQ to a new value and update timestamps for new TPQ to keep // time values the same as before. // #include "MidiFile.h" #include "Options.h" #include using namespace std; using namespace smf; ////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { Options options; options.define("t|tpq=i:120", "Set TPQ to this value and adjust timestamps"); options.process(argc, argv); int status; MidiFile midifile; if (options.getArgCount()) { status = midifile.read(options.getArg(1)); } else { status = midifile.read(cin); } if (status == 0) { cerr << "Error: could not read MIDI file" << endl; exit(1); } int tpq = midifile.getTicksPerQuarterNote(); int newtpq = options.getInteger("tpq"); double factor = (double)newtpq / (double)tpq; for (int track=0; track 1) { midifile.write(options.getArg(2)); } else { cout << midifile; } return 0; }