本文整理汇总了C++中array::find方法的典型用法代码示例。如果您正苦于以下问题:C++ array::find方法的具体用法?C++ array::find怎么用?C++ array::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array
的用法示例。
在下文中一共展示了array::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBlock
DSP_EXPORT void processBlock(BlockData& data)
{
// iterate on MIDI events
for(uint i=0;i<data.inputMidiEvents.length;i++)
{
// forward all events (unchanged)
data.outputMidiEvents.push(data.inputMidiEvents[i]);
// add transposed Note On and Off events
MidiEventType type=MidiEventUtils::getType(data.inputMidiEvents[i]);
if(type==kMidiNoteOn || type==kMidiNoteOff)
{
// determine the index of the note in the major scale
int absoluteNoteInScale=MidiEventUtils::getNote(data.inputMidiEvents[i])-key;
int noteInScale=(absoluteNoteInScale%12);
int noteIndexInScale=majorKeyNotes.find(noteInScale%12);
for(uint j=0;j<offsets.length;j++)
{
if(offsets[j]!=0)
{
int diff=0;
// if the note has been found, use our scale to find the appropriate interval
if(noteIndexInScale>=0)
{
int newNoteInScale=getRelativeNoteValueInScale(noteIndexInScale+offsets[j]);
diff=newNoteInScale-noteInScale;
// set proper octave
if(diff*offsets[j]<0)
{
diff+=12*sign(offsets[j]);
}
// handle case for more than one octave
diff+=(offsets[j]/7)*12;
}
else
{
// use predefined intervals (note is not in the scale anyway)
diff=predefinedIntervals[offsets[j]+9];
}
// create new note event if valid (not out of MIDI range)
int newNote=MidiEventUtils::getNote(data.inputMidiEvents[i])+diff;
if(newNote>=0 && newNote<128)
{
tempEvent=data.inputMidiEvents[i];
MidiEventUtils::setNote(tempEvent,newNote);
data.outputMidiEvents.push(tempEvent);
}
}
}
}
}
}
示例2: handleMidiEvent
void handleMidiEvent(const MidiEvent& evt)
{
switch(MidiEventUtils::getType(evt))
{
case kMidiNoteOn:
{
// find voice for the note on event (in case it is already here)
// or use the first empty slot (note=-1)
tempVoice.currentNote=MidiEventUtils::getNote(evt);
int index=voices.find(tempVoice);
if(index<0)
{
if(activeVoicesCount<voices.length)
{
index=activeVoicesCount;
activeVoicesCount++;
}
}
if(index>=0)
{
voices[index].NoteOn(evt);
}
break;
}
case kMidiNoteOff:
{
// find voice for the note off event
tempVoice.currentNote=MidiEventUtils::getNote(evt);
int index=voices.find(tempVoice);
if(index>=0)
{
voices[index].NoteOff();
}
break;
}
case kMidiPitchWheel:
{
// update pitch for all voices
currentPitchOffset=2*double(MidiEventUtils::getPitchWheelValue(evt))/8192.0;
for(uint i=0;i<activeVoicesCount;i++)
{
if(voices[i].omega>0)
{
voices[i].ForcePitch();
}
}
break;
}
case kMidiControlChange:
{
// sustain pedal changed event
if(MidiEventUtils::getCCNumber(evt)==64)
{
// if pedal is down
bool down=(MidiEventUtils::getCCValue(evt)>=64);
if(down!=pedalIsDown)
{
pedalIsDown=down;
if(pedalIsDown==false)
{
for(uint i=0;i<activeVoicesCount;i++)
{
voices[i].PedalReleased();
}
}
}
}
}
}
}