Ejemplo n.º 1
0
void mainloopalgorithms(void) { 
   if (synth.getNoteCount() > 0) {
      processKeyboard();
   }

   if (offTimer.expired()) {
      checkBuffers();
      checkOffNotes();
      offTimer.reset();
   }

   if (batonTimer.expired()) {
      processBaton();
      batonTimer.reset();
   }

   voicePeriod = (int)(avgDur - avgDurRange);
   if (voicePeriod <= 50) {
      voicePeriod = 50;
   }

   voiceTimer.setPeriod(voicePeriod);
   if (voiceTimer.expired()) {
      generateVoices();
      voiceTimer.reset();
   }

   if (controlDisplayQ && controlDisplayTimer.expired()) {
      displayVariables();
      controlDisplayTimer.reset();
   }

}
Ejemplo n.º 2
0
void playdata(HumdrumFile& data, int& linenum, SigTimer& timer) {
	double duration = 0;     // duration of the current line;

	if (data.getNumLines() == 0) {
		// ignore empty files.
		return;
	}

	int type = data[linenum].getType();

	while (linenum < data.getNumLines() && duration == 0.0) {
		duration = data[linenum].getDuration();

		if (type == E_humrec_data) {
			processNotes(data[linenum]);
		} else if (type == E_humrec_interpretation) {
			if (strncmp(data[linenum][0], "*MM", 3) == 0) {
				tempo = atoi(&data[linenum][0][3]);
			}
		}
		if (echoTextQ) {
			printInputLine(data, linenum);
		}
		if (duration > 0.0) {
			timer.setPeriod(60000 / tempo / tempoScale * duration);
			timer.reset();
		}
		linenum++;
		if (linenum < data.getNumLines()) {
			type = data[linenum].getType();
		}
	}
}
Ejemplo n.º 3
0
void initialization(void) { 
   notetimer.setPeriod(period); // set the period in ms between MIDI events.
   notetimer.reset();

   sentout.setSize(1024);       // store up to 1024 MIDI output bytes 
   receivedin.setSize(1024);    // store up to 1024 MIDI input bytes
   description();

   synth.makeOrphanBuffer();
   start();
}
Ejemplo n.º 4
0
void initialization(void) { 
   checkOptions(options);

   triggerTimer.setPeriod(75);

   performance.read(options.getArg(1));
   performance.setPort(outport);
   performance.setMaxAmp(maxamp);
   performance.open();
   performance.setTempoMethod(tempoMethod);

}
Ejemplo n.º 5
0
void initialization(void) { 
   batonTimer.setPeriod(50);           // time to get new state of baton
   offTimer.setPeriod(200);            // time to check buffer for forgetting
   controlDisplayTimer.setPeriod(200); // time to check buffer for forgetting

   // set the voice channels all to be 0 for the disklavier and so
   // the channels do not have to be specified when playing the note.
   for (int i=0; i<MAXVOICES; i++) {
      voice[i].setChannel(0);
   }
   computer.setChannel(0);
   computerMessage.time = t_time;
   computerMessage.p0() = 0x90;
   computerMessage.p1() = 0;
   computerMessage.p2() = 0;

   keys.setSize(1000);        // store keys for memory of previous notes
   keytimes.setSize(1000);    // note times for keys buffer
   volumes.setSize(1000);     // duration of notes being held by performer
   voltimes.setSize(1000);    // duration of notes being held by performer
   durations.setSize(1000);   // duration of notes being held by performer
   durtimes.setSize(1000);    // duration of notes being held by performer
}
Ejemplo n.º 6
0
void initialization(void) { 
   sensor.initialize(options.argv()); // start CVIRTE stuff for NIDAQ card
   sensor.setPollPeriod(1);      // check for new data every 1 millisecond   
   sensor.setFrameSize(1);       // data transfer size from NIDAQ card
   sensor.setModeLatest();       // just look at most recent data in buffer
   sensor.setSrate(500);         // set NIDAQ sampling rate to X Hz
   sensor.activateAllChannels(); // turn on all channels for sampling 
   cout << "starting data aquisition ... " << flush;
   sensor.start();              // start aquiring data from NIDAQ card
   cout << "ready." << endl;

   voice.setPort(synth.getOutputPort());   // specify output port of voice
   voice.setChannel(0);         // specify output chan of voice
   voice.pc(inst);

   displayTimer.setPeriod(200); // display position every X milliseconds
}
Ejemplo n.º 7
0
int main(int argc, char** argv) {
   Options options(argc, argv);
   checkOptions(options);

   keyboardTimer.setPeriod(10);
   int command = 0;

   MidiInput midiin;
   midiin.setPort(inport);
   midiin.open();
   MidiEvent midimessage;

   performance.read(options.getArg(1).data());
   performance.setPort(outport);
   performance.setMaxAmp(maxamp);
   performance.open();
   performance.setTempoMethod(tempoMethod);
   performance.play();
   while (command != 'Q') {
      while (midiin.getCount() > 0) {
         midiin.extract(midimessage);
         processMidiCommand(midimessage);
      }
      performance.xcheck();
      eventIdler.sleep();

      if (keyboardTimer.expired()) {
         keyboardTimer.reset();
         command = checkKeyboard();
         if (command == 'Q') {
            break;
         } else {
            keyboardCommand(command);
         }
      }

   }

   return 0;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
void keyboardchar(int key) { 
   switch (key) {
      case 'h':        // more help
         help();
         break;
      case '[':        // slow tempo
         period--;
         if (period < 1) {
            period = 1;
         }
         cout << "Period: " << period << endl;
         notetimer.setPeriod(period);
         break;
      case '{':        // slow tempo by 5
         period -= 5;
         if (period < 1) {
            period = 1;
         }
         cout << "Period: " << period << endl;
         notetimer.setPeriod(period);
         break;
      case ']':        // speed tempo
         period++;
         cout << "Period: " << period << endl;
         notetimer.setPeriod(period);
         break;
      case '}':        // speed tempo by 5
         period += 5;
         cout << "Period: " << period << endl;
         notetimer.setPeriod(period);
         break;
      case 'u':        // make glissando go up
         direction = 1;
         cout << "Glissandoing up" << endl;
         break;
      case 'd':        // make glissando go down
         direction = -1;
         cout << "Glissandoing down" << endl;
         break;
      case '1':        // lower bottom of glissando range
         if (lowestnote > 0) {
            lowestnote--;
            cout << "lowest note set to: " << lowestnote << endl;
         }
         break;
      case '2':        // raise bottom of glissando range
         if (lowestnote < highestnote - 1) {
            lowestnote++;
            cout << "lowest note set to " << lowestnote << endl;
         } 
         break;
      case '3':        // lower both the top and the bottom of range
         if (lowestnote > 0) {
            lowestnote--;
            highestnote--;
            cout << "Range lowered" << endl;
         }
         break;
      case '4':        // lower both the top and the bottom of range
         if (highestnote < 127) {
            lowestnote++;
            highestnote++;
            cout << "Range raised" << endl;
         }
         break;
      case '5':        // lower step amount
         step--;
         if (step < 1) {
            step = 1;
         }
         cout << "Step size = " << step << endl;
         break;
      case '6':        // raise step amount
         step++;
         cout << "Step size = " << step << endl;
         break;
      case '-':        // lower top of glissando range
         if (highestnote > lowestnote + 1) {
            highestnote--;
            cout << "highest note set to: " << highestnote << endl;
         }
         break;
      case '=':        // raise top or glissando range
         if (highestnote < 127) {
            highestnote++;
            cout << "highestnote note set to: " << highestnote << endl;
         }
         break;
      case ' ':       // toggle sending/comparing of data
         if (comparestate) {
            stop();
            cout << "Stopped data transmission/comparison" << endl;
         } else {
            cout << "Starting data transmission/comparison" << endl;
            start();
         }
   }
}