void checkOptions(Options& opts) { opts.define("a|auto|automatic=b"); opts.define("c|const|constant=b"); opts.define("t|tempo|tempo-average=i:1"); opts.define("m|max|max-amplitude=i:64"); opts.define("p|port|out-port=i:0"); opts.define("i|inport|in-port=i:0"); opts.define("1|z|channel-collapse=b"); opts.define("improv-author=b"); opts.define("improv-version=b"); opts.define("example=b"); opts.define("improv-help=b"); opts.process(); if (opts.getBoolean("improv-author")) { cout << "Written by Craig Stuart Sapp, " << "[email protected], Nov 1999" << endl; exit(0); } if (opts.getBoolean("improv-version")) { cout << "midiperform version 1.0" << endl; cout << "compiled: " << __DATE__ << endl; } if (opts.getBoolean("help")) { usage(opts.getCommand().data()); exit(0); } if (opts.getBoolean("example")) { example(); exit(0); } // can only have one output filename if (opts.getArgCount() != 1) { cout << "Error: need one input MIDI file for performance." << endl; usage(opts.getCommand().data()); exit(1); } // figure out the tempo performance method if (opts.getBoolean("automatic")) { tempoMethod = TEMPO_METHOD_AUTOMATIC; } else if (opts.getBoolean("constant")) { tempoMethod = TEMPO_METHOD_CONSTANT; } else { switch (opts.getInteger("tempo-average")) { case 1: tempoMethod = TEMPO_METHOD_ONEBACK; break; case 2: tempoMethod = TEMPO_METHOD_TWOBACK; break; case 3: tempoMethod = TEMPO_METHOD_THREEBACK; break; case 4: tempoMethod = TEMPO_METHOD_FOURBACK; break; default: tempoMethod = TEMPO_METHOD_ONEBACK; break; } } outport = opts.getInteger("out-port"); inport = opts.getInteger("in-port"); maxamp = opts.getInteger("max-amplitude"); performance.channelCollapse(opts.getBoolean("channel-collapse")); }
void keyboardchar(int command) { switch (command) { case ' ': performance.beat(); break; case 'b': // print beat location in performance cout << "Current beat is: " << performance.getBeatLocation() << endl; break; case 'z': // toggle MIDI collapsing { int setting = performance.channelCollapse(); setting = !setting; performance.channelCollapse(setting); if (setting) { cout << "All notes going to channel 1" << endl; } else { cout << "All channel settings are unmodified" << endl; } } break; case 'p': // start playing the performance performance.play(); cout << "Starting performance" << endl; break; case '[': // set performance volume lower { double amp = performance.getAmp(); amp /= 1.15; performance.setAmp(amp); cout << "Amplitude scaling = " << performance.getAmp() << endl; } break; case ']': // set performance volume higher { double amp = performance.getAmp(); amp *= 1.15; performance.setAmp(amp); cout << "Amplitude scaling = " << performance.getAmp() << endl; } break; case 't': // current tempo display cout << "The Current tempo is: " << performance.getTempo() << endl; break; case '-': // slow down the tempo { double tempo = performance.getTempo(); tempo /= 1.03; performance.setTempo(tempo); cout << "The Tempo was set on the keyboard to : " << tempo << endl; } break; case '=': // speed up the tempo { double tempo = performance.getTempo(); tempo *= 1.03; performance.setTempo(tempo); cout << "The Tempo was set on the keyboard to : " << tempo << endl; } break; case '0': // automatic tempo control performance.setTempoMethod(TEMPO_METHOD_AUTOMATIC); cout << "Automatic Tempo Setting at tempo = " << performance.getTempo() << endl; break; case '9': // constant tempo control performance.setTempoMethod(TEMPO_METHOD_CONSTANT); cout << "Constant Tempo Contro at tempo = " << performance.getTempo() << endl; break; case '1': // 1 beat history average tempo performance.setTempoMethod(TEMPO_METHOD_ONEBACK); cout << "One beat tempo history" << endl; break; case '2': // 2 beat history average tempo performance.setTempoMethod(TEMPO_METHOD_TWOBACK); cout << "Two beat tempo history" << endl; break; case '3': // 3 beat history average tempo performance.setTempoMethod(TEMPO_METHOD_THREEBACK); cout << "Three beat tempo history" << endl; break; case '4': // 4 beat history average tempo performance.setTempoMethod(TEMPO_METHOD_FOURBACK); cout << "Four beat tempo history" << endl; break; } }