本文整理汇总了C++中MidiMessageSequence::getEventTime方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessageSequence::getEventTime方法的具体用法?C++ MidiMessageSequence::getEventTime怎么用?C++ MidiMessageSequence::getEventTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiMessageSequence
的用法示例。
在下文中一共展示了MidiMessageSequence::getEventTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findTimeSigEvents
static void findTimeSigEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
{
MidiMessageSequence timeSigEvents;
midiFile.findAllTimeSigEvents (timeSigEvents);
const int numTimeSigEvents = timeSigEvents.getNumEvents();
MemoryOutputStream timeSigSequence;
for (int i = 0; i < numTimeSigEvents; ++i)
{
int numerator, denominator;
timeSigEvents.getEventPointer(i)->message.getTimeSignatureInfo (numerator, denominator);
String timeSigString;
timeSigString << numerator << '/' << denominator;
if (i == 0)
midiMetadata.set (CoreAudioFormat::timeSig, timeSigString);
if (numTimeSigEvents > 1)
timeSigSequence << timeSigString << ',' << timeSigEvents.getEventTime (i) << ';';
}
if (timeSigSequence.getDataSize() > 0)
midiMetadata.set ("time signature sequence", timeSigSequence.toUTF8());
}
示例2: findKeySigEvents
static void findKeySigEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
{
MidiMessageSequence keySigEvents;
midiFile.findAllKeySigEvents (keySigEvents);
const int numKeySigEvents = keySigEvents.getNumEvents();
MemoryOutputStream keySigSequence;
for (int i = 0; i < numKeySigEvents; ++i)
{
const MidiMessage& message (keySigEvents.getEventPointer (i)->message);
const int key = jlimit (0, 14, message.getKeySignatureNumberOfSharpsOrFlats() + 7);
const bool isMajor = message.isKeySignatureMajorKey();
static const char* majorKeys[] = { "Cb", "Gb", "Db", "Ab", "Eb", "Bb", "F", "C", "G", "D", "A", "E", "B", "F#", "C#" };
static const char* minorKeys[] = { "Ab", "Eb", "Bb", "F", "C", "G", "D", "A", "E", "B", "F#", "C#", "G#", "D#", "A#" };
String keySigString (isMajor ? majorKeys[key]
: minorKeys[key]);
if (! isMajor)
keySigString << 'm';
if (i == 0)
midiMetadata.set (CoreAudioFormat::keySig, keySigString);
if (numKeySigEvents > 1)
keySigSequence << keySigString << ',' << keySigEvents.getEventTime (i) << ';';
}
if (keySigSequence.getDataSize() > 0)
midiMetadata.set ("key signature sequence", keySigSequence.toUTF8());
}
示例3: findTempoEvents
static void findTempoEvents (MidiFile& midiFile, StringPairArray& midiMetadata)
{
MidiMessageSequence tempoEvents;
midiFile.findAllTempoEvents (tempoEvents);
const int numTempoEvents = tempoEvents.getNumEvents();
MemoryOutputStream tempoSequence;
for (int i = 0; i < numTempoEvents; ++i)
{
const double tempo = getTempoFromTempoMetaEvent (tempoEvents.getEventPointer (i));
if (tempo > 0.0)
{
if (i == 0)
midiMetadata.set (CoreAudioFormat::tempo, String (tempo));
if (numTempoEvents > 1)
tempoSequence << String (tempo) << ',' << tempoEvents.getEventTime (i) << ';';
}
}
if (tempoSequence.getDataSize() > 0)
midiMetadata.set ("tempo sequence", tempoSequence.toUTF8());
}
示例4: processBlock
//==============================================================================
void MidiSequencePlugin::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
MidiSequencePluginBase::processBlock(buffer, midiMessages);
MidiMessageSequence sourceMidi = *midiSequence;
std::vector<int> doneTheseControllers;
if (transport->isPlaying () && getBoolValue(PROP_SEQENABLED, true))
{
const int blockSize = buffer.getNumSamples ();
MidiBuffer* midiBuffer = midiBuffers.getUnchecked (0);
const int frameCounter = transport->getPositionInFrames ();
const int framesPerBeat = transport->getFramesPerBeat ();
const int nextBlockFrameNumber = frameCounter + blockSize;
const int seqIndex = getLoopRepeatIndex();
const double beatCount = getLoopBeatPosition();
const double frameLenBeatCount = (nextBlockFrameNumber - frameCounter) / (double)framesPerBeat;
double frameEndBeatCount = beatCount + frameLenBeatCount;
if (frameEndBeatCount > getLengthInBeats())
frameEndBeatCount -= getLengthInBeats();
// loop for each controller we need to interpolate
MidiMessage* lastCtrlEvent = NULL;
do
{
lastCtrlEvent = NULL;
// hunt for a controller event before now
int i;
for (i = 0; i < sourceMidi.getNumEvents (); i++)
{
int timeStampInSeq = roundFloatToInt (sourceMidi.getEventTime (i) * framesPerBeat);
int timeStamp = timeStampInSeq + (seqIndex * getLengthInBeats() * framesPerBeat);
MidiMessage* midiMessage = &sourceMidi.getEventPointer (i)->message;
if (timeStamp >= nextBlockFrameNumber || !midiMessage)
break; // event is after now, leave
//if (midiMessage->isController() && (std::find(doneTheseControllers.begin(), doneTheseControllers.end(), midiMessage->getControllerNumber()) == doneTheseControllers.end()))
// lastCtrlEvent = midiMessage;
}
// hunt for a matching event after that one
if (lastCtrlEvent)
{
// store the controller number so we know which controllers we've done
doneTheseControllers.push_back(lastCtrlEvent->getControllerNumber());
MidiMessage* nextCtrlEvent = NULL;
for (; i < sourceMidi.getNumEvents (); i++)
{
MidiMessage* midiMessage = &sourceMidi.getEventPointer (i)->message;
if (midiMessage->isController() && midiMessage->getControllerNumber() == lastCtrlEvent->getControllerNumber())
{
nextCtrlEvent = midiMessage;
break;
}
}
// render an interpolated event!...
if (nextCtrlEvent)
{
double bt = nextCtrlEvent->getTimeStamp();
double at = lastCtrlEvent->getTimeStamp();
double deltaBeats = bt - at;
int a = lastCtrlEvent->getControllerValue();
int b = nextCtrlEvent->getControllerValue();
double now = beatCount + (frameEndBeatCount - beatCount) / 2.0;
double interpRemainBeats = deltaBeats - (now - at);
if (deltaBeats > 0)
{
double nextPart = interpRemainBeats / deltaBeats;
nextPart = 1 - nextPart;
double interpdVal = a + nextPart * (b - a);
MidiMessage interpy = MidiMessage::controllerEvent(lastCtrlEvent->getChannel(), lastCtrlEvent->getControllerNumber(), static_cast<int>(interpdVal));
midiBuffer->addEvent (interpy, (nextBlockFrameNumber - frameCounter) / 2);
}
else
{
DBG ("Negative delta beats when rendering automation!!");
}
}
}
// now we also need to do that again if there are multiple events per frame AND we are interpolating multiple times per frame
// (at the moment only interpolating once per audio frame)
} while (lastCtrlEvent != NULL);
}
}