Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Sel_Item Notes in Time_Sel Velocity Change(Menu).eel
- Loading branch information
1 parent
d0ff554
commit d30c88c
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
Operations-with-MIDI-Notes-from-Arrange/Sel_Item Notes in Time_Sel Velocity Change(Menu).eel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//Notes Velocity Change// | ||
#Add_Velocity = "10";//Set Default Value(displayed in the menu) | ||
VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel | ||
function Change_Velocity() | ||
(Undo_BeginBlock();//Start Undo | ||
Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ | ||
Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ | ||
|
||
FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE | ||
FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take | ||
//==Select Only Notes In Current Time Selection==// | ||
note_index=0; | ||
loop(FNG_Count_Notes, | ||
FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID | ||
FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) | ||
VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! | ||
|
||
(FNG_Note_Start_PPQ >= Time_Sel_Start_PPQ)&&(FNG_Note_Start_PPQ+FNG_Note_LENGTH_PPQ <= Time_Sel_End_PPQ) ? SEL=1 : SEL=0;//check!!! | ||
extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes | ||
note_index+=1; | ||
); | ||
//==Operation With Selected Notes==// | ||
note_index=0; | ||
loop(FNG_Count_Notes, | ||
FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID | ||
FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop | ||
//IF Note Selected | ||
FNG_Note_Sel ? (Curr_Velo = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY");//note prop | ||
New_Velo = Curr_Velo + Add_Velocity;New_Velo<1?New_Velo=1;New_Velo>127?New_Velo=127;//New_Velocity | ||
extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY" , New_Velo); | ||
Suc_Operation+=1; | ||
);//note prop | ||
note_index+=1; | ||
); | ||
extension_api("FNG_FreeMidiTake", FNG_Take); | ||
#Undo_Text = "~Changed Velocity " ;//Undo_Text | ||
strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings | ||
strcat(#Undo_Text,"-Notes: ");//Compare Strings | ||
strcat(#Undo_Text,sprintf(#str, "%d", Add_Velocity));//Compare Strings | ||
Undo_EndBlock(#Undo_Text, -1);//End Und | ||
); | ||
//=======================================================================================================// | ||
MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item | ||
ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake | ||
GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel | ||
Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); | ||
Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); | ||
//OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// | ||
(Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| | ||
(Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? | ||
(Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; | ||
GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel | ||
//=======================================================================================================// | ||
TakeIsMIDI(ActiveTake) ? //If ActiveTake is MIDI | ||
(GetUserInputs("Change Velocity", 1 , "Set Value", #Add_Velocity) ? //If UserInput "OK" then | ||
(match("%i", #Add_Velocity, Add_Velocity);Change_Velocity(););//Extract Velocity and Execuate Function | ||
); | ||
|
||
UpdateArrange(); | ||
|
||
/*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) | ||
prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ |