示例#1
0
    void sendMessageNow (const MidiMessage& message)
    {
        if (message.getRawDataSize() > maxEventSize)
        {
            maxEventSize = message.getRawDataSize();
            snd_midi_event_free (midiParser);
            snd_midi_event_new (maxEventSize, &midiParser);
        }

        snd_seq_event_t event;
        snd_seq_ev_clear (&event);

        long numBytes = (long) message.getRawDataSize();
        const uint8* data = message.getRawData();

        while (numBytes > 0)
        {
            const long numSent = snd_midi_event_encode (midiParser, data, numBytes, &event);
            if (numSent <= 0)
                break;

            numBytes -= numSent;
            data += numSent;

            snd_seq_ev_set_source (&event, 0);
            snd_seq_ev_set_subs (&event);
            snd_seq_ev_set_direct (&event);

            snd_seq_event_output (seqHandle, &event);
        }

        snd_seq_drain_output (seqHandle);
        snd_midi_event_reset_encode (midiParser);
    }
    void sendMessageNow (const MidiMessage& message)
    {
        if (message.getRawDataSize() > maxEventSize)
        {
            maxEventSize = message.getRawDataSize();
            snd_midi_event_free (midiParser);
            snd_midi_event_new (maxEventSize, &midiParser);
        }

        snd_seq_event_t event;
        snd_seq_ev_clear (&event);

        snd_midi_event_encode (midiParser,
                               message.getRawData(),
                               message.getRawDataSize(),
                               &event);

        snd_midi_event_reset_encode (midiParser);

        snd_seq_ev_set_source (&event, 0);
        snd_seq_ev_set_subs (&event);
        snd_seq_ev_set_direct (&event);

        snd_seq_event_output (seqHandle, &event);
        snd_seq_drain_output (seqHandle);
    }
示例#3
0
void CtrlrMIDIDevice::handleIncomingMidiMessage (MidiInput* /*source*/, const MidiMessage& message)
{
	_MIN(getProperty(Ids::name), message, -1);

#ifdef JUCE_LINUX
    uint8 *ptr = (uint8 *)message.getRawData();

    if (!message.isSysEx() && *(ptr + (message.getRawDataSize() - 1)) == 0xf7)
    {
        dataCollector.append (ptr, message.getRawDataSize());

        deviceListeners.call (&CtrlrMIDIDevice::Listener::handleMIDIFromDevice, MidiMessage (dataCollector.getData(), dataCollector.getSize()));

        return;
    }
#endif

	if (message.isSysEx())
	{
#ifdef JUCE_LINUX


        if (*(ptr + (message.getRawDataSize() - 1)) == 0xf7)
        {
            deviceListeners.call (&CtrlrMIDIDevice::Listener::handleMIDIFromDevice, message);
        }
        else
        {
            dataCollector = MemoryBlock (ptr, message.getRawDataSize());
        }
#else
		deviceListeners.call (&CtrlrMIDIDevice::Listener::handleMIDIFromDevice, message);
#endif
	}
	else
	{
        lastMessageWasSysex = false;

		for (int i=0; i<deviceListeners.size(); i++)
		{
			const int ch = deviceListeners.getListeners() [i]->getListenerInputMidiChannel();

			if (ch == message.getChannel() || ch == 0 || message.getChannel() == 0)
			{
				deviceListeners.getListeners() [i]->handleMIDIFromDevice (message);
			}
		}
	}
}
void CtrlrSysexProcessor::sysExProcess (const Array<CtrlrSysexToken> &tokens, MidiMessage &m, const int value, const int channel)
{
	if (tokens.size() != m.getRawDataSize())
		return;

	uint8 *dataPtr = (uint8 *)m.getRawData();

	for (int i=0; i<m.getRawDataSize(); i++)
	{
		sysExProcessToken (tokens.getReference(i), dataPtr+i, value, channel);
	}

	sysexProcessPrograms(tokens, m);
	sysexProcessChecksums(tokens, m);
}
示例#5
0
static void RT_MIDI_send_msg_to_patch(struct Patch *patch, MidiMessage message, int64_t seq_time){       
  if (message.isNoteOn())
    RT_PATCH_play_note(patch, message.getNoteNumber(), -1, message.getVelocity() / 127.0f, 0.0f, seq_time);
  
  else if (message.isNoteOff())
    RT_PATCH_stop_note(patch, message.getNoteNumber(), -1, seq_time);
  
  else if (message.isAftertouch())
    RT_PATCH_change_velocity(patch, message.getNoteNumber(), -1, message.getChannelPressureValue() / 127.0f, seq_time);

  else {
    
    const uint8_t *raw_data = message.getRawData();
    int len = message.getRawDataSize();

    R_ASSERT_RETURN_IF_FALSE(len>=1 && len<=3);

    uint32_t msg;

    if (len==3)
      msg = MIDI_msg_pack3(raw_data[0],raw_data[1],raw_data[2]);
    else if (len==2)
      msg = MIDI_msg_pack2(raw_data[0],raw_data[1]);
    else if (len==1)
      msg = MIDI_msg_pack1(raw_data[0]);
    else
      return;
    
    RT_PATCH_send_raw_midi_message(patch, msg, seq_time);
  }
}
示例#6
0
void PGMidiDevice::PGMidiInputCallback::handleIncomingMidiMessage(MidiInput *source, const MidiMessage &msg)
{
	Logger::getCurrentLogger()->writeToLog("midiin: recv message:");
	string dbg = ToHexString(msg.getRawData(), msg.getRawDataSize());
	Logger::getCurrentLogger()->writeToLog(dbg);

	// currently, G1 should only send SysEx to app
	if (!msg.isSysEx())
		return;

	const uint8 *buf = msg.getSysExData();
	int size = msg.getSysExDataSize();

	if (!PGSysExParser::IsPGSysEx(buf, size))
		return;

	switch (PGSysExParser::GetOpMsb(buf, size))
	{
	case REPLY_GRP:
		OwnerMidiDevice->MidiMessageBox.NotifyReply(msg);
		break;
	case ACK_GRP:
	case NAK_GRP:
		OwnerMidiDevice->MidiMessageBox.NotifyAck(msg);
		break;
	default:
		break;
	}
}
示例#7
0
void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int samplePosition)
{

    //std::cout << "Received event of type " << eventType << std::endl;

    if (eventType == SPIKE)
    {

        const uint8_t* dataptr = event.getRawData();
        int bufferSize = event.getRawDataSize();

        if (bufferSize > 0)
        {

            SpikeObject newSpike;

            bool isValid = unpackSpike(&newSpike, dataptr, bufferSize);

            if (isValid)
            {
                int electrodeNum = newSpike.source;

                Electrode& e = electrodes.getReference(electrodeNum);
                // std::cout << electrodeNum << std::endl;

                bool aboveThreshold = false;

                // update threshold / check threshold
                for (int i = 0; i < e.numChannels; i++)
                {
                    e.detectorThresholds.set(i, float(newSpike.threshold[i])); // / float(newSpike.gain[i]));

                    aboveThreshold = aboveThreshold | checkThreshold(i, e.displayThresholds[i], newSpike);
                }

                if (aboveThreshold)
                {

                    // add to buffer
                    if (e.currentSpikeIndex < displayBufferSize)
                    {
                        //  std::cout << "Adding spike " << e.currentSpikeIndex + 1 << std::endl;
                        e.mostRecentSpikes.set(e.currentSpikeIndex, newSpike);
                        e.currentSpikeIndex++;
                    }

                    // save spike
                    if (isRecording)
                    {
						getProcessorGraph()->getRecordNode()->writeSpike(newSpike,e.recordIndex);
                    }
                }

            }

        }

    }

}
示例#8
0
const MemoryBlock CtrlrMIDITransaction::getDataFromResponse(const MidiMessage &messageToExtractFrom)
{
	MemoryBlock returnData;
	MemoryBlock temp(messageToExtractFrom.getRawData(), messageToExtractFrom.getRawDataSize());

	returnData.copyFrom (temp.getData(), getResponsePrefixLength(), getResponseDataLength());
	return (returnData);
}
示例#9
0
void MidiOutput::sendMessageNow (const MidiMessage& message)
{
   #if JUCE_IOS
    const MIDITimeStamp timeStamp = mach_absolute_time();
   #else
    const MIDITimeStamp timeStamp = AudioGetCurrentHostTime();
   #endif

    HeapBlock<MIDIPacketList> allocatedPackets;
    MIDIPacketList stackPacket;
    MIDIPacketList* packetToSend = &stackPacket;
    const size_t dataSize = (size_t) message.getRawDataSize();

    if (message.isSysEx())
    {
        const int maxPacketSize = 256;
        int pos = 0, bytesLeft = (int) dataSize;
        const int numPackets = (bytesLeft + maxPacketSize - 1) / maxPacketSize;
        allocatedPackets.malloc ((size_t) (32 * (size_t) numPackets + dataSize), 1);
        packetToSend = allocatedPackets;
        packetToSend->numPackets = (UInt32) numPackets;

        MIDIPacket* p = packetToSend->packet;

        for (int i = 0; i < numPackets; ++i)
        {
            p->timeStamp = timeStamp;
            p->length = (UInt16) jmin (maxPacketSize, bytesLeft);
            memcpy (p->data, message.getRawData() + pos, p->length);
            pos += p->length;
            bytesLeft -= p->length;
            p = MIDIPacketNext (p);
        }
    }
    else if (dataSize < 65536) // max packet size
    {
        const size_t stackCapacity = sizeof (stackPacket.packet->data);

        if (dataSize > stackCapacity)
        {
            allocatedPackets.malloc ((sizeof (MIDIPacketList) - stackCapacity) + dataSize, 1);
            packetToSend = allocatedPackets;
        }

        packetToSend->numPackets = 1;
        MIDIPacket& p = *(packetToSend->packet);
        p.timeStamp = timeStamp;
        p.length = (UInt16) dataSize;
        memcpy (p.data, message.getRawData(), dataSize);
    }
    else
    {
        jassertfalse; // packet too large to send!
        return;
    }

    static_cast<CoreMidiHelpers::MidiPortAndEndpoint*> (internal)->send (packetToSend);
}
示例#10
0
    bool sendMessageNow (const MidiMessage& message)
    {
        if (message.getRawDataSize() > maxEventSize)
        {
            maxEventSize = message.getRawDataSize();
            snd_midi_event_free (midiParser);
            snd_midi_event_new ((size_t) maxEventSize, &midiParser);
        }

        snd_seq_event_t event;
        snd_seq_ev_clear (&event);

        long numBytes = (long) message.getRawDataSize();
        const uint8* data = message.getRawData();

        snd_seq_t* seqHandle = port.client->get();
        bool success = true;

        while (numBytes > 0)
        {
            const long numSent = snd_midi_event_encode (midiParser, data, numBytes, &event);

            if (numSent <= 0)
            {
                success = numSent == 0;
                break;
            }

            numBytes -= numSent;
            data += numSent;

            snd_seq_ev_set_source (&event, 0);
            snd_seq_ev_set_subs (&event);
            snd_seq_ev_set_direct (&event);

            if (snd_seq_event_output_direct (seqHandle, &event) < 0)
            {
                success = false;
                break;
            }
        }

        snd_midi_event_reset_encode (midiParser);
        return success;
    }
示例#11
0
void CtrlrSysexProcessor::sysexProcessChecksums(const Array<CtrlrSysexToken> &tokens, MidiMessage &m)
{
	if (tokens.size() != m.getRawDataSize())
		return;

	for (int i=0; i<m.getRawDataSize(); i++)
	{
		if (tokens.getReference(i).getType() == ChecksumRolandJP8080)
		{
			checksumRolandJp8080 (tokens.getReference(i), m);
		}

		if (tokens.getReference(i).getType() == ChecksumWaldorfRackAttack)
		{
			checksumWaldorfRackAttack (tokens.getReference(i), m);
		}
	}
}
示例#12
0
const String getRawData(const MidiMessage &m, const bool rawInDecimal)
{
	if (rawInDecimal)
	{
		String ret;
		uint8 *ptr = (uint8 *)m.getRawData();
		for (int i=0; i<m.getRawDataSize(); i++)
		{
			ret << String::formatted ("%.3d", (int)*(ptr+i));
			ret << " ";
		}
		return (" RAW:["+ret.trim()+"]");
	}
	else
	{
		return (" RAW:["+String::toHexString (m.getRawData(), m.getRawDataSize())+"]");
	}
}
void CtrlrSysexProcessorOwned::sysexProcessPrograms(const Array<CtrlrSysexToken> &tokens, MidiMessage &m)
{
	if (tokens.size() != m.getRawDataSize())
		return;

	for (int i=0; i<m.getRawDataSize(); i++)
	{
		if (tokens.getReference(i).getType() == CurrentProgram)
		{
			uint8 *ptr	= (uint8 *)m.getRawData();
			*(ptr+tokens.getReference(i).getPosition()) = owner.getCurrentProgramNumber();
		}
		if (tokens.getReference(i).getType() == CurrentBank)
		{
			uint8 *ptr	= (uint8 *)m.getRawData();
			*(ptr+tokens.getReference(i).getPosition()) = owner.getCurrentBankNumber();
		}
	}
}
示例#14
0
void MidiOutput::sendMessageNow (const MidiMessage& message)
{
    const MidiOutHandle* const handle = static_cast <const MidiOutHandle*> (internal);

    if (message.getRawDataSize() > 3
         || message.isSysEx())
    {
        MIDIHDR h = { 0 };

        h.lpData = (char*) message.getRawData();
        h.dwBufferLength = message.getRawDataSize();
        h.dwBytesRecorded = message.getRawDataSize();

        if (midiOutPrepareHeader (handle->handle, &h, sizeof (MIDIHDR)) == MMSYSERR_NOERROR)
        {
            MMRESULT res = midiOutLongMsg (handle->handle, &h, sizeof (MIDIHDR));

            if (res == MMSYSERR_NOERROR)
            {
                while ((h.dwFlags & MHDR_DONE) == 0)
                    Sleep (1);

                int count = 500; // 1 sec timeout

                while (--count >= 0)
                {
                    res = midiOutUnprepareHeader (handle->handle, &h, sizeof (MIDIHDR));

                    if (res == MIDIERR_STILLPLAYING)
                        Sleep (2);
                    else
                        break;
                }
            }
        }
    }
    else
    {
        midiOutShortMsg (handle->handle,
                         *(unsigned int*) message.getRawData());
    }
}
示例#15
0
StringTS::StringTS(MidiMessage& event)
{
	const uint8* dataptr = event.getRawData();
	int bufferSize = event.getRawDataSize();
	len = bufferSize - 20; 
	str = new uint8[len];
	memcpy(str, dataptr+6, len);

	memcpy(&timestamp, dataptr +6+ len, 8); 
	
}
示例#16
0
bool MidiMessageBox::SendMessageAndWaitReply(MidiOutput *out, MidiMessage &msg, int msec)
{
	if (!out)
		return false;

	Logger::getCurrentLogger()->writeToLog("midiout: send message and wait reply");
	string dbg = ToHexString(msg.getRawData(), msg.getRawDataSize());
	Logger::getCurrentLogger()->writeToLog(dbg);

	std::unique_lock<std::mutex> lck(_mutex);
	out->sendMessageNow(msg);
	return std::cv_status::no_timeout == _reply_cv.wait_for(lck, std::chrono::milliseconds(msec));
}
示例#17
0
void MidiOutput::sendMessageNow (const MidiMessage& message)
{
    CoreMidiHelpers::MidiPortAndEndpoint* const mpe = static_cast<CoreMidiHelpers::MidiPortAndEndpoint*> (internal);

    if (message.isSysEx())
    {
        const int maxPacketSize = 256;
        int pos = 0, bytesLeft = message.getRawDataSize();
        const int numPackets = (bytesLeft + maxPacketSize - 1) / maxPacketSize;
        HeapBlock <MIDIPacketList> packets;
        packets.malloc (32 * numPackets + message.getRawDataSize(), 1);
        packets->numPackets = numPackets;

        MIDIPacket* p = packets->packet;

        for (int i = 0; i < numPackets; ++i)
        {
            p->timeStamp = 0;
            p->length = jmin (maxPacketSize, bytesLeft);
            memcpy (p->data, message.getRawData() + pos, p->length);
            pos += p->length;
            bytesLeft -= p->length;
            p = MIDIPacketNext (p);
        }

        mpe->send (packets);
    }
    else
    {
        MIDIPacketList packets;
        packets.numPackets = 1;
        packets.packet[0].timeStamp = 0;
        packets.packet[0].length = message.getRawDataSize();
        *(int*) (packets.packet[0].data) = *(const int*) message.getRawData();

        mpe->send (&packets);
    }
}
示例#18
0
static PyObject *
MidiOut_sendMessage(MidiOut *self, PyObject *args)
{
  
  PyObject *a0 = NULL;
  if(PyArg_ParseTuple(args, "O", &a0) == 0)
    return NULL;

  MidiMessage *created = NULL; // delete if set
  MidiMessage *midi = NULL;
  if(PyMidiMessage_Check(a0))
    {
      midi = ((PyMidiMessage *) a0)->m;
    }
  else if(PyLong_Check(a0))
    {
      PyErr_SetString(rtmidi_Error, "long ctor args not supported yet.");
      return NULL;
      /*
      int i0 = (int) PyLong_AsUnsignedLong(a0);
      printf("MidiOut_sendMessage: %i\n", i0);
      midi = created = new MidiMessage(i0);
      */
    }
  else
    {
      PyErr_SetString(rtmidi_Error, "argument 1 must be of type MidiMessage or a number.");
      return NULL;
    }
  
  std::vector<unsigned char> outMessage;
  uint8 *data = midi->getRawData();
  for(int i=0; i < midi->getRawDataSize(); ++i)
    outMessage.push_back((unsigned char) data[i]);
  
  try
  {
    self->rtmidi->sendMessage(&outMessage);
  }
  catch(RtMidiError &error)
  {
    PyErr_SetString(rtmidi_Error, error.what());
    if(created) delete created;
    return NULL;
  }
  
  if(created) delete created;
  Py_RETURN_NONE;
}
void CtrlrPanelMIDIInputThread::handleMIDIFromDevice (const MidiMessage &message)
{
	const ScopedWriteLock sl (lock);

	if (owner.getMidiOptionBool(panelMidiRealtimeIgnore) && message.getRawDataSize() <= 1)
		return;

	if (message.isNoteOnOrOff() || message.isMidiClock())
	{
		deviceInputBuffer.addEvent (message, deviceInputBuffer.getNumEvents()+1);
	}
	else
	{
		deviceInputBuffer.addEvent (message, deviceInputBuffer.getNumEvents()+2);
	}

	notify();
}
示例#20
0
void MetronomeProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int numSamples = buffer.getNumSamples();
    int channel;

	// convert special metronome bip and bop (0xf2 00 and 0xf2 01) into note on/off messages

	MidiBuffer metronomeMidiBuffer;
	MidiBuffer::Iterator iter(midiMessages);
	MidiMessage message;
	int pos;
	while (iter.getNextEvent(message,pos))
	{
		if (message.getRawDataSize()==2 && message.isSongPositionPointer())
		{
			char raw[4] = {0,0,0,0};

			char* data = (char*)message.getRawData();
			if (data[1]==0)
			{
				// bip
				MidiMessage b = MidiMessage::noteOn(1,80,64.0f);
				memcpy(raw,b.getRawData(),4);
			}
			else
			{
				// bop
				MidiMessage b = MidiMessage::noteOn(1,70,64.0f);
				memcpy(raw,b.getRawData(),4);
			}

			if (raw[0])
			{
				MidiMessage m(raw[0],raw[1],raw[2]);
				//printf("m %d %d %d at %d\n",m.getRawData()[0],m.getRawData()[1],m.getRawData()[2],pos);

				metronomeMidiBuffer.addEvent(m,pos);
			}
		}
	}

    // and now get the synth to process these midi events and generate its output.
    synth.renderNextBlock (buffer, metronomeMidiBuffer, 0, numSamples);
}
示例#21
0
    //==============================================================================
    void extractRawBinaryData (const MidiBuffer& midiBuffer, const uint8* bufferToCopyTo, std::size_t maxBytes)
    {
        std::size_t pos = 0;
        MidiBuffer::Iterator iter (midiBuffer);
        MidiMessage midiMessage;
        int samplePosition; // Note: not actually used, so no need to initialise.

        while (iter.getNextEvent (midiMessage, samplePosition))
        {
            const uint8* data = midiMessage.getRawData();
            std::size_t dataSize = (std::size_t) midiMessage.getRawDataSize();

            if (pos + dataSize > maxBytes)
                return;

            std::memcpy ((void*) (bufferToCopyTo + pos), data, dataSize);
            pos += dataSize;
        }
    }
//==============================================================================
void MiosTerminal::handleIncomingMidiMessage(const MidiMessage& message, uint8 runningStatus)
{
    uint8 *data = (uint8 *)message.getRawData();
    uint32 size = message.getRawDataSize();
    int messageOffset = 0;

    bool messageReceived = false;
    if( runningStatus == 0xf0 &&
        SysexHelper::isValidMios32DebugMessage(data, size, -1) &&
        (data[7] == 0x40 || data[7] == 0x00) ) { // allow 0x40 (received) and 0x00 (sent) terminal message
                                                 // 0x00 is allowed for the "feedback test" which is described in the MIDI troubleshooting guide
            messageOffset = 8;
            messageReceived = true;
    }

    if( messageReceived ) {
        String str = "";

        for(int i=messageOffset; i<size; ++i) {
            if( data[i] < 0x80 ) {
                if( data[i] != '\n' || size < (i+1) )
                    str += String::formatted(T("%c"), data[i] & 0x7f);
            }
        }

        if( !gotFirstMessage )
            terminalLogBox->clear();
        gotFirstMessage = 1;

        double timeStamp = message.getTimeStamp() ? message.getTimeStamp() : ((double)Time::getMillisecondCounter() / 1000.0);
        String timeStampStr = (timeStamp > 0)
            ? String::formatted(T("%8.3f"), timeStamp)
            : T("now");

        String terminalStr = "[" + timeStampStr + "] " + str;
        if( miosStudio->runningInBatchMode() ) {
            std::cout << terminalStr << std::endl;
        } else {
            terminalLogBox->addEntry(Colours::black, terminalStr);
        }
    }
}
void CtrlrMidiInputComparatorSingle::matchSysEx(const MidiMessage &m)
{
	BigInteger bi = memoryToBits(MemoryBlock(m.getRawData(), m.getRawDataSize()));

	CtrlrMultiMidiMapIterator it;

	for (it=mapSysEx.begin(); it != mapSysEx.end(); it++)
	{
		if (compareMemory ((*it).first.toMemoryBlock(), messageContainer.getData()))
		{
			for (int i=0; i < (*it).second.targets.size(); i++)
			{
				(*it).second.targets[i]->getProcessor().setValueFromMIDI (messageContainer, source);
			}

			updateCacheSysEx (it);
			break;
		}
	}
}
示例#24
0
void OriginalRecording::writeMessage(MidiMessage& event, int samplePosition)
{
    if (messageFile == nullptr)
        return;
    uint64 samplePos = (uint64) samplePosition;

    int64 eventTimestamp = timestamp + samplePos;

    int msgLength = event.getRawDataSize() - 5;
    const char* dataptr = (const char*)event.getRawData() + 4;

    String timestampText(eventTimestamp);

    diskWriteLock.enter();
    fwrite(timestampText.toUTF8(),1,timestampText.length(),messageFile);
    fwrite(" ",1,1,messageFile);
    fwrite(dataptr,1,msgLength,messageFile);
    fwrite("\n",1,1,messageFile);
    diskWriteLock.exit();

}
示例#25
0
void Gsp1101::handleIncomingMidiMessage(MidiInput *source, MidiMessage const& message)
{
    MemoryBlock mb (message.getRawData(), message.getRawDataSize());
    Logger::outputDebugString("\nMidiInput = " + asHex(mb));

    juce::uint8 const* msgBuff = message.getSysExData();
    if (!msgBuff)
    {
        lastMidiInput_M.setSize(0);
        return;
    }
    lastMidiInput_M = MemoryBlock(message.getSysExData(), message.getSysExDataSize());

    // A sysx ACK is:
    // F0 00 00 10 XX XX XX 7E 00 (procedure) (checksum) F7
    if (msgBuff[6] == 0x7e)
    {}

    // A sysx NACK is:
    // F0 00 00 10 XX XX XX 7F 00 (procedure) (err code) (checksum) F7
    else if (msgBuff[6] == 0x7f)
    {
        deviceReady_M = false;
        // NACK error codes:
#define SYSX_INVALID_CHECKSUM          7
#define MERR_OVERRUN                   10
#define MIDI_PROC_FAILED               12
        switch (msgBuff[9])
        {
        case SYSX_INVALID_CHECKSUM:
        case MERR_OVERRUN:
        case MIDI_PROC_FAILED:
        default:
            break;
        }
        //Logger::outputDebugString("MidiInput error = " + String(msgBuff[9]));
    }
    else
    {}
}
示例#26
0
void CtrlrMIDITransaction::checkPossibleResponse(const MidiMessage &responseToCheck)
{
	ScopedReadLock slr(transactionLock);

	_TRANS("["+getName()+"] check if response is for us");
	_TRANS("["+getName()+"] expecting size: "+STR((int)expectedResponseMask.getSize()));

	if (responseToCheck.getRawDataSize() == (int)expectedResponseMask.getSize())
	{
		_TRANS("["+getName()+"] response matches size");

		if (!getHasDataCheck())
		{
			triggerAsyncUpdate();
			return;
		}

		if (getHasDataCheck() && compareMemoryWithWildcard (responseToCheck, expectedResponseMask))
		{
			triggerAsyncUpdate();
			return;
		}
	}
}
String ZenMidiVisualiserComponent::getMidiMessageDescription(const MidiMessage& m)
{
	if (m.isNoteOn())           return "Note on: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ") Vel: " + S(m.getVelocity());
	if (m.isNoteOff())          return "Note off: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ")";
	if (m.isProgramChange())    return "Program change (Number): " + String(m.getProgramChangeNumber());
	if (m.isPitchWheel())       return "Pitch wheel: " + String(m.getPitchWheelValue());
	if (m.isAftertouch())       return "After touch: " + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ": " + String(m.getAfterTouchValue());
	if (m.isChannelPressure())  return "Channel pressure: " + String(m.getChannelPressureValue());
	if (m.isAllNotesOff())      return "All notes off";
	if (m.isAllSoundOff())      return "All sound off";
	if (m.isMetaEvent())        return "Meta event";

	if (m.isController())
	{
		String temp = MidiMessage::getControllerName(m.getControllerNumber());
		String name = "Controller [" + S(m.getControllerNumber()) + "]";
		if (!temp.isEmpty())
			name += " " + temp;

		return name + ": " + String(m.getControllerValue());
	}

	return String::toHexString(m.getRawData(), m.getRawDataSize());
}
示例#28
0
文件: MidiDemo.cpp 项目: audient/JUCE
static String getMidiMessageDescription (const MidiMessage& m)
{
    if (m.isNoteOn())           return "Note on "  + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isNoteOff())          return "Note off " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isProgramChange())    return "Program change " + String (m.getProgramChangeNumber());
    if (m.isPitchWheel())       return "Pitch wheel " + String (m.getPitchWheelValue());
    if (m.isAftertouch())       return "After touch " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3) +  ": " + String (m.getAfterTouchValue());
    if (m.isChannelPressure())  return "Channel pressure " + String (m.getChannelPressureValue());
    if (m.isAllNotesOff())      return "All notes off";
    if (m.isAllSoundOff())      return "All sound off";
    if (m.isMetaEvent())        return "Meta event";

    if (m.isController())
    {
        String name (MidiMessage::getControllerName (m.getControllerNumber()));

        if (name.isEmpty())
            name = "[" + String (m.getControllerNumber()) + "]";

        return "Controler " + name + ": " + String (m.getControllerValue());
    }

    return String::toHexString (m.getRawData(), m.getRawDataSize());
}
示例#29
0
void CtrlrMIDITransaction::setRequest(const MidiMessage &request)
{
	ScopedWriteLock slw(transactionLock);
	requestToSend = MemoryBlock(request.getRawData(), request.getRawDataSize());
}
示例#30
0
void MidiBuffer::addEvent (const MidiMessage& m, const int sampleNumber)
{
    addEvent (m.getRawData(), m.getRawDataSize(), sampleNumber);
}