Пример #1
0
void keyboardchar(int key) { 
   switch (key) {
      case ',':      // slow the tempo down
      case '<':
         tempo *= 0.95;
         metronome.setTempo(tempo);
         cout << "Tempo = " << tempo << endl;
         maxwait = calculateMaxWait(tempo);
         break;

      case '.':      // speed the tempo up
      case '>':
         tempo *= 1.05;
         metronome.setTempo(tempo);
         cout << "Tempo = " << tempo << endl;
         maxwait = calculateMaxWait(tempo);
         break;

      case '[':    // decrease the beat lag time in determing a chord
         lagmaxinsec -= 0.05;
         if (lagmaxinsec < 0.05) {
            lagmaxinsec = 0.05;
         }
         cout << "Chord decision time set to " << lagmaxinsec << endl;
         maxwait = calculateMaxWait(tempo);
         break;

      case ']':    // increase the beat lag time in determing a chord
         lagmaxinsec += 0.05;
         if (lagmaxinsec > 60.0/tempo - 0.05) {
            lagmaxinsec = 60.0/tempo - 0.05;
         }
         cout << "Chord decision time set to " << lagmaxinsec << endl;
         maxwait = calculateMaxWait(tempo);
         break;

      default:
         cout << "Undefined keyboard command" << endl;
   }

}
Пример #2
0
void initialization(void) { 
   cout << "Enter a tempo for melody performance: ";
   echoKeysOn();
   cin  >> tempo;
   echoKeysOff();

   metronome.setTempo(tempo);
   maxwait = calculateMaxWait(tempo);

   playChord = playChordByRules;
   cout << "Using rules for playing accompaniment" << endl;
}