View Single Post
Old 07-20-2017, 06:18 AM   #1489
Audio_Birdi
Human being with feelings
 
Audio_Birdi's Avatar
 
Join Date: Dec 2015
Posts: 73
Default

Hi there,

How would I go about creating a script that unselects / deselects only the first note / event of a pre-existing note selection? Below is a script that selects every 2nd event within a note selection, but i am unsure how to modify it so that it only selects the first note/event within a pre-existing note selection.

Thanks in advance!

Quote:
// Unselects every second selected event. Notes and CC are handled separately. (original by Veto, this version by spk77 - thanks a lot, guys)
// Uses "MIDI_Enum" -functions

Undo_BeginBlock2(0);
function unselectEverySecondEvent()
(
(take = MIDIEditor_GetTake(MIDIEditor_GetActive())) ? (
allEvents = MIDI_CountEvts(take, noteCount, ccCount, sysExCount);

index = -1;
k = 1;
while ((index = MIDI_EnumSelNotes(take, index)) != -1) (
MIDI_GetNote(take, index, isSelected, isMuted, startPpqPos, endPpqPos, channel, pitch, velocity) ? (
k % 2 == 0 ? (
MIDI_SetNote(take, index, 0, isMuted, startPpqPos, endPpqPos, channel, pitch, velocity);
);
k += 1;
);
);

index = -1;
n = 1;
while ((index = MIDI_EnumSelCC(take, index)) != -1) (
MIDI_GetCC(take, index, isSelected, isMuted, PpqPos, type, channel, CCnr, value) ? (
n % 2 == 0 ? (
MIDI_SetCC(take, index, 0, isMuted, PpqPos, type, channel, CCnr, value);
);
n += 1;
);
);
);
);

unselectEverySecondEvent();
Undo_EndBlock2(0,"Unselect every second note/CC",-1);
Audio_Birdi is offline   Reply With Quote