当前位置: 首页>>代码示例>>C++>>正文


C++ MidiMessage::getRawData方法代码示例

本文整理汇总了C++中MidiMessage::getRawData方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::getRawData方法的具体用法?C++ MidiMessage::getRawData怎么用?C++ MidiMessage::getRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MidiMessage的用法示例。


在下文中一共展示了MidiMessage::getRawData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendMessageNow

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);
}
开发者ID:410pfeliciano,项目名称:JUCE,代码行数:58,代码来源:juce_mac_CoreMidi.cpp

示例2: fmod

/** Checksum processors
*/
void CtrlrSysexProcessor::checksumRolandJp8080(const CtrlrSysexToken token, MidiMessage &m)
{
	/*
	Since +5 is parameter value 1DH,
	F0 41 10 00 06 (model id) 12 (command if) 01 00 10 03 (address) 1D (data) ?? (checksum) F7

	Next we calculate the checksum.
	01H + 00H + 10H + 03H + 1DH = 1 + 0 + 16 + 3 + 29 = 49 (sum)
	49 (total) 128 ÷ 0 (quotient) ... 49 (remainder)
	checksum = 128 - 49 (quotient) = 79 = 4FH

	This means that the message transmitted will be F0 41 10 00 06 12 01 00 10 03 1D 4F F7
	*/

	const int startByte = token.getPosition() - token.getAdditionalData();
	double chTotal		= 0.0;
	uint8 *ptr	= (uint8 *)m.getRawData();

	for (int i=startByte; i<token.getPosition(); i++)
	{
		chTotal = chTotal + *(ptr+i);
	}
	const double remainder	= fmod(chTotal, 128);
	const uint8 ch			= (uint8)(remainder ? (128 - remainder) : 0);
	*(ptr+token.getPosition())   = ch;
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:28,代码来源:CtrlrSysexProcessor.cpp

示例3: handleEvent

void RecordControl::handleEvent(int eventType, MidiMessage& event, int)
{
    const uint8* dataptr = event.getRawData();

    int eventId = *(dataptr+2);
    int eventChannel = *(dataptr+3);

    //std::cout << "Received event with id=" << eventId << " and ch=" << eventChannel << std::endl;

    if (eventType == TTL && eventChannel == triggerChannel)
    {

        //std::cout << "Trigger!" << std::endl;

        const MessageManagerLock mmLock;

        if (eventId == 1)
        {
            getControlPanel()->setRecordState(true);
        }
        else
        {
            getControlPanel()->setRecordState(false);
        }


    }

}
开发者ID:ahermosm,项目名称:GUI,代码行数:29,代码来源:RecordControl.cpp

示例4: handleEvent

void PulsePalOutput::handleEvent(int eventType, MidiMessage& event, int sampleNum)
{
    if (eventType == TTL)
    {
        //  std::cout << "Received an event!" << std::endl;

        const uint8* dataptr = event.getRawData();

        // int eventNodeId = *(dataptr+1);
        int eventId = *(dataptr+2);
        int eventChannel = *(dataptr+3);

        for (int i = 0; i < channelTtlTrigger.size(); i++)
        {
            if (eventId == 1 && eventChannel == channelTtlTrigger[i] && channelState[i])
            {
                pulsePal.triggerChannel(i+1);
            }

            if (eventChannel == channelTtlGate[i])
            {
                if (eventId == 1)
                    channelState.set(i, true);
                else
                    channelState.set(i, false);
            }
        }

    }

}
开发者ID:ArmandNM,项目名称:GUI,代码行数:31,代码来源:PulsePalOutput.cpp

示例5: RT_MIDI_send_msg_to_patch

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);
  }
}
开发者ID:erdoukki,项目名称:radium,代码行数:31,代码来源:Juce_plugins.cpp

示例6: handleEvent

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);
                    }
                }

            }

        }

    }

}
开发者ID:SireniaLizbeth,项目名称:GUI,代码行数:60,代码来源:SpikeDisplayNode.cpp

示例7: sendMessageNow

    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);
    }
开发者ID:Theadd,项目名称:WickedExile,代码行数:34,代码来源:juce_linux_Midi.cpp

示例8: sendMessageNow

    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);
    }
开发者ID:GuillaumeLeNost,项目名称:ConvolutionFilter,代码行数:26,代码来源:juce_linux_Midi.cpp

示例9: handleEvent

void PhaseDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum)
{
    // MOVED GATING TO PULSE PAL OUTPUT!
    // now use to randomize phase for next trial

    //std::cout << "GOT EVENT." << std::endl;

    if (eventType == TTL)
    {
        const uint8* dataptr = event.getRawData();

        // int eventNodeId = *(dataptr+1);
        int eventId = *(dataptr+2);
        int eventChannel = *(dataptr+3);
        //int eventTime = event.getTimeStamp();

        //     //	std::cout << "Received event from " << eventNodeId << ", channel "
        //     //          << eventChannel << ", with ID " << eventId << std::endl;

        //     if (eventId == 1 && eventChannel == 5)
        //     {
        //         canBeTriggered = true;
        //     }
        if (eventId == 0 && eventChannel == 5)
        {
            triggerOnPeak = randomNumberGenerator.nextBool();

        }

    }

}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例10: ToHexString

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;
	}
}
开发者ID:bbchung,项目名称:pg1,代码行数:29,代码来源:PGMidiDevice.cpp

示例11: handleEvent

void PhaseDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum)
{
    // MOVED GATING TO PULSE PAL OUTPUT!
    // now use to randomize phase for next trial

    //std::cout << "GOT EVENT." << std::endl;

    if (eventType == TTL)
    {
        const uint8* dataptr = event.getRawData();

        // int eventNodeId = *(dataptr+1);
        int eventId = *(dataptr+2);
        int eventChannel = *(dataptr+3);

        for (int i = 0; i < modules.size(); i++)
        {
            DetectorModule& module = modules.getReference(i);

            if (module.gateChan == eventChannel)
            {
                if (eventId)
                    module.isActive = true;
                else
                    module.isActive = false;
            }
        }

    }

}
开发者ID:ArmandNM,项目名称:GUI,代码行数:31,代码来源:PhaseDetector.cpp

示例12: if

void HDF5Recording::writeEvent(int eventType, const MidiMessage& event, int64 timestamp)
{
    const uint8* dataptr = event.getRawData();
    if (eventType == GenericProcessor::TTL)
        eventFile->writeEvent(0,*(dataptr+2),*(dataptr+1),(void*)(dataptr+3),timestamp);
    else if (eventType == GenericProcessor::MESSAGE)
        eventFile->writeEvent(1,*(dataptr+2),*(dataptr+1),(void*)(dataptr+6),timestamp);
}
开发者ID:LabPF,项目名称:plugin-GUI,代码行数:8,代码来源:HDF5Recording.cpp

示例13: getDataFromResponse

const MemoryBlock CtrlrMIDITransaction::getDataFromResponse(const MidiMessage &messageToExtractFrom)
{
	MemoryBlock returnData;
	MemoryBlock temp(messageToExtractFrom.getRawData(), messageToExtractFrom.getRawDataSize());

	returnData.copyFrom (temp.getData(), getResponsePrefixLength(), getResponseDataLength());
	return (returnData);
}
开发者ID:gareth8118,项目名称:ctrlr,代码行数:8,代码来源:CtrlrMIDITransaction.cpp

示例14: if

void HDF5Recording::writeEvent(int eventType, MidiMessage& event, int samplePosition)
{
    const uint8* dataptr = event.getRawData();
	if (eventType == GenericProcessor::TTL)
		mainFile->writeEvent(0,*(dataptr+2),*(dataptr+1),(void*)(dataptr+3),timestamp+samplePosition);
	else if (eventType == GenericProcessor::MESSAGE)
		mainFile->writeEvent(1,*(dataptr+2),*(dataptr+1),(void*)(dataptr+4),timestamp+samplePosition);
}
开发者ID:macstry,项目名称:GUI,代码行数:8,代码来源:HDF5Recording.cpp

示例15: getRawData

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())+"]");
	}
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:18,代码来源:CtrlrUtilities.cpp


注:本文中的MidiMessage::getRawData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。