本文整理汇总了C++中MidiMessage::getRawDataSize方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::getRawDataSize方法的具体用法?C++ MidiMessage::getRawDataSize怎么用?C++ MidiMessage::getRawDataSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiMessage
的用法示例。
在下文中一共展示了MidiMessage::getRawDataSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: handleIncomingMidiMessage
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);
}
}
}
}
示例4: sysExProcess
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: 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);
}
}
示例6: 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;
}
}
示例7: 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);
}
}
}
}
}
}
示例8: getDataFromResponse
const MemoryBlock CtrlrMIDITransaction::getDataFromResponse(const MidiMessage &messageToExtractFrom)
{
MemoryBlock returnData;
MemoryBlock temp(messageToExtractFrom.getRawData(), messageToExtractFrom.getRawDataSize());
returnData.copyFrom (temp.getData(), getResponsePrefixLength(), getResponseDataLength());
return (returnData);
}
示例9: 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);
}
示例10: sendMessageNow
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: sysexProcessChecksums
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: 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())+"]");
}
}
示例13: sysexProcessPrograms
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: sendMessageNow
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:
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(×tamp, dataptr +6+ len, 8);
}