Beispiel #1
0
static void EchoAlgorithm(FunctionEvent& p, EventBuffer& midiOutput) {
   static NoteEvent note;            // temporary note before placing in buffer

   // check if pausing
   if (decaystates[p.getKey()] < 0.0) {
      p.setOnTime(p.getOnTime() + p.getDur() + p.shortValue(14)); 
      return;
   }
      
   // set the parameters for the output note:
   note.setOnDur(t_time, p.getOffTime()); // off time holds dur
   note.setVel(p.getVel());
   note.setChan(p.getChan());
   note.setKey(p.getKey());

   // update the parameters for the function:
   decaystates[p.getKey()] *= decayrate;
   p.setVel((int)decaystates[p.getKey()]);

   // if note is too quiet, end the note
   if (p.getVel() <= 2) {
      p.off(midiOutput);
      decaystates[p.getKey()] = 0.0;
   }

   // next time includes a gap so that key can raise on keyboard
   p.setOnTime(p.getOnTime() + p.getDur() + p.shortValue(14)); 

   note.activate();
   note.action(midiOutput);       // start right now, avoiding any buffer delay
   midiOutput.insert(note);       // the note off message is being buffered

}
Beispiel #2
0
static void EnhanceFunction(FunctionEvent& p, EventBuffer& midiOutput) {
   static NoteEvent note;            // temporary note before placing in buffer

   // set the parameters for the output note:
   note.setOnDur(t_time, p.getOffTime()); // off time holds dur
   note.setVel(p.getVel());
   note.setChan(p.getChan());
   note.setKey(p.getKey());

   // if note is too quiet
   if (p.getVel() <= 5) {
      p.off(midiOutput);
   }

   // update the parameters for the function:
   p.setKey(p.getKey()+p.shortValue(14));
   p.setVel(p.getVel()-5);
   p.setOnTime(p.getOnTime() + p.getDur());  // OffTime stores duration

   note.activate();
   note.action(midiOutput);       // start right now, avoiding any buffer delay
   midiOutput.insert(note);       // the note off message is being buffered


   // check wether to kill the algorithm or not:

   // if note is off the range of the keyboard
   if (p.getKey() > C8 || p.getKey() < A0) {
      p.off(midiOutput);
   }

}
Beispiel #3
0
void playgliss(int basenote, int loudness, int channel, int duration, 
      int distancee) { 
   static FunctionEvent tn;   // a Temporary Note for copying into eventBuffer
   
   // setting the fields of the function note
   tn.shortValue(14) = distancee;

   tn.setFunction(EnhanceFunction);
   tn.setChannel(channel);
   tn.setKeyno(basenote + distancee);
   tn.setVelocity(loudness - 5);
 
   tn.setStatus(EVENT_STATUS_ACTIVE);

   // start time of function and the duration between calling it
   tn.setOnDur(t_time, duration);

   eventBuffer.insert(tn);

   cout << "StartKey =    "  << basenote
        << "\tLoudness =  "  << loudness
        << "\tRate =      "  << duration
        << "\tDirection = "  << distancee
        << endl;
}
Beispiel #4
0
void createDecay(int channel, int key, int duration, int velocity) {
   static FunctionEvent tn;   // temporary function for copying into eventBuffer

   tn.shortValue(14) = gap;    // gap between successive notes

   tn.setFunction(EchoAlgorithm);
   tn.setChannel(channel);
   tn.setKeyno(key);
   decaystates[key] = velocity * decayrate;
   tn.setVelocity((int)decaystates[key]);
   tn.setStatus(EVENT_STATUS_ACTIVE);

   // start time of function and the duration between calling it
   tn.setOnDur(t_time, duration);

   eventBuffer.insert(tn);

   cout << "Key=    "  << key
        << "\tDuration =  "  << duration + gap
        << "\tVelocity =  "  << velocity
        << endl;
}