コード例 #1
0
ファイル: seny.cpp プロジェクト: Isssmael/improv
void updateVolume(void) {
   int i;
   double volsum = 0.0;
   for (i=0; i<volumes.getCount(); i++) {
      volsum += volumes[i];
   }
   if (volumes.getCount() != 0) {
      avgVol = volsum / volumes.getCount();
   } else {
      avgVol = 0.0;
   }
   // get the variance
   volsum = 0.0;
   for (i=0; i<volumes.getCount(); i++) {
      volsum += (avgVol - volumes[i]) * (avgVol - volumes[i]);
   }
   avgVolRange = sqrt(volsum);
}
コード例 #2
0
ファイル: seny.cpp プロジェクト: Isssmael/improv
void updateDuration(void) {
   int i;
   double dursum = 0.0;
   for (i=0; i<durations.getCount(); i++) {
      dursum += durations[i];
   }
   if (durations.getCount() != 0) {
      avgDur = dursum / durations.getCount();
   } else {
      avgDur = 0.0;
   }
   // get the variance
   dursum = 0.0;
   for (i=0; i<durations.getCount(); i++) {
      dursum += (avgDur - durations[i]) * (avgDur - durations[i]);
   }
   avgDurRange = sqrt(dursum);
}
コード例 #3
0
ファイル: seny.cpp プロジェクト: Isssmael/improv
void checkBuffers(void) {

   // look at the volume buffers for old volumes:
   while ( (voltimes.getCount() > 0) && (voltimes[voltimes.getCount()-1] <
         t_time - volDuration) ) {
      volumes.extract();
      voltimes.extract();
   }

   // look at the duration buffers for old durations:
   while ( (durtimes.getCount() > 0) && (durtimes[durtimes.getCount()-1] <
         t_time - durDuration) ) {
      durations.extract();
      durtimes.extract();
   }

   // look at the key buffers for old keys:
   int oldkey;
   while ( (keytimes.getCount() > 0) && (keytimes[keytimes.getCount()-1] <
         t_time - keyDuration) ) {
      oldkey = keys.extract();
      keytimes.extract();
  
      performerPCHistory[oldkey%12]--;
      if (performerPCHistory[oldkey%12] < 0) {
         performerPCHistory[oldkey%12] = 0;
      }

   }

}
コード例 #4
0
ファイル: testgliss.cpp プロジェクト: Isssmael/improv
void mainloopalgorithms(void) { 
   if (comparestate && notetimer.expired()) {
      if (notetimer.expired() > 2) {
         notetimer.reset();
      } else {
         notetimer.update();
      }

      notestate = !notestate;
      if (notestate == 1 || notestate == -1) {
         synth.play(0, note, 64);
         data = 0x90; sentout.insert(data);
         data = note; sentout.insert(data);
         data = 64;   sentout.insert(data);
      } else {
         synth.play(0, note, 0);
         data = 0x90; sentout.insert(data);
         data = note; sentout.insert(data);
         data = 0;    sentout.insert(data);
         note += step * direction;
         if (note > highestnote) {
            note = lowestnote;
         }
         if (note < lowestnote) {
            note = highestnote;
         }
      }
   }

   if (midiinput.getCount() > 0) {
      message = midiinput.extract();
      receivedin.insert(message.p0());
      receivedin.insert(message.p1());
      receivedin.insert(message.p2());

      // check that the messages are identical
      if (receivedin.getCount() < 3) {
         cout << "Error: not enough received data" << endl;
      } else {
         checkin[0] = receivedin.extract();
         checkin[1] = receivedin.extract();
         checkin[2] = receivedin.extract();
      }

      if (sentout.getCount() < 3) {
         cout << "Error: not enough sent data" << endl;
      } else {
         checkout[0] = sentout.extract();
         checkout[1] = sentout.extract();
         checkout[2] = sentout.extract();
      }

      if ((checkout[0] != checkin[0]) || (checkout[1] != checkin[1]) ||
          (checkout[2] != checkin[2])) {
         synth.rawsend(0xaa, 0x7f, 0x00);
         cout << "Error " 
              << "output was = (" << hex << (int)checkout[0] << ") "
              << dec << (int)checkout[1] << " "
              << dec << (int)checkout[2] << "\tbut input is = ("
              << hex << (int)checkin[0] << ") "
              << dec << (int)checkin[1] << " "
              << dec << (int)checkin[2] << " "
              << endl;

         // assume that a note message was missed.
         if (sentout.getCount() < 3) {
            cout << "Error: not enough sent data during error" << endl;
         } else {
            checkout[0] = sentout.extract();
            checkout[1] = sentout.extract();
            checkout[2] = sentout.extract();
         }

         stop();  
         cout << "Press space to restart testing, "
                 "or press 'S' to silence synth" << endl;
      }

   }
 
}