Example #1
0
int GenericProcessor::checkForEvents(MidiBuffer& midiMessages)
{

	if (midiMessages.getNumEvents() > 0) 
	{
			
		int m = midiMessages.getNumEvents();
		//std::cout << m << " events received by node " << getNodeId() << std::endl;

		MidiBuffer::Iterator i (midiMessages);
		MidiMessage message(0xf4);

		int samplePosition = 0;
		i.setNextSamplePosition(samplePosition);

		while (i.getNextEvent (message, samplePosition)) {
			
			uint8* dataptr = message.getRawData();

			handleEvent(*dataptr, message, samplePosition);

		}

	}

	return -1;

}
Example #2
0
int GenericProcessor::getNumSamples(MidiBuffer& events) {

	int numRead = 0;

	if (events.getNumEvents() > 0) 
	{
			
		int m = events.getNumEvents();

		//std::cout << getName() << " received " << m << " events." << std::endl;

		MidiBuffer::Iterator i (events);
		MidiMessage message(0xf4);

		int samplePosition = -5;

		while (i.getNextEvent (message, samplePosition)) {
			
			uint8* dataptr = message.getRawData();

			if (*dataptr == BUFFER_SIZE)
			{
				numRead = message.getTimeStamp();
			}
		}
	}

	return numRead;
}
Example #3
0
void GenericSynth::processBlock (AudioSampleBuffer& buffer,
                                 MidiBuffer& midiMessages)
{
    buffer.clear();

    if (midiMessages.getNumEvents())
    {
        DBG("events "<<midiMessages.getNumEvents());
    }

    synth.renderNextBlock (buffer, midiMessages, 0, buffer.getNumSamples());
}
//------------------------------------------------------------------------------
void MidiInterceptor::processBlock(AudioSampleBuffer &buffer,
								   MidiBuffer &midiMessages)
{
	int samplePos;
	double seconds;
	MidiMessage tempMess(0xf0);
	MidiBuffer::Iterator it(midiMessages);
	const double sampleRate = getSampleRate();

	jassert(sampleRate > 0.0);

	if(midiManager)
	{
		int numMess = midiMessages.getNumEvents();

		if(numMess > 0)
			numMess = numMess;

		while(it.getNextEvent(tempMess, samplePos))
		{
			seconds = (double)(samplesSinceStart+samplePos)/sampleRate;
			midiManager->midiCcReceived(tempMess, seconds);
		}
	}

	samplesSinceStart += buffer.getNumSamples();

	midiMessages.clear();
}
Example #5
0
void CtrlrProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    AudioPlayHead::CurrentPositionInfo info;
    if (getPlayHead())
    {
        getPlayHead()->getCurrentPosition(info);
    }

	if (midiMessages.getNumEvents() > 0)
	{
		processPanels(midiMessages, info);
	}

	midiCollector.removeNextBlockOfMessages (midiMessages, buffer.getNumSamples());

	MidiBuffer::Iterator i(midiMessages);
	while (i.getNextEvent(logResult, logSamplePos))
		_MOUT("VST OUTPUT", logResult, logSamplePos);
}
Example #6
0
void EventNode::process(AudioSampleBuffer &buffer, 
                            MidiBuffer &midiMessages,
                            int& nSamples)
{
	accumulator++;

	if (!isSource) {
		
		if (midiMessages.getNumEvents() > 0) {
			
			std::cout << "Events received by node " << getNodeId() << std::endl;

			 MidiBuffer::Iterator i (midiMessages);
			 MidiMessage message(0xf4);

			 int samplePosition;
			 i.setNextSamplePosition(samplePosition);

			 while (i.getNextEvent (message, samplePosition)) {
				
					//message.getChannel();

					//MidiMessage msgCopy = MidiMessage(message);
					int numbytes = message.getRawDataSize();
					uint8* dataptr = message.getRawData();

					

					std::cout << " Bytes received: " << numbytes << std::endl;
					std::cout << " Message timestamp = " << message.getTimeStamp() << std::endl;

					//std::cout << sizeof(int) << " " << sizeof(uint16) << std::endl;
 
 					std::cout << "   ";
					for (int n = 0; n < numbytes; n++) {
						std::cout << String(*dataptr++) << " ";
					}
					
					std::cout << std::endl << std::endl;
				 	//std::cout << "  Event on channel " << message.getRawData() << std::endl; //<< message.getRawDataSize() << std::endl;

			}


			// accumulator = 0;
		}//MidiBuffer::Iterator = midiMessages.

		//midiMessages.clear();

	} else {

		if (accumulator > 20) {

			uint8 data[95];

			for (int n = 0; n < sizeof(data); n++) {
				data[n] = 1;
			}

			//MidiMessage event = MidiMessage::noteOn(2,1,10.0f);
			MidiMessage event = MidiMessage(data, 	// spike data (float)
											sizeof(data), 	// number of bytes to use
											1000.0 	// timestamp (64-bit)
											);
			
			//event.setChannel(1);

			midiMessages.addEvent(data, sizeof(data), 5);
			//midiMessages.addEvent(event, 1);

			for (int n = 0; n < sizeof(data); n++) {
				data[n] = 2;
			}

			midiMessages.addEvent(data, sizeof(data), 10);

			for (int n = 0; n < sizeof(data); n++) {
				data[n] = 3;
			}

			midiMessages.addEvent(data, sizeof(data), 15);

			//midiMessages.addEvent(event, 5);

			//std::cout << "Midi buffer contains " << midiMessages.getNumEvents() << " events." << std::endl;

			accumulator = 0;
		}
		

	}

	
	

}