Example #1
0
void Caen785Module::setChannels()
{
    // Setup channels
    EventBuffer *evbuf = RunManager::ref ().getEventBuffer ();
    for (int i= 0; i < 32; ++i)
        evslots << evbuf->registerSlot (this, QString ("out %1").arg (i), PluginConnector::VectorUint32);
    // Output for raw data -> to event builder
    evslots << evbuf->registerSlot(this, "raw out", PluginConnector::VectorUint32);
}
Example #2
0
void createTrill(int key1, int key2, int velocity, int channel, int duration) {
   static FunctionEvent tn;   // a Temporary Note for copying into eventBuffer

   // key1 should always be smaller than key2
   int temp;
   if (key1 > key2) {
      temp = key1;
      key1 = key2;
      key2 = temp;
   }

   // setting the fields of the function note
   tn.setFunction(TrillAlgorithm);
   tn.setChannel(channel);
   tn.setKeyno(key1);
   tn.setVelocity(velocity);

   // set extra parameters
   tn.charValue(15) = 0;        // 0 = play key1 next, 1 = play key2 next
   tn.charValue(14) = key2;     // secondary pitch
   tn.intValue(10) = t_time;    // initialization time

   tn.setStatus(EVENT_STATUS_ACTIVE);

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

   eventBuffer.insert(tn);

   cout << "Trill = " << key1 << " to " << key2 
        << "\tRate = " << duration
        << endl;
}
Example #3
0
void mainloopalgorithms(void) { 
   eventBuffer.checkPoll();             // see if any notes need playing

   while (synth.getNoteCount() > 0) {
      processNote(synth.extractNote());
   }
}
Example #4
0
static void TumbleNoteFunction(FunctionEvent& p, EventBuffer& midiOutput) {
   static NoteEvent note;           // temporary note for placing in buffer

   TumbleParameters& param = tparam[p.charValue(0)];
   int newnote = limit(param.current + param.dir * param.n[param.pos], 0, 127);

   // turn off algorithm if someone turned the algorithm off externally
   // or if the current note is too large or too small.
   if (param.active == 0 || newnote < A0 || newnote > C7) {
      param.active = 0;
      p.off(midiOutput);
      return;
   }

   // set the parameters of the output note:
   note.setOnDur(t_time, param.d[param.pos]);   // off time holds dur
   note.setVel(param.v[param.pos]);
   note.setChan(p.getChan());
   note.setKey(newnote);
   note.activate();
   note.action(midiOutput);     // start right now, avoiding any buffer delay
   midiOutput.insert(note);     // store the note for turning off later

   // update the parameters for the tumble algorithm
   p.setOnTime(p.getOnTime() + param.i[param.pos]);
   param.current = newnote;
   param.pos++;
   if (param.pos > param.n.getSize()) {
      param.pos = 0;
   }
}
Example #5
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);
   }

}
Example #6
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;
}
Example #7
0
int startAlgorithm(TumbleParameters& p) {
   static FunctionEvent tn;   // a Temporary Note for copying into eventBuffer

   int ploc = storeParameters(tparam, p);
   if (ploc < 0) {
      cout << "Warning: Parameter space is full.  Not adding new algorithm"
           << endl;
      return -1;
   }

   // setting the fields of the function note
   tn.setFunction(TumbleNoteFunction);
   tn.setChannel(channel);
   tn.setKeyno(0);
   tn.setVelocity(0);
   tn.charValue(0) = (char)ploc;         // store location of the parameters
   tn.setStatus(EVENT_STATUS_ACTIVE);
   tn.setOnTime(t_time + p.i[0] - anticipation);

   // display the basic algorithm info
   cout << "Tumble: Time: " << t_time << "\tStart = " << (int)p.current
        << "\tPattern = . ";
   for (int i=1; i<p.n.getSize(); i++) {
      cout << (int)p.n[i] << " ";
   }
   cout << "(" << (int)p.n[0] << ")";
   cout << " ioi: " << p.i[0];
   cout << endl;

   return eventBuffer.insert(tn);
}
Example #8
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

}
Example #9
0
void playNextPattern(EventBuffer& eventbuffer, NoteScore& score,
                     int pattern, int subpattern, double tempo) {
    if (pattern == 0 && subpattern == 3) {
        subpattern = 2;
    }
    if (pattern == 6 && subpattern == 3) {
        subpattern = 2;
    }
    int p  = pattern;
    int sp = subpattern;
    cout << "playing pattern " << pattern << (char)('a' + subpattern) << endl;

    NoteEvent note;   // temporary note for placing in buffer
    int i;
    for (i=0; i<score[pattern][subpattern].getSize(); i++) {
        if (!activevoice[score[pattern][subpattern][i].voice]) {
            continue;
        }
        note.setOnDur((int)(t_time + score[p][sp][i].start * 1000 * 60 / tempo +
                            0.5), (int)(score[p][sp][i].dur * 1000 * 60 / tempo + 0.5));
        note.setChan(CH_10);
        note.setKey(voicetokey[score[p][sp][i].voice]);
        note.setVel(score[p][sp][i].vel);
        note.activate();
        if (score[p][sp][i].start == 0.0) {
            note.action(eventbuffer);   // play starting notes now, avoiding delay
        }
        eventbuffer.insert(note);
    }
}
Example #10
0
void initialization(void) { 
   eventBuffer.setPollPeriod(10);
   for (int i=0; i<notestates.getSize(); i++) {
      notestates[i] = 0;
      onvels[i] = 0;
      decaystates[i] = 0.0;
   }
}
Example #11
0
void mainloopalgorithms(void) { 
   eventBuffer.checkPoll();        // see if any notes to play

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      processNote(message);
   }
}
Example #12
0
void initialization(void) { 
   eventBuffer.setPollPeriod(10);
   notetimes.reset();
   notetimes.insert(0);
   notetimes.insert(0);
   notes.reset();
   notes.insert(0);
   notes.insert(0);
   noteontimes.zero();
}
Example #13
0
void mainloopalgorithms(void) {
   eventBuffer.checkPoll();             // see if any notes need playing

   while (synth.getNoteCount() > 0) {
      noteMessage = synth.extractNote();
      if (noteMessage.getP2() != 0) {
         playchord(noteMessage, chordType, onset, duration);
      }
   }
}
Example #14
0
void mainloopalgorithms(void) {
    eventbuffer.checkPoll();
    if (nextpatterntime <= t_time) {
        patternbeats = nextpattern + 2;
        if (nextpattern == 0) {
            patternbeats = 3;
        }
        nextpatterntime = t_time + (int)(60.0/tempo*1000*patternbeats + 0.5);
        playNextPattern(eventbuffer, rpscore, nextpattern, nextsubpattern, tempo);
    }
}
Example #15
0
void keyboardchar(int key) { 
   switch (key) {
      case 'p':
         cout << "current list in eventBuffer: " << endl;
         eventBuffer.print();
         cout << endl;
         cout << "Event[0] status: " << eventBuffer[0].getStatus() << endl;
         break;
      default:
         sillyKeyboard(key);
   }
}
Example #16
0
void initialization(void) {
    eventbuffer.setPort(synth.getInputPort());
    nextpatterntime = t_time;
    voicetokey.setSize(5);
    readScore(rpscore);
    voicetokey[0] = GM_CLAVES;
    voicetokey[1] = GM_COWBELL;
    voicetokey[2] = GM_HIGH_AGOGO;
    voicetokey[3] = GM_LOW_AGOGO;
    voicetokey[4] = GM_HI_BONGO;
    activevoice.setSize(5);
    activevoice.setAll(1);
}
void Track_Pattern::add_noteon_event_to_buffer(char p_note,char p_velocity,int p_column,EventBuffer &p_buffer,int p_frame_offset) {
	
	EventBuffer &event_buffer=get_event_buffer();
	
	//printf("note %i\n",p_note);
	
	if (data.last_note[p_column].is_note() && data.last_note[p_column].note==p_note) {
		/* IF the note is the same, we must mute it before */
		Event e;
		SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_OFF,0,data.last_note[p_column].note,0);
		e.frame_offset=p_frame_offset; //off te
		p_buffer.push_event(e);
		data.last_note[p_column]=Note(Note::NOTE_OFF); //avoid the next check
		
	}
	
	/* send new note */
	{
		int velocity=(int)p_velocity*127/99;
		Event e;
		SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_ON,0,p_note,velocity);
		e.frame_offset=p_frame_offset;
		p_buffer.push_event(e);

	}
	
	if (data.last_note[p_column].is_note() && data.last_note[p_column].note!=p_note) {
		/* If the note is different, mute it later */
		Event e;
		SET_EVENT_MIDI(e,EventMidi::MIDI_NOTE_OFF,0,data.last_note[p_column].note,0);
		e.frame_offset=p_frame_offset; //off te
		p_buffer.push_event(e);

	}
	
	
	data.last_note[p_column]=Note(p_note);	
	
}
Example #18
0
void initialization(void) {
   eventBuffer.setPollPeriod(10);

   onset[0] = 0;
   onset[1] = 100;
   onset[2] = 200;
   onset[3] = 300;

   duration[0] = 600;
   duration[1] = 500;
   duration[2] = 400;
   duration[3] = 300;
}
Example #19
0
void initialization(void) {
	checkOptions();
	timer.setPeriod(500);
	timer.reset();
	eventIdler.setPeriod(0);
	eventBuffer.setPollPeriod(10);
	eventBuffer.setPort(synth.getOutputPort());
	if (colorQ) {
		colormessage(cout, COLOR_INIT, colormode, colorQ);
		colormessage(cout, COLOR_CLEAR_SCREEN, colormode, colorQ);
		//if (!options.getBoolean("Q")) {
		//   print_commands();
		//}
		//sleep(1);
	}
	trackmute.resize(1000); // maximum track in humdrum file assumed to be 1000
							       // space 1000-10 is used for a special purpose.
	std::fill(trackmute.begin(), trackmute.end(), 0);

	markers.resize(1001);
	std::fill(markers.begin(), markers.end(), 0);
	markerindex = 0;
}
Example #20
0
void mainloopalgorithms(void) {
	eventBuffer.checkPoll();
	if (pauseQ) {
		return;
	}
	if (timer.expired()) {
		playdata(data, linenum, timer);
		if (linenum >= data.getNumLines()) {
			printAllMarkers(cout, markers, data);
			std::fill(markers.begin(), markers.end(), 0);
			inputNewFile();
		}
	}
}
Example #21
0
static void TrillAlgorithm(FunctionEvent& p, EventBuffer& midiOutput) {
   static NoteEvent note;           // temporary note before placing in buffer

   int key1 = p.getKey();           // lower key of trill
   int key2 = p.charValue(14);      // upper key of trill
   int state = p.charValue(15);     // which note to play next
   int starttime = p.intValue(10);  // when trill was started
   int i;
  
   // turn off the trill if there is a note played inside the trill
   int range1 = key1;
   int range2 = key2;
   if (range2 - range1 == 1) {
      range1--;
      range2++;
   }
   for (i=range1; i<=range2; i++) {
      if (noteontimes[i] > starttime) {
         p.off(midiOutput);
         return;
      }
   }

   // set the next note to play
   int key = state ? key2 : key1;
   state = !state;
   p.charValue(15) = state;

   // set the parameters for the output note:
   note.setOnDur(t_time, p.getDur()); 
   note.setVel(p.getVel());
   note.setChan(p.getChan());
   note.setKey(key);

   // update the parameters for the gliss function:
   p.setOnTime(p.getOnTime() + p.getDur());  
   
   int value = p.getVel() + velcorrection;
   if (value < 100 && value > 3) {
      p.setVel(value);
   }
   if (p.getDur() + trillcorrection > MINTRIGTIME) {
      p.setDur(p.getDur() + trillcorrection);
   }

   note.activate();
   note.action(midiOutput);       // start right now, avoiding any buffer delay
   midiOutput.insert(note);       // the note off message is being buffered
}
Example #22
0
void mainloopalgorithms(void) { 
   eventBuffer.checkPoll();        // see if any notes to play

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      if (message.getP2() != 0) {
         lastnotes.insert(message.getP1());
         lasttimes.insert(message.tick);
         distancee = lastnotes[0] - lastnotes[1];
         duration = lasttimes[0] - lasttimes[1];
         channel = 0x0f & message.getP0();
         if (distancee != 0) {
            playgliss(message.getP1(), message.getP2(), channel,  duration, distancee);
         }
      }
   }
}
Example #23
0
void keyboardchar(int key) { 
   switch (key) {
      case 'p':                    // print eventbuffer info
         eventBuffer.print();
         cout << endl;
         break;
      case '[':                    // speed up echo rate
         decayrate *= 0.99;
         cout << "Decay rate = " << decayrate << endl;
         break;
      case ']':                    // slow down echo rate
         decayrate /= 0.99;
         cout << "Decay rate = " << decayrate << endl;
         break;
      default:
         sillyKeyboard(key);
   }
}
Example #24
0
void keyboardchar(int key) { 
   switch (key) {
      case 'p':
         cout << "current list in eventBuffer: " << endl;
         eventBuffer.print();
         cout << endl;
         cout << "Event[0] status: " << eventBuffer[0].getStatus() << endl;
         break;
      case '\\':
         direction *= -1;
         if (direction == 1) {
            cout << "Up" << endl;
         } else {
            cout << "Down" << endl;
         }
         break;
      case 'r':                       // random direction to current algorithms
         randomizeDirections(tparam);
         cout << "Random directions" << endl;
         break;
      case 'f':                       // normal direction of algorithms
         forwardDirections(tparam);
         cout << "Normal directions" << endl;
         break;
      case 'i':                       // invert direction of algorithms
         invertDirections(tparam);
         cout << "Inverted directions" << endl;
         break;
      case 'c':                       // reverse direction of algorithms
         reverseDirections(tparam);
         cout << "Changed directions" << endl;
         break;
      case 's':	                      // increase rhythmic sensitivity
         tolerance = limit(tolerance * 1.02, 0.01, 0.99);
         cout << "Sensitivity = " << tolerance << endl;
         break;
      case 'x':	                      // decrease rhythmic sensitivity
         tolerance = limit(tolerance / 1.02, 0.01, 0.99);
         cout << "Sensitivity = " << tolerance << endl;
         break;
      default:
         sillyKeyboard(key);
   }
}
Example #25
0
void mainloopalgorithms(void) {
   eventBuffer.checkPoll();

   while (synth.getNoteCount() > 0) {
      message = synth.extractNote();
      if (message.isNoteOn() && message.getP1() == A0) {
         direction = -direction;
         cout << "Direction = " << direction << endl;
      } else if (message.isNoteOn() && message.getP1() == C7) {
         // add one to the length of the tumble sequence
         length = limit(length+1, 2, 200);
         cout << "Sequence length = " << length << endl;
      } else if (message.isNoteOn() && message.getP1() == B6) {
         // subtract one from the length of the tumble sequence
         length = limit(length-1, 2, 200);
         cout << "Sequence length = " << length << endl;
      } else {
         processNote(message, length, direction);
      }
   }
}
Example #26
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;
}
Example #27
0
void playchord(MidiEvent aMessage, int chordQuality, 
      int* rhythm, int* dur) {
   int numNotes = 0;             // the number of notes to play
   NoteEvent tempNote;           // temporary Note for copying into eventBuffer
   int chordNote[4];             // the notes of the chord to be calculated
   int rootNote = aMessage.getP1(); // root of chord to be created

   chordNote[0] = rootNote;
   switch (chordQuality) {
      case DIMINISHED_TRIAD:
         chordNote[1] = rootNote + 3;  chordNote[2] = rootNote + 6;
         numNotes = 3;
         break;
      case MINOR_TRIAD:
         chordNote[1] = rootNote + 3;  chordNote[2] = rootNote + 7;
         numNotes = 3;
         break;
      case MAJOR_TRIAD:
         chordNote[1] = rootNote + 4;  chordNote[2] = rootNote + 7;
         numNotes = 3;
         break;
      case AUGMENTED_TRIAD:
         chordNote[1] = rootNote + 4;  chordNote[2] = rootNote + 8;
         numNotes = 3;
         break;
      case FULLY_DIM_7TH:
         chordNote[1] = rootNote + 3;
         chordNote[2] = rootNote + 6;
         chordNote[3] = rootNote + 9;
         numNotes = 4;
         break;
      case HALF_DIM_7TH:
         chordNote[1] = rootNote + 3;
         chordNote[2] = rootNote + 6;
         chordNote[3] = rootNote + 10;        
         numNotes = 4;
         break;
      case mm_7TH:
         chordNote[1] = rootNote + 3;
         chordNote[2] = rootNote + 7;
         chordNote[3] = rootNote + 10;        
         numNotes = 4;
         break;
      case mM_7TH:
         chordNote[1] = rootNote + 3;
         chordNote[2] = rootNote + 7;
         chordNote[3] = rootNote + 11;        
         numNotes = 4;
         break;
      case Mm_7TH:
         chordNote[1] = rootNote + 3;
         chordNote[2] = rootNote + 4;
         chordNote[3] = rootNote + 10;        
         numNotes = 4;
         break;
      case MM_7TH:
         chordNote[1] = rootNote + 4;
         chordNote[2] = rootNote + 7;
         chordNote[3] = rootNote + 10;        
         numNotes = 4;
         break;
      default:                                    // invalid quality
         return;
   }

   cout << "Chord: (";
   for (int i=0; i<numNotes; i++) {
      tempNote.setKeyno(chordNote[i]);
      if (tempNote.getKeyno() < 0 || tempNote.getKeyno() > 127)  continue;

      if (attack[i] == 0) {
         tempNote.setVelocity(aMessage.getP2());
      } else {
         tempNote.setVelocity(attack[i]);
      }

      tempNote.setOnDur(t_time+rhythm[i]+offset, dur[i]);
      tempNote.setStatus(0);                   // note hasn't been played yet
      eventBuffer.insert(&tempNote);

      cout << tempNote.getKeyno();
      if (i != numNotes-1)  cout << ",";
   }
   cout << ")" << endl;
}
Example #28
0
void keyboardchar(int key) {
	static int lastkeytime = 0;
	static int number      = 0;

	if (t_time - lastkeytime > 5000) {
		// reset the number value if more than 5 seconds has elapsed
		// since the last key press.
		number = 0;
	}
	lastkeytime = t_time;

	if (isdigit(key)) {
		number = number * 10 + (key - '0');
		return;
	}
	switch (key) {
	// case 'a': break;
		case 'b':               // set color mode to black
			colorQ = 1;          // turn on colorization automatically
			colormode = 'b';
			colormessage(cout, COLOR_INIT, colormode, colorQ);
			cout << "!! CHANGING TO BLACK BACKGROUND" << endl;
			break;
		case 'c':               // toggle colorization
			colorQ = !colorQ;
			if (colorQ) {
				colormessage(cout, COLOR_INIT, colormode, colorQ);
				cout << "!! COLORIZATION TURNED ON" << endl;
			} else {
				colormessage(cout, COLOR_RESET, colormode, !colorQ);
				cout << "!! COLORIZATION TURNED OFF" << endl;
			}
			break;
	// case 'd': break;
		case 'e':               // print exclusive interpretation info for spines
			printExclusiveInterpLine(linenum, data);
			break;
	// case 'f': break;
	// case 'g': break;

		case 'h':               // hide/unhide non-kern spine (remove later)
		case 'k':               // hide/unhide non-kern spine
			hideQ = !hideQ;
			if (hideQ) {
				cout << "!! Hiding non-kern spines" << endl;
			} else {
				cout << "!! Showing all spines" << endl;
			}
			break;
	// case 'i': break;
	// case 'j': break;
	// case 'k': break;
		case 'l':               // transpose up specified number of semitones
			if (number < 100) {
				transpose = number;
				cout << "!! Transposing " << transpose << " steps up" << endl;
			}
			break;
		case 'L':               // transpose down specified number of semitones
			if (number < 100) {
				transpose = -number;
				cout << "!! Transposing " << -transpose << " steps down" << endl;
			}
			break;
		case 'm':               // mute or unmute all tracks
			if (number == 0) {
				std::fill(trackmute.begin(), trackmute.end(), 
						!trackmute[(int)trackmute.size()-1]);
				if (trackmute[0]) {
					cout << "!! All spines are muted" << endl;
				} else {
					cout << "!! All spines are unmuted" << endl;
				}
			} else {
				int tracknum = getKernTrack(number, data);
				trackmute[tracknum] = !trackmute[tracknum];
				if (trackmute[tracknum]) {
					cout << "!! **kern spine " << number << " is muted" << endl;
				} else {
					cout << "!! **kern spine " << number << " is unmuted" << endl;
				}
			}
			break;
			break;
		case 'n':     // toggle display of note only (supression
						  // of beam and stem display
						  // Also, don't display ![!]LO: lines.
			noteonlyQ = !noteonlyQ;
			if (noteonlyQ) {
				cout << "!! Notes only: supressing beams and stems in **kern data"
					  << endl;
			} else {
				cout << "!! Displaying **kern data unmodified" << endl;
			}
			break;
		case 'o':               // set the tempo to a particular value
			if (number > 20 && number < 601) {
				cout << "!! TEMPO SET TO " << number << endl;
				tempo = number;
				tempoScale = 1.0;
			} else if (number == 0) {
				cout << "!! Current tempo: " << tempo * tempoScale << endl;
			}
			break;
		case 'p':               // toggle music pausing
			eventBuffer.off();
			timer.reset();
			pauseQ = !pauseQ;
			if (pauseQ) {
				cout << "!! Paused" << endl;
			}
			break;
		case 'q':               // toggle display of file while playing
			echoTextQ = !echoTextQ;
			if (echoTextQ) {
				cout << "!! FILE DISPLAY TURNED ON" << endl;
			} else {
				cout << "!! FILE DISPLAY TURNED OFF" << endl;
			}
			break;
		case 'r':               // return to a marker
			if (number == 0) {
				linenum = markers[0];
				cout << "!! Going to line " << linenum << endl;
				eventBuffer.off();
				timer.reset();
			} else if (number < (int)markers.size()) {
				linenum = markers[number];
				cout << "!! Going to line " << linenum << endl;
				eventBuffer.off();
				timer.reset();
			}
			break;
		case 'R':               // Print a list of all markers
			printAllMarkers(cout, markers, data);
			break;
		case 's':    // silence notes
			eventBuffer.off();
			break;
		case 't':    // increase tab size
			tabsize++;
			// cout << "!! tabsize = " << tabsize << endl;
			break;
		case 'T':    // decrease tab size
			tabsize--;
			if (tabsize < 3) {
				tabsize = 3;
			}
			// cout << "!! tabsize = " << tabsize << endl;
			break;
	// case 'u': break;
	// case 'v': break;
		case 'w':               // set color mode to white
			colorQ = 1;          // turn on colorization automatically
			colormode = 'w';
			colormessage(cout, COLOR_INIT, colormode, colorQ);
			cout << "!! CHANGING TO WHITE BACKGROUND" << endl;
			break;
		case 'x':               // clear the screen
			colormessage(cout, COLOR_CLEAR_SCREEN, colormode, 1);
			printInputLine(data, linenum-1);
			break;
	// case 'y': break;
	// case 'z': break;

		case ' ':               // mark the measure/beat/line of the music
			if ((number != 0) && (number < (int)markers.size())) {
				markerindex = number;
			} else {
				markerindex++;
				if (markerindex > (int)markers.size()-1) {
					markerindex = 1;
				}
			}
			printMarkLocation(data, linenum == 0 ? 0 : linenum-1, markerindex);
			break;
		case ',':    // slow down tempo
			tempoScale *= 0.97;
			cout << "!! TEMPO SET TO " << (int)(tempo * tempoScale) << endl;
			break;
		case '<':
			tempoScale *= 0.93;
			cout << "!! TEMPO SET TO " << (int)(tempo * tempoScale) << endl;
			break;
		case '.':    // speed up tempo
			tempoScale *= 1.03;
			cout << "!! TEMPO SET TO " << (int)(tempo * tempoScale) << endl;
			break;
		case '>':
			tempoScale *= 1.07;
			cout << "!! TEMPO SET TO " << (int)(tempo * tempoScale) << endl;
			break;
		case '=':
			{
				int newline = 0;
				if (number == 0) {
					newline = 0;
				} else {
					newline = getMeasureLine(data, number);
				}
				if (newline >= 0) {
					cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
						  << " =" << number
						  << endl;
					linenum = newline;
					eventBuffer.off();
					timer.reset();
				}
			}
			break;
		case '(':
			{
				int newline = goBackMeasures(data, linenum, number);
				cout << "!! back " << number << " measure"
		 << (number==1? "":"s") << endl;
				linenum = newline;
				eventBuffer.off();
				timer.reset();
			}
			break;
		case ')':
			{
				int newline = goForwardMeasures(data, linenum, number);
				cout << "!! forward " << number << " measure"
					  << (number==1? "":"s") << endl;
				linenum = newline;
				eventBuffer.off();
				timer.reset();
			}
			break;
		case '+':    // louder
			velocity++;
			if (velocity > 127) {
				velocity = 127;
			}
			cout << "!! velocity = " << velocity << endl;
			break;

		case '_':    // sofer
			velocity--;
			if (velocity < 1) {
				velocity = 1;
			}
			cout << "!! velocity = " << velocity << endl;
			break;

		case '^':    // go to the start of the file
			linenum = 0;
			cout << "!! Going to start of file" << endl;
			break;

		case '$':    // go to the end of the file
			linenum = data.getNumLines() - 1;
			cout << "!! Going to end of file" << endl;
			break;
	}

	if (!isdigit(key)) {
		number = 0;
	}
}
Example #29
0
void finishup(void) {
	eventBuffer.off();
	printAllMarkers(cout, markers, data);
	std::fill(markers.begin(), markers.end(), 0);
	colormessage(cout, COLOR_RESET, colormode, colorQ);
}
Example #30
0
void processNotes(HumdrumRecord& record) {
	NoteEvent note;
	int pitch = 0;
	double duration = 0.0;
	int staccatoQ = 0;
	int accentQ = 0;
	int sforzandoQ = 0;
	int i, j;
	int notecount = 0;
	char buffer[128] = {0};
	for (i=0; i<record.getFieldCount(); i++) {
		if ((record.getPrimaryTrack(i) < (int)trackmute.size())
				&& trackmute[record.getPrimaryTrack(i)]) {
			continue;
		}
		if (record.getExInterpNum(i) == E_KERN_EXINT) {
			notecount = record.getTokenCount(i);
			if (strcmp(record[i], ".") == 0) {
				continue;
			}
			for (j=0; j<notecount; j++) {
				record.getToken(buffer, i, j);
				if (strchr(buffer, '[')) {
					// total tied note durations
					duration = data.getTiedDuration(linenum, i, j);
				} else {
					duration = Convert::kernToDuration(buffer);
				}
				pitch = Convert::kernToMidiNoteNumber(buffer);
				// skip rests
				if (pitch < 0) {
					continue;
				}
				pitch += transpose;
				// don't play note which is transposed too extremely
				if (pitch < 0)   { continue; }
				if (pitch > 127) { continue; }

				// skip tied notes
				if (strchr(buffer, '_') || strchr(buffer, ']')) {
					continue;
				}

				accentQ    = strchr(buffer, '^')  == NULL? 0 : 1;
				sforzandoQ = strchr(buffer, 'z')  == NULL? 0 : 1;
				staccatoQ  = strchr(buffer, '\'') == NULL? 0 : 1;
				note.setChannel(0);
				note.setKey(pitch);
				note.setOnTime(t_time);
				duration = duration * 60000 / tempo / tempoScale;
				if (shortenQ) {
					duration -= shortenamount;
					if (duration < mine) {
						duration = mine;
					}
				}
				note.setDur((int)duration);
				if (staccatoQ) {
					note.setDur((int)(0.5 * note.getDur()));
				}
				note.setKey(pitch);
				if (accentQ) {
					velocity *= 1.3;
				}
				if (sforzandoQ) {
					velocity *= 1.5;
				}
				if (velocity > 127) {
					velocity = 127;
				}
				note.setVelocity(velocity);

				note.activate();
				note.action(eventBuffer);
				eventBuffer.insert(note);
			}
		}
	}
}