Why are chords notes not played simultaneously?

    If improv programs do not seem to be responsive enough or feel sluggish, it is probably due to idling that occurs after each iteration throught the mainloopalgorithms() function. By default the program sleeps for 10 millisecond after each pass through mainloopalgorithms(). However, your program may be setup in a way that cannot tolerate this idle time.

    There are two solutions: (1) fix you program flow so that your program can tolerate the idle times, or (2) set the idle time to a smaller value, or to 0.

    For case (1), this general example might cause problems:

      void mainloopalgorithms(void) {
         if (synth.getNoteCount() > 0) {
            message = synth.extractNote();
            processNote(message);
         }
      }
      

    A better way to write the above function to handle input chords in a timely manner would be:

      void mainloopalgorithms(void) {
         while (synth.getNoteCount() > 0) {
            message = synth.extractNote();
            processNote(message);
         }
      }
      

    For case 2, you can set the idling to be less than 1 millisecond in the initialization function:

      void initialize(void) {
         setEventIdlePeriod(0.5);        // set to 0.5 milliseconds 
         setEventIdlePeriod(0);          // set to 0 milliseconds 
      }
      

    The pause after each iteration of mainloopalgorithms is there because (1) MIDI programs don't take that much computing power, and (2) It keeps thing running smoothly on multi-tasking systems like linux.











craig@ccrma.stanford.edu