Пример #1
0
static void SelectAllNearestEditCursor(int flag, void *data)
{
    double editCursor = GetCursorPosition();
    RprMidiTakePtr midiTake = RprMidiTake::createFromMidiEditor();

    if (midiTake->countNotes() == 0)
        return;

    int closest = midiTake->getNoteAt(0)->getItemPosition();
    double closestDifference = std::fabs(editCursor - midiTake->getNoteAt(0)->getPosition());
    for(int i = 1; i < midiTake->countNotes(); i++) {
        RprMidiNote *note = midiTake->getNoteAt(i);
        double difference = std::fabs(editCursor - note->getPosition());
        if (difference < closestDifference) {
            closest = note->getItemPosition();
            closestDifference = difference;
        }
    }

    for(int i = 0; i < midiTake->countNotes(); i++) {
        RprMidiNote *note = midiTake->getNoteAt(i);
        if (note->getItemPosition() == closest) {
            note->setSelected(true);
        } else {
            note->setSelected(false);
        }
    }
}
Пример #2
0
static bool hasEventsofType(const RprMidiTakePtr &midiTake, int cc)
{
    if( cc > 120) {
        for(int i = 0; i < __ARRAY_SIZE(eventIndexTable); ++i) {
            if( cc != eventIndexTable[i].index)
                continue;
            if(midiTake->hasEventType(eventIndexTable[i].messageType))
                return true;
            return false;
        }
        return false;
    }
    if(cc == -1) {
        if(midiTake->countNotes() > 0)
            return true;
        return false;
    }
    if(midiTake->countCCs(cc) > 0)
        return true;
    return false;
}
Пример #3
0
static void SelectMutedMidiNotes(int flag, void *data)
{
    RprMidiTakePtr midiTake = RprMidiTake::createFromMidiEditor();
    for(int i = 0; i < midiTake->countNotes(); i++)
        midiTake->getNoteAt(i)->setSelected(midiTake->getNoteAt(i)->isMuted());
}