├── FX ├── gen_Save Preset for last touched FX.lua └── gen_TrackFX Routing Matrix.lua ├── Item Editing ├── MIDI item adjustment │ ├── gen_Adjust +10 velocity of selected item notes within time selection.eel │ ├── gen_Adjust -10 velocity of selected item notes within time selection.eel │ ├── gen_Adjust parameters of selected item notes.eel │ ├── gen_Adjust velocity of selected item notes within time selection.eel │ ├── gen_Move selected item notes left within time selection (grid relative).eel │ ├── gen_Move selected item notes right within time selection (grid relative).eel │ ├── gen_Transpose selected item notes down within time selection (one semitone).eel │ ├── gen_Transpose selected item notes up within time selection (one semitone).eel │ └── gen_Transpose selected item notes within time selection with prompt.eel ├── gen_Explode multichannel Audio (Non-destructive).lua ├── gen_Open media item (source relative).lua ├── gen_Open media item (type relative).eel ├── gen_Remove empty bars from selected MIDI items (grid relative).lua ├── gen_Remove empty bars from selected MIDI items (regard CC).lua ├── gen_Remove empty bars from selected MIDI items (regard CC, grid relative).lua ├── gen_Remove empty bars from selected MIDI items.lua ├── gen_Render selected item as new take, up to last VSTi.lua ├── gen_Render selected item on new track, up to last VSTi.lua ├── gen_SampleEditor.lua ├── gen_Stretch selected items positions and rate.lua └── gen_Vox-Deess Enveloper.lua ├── MIDI Editor └── gen_Delete Notes Overlaps (poly).lua ├── README.md ├── Templates └── GUI │ └── gen_Simple GUI template for scripts.lua ├── Track Editing └── gen_Freeze selected tracks(only instruments).lua ├── Tracks Properties ├── gen_Select next first level track.lua └── gen_Select previous first level track.lua ├── Various ├── Envelope-based Compressor │ ├── gen_Envelope-based Compressor v2.eel │ └── inc │ │ ├── AudioFunctions.eel │ │ ├── DevMenu.eel │ │ ├── MiniGui.eel │ │ ├── Mouse.eel │ │ ├── Presets.eel │ │ └── TextField.eel ├── FXRack │ ├── Images │ │ ├── BG_PatchWork.png │ │ ├── button_phase_22x22x2.png │ │ ├── button_power_17x18x2.png │ │ ├── button_solo_22x22x2.png │ │ ├── button_summing_26x17x2.png │ │ ├── knob_pan_28x28x127.png │ │ └── knob_vol_28x28x127.png │ ├── JSUtilities │ │ ├── (Mix)RackMixer │ │ └── (Split)RackSplitter │ ├── Modules │ │ ├── FXChain.lua │ │ ├── File.lua │ │ ├── Presets.lua │ │ ├── RackSplitMix.lua │ │ └── SimpleControls.lua │ └── gen_FXRack.lua ├── gen_Align Items by transients.lua ├── gen_Create stretch-markers at transients.eel ├── gen_Drum trigger.lua ├── gen_Envelope-based Compressor.eel ├── gen_Envelope-based Deesser.eel ├── gen_Retrospective Record (MIDI).eel ├── gen_Retrospective Record (audio).eel ├── gen_True Stereo Takes Test.eel └── gen_WAVE Generator.lua └── index.xml /FX/gen_Save Preset for last touched FX.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name: Save_FX_Preset 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.03 8 | ]] 9 | 10 | -------------------------------------------------------------------------------- 11 | -- Base64_to_Hex(modded from lua.org functions) ------------------------------- 12 | -------------------------------------------------------------------------------- 13 | -- decryption table -- 14 | local base64bytes = {['A']=0, ['B']=1, ['C']=2, ['D']=3, ['E']=4, ['F']=5, ['G']=6, ['H']=7, ['I']=8, ['J']=9, ['K']=10,['L']=11,['M']=12, 15 | ['N']=13,['O']=14,['P']=15,['Q']=16,['R']=17,['S']=18,['T']=19,['U']=20,['V']=21,['W']=22,['X']=23,['Y']=24,['Z']=25, 16 | ['a']=26,['b']=27,['c']=28,['d']=29,['e']=30,['f']=31,['g']=32,['h']=33,['i']=34,['j']=35,['k']=36,['l']=37,['m']=38, 17 | ['n']=39,['o']=40,['p']=41,['q']=42,['r']=43,['s']=44,['t']=45,['u']=46,['v']=47,['w']=48,['x']=49,['y']=50,['z']=51, 18 | ['0']=52,['1']=53,['2']=54,['3']=55,['4']=56,['5']=57,['6']=58,['7']=59,['8']=60,['9']=61,['+']=62,['/']=63,['=']=nil} 19 | -------------------------------------------- 20 | -- Decode Base64 to HEX -------------------- 21 | -------------------------------------------- 22 | function B64_to_HEX(data) 23 | local chars = {} 24 | local result = {} 25 | local hex 26 | for dpos=0, #data-1, 4 do 27 | -- Get chars ------------------- 28 | for char=1,4 do chars[char] = base64bytes[(string.sub(data,(dpos+char), (dpos+char)) or "=")] end -- Get chars 29 | -- To hex ---------------------- 30 | if chars[3] and chars[4] then 31 | hex = string.format('%02X%02X%02X', -- if 1,2,3,4 chars 32 | (chars[1]<<2) + ((chars[2]&0x30)>>4), -- 1 33 | ((chars[2]&0xf)<<4) + (chars[3]>>2), -- 2 34 | ((chars[3]&0x3)<<6) + chars[4] ) -- 3 35 | elseif chars[3] then 36 | hex = string.format('%02X%02X', -- if 1,2,3 chars 37 | (chars[1]<<2) + ((chars[2]&0x30)>>4), -- 1 38 | ((chars[2]&0xf)<<4) + (chars[3]>>2), -- 2 39 | ((chars[3]&0x3)<<6) ) 40 | else 41 | hex = string.format('%02X', -- if 1,2 chars 42 | (chars[1]<<2) + ((chars[2]&0x30)>>4) ) -- 1 43 | end 44 | --------------------------------- 45 | table.insert(result,hex) 46 | end 47 | return table.concat(result) 48 | end 49 | 50 | ---------------------------------------- 51 | -- String_to_HEX ---------------------- 52 | ---------------------------------------- 53 | function String_to_HEX(Preset_Name) 54 | local VAL = {Preset_Name:byte(1,-1)} -- to bytes, values 55 | local Pfmt = string.rep("%02X", #VAL) 56 | return string.format(Pfmt, table.unpack(VAL)) 57 | end 58 | 59 | -------------------------------------------------------------------------------- 60 | -- FX_Chunk_to_HEX ------------------------------------------------------------- 61 | -------------------------------------------------------------------------------- 62 | -- Variant 1 --------------------------- 63 | function FX_Chunk_to_HEX(FX_Type, FX_Chunk, Preset_Name) 64 | local Preset_Chunk = FX_Chunk:match("\n.*\n") -- extract preset(simple var) 65 | 66 | --------------------------------------- 67 | -- For JS ----------------------------- 68 | --------------------------------------- 69 | if FX_Type=="JS" then 70 | Preset_Chunk = Preset_Chunk:gsub("\n", "") -- del "\n" 71 | --reaper.ShowConsoleMsg(Preset_Chunk..'\n') 72 | return String_to_HEX(Preset_Chunk..Preset_Name) 73 | end 74 | 75 | --------------------------------------- 76 | -- For VST ---------------------------- 77 | --------------------------------------- 78 | local Hex_TB = {} 79 | local init = 1 80 | --------------------- 81 | for i=1, math.huge do 82 | line = Preset_Chunk:match("\n.-\n", init) -- extract line from preset(simple var) 83 | if not line then 84 | --reaper.ShowConsoleMsg(Hex_TB[i-1].."\n") 85 | Hex_TB[i-1] = "00"..String_to_HEX(Preset_Name).."0010000000" -- Preset_Name to Hex(replace name from chunk) 86 | --reaper.ShowConsoleMsg(Hex_TB[i-1].."\n") 87 | break 88 | end 89 | --------------- 90 | init = init + #line - 1 -- for next line 91 | line = line:gsub("\n","") -- del "\n" 92 | --reaper.ShowConsoleMsg(line.."\n") 93 | Hex_TB[i] = B64_to_HEX(line) 94 | end 95 | --------------------- 96 | return table.concat(Hex_TB) 97 | end 98 | 99 | -- Variant 2(without Name to Hex, simple var) ------ 100 | --[[ 101 | function FX_Chunk_to_HEX(FX_Type, FX_Chunk, Preset_Name) 102 | local Preset_Chunk = FX_Chunk:match("\n.*\n") -- extract preset(simple var) 103 | ---------------------------------------- 104 | Preset_Chunk = Preset_Chunk:gsub("\n","") -- del "\n" 105 | if FX_Type=="JS" then return String_to_HEX(Preset_Chunk..Preset_Name) 106 | else return B64_to_HEX(Preset_Chunk) 107 | end 108 | end 109 | --]] 110 | 111 | -------------------------------------------------------------------------------- 112 | -- Get_CtrlSum ----------------------------------------------------------------- 113 | -------------------------------------------------------------------------------- 114 | function Get_CtrlSum(HEX) 115 | local Sum = 0 116 | for i=1, #HEX, 2 do Sum = Sum + tonumber( HEX:sub(i,i+1), 16) end 117 | return string.sub( string.format("%X", Sum), -2, -1 ) 118 | end 119 | 120 | -------------------------------------------------------------------------------- 121 | -- Write preset to PresetFile -------------------------------------------------- 122 | -------------------------------------------------------------------------------- 123 | function Write_to_File(PresetFile, Preset_HEX, Preset_Name) 124 | local file, Presets_ini, Nprsts 125 | ---------------------------------------------------------- 126 | -- Rewrite header(or create) ----------------------------- 127 | ---------------------------------------------------------- 128 | local ret_r, ret_w 129 | if reaper.file_exists(PresetFile) then 130 | -- BR function works faster than lua r,w -- 131 | ret_r, Nprsts = reaper.BR_Win32_GetPrivateProfileString("General", "NbPresets", "", PresetFile) 132 | Nprsts = math.tointeger(Nprsts) 133 | ------------------ 134 | ret_w = reaper.BR_Win32_WritePrivateProfileString("General", "NbPresets", math.tointeger(Nprsts+1), PresetFile) 135 | else Nprsts = 0 136 | Presets_ini = "[General]\nNbPresets="..Nprsts+1 137 | file = io.open(PresetFile, "w") 138 | file:write(Presets_ini) 139 | file:close() 140 | end 141 | ---------------------------------------------------------- 142 | -- Write preset data to file ----------------------------- 143 | ---------------------------------------------------------- 144 | file = io.open(PresetFile, "r+") 145 | file:seek("end") -- to end of file 146 | ------------------ 147 | file:write("\n[Preset"..Nprsts.."]") -- preset number(0-based) 148 | -------------------------------------- 149 | -------------------------------------- 150 | local Len = #Preset_HEX -- Data Lenght 151 | local s = 1 152 | local Ndata = 0 153 | for i=1, math.ceil(Len/32768) do 154 | if i==1 then Ndata = "\nData=" else Ndata = "\nData_".. i-1 .."=" end 155 | local Data = Preset_HEX:sub(s, s+32767) 156 | local Sum = Get_CtrlSum(Data) 157 | file:write(Ndata, Data, Sum) 158 | s = s+32768 159 | end 160 | -------------------------------------- 161 | --- Preset_Name, Data Lenght --------- 162 | -------------------------------------- 163 | file:write("\nName=".. Preset_Name .."\nLen=".. Len//2 .."\n") 164 | ------------------- 165 | file:close() 166 | end 167 | 168 | -------------------------------------------------------------------------------- 169 | -- Get FX_Chunk and PresetFile ------------------------------------------------ 170 | -------------------------------------------------------------------------------- 171 | function Get_FX_Data(track, fxnum) 172 | local fx_cnt = reaper.TrackFX_GetCount(track) 173 | if fx_cnt==0 or fxnum>fx_cnt-1 then return end -- if fxnum not valid 174 | local ret, Track_Chunk = reaper.GetTrackStateChunk(track,"",false) 175 | --reaper.ShowConsoleMsg(Track_Chunk) 176 | 177 | ------------------------------------ 178 | -- Find FX_Chunk(use fxnum) -------- 179 | ------------------------------------ 180 | local s, e = Track_Chunk:find("", e) 184 | end 185 | ---------------------------------- 186 | -- FX_Type ----------------------- 187 | local FX_Type = string.match(Track_Chunk:sub(s+1,s+3), "%u+") -- FX Type 188 | if not(FX_Type=="VST" or FX_Type=="JS") then return end -- Only VST and JS supported 189 | ---------------------------------- 190 | -- extract FX_Chunk -------------- 191 | local FX_Chunk = Track_Chunk:match("%b<>", s) -- FX_Chunk(simple var) 192 | ---------------------------------- 193 | --reaper.ShowConsoleMsg("\n\n"..fxnum.."\n"..FX_Chunk.."\n") 194 | 195 | ------------------------------------ 196 | -- Get UserPresetFile -------------- 197 | ------------------------------------ 198 | local PresetFile = reaper.TrackFX_GetUserPresetFilename(track, fxnum, "") 199 | ------------------------------------ 200 | return FX_Type, FX_Chunk, PresetFile 201 | end 202 | 203 | -------------------------------------------------------------------------------- 204 | -- Main function -------------------------------------------------------------- 205 | -------------------------------------------------------------------------------- 206 | function Save_VST_Preset(track, fxnum, Preset_Name) 207 | if not (track and fxnum and Preset_Name) then return end -- Need track, fxnum, Preset_Name 208 | local FX_Type, FX_Chunk, PresetFile = Get_FX_Data(track, fxnum) 209 | --reaper.ShowConsoleMsg(FX_Chunk..'\n') 210 | ----------- 211 | if FX_Chunk and PresetFile then 212 | local start_time = reaper.time_precise() 213 | local Preset_HEX = FX_Chunk_to_HEX(FX_Type, FX_Chunk, Preset_Name) 214 | --reaper.ShowConsoleMsg("Processing time = ".. reaper.time_precise()-start_time ..'\n') -- time test 215 | local start_time = reaper.time_precise() 216 | Write_to_File(PresetFile, Preset_HEX, Preset_Name) 217 | --reaper.ShowConsoleMsg("Write time = ".. reaper.time_precise()-start_time ..'\n') -- time test 218 | reaper.TrackFX_SetPreset(track, fxnum, Preset_Name) -- For "update", but this is optional 219 | end 220 | end 221 | 222 | ---------------------------------------------------------------------------------------------------- 223 | -- GetLastTouchedFX ------------------------------------------------------------------------------- 224 | ---------------------------------------------------------------------------------------------------- 225 | function Get_LastTouch_FX() 226 | local retval, tracknum, fxnum = reaper.GetLastTouchedFX() -- fxnum 227 | if not retval then return end 228 | local track = reaper.GetTrack(0, tracknum-1) -- track(trackID) 229 | local Pidx, Npt = reaper.TrackFX_GetPresetIndex(track, fxnum) 230 | local Preset_Name = "New "..Npt+1 -- New Preset_Name 231 | return track, fxnum, Preset_Name 232 | end 233 | 234 | ---------------------------------------------------------------------------------------------------- 235 | -- Start ------------------------------------------------------------------------------------------ 236 | ---------------------------------------------------------------------------------------------------- 237 | local track, fxnum, Preset_Name = Get_LastTouch_FX() -- any function can be used 238 | Save_VST_Preset(track, fxnum, Preset_Name) -- RUN 239 | 240 | -------------------------------------------------------------------------------- /FX/gen_TrackFX Routing Matrix.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name: TrackFX Routing Matrix 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | 11 | ---------------------------------------------------------------------------------------------------- 12 | ---------------------------------------------------------------------------------------------------- 13 | function pointIN(x,y,w,h) 14 | return mouse_ox >= x and mouse_ox <= x + w and mouse_oy >= y and mouse_oy <= y + h and 15 | gfx.mouse_x >= x and gfx.mouse_x <= x + w and gfx.mouse_y >= y and gfx.mouse_y <= y + h 16 | end 17 | ----- 18 | function mouseClick() 19 | return gfx.mouse_cap&1==0 and last_mouse_cap&1==1 20 | end 21 | ---------------------------------------------------------------------------------------------------- 22 | ---------------------------------------------------------------------------------------------------- 23 | ---draw current pin--------------------------------------------------------------------------------- 24 | function draw_pin(track,fx,isOut,pin,chans, x,y,w,h) 25 | local Low32,Hi32 = reaper.TrackFX_GetPinMappings(track, fx, isOut, pin)--Get current pin 26 | local bit,val 27 | local Click = mouseClick() 28 | if (pin+1)%2==0 then gfx.set(0,0.6,0) else gfx.set(0.6,0,0) end --set pin color(odd parity) 29 | -------------------------------------- 30 | --draw(and change val if Clicked)------- 31 | for i = 1, chans do 32 | bit = 2^(i-1) --cuurent bit 33 | val = (Low32&bit)>0 --current bit(aka channel value as booleen) 34 | if Click and pointIN(x,y,w,h-1) then 35 | if val then Low32 = Low32 - bit else Low32 = Low32 + bit end 36 | reaper.TrackFX_SetPinMappings(track, fx, isOut , pin, Low32, Hi32)--Set pin 37 | end 38 | if val and reaper.TrackFX_GetEnabled(track,fx) then gfx.a = 1 else gfx.a = 0.3 end --set gfx.a 39 | gfx.rect(x,y,w-2,h-2, val) --bool = val 40 | y = y + h --next y 41 | end 42 | -------------------------------------- 43 | end 44 | -------------------------------------------------------- 45 | ---draw_FX_head----------------------------------------- 46 | function draw_FX_head(track,fx,in_Pins,out_Pins, x,y,w,h) 47 | local _, fx_name = reaper.TrackFX_GetFXName(track, fx, ""); fx_name = fx_name:match(" %P+") 48 | --draw head and name---------- 49 | y,w,h = y-w ,w*(in_Pins+out_Pins+1.2)-2,h-1 --correct values for head position 50 | gfx.set(0.5,0.7,0)--set head color 51 | if reaper.TrackFX_GetEnabled(track,fx) then gfx.a = 1 else gfx.a = 0.3 end --if FX enabled/disabled 52 | ----------------------- 53 | gfx.x, gfx.y = x, y+(h-gfx.texth)/2 54 | gfx.rect(x,y,w,h,false) 55 | gfx.printf("%.12s",fx_name) 56 | --Open-Close FX on click-- 57 | if mouseClick() and pointIN(x,y,w,h) then 58 | reaper.TrackFX_SetOpen(track, fx, not reaper.TrackFX_GetOpen(track, fx) )--not bool for change state 59 | end 60 | end 61 | -------------------------------------------------------- 62 | -------------------------------------------------------- 63 | ---draw current FX-------------------------------------- 64 | function draw_FX(track,fx,chans, x,y,w,h) 65 | local _, in_Pins,out_Pins = reaper.TrackFX_GetIOSize(track,fx) 66 | --for some JS-plug-ins--------------------------------- 67 | if out_Pins==-1 and in_Pins~=-1 then out_Pins=in_Pins end --in some JS outs ret "-1" 68 | --------------------------------- 69 | --Draw FX-head------------------- 70 | draw_FX_head(track,fx,in_Pins,out_Pins, x,y,w,h) 71 | -------------------------------- 72 | --Draw FX pins,chans etc-- 73 | --------------- 74 | --input pins--- 75 | local isOut=0 76 | for i=1,in_Pins do 77 | draw_pin(track,fx,isOut, i-1,chans, x,y,w,h)--(track,fx,isOut, pin,chans, x,y, w,h) 78 | x = x + w --next x 79 | end 80 | --------------- 81 | x = x + 1.2*w --Gap between FX in-out pins 82 | --------------- 83 | --output pins-- 84 | local isOut=1 85 | for i=1,out_Pins do 86 | draw_pin(track,fx,isOut, i-1,chans, x,y,w,h)--(track,fx,isOut, pin,chans, x,y, w,h) 87 | x = x + w --next x 88 | end 89 | return x --return x value for next FX position 90 | end 91 | ------------------------------------------------ 92 | --draw in-out +/- buttons----------------------- 93 | function draw_track_chan_add_sub(track,chans, x,y,w,h) 94 | -- "-" -- 95 | gfx.set(0.9,0.8,0, 0.5) 96 | x = x+1.5*w ; y = y + h*(chans-1.5) 97 | w, h = w-2, h-2 98 | local s_w, s_h = gfx.measurestr("-") 99 | gfx.x, gfx.y = x + (w-s_w)/2 , y + (h-s_h)/2 100 | gfx.rect(x,y,w,h, 0); gfx.printf("-") 101 | if mouseClick() and pointIN(x,y,w,h) then reaper.SetMediaTrackInfo_Value(track, "I_NCHAN", math.max(chans-2,2)) end 102 | -- "+" -- 103 | y = y+2*h ; 104 | s_w, s_h = gfx.measurestr("+") 105 | gfx.x, gfx.y = x + (w-s_w)/2 , y + (h-s_h)/2 106 | gfx.set(0.9,0.8,0, 0.5) 107 | gfx.rect(x,y,w,h, 0); gfx.printf("+") 108 | if mouseClick() and pointIN(x,y,w,h) then reaper.SetMediaTrackInfo_Value(track, "I_NCHAN", math.min(chans+2,32)) end 109 | end 110 | ------------------------------------------------ 111 | ---draw track in/out---------------------------- 112 | function draw_track_in_out(type,track,chans, x,y,w,h) 113 | gfx.x, gfx.y = x, y-2*w 114 | gfx.set(0.9,0.8,0, 1) 115 | gfx.printf(type) 116 | for i=1,chans do 117 | if i%2==0 then gfx.set(0,0.6,0, 0.6) else gfx.set(0.6,0,0, 0.6) end 118 | gfx.rect(x,y,w-2,h-2, 1) 119 | y = y + h 120 | end 121 | end 122 | ------------------------------------------------ 123 | ------------------------------------------------ 124 | ---Main DRAW function--------------------------- 125 | function DRAW() 126 | local w,h = Z,Z --its only one chan(rectangle) w and h (but it used in all calculation) 127 | local x,y = 4*w, 4*h --its first pin of first FX x and y (but it used in all calculation) 128 | local M_Wheel 129 | ---- 130 | local track = reaper.GetSelectedTrack(0, 0) 131 | if track then 132 | local _, track_name = reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "", false) 133 | local fx_count = reaper.TrackFX_GetCount(track) 134 | local chans = math.min( reaper.GetMediaTrackInfo_Value(track, "I_NCHAN"), 32 ) -- max value for visible chans 135 | -------------------------------------------------------- 136 | -------------------------------------------------------- 137 | ---Zoom------ 138 | if Ctrl and not Shift then M_Wheel = gfx.mouse_wheel;gfx.mouse_wheel = 0 139 | if M_Wheel>0 then Z = math.min(Z+1, 30) elseif M_Wheel<0 then Z = math.max(Z-1, 8) end 140 | gfx.setfont(1,"Calibri", Z) 141 | end 142 | ---Rewind--- 143 | if Shift and not Ctrl then M_Wheel = gfx.mouse_wheel;gfx.mouse_wheel = 0 144 | if M_Wheel>0 then R = math.min(R+1, fx_count) elseif M_Wheel<0 then R = math.max(R-1, 1) end 145 | gfx.setfont(1,"Calibri", Z) 146 | end 147 | -------------------------------------- 148 | --draw track info(name,fx count etc)-- 149 | gfx.set(0.9,0.7,0, 1) 150 | gfx.x, gfx.y = y, h 151 | gfx.printf("Track: " .. track_name.." FXs: "..fx_count ) 152 | -------------------------------------- 153 | --draw track in,chan_add_sub---------- 154 | draw_track_in_out("IN", track,chans, w,y,w,h) 155 | draw_track_chan_add_sub(track,chans, w,y,w,h) 156 | --draw each FX(pins,chans etc)-------- 157 | for i=R, fx_count do --R = 1-st drawing FX(used for rewind FXs) 158 | x = draw_FX(track, i-1,chans, x,y,w,h) + w*2 -- offset for next FX 159 | end 160 | -------------------------------------- 161 | --draw track out---------------------- 162 | draw_track_in_out("OUT",track,chans, x,y,w,h) 163 | ---------------------------- 164 | else gfx.set(0.9,0.7,0, 1); gfx.x, gfx.y = 4*w, h; gfx.printf("Track: " .. "No selected!") 165 | end 166 | 167 | end 168 | ---------------------------------------------------------------------------------------------------- 169 | ---------------------------------------------------------------------------------------------------- 170 | ---INIT--------------------------------------------------------------------------------------------- 171 | Z = 15 --used as cell w,h(and for change zoom level etc) 172 | R = 1 --used for rewind FXs 173 | gfx.clear=1315860 174 | gfx.init( "EUGEN27771 TrackFX Routing Matrix", 700,300 ) 175 | gfx.setfont(1,"Calibri", Z) 176 | last_mouse_cap=0 177 | mouse_dx, mouse_dy =0,0 178 | --------------------------------------- 179 | function mainloop() 180 | if gfx.mouse_cap&1==1 and last_mouse_cap&1==0 then 181 | mouse_ox, mouse_oy = gfx.mouse_x, gfx.mouse_y 182 | end 183 | Ctrl = gfx.mouse_cap&4==4 184 | Shift = gfx.mouse_cap&8==8 185 | 186 | ---------------------- 187 | --MAIN DRAW function-- 188 | DRAW() 189 | ---------------------- 190 | ---------------------- 191 | last_mouse_cap = gfx.mouse_cap 192 | last_x,last_y = gfx.mouse_x,gfx.mouse_y 193 | if gfx.getchar()~=-1 then reaper.defer(mainloop) end --defer 194 | gfx.update(); 195 | end 196 | --------------------------------------- 197 | ------------- 198 | mainloop() 199 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Adjust +10 velocity of selected item notes within time selection.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Adjust +10 velocity of selected item notes within time selection 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Notes Velocity Change// 11 | Add_Velocity = +10;//Set Value 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Change_Velocity() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected 37 | FNG_Note_Sel ? (Curr_Velo = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY");//note prop 38 | New_Velo = Curr_Velo + Add_Velocity;New_Velo<1?New_Velo=1;New_Velo>127?New_Velo=127;//New_Velocity 39 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY" , New_Velo); 40 | Suc_Operation+=1; 41 | );//note prop 42 | note_index+=1; 43 | ); 44 | extension_api("FNG_FreeMidiTake", FNG_Take); 45 | #Undo_Text = "~Changed Velocity " ;//Undo_Text 46 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 47 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 48 | strcat(#Undo_Text,sprintf(#str, "%d", Add_Velocity));//Compare Strings 49 | Undo_EndBlock(#Undo_Text, -1);//End Und 50 | ); 51 | //=======================================================================================================// 52 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 53 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 54 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 55 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 56 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 57 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 58 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 59 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 60 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 61 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 62 | //=======================================================================================================// 63 | TakeIsMIDI(ActiveTake) ? Change_Velocity();//If ActiveTake is MIDI execute function 64 | UpdateArrange(); 65 | 66 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 67 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 68 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Adjust -10 velocity of selected item notes within time selection.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Adjust -10 velocity of selected item notes within time selection 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Notes Velocity Change// 11 | Add_Velocity = -10;//Set Value 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Change_Velocity() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected 37 | FNG_Note_Sel ? (Curr_Velo = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY");//note prop 38 | New_Velo = Curr_Velo + Add_Velocity;New_Velo<1?New_Velo=1;New_Velo>127?New_Velo=127;//New_Velocity 39 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY" , New_Velo); 40 | Suc_Operation+=1; 41 | );//note prop 42 | note_index+=1; 43 | ); 44 | extension_api("FNG_FreeMidiTake", FNG_Take); 45 | #Undo_Text = "~Changed Velocity " ;//Undo_Text 46 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 47 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 48 | strcat(#Undo_Text,sprintf(#str, "%d", Add_Velocity));//Compare Strings 49 | Undo_EndBlock(#Undo_Text, -1);//End Und 50 | ); 51 | //=======================================================================================================// 52 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 53 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 54 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 55 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 56 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 57 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 58 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 59 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 60 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 61 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 62 | //=======================================================================================================// 63 | TakeIsMIDI(ActiveTake) ? Change_Velocity();//If ActiveTake is MIDI execute function 64 | UpdateArrange(); 65 | 66 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 67 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 68 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Adjust parameters of selected item notes.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Change Parameters of selected item notes 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Change Parameters// 11 | #Parameter_Values = "0,0,0";//Set Default Values(displayed in the menu) 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time-Sel; 0 for Notes-Start Only in time-Sel 13 | function Change_Parameters() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | //==Get Proj Grid( PPQ )==// 18 | Grid_Close = extension_api("BR_GetClosestGridDivision",Time_Sel_Start);//Close(near) 19 | Grid_Next = extension_api("BR_GetNextGridDivision", Grid_Close);//Next after Close 20 | Grid_Div_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Next) - MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Close);//to PPQ 21 | 22 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 23 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 24 | //==Select Only Notes In Current Time Selection==// 25 | note_index=0; 26 | loop(FNG_Count_Notes, 27 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 28 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 29 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 30 | 31 | (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!!! 32 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 33 | note_index+=1; 34 | ); 35 | //==Operation With Selected Notes==// 36 | note_index=0; 37 | loop(FNG_Count_Notes, 38 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 39 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 40 | //IF Note Selected && Add_Velocity!=0 -Change Velocity 41 | (FNG_Note_Sel>0&&Add_Velocity!=0) ? (Curr_Velo = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY");//note prop 42 | New_Velo = Curr_Velo + Add_Velocity;New_Velo<1?New_Velo=1;New_Velo>127?New_Velo=127;//New_Velocity 43 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY" , New_Velo); 44 | Suc_Velo_Operation+=1; 45 | );//note prop 46 | //IF Note Selected && Transpose!=0 -Change Pitch(Transpose) 47 | (FNG_Note_Sel>0&&Transpose!=0) ? (Curr_Pitch = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "PITCH");//note prop 48 | New_Pitch = Curr_Pitch + Transpose;New_Pitch<0?New_Pitch=0;New_Pitch>127?New_Pitch=127;//New_Pitch 49 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "PITCH" , New_Pitch); 50 | Suc_Pitch_Operation+=1; 51 | );//note prop 52 | //IF Note Selected && Move_Notes!=0 -Change Position 53 | (FNG_Note_Sel>0&&Move_Notes!=0) ? (Curr_POSITION = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note prop 54 | New_POSITION = Curr_POSITION + Grid_Div_PPQ*Move_Notes ; 55 | New_POSITION_Time = MIDI_GetProjTimeFromPPQPos(ActiveTake, New_POSITION);//New_POSITION to Time 56 | (New_POSITION_Time>=Item_End_Time || New_POSITION_Time=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 75 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 76 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 77 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 78 | //=======================================================================================================// 79 | TakeIsMIDI(ActiveTake) ? //If ActiveTake is MIDI 80 | (GetUserInputs("Change Parameters(add or subtract)", 3 , "Velocity,Transpose,Position", #Parameter_Values) ? //If UserInput "OK" then 81 | (match("%i,%i,%i", #Parameter_Values,Add_Velocity,Transpose,Move_Notes); 82 | Change_Parameters(););//Extract Velocity and Execuate Function 83 | ); 84 | 85 | UpdateArrange(); 86 | 87 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 88 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 89 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Adjust velocity of selected item notes within time selection.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Adjust velocity of selected item notes within time selection 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Notes Velocity Change// 11 | #Parameter_Values = "0,0,0,127";//Set Default Values for "Add Value,Set Fix Value,Low limit,Hi limit"(displayed in the menu) 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Change_Velocity() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected 37 | FNG_Note_Sel ? (Curr_Velo = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY");//Current_Velo 38 | New_Velo = Curr_Velo + Add_Velocity;//Add_Velocity 39 | Set_Velocity ? New_Velo = Set_Velocity;//Set_Velocity 40 | Low_limit>0 ? (New_Velo0 && Hi_limit<127) ? (New_Velo>Hi_limit ? New_Velo=Hi_limit;);//Set Hi limit 42 | 43 | New_Velo<1?New_Velo=1;New_Velo>127?New_Velo=127;//Verify New_Velocity 44 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "VELOCITY" , New_Velo); 45 | Suc_Operation+=1; 46 | );//note prop 47 | note_index+=1; 48 | ); 49 | extension_api("FNG_FreeMidiTake", FNG_Take); 50 | #Undo_Text = "~Changed Velocity " ;//Undo_Text 51 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 52 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 53 | strcat(#Undo_Text,sprintf(#str, "%d", Add_Velocity));//Compare Strings 54 | Undo_EndBlock(#Undo_Text, -1);//End Und 55 | ); 56 | //=======================================================================================================// 57 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 58 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 59 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 60 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 61 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 62 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 63 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 64 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 65 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 66 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 67 | //=======================================================================================================// 68 | TakeIsMIDI(ActiveTake) ? //If ActiveTake is MIDI 69 | (GetUserInputs("Change Velocity", 4 , "Add Value,Set Val(0=No),Low limit,Hi limit", #Parameter_Values) ? //If UserInput "OK" then 70 | (match("%i,%i,%i,%i", #Parameter_Values, Add_Velocity,Set_Velocity,Low_limit,Hi_limit); 71 | Change_Velocity(););//Extract Velocity and Execuate Function 72 | ); 73 | 74 | UpdateArrange(); 75 | 76 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 77 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 78 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Move selected item notes left within time selection (grid relative).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Move selected item notes left within time selection (grid relative) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Move Notes// 11 | Move_Notes = -1;//-1=Left;1=Right 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Move_Notes_One_Grid_Div() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | //==Get Proj Grid( PPQ )==// 18 | Grid_Close = extension_api("BR_GetClosestGridDivision",Time_Sel_Start);//Close(near) 19 | Grid_Next = extension_api("BR_GetNextGridDivision", Grid_Close);//Next after Close 20 | Grid_Div_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Next) - MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Close);//to PPQ 21 | 22 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 23 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 24 | //==Select Only Notes In Current Time Selection==// 25 | note_index=0; 26 | loop(FNG_Count_Notes, 27 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 28 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 29 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 30 | 31 | (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!!! 32 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 33 | note_index+=1; 34 | ); 35 | //==Operation With Selected Notes==// 36 | note_index=0; 37 | loop(FNG_Count_Notes, 38 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 39 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 40 | //IF Note Selected-Apply 41 | FNG_Note_Sel ? (Curr_POSITION = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note prop 42 | New_POSITION = Curr_POSITION + Grid_Div_PPQ*Move_Notes ; 43 | New_POSITION_Time = MIDI_GetProjTimeFromPPQPos(ActiveTake, New_POSITION);//New_POSITION to Time 44 | (New_POSITION_Time>=Item_End_Time || New_POSITION_Time=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 65 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 66 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 67 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 68 | //=======================================================================================================// 69 | TakeIsMIDI(ActiveTake) ? Move_Notes_One_Grid_Div();//If ActiveTake is MIDI execuate function 70 | UpdateArrange(); 71 | 72 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 73 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 74 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Move selected item notes right within time selection (grid relative).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Move selected item notes right within time selection (grid relative) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Move Notes// 11 | Move_Notes = +1;//-1=Left;1=Right 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Move_Notes_One_Grid_Div() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | //==Get Proj Grid( PPQ )==// 18 | Grid_Close = extension_api("BR_GetClosestGridDivision",Time_Sel_Start);//Close(near) 19 | Grid_Next = extension_api("BR_GetNextGridDivision", Grid_Close);//Next after Close 20 | Grid_Div_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Next) - MIDI_GetPPQPosFromProjTime(ActiveTake, Grid_Close);//to PPQ 21 | 22 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 23 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 24 | //==Select Only Notes In Current Time Selection==// 25 | note_index=0; 26 | loop(FNG_Count_Notes, 27 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 28 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 29 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 30 | 31 | (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!!! 32 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 33 | note_index+=1; 34 | ); 35 | //==Operation With Selected Notes==// 36 | note_index=0; 37 | loop(FNG_Count_Notes, 38 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 39 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 40 | //IF Note Selected-Apply 41 | FNG_Note_Sel ? (Curr_POSITION = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note prop 42 | New_POSITION = Curr_POSITION + Grid_Div_PPQ*Move_Notes ; 43 | New_POSITION_Time = MIDI_GetProjTimeFromPPQPos(ActiveTake, New_POSITION);//New_POSITION to Time 44 | (New_POSITION_Time>=Item_End_Time || New_POSITION_Time=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 65 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 66 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 67 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 68 | //=======================================================================================================// 69 | TakeIsMIDI(ActiveTake) ? Move_Notes_One_Grid_Div();//If ActiveTake is MIDI execuate function 70 | UpdateArrange(); 71 | 72 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 73 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 74 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Transpose selected item notes down within time selection (one semitone).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Transpose selected item notes down within time selection (one semitone) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Transpose notes// 11 | Transpose = -1;//Set Transpose Range 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Transpose_Notes() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected-Apply Transpose 37 | FNG_Note_Sel ? (Curr_Pitch = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "PITCH");//note prop 38 | New_Pitch = Curr_Pitch + Transpose;New_Pitch<0?New_Pitch=0;New_Pitch>127?New_Pitch=127;//New_Pitch 39 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "PITCH" , New_Pitch); 40 | Suc_Operation+=1; 41 | );//note prop 42 | note_index+=1; 43 | ); 44 | extension_api("FNG_FreeMidiTake", FNG_Take); 45 | #Undo_Text = "~Transposed " ;//Undo_Text 46 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 47 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 48 | strcat(#Undo_Text,sprintf(#str, "%d", Transpose));//Compare Strings 49 | Undo_EndBlock(#Undo_Text, -1);//End Und 50 | ); 51 | //=======================================================================================================// 52 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 53 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 54 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 55 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 56 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 57 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 58 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 59 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 60 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 61 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 62 | //=======================================================================================================// 63 | TakeIsMIDI(ActiveTake) ? Transpose_Notes();//If ActiveTake is MIDI execute function 64 | UpdateArrange(); 65 | 66 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 67 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 68 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Transpose selected item notes up within time selection (one semitone).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: EUGEN27771_Transpose selected item notes up within time selection (one semitone) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Transpose notes// 11 | Transpose = +1;//Set Transpose Range 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Transpose_Notes() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected-Apply Transpose 37 | FNG_Note_Sel ? (Curr_Pitch = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "PITCH");//note prop 38 | New_Pitch = Curr_Pitch + Transpose;New_Pitch<0?New_Pitch=0;New_Pitch>127?New_Pitch=127;//New_Pitch 39 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "PITCH" , New_Pitch); 40 | Suc_Operation+=1; 41 | );//note prop 42 | note_index+=1; 43 | ); 44 | extension_api("FNG_FreeMidiTake", FNG_Take); 45 | #Undo_Text = "~Transposed " ;//Undo_Text 46 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 47 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 48 | strcat(#Undo_Text,sprintf(#str, "%d", Transpose));//Compare Strings 49 | Undo_EndBlock(#Undo_Text, -1);//End Und 50 | ); 51 | //=======================================================================================================// 52 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 53 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 54 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 55 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 56 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 57 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 58 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 59 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 60 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 61 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 62 | //=======================================================================================================// 63 | TakeIsMIDI(ActiveTake) ? Transpose_Notes();//If ActiveTake is MIDI execute function 64 | UpdateArrange(); 65 | 66 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 67 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 68 | -------------------------------------------------------------------------------- /Item Editing/MIDI item adjustment/gen_Transpose selected item notes within time selection with prompt.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Transpose selected item notes with prompt within time selection 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | //Transpose notes// 11 | #Transpose = "1";//Set Transpose Range 12 | VAR_FLAG = 0;// 1 for Notes Start-End in time Sel; 0 for Notes Start Only in time Sel 13 | function Transpose_Notes() 14 | (Undo_BeginBlock();//Start Undo 15 | Time_Sel_Start_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_Start);//Time Sel Start to PPQ 16 | Time_Sel_End_PPQ = MIDI_GetPPQPosFromProjTime(ActiveTake, Time_Sel_End);//Time Sel End Start to PPQ 17 | 18 | FNG_Take = extension_api("FNG_AllocMidiTake", ActiveTake);//Get FNG TAKE 19 | FNG_Count_Notes = extension_api("FNG_CountMidiNotes", FNG_Take);//Count_Notes in take 20 | //==Select Only Notes In Current Time Selection==// 21 | note_index=0; 22 | loop(FNG_Count_Notes, 23 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET FNG_Note_ID 24 | FNG_Note_Start_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "POSITION");//note position(PPQ) 25 | VAR_FLAG ? FNG_Note_LENGTH_PPQ = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "LENGTH");//note lenght(PPQ)-ALSO SEE VAR_FLAG!!! 26 | 27 | (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!!! 28 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "SELECTED" , SEL);//Sel-Unsel Notes 29 | note_index+=1; 30 | ); 31 | //==Operation With Selected Notes==// 32 | note_index=0; 33 | loop(FNG_Count_Notes, 34 | FNG_Note_ID = extension_api("FNG_GetMidiNote", FNG_Take, note_index);//GET Note_ID 35 | FNG_Note_Sel = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "SELECTED");//note prop 36 | //IF Note Selected-Apply Transpose 37 | FNG_Note_Sel ? (Curr_Pitch = extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID , "PITCH");//note prop 38 | New_Pitch = Curr_Pitch + Transpose;New_Pitch<0?New_Pitch=0;New_Pitch>127?New_Pitch=127;//New_Pitch 39 | extension_api("FNG_SetMidiNoteIntProperty", FNG_Note_ID , "PITCH" , New_Pitch); 40 | Suc_Operation+=1; 41 | );//note prop 42 | note_index+=1; 43 | ); 44 | extension_api("FNG_FreeMidiTake", FNG_Take); 45 | #Undo_Text = "~Transposed " ;//Undo_Text 46 | strcat(#Undo_Text,sprintf(#str, "%d", Suc_Operation));//Compare Strings 47 | strcat(#Undo_Text,"-Notes: ");//Compare Strings 48 | strcat(#Undo_Text,sprintf(#str, "%d", Transpose));//Compare Strings 49 | Undo_EndBlock(#Undo_Text, -1);//End Und 50 | ); 51 | //=======================================================================================================// 52 | MediaItem = GetSelectedMediaItem(0, 0);//Get selected media item 53 | ActiveTake = GetActiveTake(MediaItem);//Get ActiveTake 54 | GetSet_LoopTimeRange(0,0, Time_Sel_Start, Time_Sel_End,0); //Get Current Time Sel 55 | Item_Start_Time = GetMediaItemInfo_Value(MediaItem, "D_POSITION"); 56 | Item_End_Time = Item_Start_Time+GetMediaItemInfo_Value(MediaItem, "D_LENGTH"); 57 | //OUT OF RANGE VERIFICATION - if the item is outside the time_selection,time_selection will be changed// 58 | (Item_Start_Time>=Time_Sel_Start && Item_Start_Time>=Time_Sel_End)|| 59 | (Item_End_Time<=Time_Sel_Start && Item_End_Time<=Time_Sel_End) ? 60 | (Time_Sel_Start = Item_Start_Time;Time_Sel_End = Item_End_Time; 61 | GetSet_LoopTimeRange(1,0, Time_Sel_Start, Time_Sel_End,0););//Set New Time Sel 62 | //=======================================================================================================// 63 | TakeIsMIDI(ActiveTake) ? //If ActiveTake is MIDI 64 | (GetUserInputs("Change Pitch", 1 , "Set Value", #Transpose) ? //If UserInput "OK" then 65 | (match("%i", #Transpose, Transpose);Transpose_Notes(););//Extract Velocity and Execuate Function 66 | ); 67 | 68 | UpdateArrange(); 69 | 70 | /*===Example for extension_api("FNG_GetMidiNoteIntProperty", FNG_Note_ID,prop) 71 | prop = "PITCH","CHANNEL","VELOCITY","POSITION","LENGTH","SELECTED"========== */ 72 | -------------------------------------------------------------------------------- /Item Editing/gen_Explode multichannel Audio (Non-destructive).lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name: Explode multichannel Audio (Non-destructive) 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | 11 | ------------------------------------------------ 12 | -- Non-destructive explode multichannel Audio -- 13 | ------------------------------------------------ 14 | function non_destructive_explode() 15 | Item_ID = reaper.GetSelectedMediaItem(0,0) 16 | if Item_ID then Take_ID = reaper.GetActiveTake(Item_ID) 17 | if Take_ID and reaper.BR_IsTakeMidi(Take_ID)==false then 18 | _, Item_Chunk = reaper.GetItemStateChunk(Item_ID , "", false) -- Get Item Chunk 19 | PCM_source = reaper.GetMediaItemTake_Source(Take_ID) -- Get Item Source 20 | SourceNChan = reaper.GetMediaSourceNumChannels(PCM_source) -- Num Chan in source 21 | Item_Track = reaper.GetMediaItem_Track(Item_ID) -- Get Item Track 22 | Track_Num = reaper.GetMediaTrackInfo_Value(Item_Track, "IP_TRACKNUMBER") -- Track number(1-based) 23 | index = Track_Num-1 -- Original Item_Track index 24 | 25 | -- For each Source Channeel -- 26 | for i=1, SourceNChan, 1 do 27 | reaper.InsertTrackAtIndex(index+i, 0) -- New_Track 28 | New_Track_ID = reaper.GetTrack(0, index+i) -- Get New_Track ID 29 | New_Item = reaper.AddMediaItemToTrack(New_Track_ID) -- New_Item 30 | reaper.SetItemStateChunk(New_Item, Item_Chunk, true) -- Set Item Chunk 31 | New_Take = reaper.GetActiveTake(New_Item) -- Get Acive take 32 | reaper.SetMediaItemTakeInfo_Value(New_Take, "I_CHANMODE", i+2) -- Set channel mode 33 | end 34 | 35 | -- Mute orig Item,Set folder states -- 36 | reaper.SetMediaItemInfo_Value(Item_ID, "B_MUTE", 1) -- Mute Original Item 37 | reaper.SetMediaTrackInfo_Value(New_Track_ID, "I_FOLDERDEPTH", -1) -- Set track is last in the innermost folder 38 | reaper.SetMediaTrackInfo_Value(Item_Track, "I_FOLDERDEPTH", 1) -- Set track is a folder parent 39 | reaper.TrackList_AdjustWindows(0) -- update tracklist 40 | end 41 | end 42 | end 43 | 44 | ----------------------- 45 | ----------------------- 46 | reaper.Undo_BeginBlock() 47 | non_destructive_explode() 48 | reaper.Undo_EndBlock("Explode multichannel Audio (Non-destructive)", -1) 49 | reaper.UpdateArrange() 50 | -------------------------------------------------------------------------------- /Item Editing/gen_Open media item (source relative).lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name: Open media item (source relative) 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | 11 | --------------------------------------------------------------------- 12 | -- Open Item(Var Actions depending of item source) ------------------ 13 | --------------------------------------------------------------------- 14 | --[[ 15 | INFO: 16 | Open the Action list, right-click on the Action and Copy Sel Action ID 17 | Insert the Action ID in the "Action ID" column 18 | For text ID used quotes! 19 | For no-action used zero! 20 | ]]-- 21 | 22 | --------------------------------- 23 | --------------------------------- 24 | -- SourceType = Action ID -- 25 | --------------------------------- 26 | -- Midi Source --------- 27 | MIDI = 40153 28 | -- Audio Source -------- 29 | WAVE = "_SWS_TOGZOOMIONLY" 30 | REX = "_SWS_TOGZOOMIONLY" 31 | FLAC = "_SWS_TOGZOOMIONLY" 32 | MP3 = "_SWS_TOGZOOMIONLY" 33 | VORBIS = "_SWS_TOGZOOMIONLY" 34 | OPUS = "_SWS_TOGZOOMIONLY" 35 | -- Video Source -------- 36 | VIDEO = 50125 37 | -- Special Source ------ 38 | RPP_PROJECT = 41816 39 | EMPTY = 40850 40 | CLICK = 40011 41 | LTC = 40011 42 | 43 | -- if no sel item or no-action(Action ID=0) -- 44 | NoSelItem = 40113 45 | --------------------------------------------------------------------- 46 | --------------------------------------------------------------------- 47 | function Get_Source_Type(Item_ID) 48 | if Item_ID then 49 | Take_ID = reaper.GetActiveTake(Item_ID)-- Get Active Take(from Item) 50 | if Take_ID then 51 | PCM_source = reaper.GetMediaItemTake_Source(Take_ID) 52 | S_Type = reaper.GetMediaSourceType(PCM_source,"") 53 | if S_Type == "SECTION" then 54 | PCM_source = reaper.GetMediaSourceParent(PCM_source) 55 | S_Type = reaper.GetMediaSourceType(PCM_source,"") 56 | end 57 | else S_Type = "EMPTY" 58 | end 59 | end 60 | return S_Type 61 | end 62 | 63 | ---------------------- 64 | function Set_ID(S_Type) 65 | -- Midi Source --------- 66 | if S_Type == "MIDI" then ID = MIDI 67 | -- Audio Source -------- 68 | elseif S_Type == "WAVE" then ID = WAVE 69 | elseif S_Type == "REX" then ID = REX 70 | elseif S_Type == "FLAC" then ID = FLAC 71 | elseif S_Type == "MP3" then ID = MP3 72 | elseif S_Type == "VORBIS" then ID = VORBIS 73 | elseif S_Type == "OPUS" then ID = OPUS 74 | -- Video Source -------- 75 | elseif S_Type == "VIDEO" then ID = VIDEO 76 | -- Special Source ------ 77 | elseif S_Type == "RPP_PROJECT" then ID = RPP_PROJECT 78 | elseif S_Type == "EMPTY" then ID = EMPTY 79 | elseif S_Type == "CLICK" then ID = CLICK 80 | elseif S_Type == "LTC" then ID = LTC 81 | end 82 | 83 | -- if non-native Action ID -- 84 | if ID and type(ID) == "string" then 85 | ID = reaper.NamedCommandLookup(ID) 86 | end 87 | -- if Action no assigned ---- 88 | if not S_Type or not ID or ID == 0 then 89 | ID = NoSelItem -- Action for others 90 | end 91 | 92 | return ID 93 | end 94 | 95 | ---------------------- 96 | function Run_Action() 97 | reaper.Undo_BeginBlock() 98 | reaper.Main_OnCommandEx(ID,0, 0) 99 | reaper.Undo_EndBlock("Open media item (source relative)", -1) 100 | end 101 | 102 | ---------------------------------------- 103 | ---------------------------------------- 104 | Item_ID = reaper.GetSelectedMediaItem(0, 0) 105 | Get_Source_Type(Item_ID) 106 | Set_ID(S_Type) 107 | reaper.defer(Run_Action) 108 | -------------------------------------------------------------------------------- /Item Editing/gen_Open media item (type relative).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Open media item (type relative) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | */ 9 | 10 | 11 | 12 | // For MIDI === Open MIDI-Item in MIDI-EDITOR with a FIXED VIEW(stable zoom in Project-Bars) 13 | // For AUDIO === Open AUDIO-Item(Simply Toggle MAX/Normal Zoom & IT CAN BE CHANGED IF NEED) 14 | 15 | // == Edit This Section For Set Zoom-Range, Start-View Point etc == // 16 | Zoom_In_Bars = 4; // Set Zoom_In_Bars for Zoom_Rang(for example 1,2,4 etc) 17 | Add_Zoom_Out = 0; // Set Addenum Zoom_Out(ONLY IF NEED)(for example 0,1,2,3 etc) 18 | Start_Zoom_Flag = 1; // Set FLAG(Start-View Point) : 0=Cursor_Pos OR 1=Meas_Start(BAR start) 19 | Audio_Action_ID = 41622; // IT CAN BE CHANGED IF NEED, paste another ID From Action List(DefID=Toggle Zoom to Sel items) 20 | 21 | // ================================================================= // 22 | PreventUIRefresh(1); 23 | Undo_BeginBlock(); // Start Undo(TOTAL FOR MIDI-Item & AUDIO-Items) 24 | function Open_MIDI_and_Zoom() 25 | ( 26 | GetSet_LoopTimeRange(0,0,User_T_Sel_Start,User_T_Sel_End,0); // Get-Save User Time Sel 27 | Cursor_Pos_QN = TimeMap_timeToQN(GetCursorPosition()); // Get Cursor Pos(in Project QN) 28 | TimeMap_QNToMeasures(0, Cursor_Pos_QN , Bar_Start_QN , Bar_End_QN ); // Get BAR Start-End in QN 29 | One_Bar_QN = Bar_End_QN - Bar_Start_QN; // Calculate QN in Current Bar 30 | Zoom_Range_QN = Zoom_In_Bars*One_Bar_QN; // Calculate Zoom_Range in QN(see Zoom_In_Bars) 31 | Start_Zoom_Flag ? Start_Zoom_QN = Bar_Start_QN : Start_Zoom_QN = Cursor_Pos_QN; // Set Start_Zoom Point(see Flag) 32 | End_Zoom_QN = Start_Zoom_QN + Zoom_Range_QN; // Calculate End_Zoom Point 33 | Start_Zoom = TimeMap_QNToTime(Start_Zoom_QN); // Start_Zoom_QN to Time 34 | End_Zoom = TimeMap_QNToTime(End_Zoom_QN); // End_Zoom_QN to Time 35 | 36 | GetSet_LoopTimeRange(1,0, Start_Zoom , End_Zoom , 0); // Set Time Sel For Zoom 37 | Main_OnCommand(40153, 0); // 40153 = open selected MIDI-Item in MIDI editor 38 | ME = MIDIEditor_GetActive(); // Get Active MIDI-EDITOR 39 | MIDIEditor_OnCommand(ME, 40726); // Zoom to Zoom_Rang_Sel 40 | loop(Add_Zoom_Out,MIDIEditor_OnCommand(ME, 1011);); // Zoom Out Horiz if Need(see Add_Zoom_Out) 41 | 42 | GetSet_LoopTimeRange(1,0,User_T_Sel_Start,User_T_Sel_End,0); // Restore User Time Sel 43 | Undo_EndBlock("Open MIDI-Item + Zoom", -1); // End Undo(Local-FOR MIDI ONLY) 44 | ); 45 | 46 | // ================================================================= // 47 | MediaItem = GetSelectedMediaItem(0, 0); // Get 1-st selected media item 48 | ActiveTake = GetActiveTake(MediaItem); // Get Active Take 49 | TakeIsMIDI(ActiveTake) ? // IF Take is MIDI,then exec Open_MIDI_and_Zoom(),else run Audio_Action 50 | Open_MIDI_and_Zoom() : 51 | (Main_OnCommand(Audio_Action_ID, 0); // Action for AUDIO-Items(see Audio_Action_ID) 52 | Undo_EndBlock("Open Audio-Item + Zoom", -1); // End Undo(Local-FOR Audio ONLY) 53 | ); 54 | PreventUIRefresh(-1); 55 | -------------------------------------------------------------------------------- /Item Editing/gen_Remove empty bars from selected MIDI items (grid relative).lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name:Remove empty bars from selected MIDI items (grid relative) 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | 11 | function msg(m) reaper.ShowConsoleMsg(tostring(m.."\n")) end 12 | ---------------------------- 13 | ---------------------------- 14 | --------- 15 | function Add_range_to_Split(range_start,range_end,note_start,note_end) 16 | if range_startnote_start then return end -- | --|- 17 | if range_startnote_end then return end -- -|-- | 18 | if range_start<=note_start and range_end>=note_end then return end -- | - | 19 | if range_start>=note_start and range_end<=note_end then return end -- -|---|- 20 | return true 21 | end 22 | --------- 23 | function Remove_Empty_Bars(Item,Take) 24 | local Split_Points = {} 25 | -- if LOOPSRC -- 26 | if reaper.GetMediaItemInfo_Value(Item, "B_LOOPSRC") then reaper.Main_OnCommand(40362,0) 27 | Item = reaper.GetSelectedMediaItem(0,0) 28 | Take = reaper.GetActiveTake(Item) 29 | end 30 | ---------------- 31 | local Item_Start = reaper.GetMediaItemInfo_Value(Item, "D_POSITION") 32 | local Item_End = Item_Start + reaper.GetMediaItemInfo_Value(Item, "D_LENGTH") 33 | local ret, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(Take) 34 | ---------------- 35 | local range_start = Item_Start 36 | local range_end = reaper.BR_GetNextGridDivision(Item_Start) 37 | local spl = 1 38 | ---------------------------- 39 | while range_startnote_start then return end -- | --|- 24 | if range_startnote_end then return end -- -|-- | 25 | if range_start<=note_start and range_end>=note_end then return end -- | - | 26 | if range_start>=note_start and range_end<=note_end then return end -- -|---|- 27 | return true 28 | end 29 | --------- 30 | function Add_range_to_Split2(range_start,range_end,CC_pos) 31 | if range_start<=CC_pos and range_end>CC_pos then return end -- | - | 32 | return true 33 | end 34 | --------- 35 | function Remove_Empty_Bars(Item,Take) 36 | local Split_Points = {} 37 | -- if LOOPSRC -- 38 | if reaper.GetMediaItemInfo_Value(Item, "B_LOOPSRC") then reaper.Main_OnCommand(40362,0) 39 | Item = reaper.GetSelectedMediaItem(0,0) 40 | Take = reaper.GetActiveTake(Item) 41 | end 42 | ---------------- 43 | local Item_Start = reaper.GetMediaItemInfo_Value(Item, "D_POSITION") 44 | local Item_End = Item_Start + reaper.GetMediaItemInfo_Value(Item, "D_LENGTH") 45 | local ret, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(Take) 46 | ---------------- 47 | local range_start, range_end = range_start_end(Item_Start) 48 | local spl = 1 49 | ---------------------------- 50 | while range_startnote_start then return end -- | --|- 16 | if range_startnote_end then return end -- -|-- | 17 | if range_start<=note_start and range_end>=note_end then return end -- | - | 18 | if range_start>=note_start and range_end<=note_end then return end -- -|---|- 19 | return true 20 | end 21 | --------- 22 | function Add_range_to_Split2(range_start,range_end,CC_pos) 23 | if range_start<=CC_pos and range_end>CC_pos then return end -- | - | 24 | return true 25 | end 26 | --------- 27 | function Remove_Empty_Bars(Item,Take) 28 | local Split_Points = {} 29 | -- if LOOPSRC -- 30 | if reaper.GetMediaItemInfo_Value(Item, "B_LOOPSRC") then reaper.Main_OnCommand(40362,0) 31 | Item = reaper.GetSelectedMediaItem(0,0) 32 | Take = reaper.GetActiveTake(Item) 33 | end 34 | ---------------- 35 | local Item_Start = reaper.GetMediaItemInfo_Value(Item, "D_POSITION") 36 | local Item_End = Item_Start + reaper.GetMediaItemInfo_Value(Item, "D_LENGTH") 37 | local ret, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(Take) 38 | ---------------- 39 | local range_start = Item_Start 40 | local range_end = reaper.BR_GetNextGridDivision(Item_Start) 41 | local spl = 1 42 | ---------------------------- 43 | while range_startnote_start then return end -- | --|- 25 | if range_startnote_end then return end -- -|-- | 26 | if range_start<=note_start and range_end>=note_end then return end -- | - | 27 | if range_start>=note_start and range_end<=note_end then return end -- -|---|- 28 | return true 29 | end 30 | --------- 31 | function Remove_Empty_Bars(Item,Take) 32 | local Split_Points = {} 33 | -- if LOOPSRC -- 34 | if reaper.GetMediaItemInfo_Value(Item, "B_LOOPSRC") then reaper.Main_OnCommand(40362,0) 35 | Item = reaper.GetSelectedMediaItem(0,0) 36 | Take = reaper.GetActiveTake(Item) 37 | end 38 | ---------------- 39 | local Item_Start = reaper.GetMediaItemInfo_Value(Item, "D_POSITION") 40 | local Item_End = Item_Start + reaper.GetMediaItemInfo_Value(Item, "D_LENGTH") 41 | local ret, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(Take) 42 | ---------------- 43 | local range_start, range_end = range_start_end(Item_Start) 44 | local spl = 1 45 | ---------------------------- 46 | while range_start0 then 16 | -- Save all selected items ids -- 17 | item_id = {} 18 | for i=1, sel_items do item_id[i] = reaper.GetSelectedMediaItem(0, i-1) end 19 | 20 | -- Get first item start and last item end -- 21 | s_start = reaper.GetMediaItemInfo_Value(item_id[1], "D_POSITION") 22 | s_end = reaper.GetMediaItemInfo_Value(item_id[sel_items], "D_POSITION")+ 23 | reaper.GetMediaItemInfo_Value(item_id[sel_items], "D_LENGTH") 24 | 25 | mouse = reaper.BR_PositionAtMouseCursor(false) -- V1 -- mouse cursor variant 26 | -- mouse = reaper.GetCursorPosition() -- V2 -- edit cursor variant 27 | 28 | if mouse~=-1 and mouse>s_start then K = (s_end-s_start)/(mouse-s_start) -- its coefficient 29 | -- change each selected item(starting from the last) -- 30 | i=sel_items 31 | while i>0 do 32 | Item = item_id[i] 33 | Take = reaper.GetActiveTake(Item) 34 | Pos = reaper.GetMediaItemInfo_Value(Item, "D_POSITION") - s_start -- Its position relative to the first sel item 35 | Len = reaper.GetMediaItemInfo_Value(Item, "D_LENGTH") -- Length 36 | reaper.SetMediaItemInfo_Value(Item,"D_POSITION", s_start + Pos/K) 37 | reaper.SetMediaItemInfo_Value(Item,"D_LENGTH",Len/K) 38 | Playrate = reaper.GetMediaItemTakeInfo_Value(Take, "D_PLAYRATE") 39 | reaper.SetMediaItemTakeInfo_Value(Take, "D_PLAYRATE", Playrate*K) 40 | i=i-1 41 | end 42 | end 43 | end 44 | 45 | -- For NoUndo(no trash in undo history) -- 46 | reaper.Undo_BeginBlock() 47 | reaper.Undo_EndBlock("Stretch selected items positions and rate", 2) 48 | -------------------------------------------------------------------------------- /MIDI Editor/gen_Delete Notes Overlaps (poly).lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name:Delete Notes Overlaps (poly) 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | ----------------------------------------------------------------- 11 | -------- Delete Notes Overlaps(Poly) ---------------------------- 12 | ----------------------------------------------------------------- 13 | 14 | -- Get Take From Midi Editor or From Arrange -- 15 | function Get_MIDI_Take() 16 | local ME, Item_ID, Take_ID 17 | ME = reaper.MIDIEditor_GetActive() -- Active Midi Editor 18 | if ME then Take_ID = reaper.MIDIEditor_GetTake(ME); ME_Flag = 1 -- Active Take from ME 19 | else Item_ID = reaper.GetSelectedMediaItem(0,0) 20 | if Item_ID then Take_ID = reaper.GetActiveTake(Item_ID); ME_Flag = 0 -- Active Take from Arrange 21 | end 22 | end 23 | -------------- 24 | if not Take_ID or not reaper.TakeIsMIDI(Take_ID) then return false end 25 | return Take_ID, ME_Flag 26 | end 27 | 28 | -- Get note properties -- 29 | function Get_Note_Prop(FNG_Take,idx) 30 | local Note, Note_Sel, Note_Pos, Note_Len, Note_End 31 | -- Get Cur_Note Parameters -- 32 | Note = reaper.FNG_GetMidiNote(FNG_Take, idx) -- Get current Note 33 | Note_Sel = reaper.FNG_GetMidiNoteIntProperty( Note,"SELECTED") -- Get Sel State 34 | Note_Pos = reaper.FNG_GetMidiNoteIntProperty( Note,"POSITION") -- Get Position PPQ 35 | Note_Len = reaper.FNG_GetMidiNoteIntProperty( Note,"LENGTH") -- Get LENGTH PPQ 36 | Note_End = Note_Pos+ Note_Len -- Calc End PPQ 37 | return Note, Note_Sel, Note_Pos ,Note_End 38 | end 39 | 40 | -- Find and Delete Overlaps -- 41 | function Del_Overlaps(Take_ID, ME_Flag) 42 | local FNG_Take = reaper.FNG_AllocMidiTake(Take_ID) -- AllocTake 43 | local Count_Notes = reaper.FNG_CountMidiNotes(FNG_Take) -- Count Notes 44 | 45 | for i=1, Count_Notes-1 do 46 | local Cur_Note, Cur_Note_Sel, Cur_Note_Pos, Cur_Note_End = Get_Note_Prop(FNG_Take,i-1) -- func Get_Note_Prop 47 | -- Find the first note corresponding to the conditions -- 48 | if ME_Flag==0 or Cur_Note_Sel==1 then 49 | local Del_Overlap = 0 50 | local j = i 51 | while j < Count_Notes and Del_Overlap < 1 do 52 | local Next_Note, Next_Note_Sel, Next_Note_Pos, Next_Note_End = Get_Note_Prop(FNG_Take,j) -- Get_Note_Prop 53 | -- Compare Notes Data -- 54 | if Next_Note_Pos-Cur_Note_Pos > Min_Diff and 55 | Cur_Note_End > Next_Note_Pos and (InCh_Flag > 0 or Next_Note_End > Cur_Note_End) then 56 | -- then set new Lenght -- 57 | local New_Lenght = Next_Note_Pos-Cur_Note_Pos 58 | reaper.FNG_SetMidiNoteIntProperty(Cur_Note, "LENGTH", New_Lenght) -- Set New Lenght 59 | Del_Overlap = 1 60 | end 61 | j=j+1 62 | end 63 | end 64 | end 65 | reaper.FNG_FreeMidiTake(FNG_Take) -- FreeTake 66 | end 67 | 68 | --------------------------------------------------- 69 | --- You can set some additional parameters -------- 70 | --------------------------------------------------- 71 | Min_Diff = 960/4 -- Set Min Differnce(in PPQ) 72 | InCh_Flag = 0 -- Save Overlaps Inside of a Chord var 73 | -- InCh_Flag = 1 -- Del Overlaps Inside of a Chord var 74 | 75 | --- Start --- 76 | reaper.Undo_BeginBlock() 77 | local Take_ID, ME_Flag = Get_MIDI_Take() 78 | if Take_ID then Del_Overlaps(Take_ID, ME_Flag) end 79 | reaper.Undo_EndBlock("Delete Notes Overlaps (poly)", -1) 80 | reaper.UpdateArrange() 81 | 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReaScripts 2 | ReaScripts(eel, lua) 3 | 4 | -------------------------------------------------------------------------------- /Track Editing/gen_Freeze selected tracks(only instruments).lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name:Freeze selected tracks(only instruments) 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | 11 | --------------------------------------------- 12 | -- Freeze ----------------------------------- 13 | --------------------------------------------- 14 | function Freeze(track) 15 | local fx_count = reaper.TrackFX_GetCount(track) 16 | if fx_count==0 then return end 17 | ----------------------------------------- 18 | local sel_first = reaper.NamedCommandLookup("_S&M_SELFX1") 19 | local sel_next = reaper.NamedCommandLookup("_S&M_SELFXNEXT") 20 | local online_sel_fx = reaper.NamedCommandLookup("_S&M_FXOFF_SETONSEL") 21 | local online_all_fx = 40536 22 | local offline_all_fx = 40535 23 | local freeze_track = 41223 24 | ----------------------------------------- 25 | reaper.SetOnlyTrackSelected(track) -- Select current track only 26 | reaper.Main_OnCommand(offline_all_fx, 0) -- offline all fxs 27 | reaper.Main_OnCommand(sel_first, 0) -- select first fx 28 | 29 | -- Online instruments only -------------- 30 | for fx=1, fx_count do 31 | local retval, fx_name = reaper.TrackFX_GetFXName(track, fx-1, "") 32 | if fx_name:match("VSTi") or fx_name:match("AUi") then 33 | reaper.Main_OnCommand(online_sel_fx, 0) 34 | end 35 | reaper.Main_OnCommand(sel_next, 0) -- to next fx 36 | end 37 | 38 | -- Freeze, online all ------------------- 39 | reaper.Main_OnCommand(freeze_track, 0) -- Freeze 40 | reaper.Main_OnCommand(online_all_fx, 0) -- online all fxs 41 | end 42 | 43 | --------------------------------------------- 44 | -- Start ------------------------------------ 45 | --------------------------------------------- 46 | local track_cnt = reaper.CountSelectedTracks(0) 47 | local track_tb = {} 48 | -- Get sel tracks ------ 49 | for i=1, track_cnt do 50 | track_tb[i] = reaper.GetSelectedTrack(0, i-1) 51 | end 52 | -- Freeze tracks ------- 53 | reaper.Undo_BeginBlock() 54 | for i=1, track_cnt do 55 | Freeze(track_tb[i]) 56 | end 57 | -- Restore sel state --- 58 | for i=1, track_cnt do 59 | reaper.SetTrackSelected(track_tb[i], true) 60 | end 61 | reaper.Undo_EndBlock("Freeze selected tracks(only instruments)", -1) 62 | -------------------------------------------------------------------------------- /Tracks Properties/gen_Select next first level track.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * ReaScript Name: Select next first level track 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.0 8 | ]] 9 | 10 | ---------------------------------- 11 | -- Select next 1-st level track -- 12 | ---------------------------------- 13 | function sel_next_track(tr_id) 14 | local sel_tr_num, i, tr_depth 15 | sel_tr_num = reaper.GetMediaTrackInfo_Value(tr_id, "IP_TRACKNUMBER") 16 | reaper.SetMediaTrackInfo_Value(tr_id, "I_SELECTED", 0) -- unselect 17 | i = sel_tr_num 18 | while i=0 do 19 | tr_id = reaper.GetTrack(0,i) 20 | tr_depth = reaper.GetTrackDepth(tr_id) 21 | if tr_depth==0 then reaper.SetMediaTrackInfo_Value(tr_id, "I_SELECTED", 1) 22 | break 23 | end 24 | i=i-1 25 | end 26 | end 27 | 28 | ---------------------------------- 29 | tr_id = reaper.GetSelectedTrack(0,0) 30 | if tr_id then sel_prev_track(tr_id) end 31 | 32 | -------------------------------------------------------------------------------- /Various/Envelope-based Compressor/inc/AudioFunctions.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: EUGEN27771 3 | * Author URI: http://forum.cockos.com/member.php?u=50462 4 | * Licence: GPL v3 5 | * Version: 1.0 6 | * NoIndex: true 7 | */ 8 | 9 | //************************************************************************************************** 10 | //*** Audio functions ****************************************************************************** 11 | //************************************************************************************************** 12 | // -- DB2VAL - VAL2DB ---------------------------- 13 | function DB2VAL(x) 14 | ( 15 | exp((x)*0.11512925464970228420089957273422); 16 | ); 17 | //---------------------------- 18 | function VAL2DB(x) 19 | local(v) 20 | ( 21 | x < 0.0000000298023223876953125 ? ( 22 | -150; 23 | ) : ( 24 | v = log(x)*8.6858896380650365530225783783321; 25 | v < -150 ? -150 : v; 26 | ); 27 | ); 28 | 29 | //------------------------------------------------ 30 | //-- Simple Filter ------------------------------- 31 | //------------------------------------------------ 32 | function FilterB.SetValues(type, FreqHz, samplerate) 33 | local(sqr2, c, c2, csqr2, d) 34 | instance(active, ampIn0, ampIn1, ampIn2, ampOut1, ampOut2, 35 | dlyIn1, dlyIn2, dlyOut1, dlyOut2) //reset on change 36 | ( 37 | // пересмотреть акт. значения. LP тоже не должен заходить в ноль! 38 | active = (type == 0 && FreqHz < 19999) || (type == 1 && FreqHz > 1); 39 | 40 | active ? ( 41 | type ? ( 42 | // Hi Pass // 43 | sqr2 = 1.414213562; 44 | c = tan(($pi/samplerate) * FreqHz ); 45 | c2 = c * c; 46 | csqr2 = sqr2 * c; 47 | d = (c2 + csqr2 + 1); 48 | ampIn0 = 1 / d; 49 | ampIn1 = -(ampIn0 + ampIn0); 50 | ampIn2 = ampIn0; 51 | ampOut1 = (2 * (c2 - 1)) / d; 52 | ampOut2 = (1 - csqr2 + c2) / d; 53 | ) : ( 54 | // Low Pass // 55 | sqr2 = 1.414213562; 56 | c = 1 / tan(($pi/samplerate) * FreqHz ); 57 | c2 = c * c; 58 | csqr2 = sqr2 * c; 59 | d = (c2 + csqr2 + 1); 60 | ampIn0 = 1 / d; 61 | ampIn1 = ampIn0 + ampIn0; 62 | ampIn2 = ampIn0; 63 | ampOut1 = (2 * (1 - c2)) / d; 64 | ampOut2 = (c2 - csqr2 + 1) / d; 65 | ); 66 | ); 67 | 68 | // без сброса тянется хвост, на скриптах не подходит! 69 | dlyIn1 = dlyIn2 = dlyOut1 = dlyOut2 = 0; //reset on change 70 | 71 | ); 72 | 73 | //---------------------------- 74 | // Filter in = input sample 75 | // Filter out = out sample 76 | function FilterB.Apply(in) 77 | instance(active, ampIn0, ampIn1, ampIn2, ampOut1, ampOut2, dlyIn1, dlyIn2, dlyOut1, dlyOut2, out) 78 | ( 79 | out = in; 80 | active ? ( 81 | out = (ampIn0 * in) + (ampIn1 * dlyIn1) + (ampIn2 * dlyIn2) - (ampOut1 * dlyOut1) - (ampOut2 * dlyOut2); 82 | dlyOut2 = dlyOut1; 83 | dlyOut1 = out; 84 | dlyIn2 = dlyIn1; 85 | dlyIn1 = in; 86 | ); 87 | 88 | out; 89 | ); 90 | 91 | //------------------------------------------------ 92 | // -- RMS follower(Test, need some fixes) -------- 93 | //------------------------------------------------ 94 | /* for JSFX variant 95 | function RMSFollower.SetValues(buf, rms_size_ms, samplerate) 96 | local(last_rms_size) 97 | ( 98 | // samplerate can be different from the global srate if need 99 | // rms_size_ms - max 1000 ms, change if need 100 | this.buf = buf; 101 | last_rms_size = this.rms_size; 102 | this.rms_size = min( max(samplerate*rms_size_ms/1000, 1), samplerate); 103 | last_rms_size != this.rms_size ? ( 104 | this.rms_sqr_sum = this.rms_bpos = 0; 105 | memset(this.buf, 0, this.rms_size); 106 | ); 107 | ); 108 | */ 109 | // for script 110 | function RMSFollower.SetValues(buf, rms_size_ms, samplerate) 111 | local(last_rms_size) 112 | ( 113 | // samplerate can be different from the global srate if need 114 | // rms_size_ms - max 1000 ms, change if need 115 | this.buf = buf; 116 | this.rms_size = floor(min(max(samplerate*rms_size_ms/1000, 1), samplerate)); 117 | this.rms_sqr_sum = 0; 118 | this.rms_bpos = 0; 119 | memset(this.buf, 0, this.rms_size); // clear 120 | ); 121 | 122 | //---------------------------------------- 123 | function RMSFollower.Apply(in) 124 | instance(buf, rms_size, rms_sqr_sum, rms_bpos) 125 | ( 126 | rms_sqr_sum = max(rms_sqr_sum - buf[rms_bpos], 0) + (buf[rms_bpos] = sqr(in)); 127 | (rms_bpos+=1) >= rms_size ? rms_bpos=0; 128 | sqrt(rms_sqr_sum/rms_size); // ret 129 | ); 130 | 131 | //------------------------------------------------ 132 | // -- Env follower ------------------------------- 133 | //------------------------------------------------ 134 | function EnvFollower.SetValues(attack_ms, release_ms, samplerate) 135 | ( 136 | this.ga = exp(-1/(samplerate*attack_ms/1000)); 137 | this.gr = exp(-1/(samplerate*release_ms/1000)); 138 | this.out = 0; 139 | ); 140 | 141 | //------------------------------ 142 | // Env in = input sample 143 | // Env retval = out = output envelope 144 | function EnvFollower.Apply(in) 145 | instance(ga, gr, out) 146 | ( 147 | in = abs(in); // abs sample value 148 | out < in ? out = in + ga*(out-in) : out = in + gr*(out-in); 149 | ); 150 | 151 | //------------------------------------------------ 152 | // -- Simple Compressor -------------------------- 153 | //------------------------------------------------ 154 | //thresh_dB = comp threshold 155 | //ratio = X in form X : 1, must be num 1 ... max, 156 | //slope 0 = no compress, 1 = max compression 157 | function CompD.SetValues(thresh_dB, ratio) 158 | ( 159 | this.thresh_dB = thresh_dB; 160 | this.thresh = 10^(thresh_dB/20); 161 | this.ratio = ratio; 162 | this.slope = 1 - 1/ratio; // slope 163 | ); 164 | 165 | //------------------------------ 166 | //Comp env = envelope 167 | //Comp gain = gain multiplier 168 | //slope прим. к разнице в dB, поэтому преобразования 169 | function CompD.Apply(env) 170 | instance(thresh_dB, thresh, slope, gain_dB, gain) 171 | ( 172 | gain = 1; 173 | gain_dB = 0; 174 | env > thresh ? ( 175 | gain_dB = slope * (thresh_dB - VAL2DB(env)); 176 | gain = DB2VAL(gain_dB); 177 | ); 178 | gain; // comp out gain 179 | ); 180 | 181 | 182 | -------------------------------------------------------------------------------- /Various/Envelope-based Compressor/inc/Mouse.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: EUGEN27771 3 | * Author URI: http://forum.cockos.com/member.php?u=50462 4 | * Licence: GPL v3 5 | * Version: 1.0 6 | * NoIndex: true 7 | */ 8 | 9 | //************************************************************************************************** 10 | //*** Mouse functions ****************************************************************************** 11 | //************************************************************************************************** 12 | //------------------------------------------------------------ 13 | //-- Get current mouse state --------------------------------- 14 | //------------------------------------------------------------ 15 | function GetMouseState() 16 | globals(mouse_cap, mouse_x, mouse_y, mouse_last_cap, mouse_last_x, mouse_last_y, 17 | mouse_down, mouse_rdown, mouse_mdown, mouse_up, mouse_rup, mouse_mup, 18 | mouse_down_x, mouse_rdown_x, mouse_mdown_x, mouse_down_y, mouse_rdown_y, mouse_mdown_y, 19 | mouse_move, mouse_dbl, mouse_captimer, mouse_Ctrl, mouse_Shift, mouse_Alt) 20 | 21 | ( 22 | //-- Mouse btn has been pressed(anywhere) ------ 23 | mouse_down = (mouse_cap&1) && !(mouse_last_cap&1); // L mouse 24 | mouse_rdown = (mouse_cap&2) && !(mouse_last_cap&2); // R mouse 25 | mouse_mdown = (mouse_cap&64) && !(mouse_last_cap&64); // M mouse 26 | //-- Mouse btn has been released(anywhere) ----- 27 | mouse_up = (mouse_last_cap&1) && !(mouse_cap&1); // L mouse 28 | mouse_rup = (mouse_last_cap&2) && !(mouse_cap&2); // R mouse 29 | mouse_mup = (mouse_last_cap&64) && !(mouse_cap&64); // M mouse 30 | //-- Mouse moved(anywhere) --------------------- 31 | mouse_move = (mouse_last_x != mouse_x) || (mouse_last_y != mouse_y); 32 | //-- Mouse dbl(used for mouseDblClick) --------- 33 | mouse_down ? ( 34 | mouse_dbl = abs(mouse_down_x-mouse_x)<2 && abs(mouse_down_y-mouse_y)<2 && (mouse_captimer<12); 35 | mouse_captimer = 0; 36 | ); 37 | 38 | //-- mouse press coordinates ------------------- 39 | mouse_down ? (mouse_down_x = mouse_x; mouse_down_y = mouse_y; ); 40 | mouse_rdown ? (mouse_rdown_x = mouse_x; mouse_rdown_y = mouse_y; ); 41 | mouse_mdown ? (mouse_mdown_x = mouse_x; mouse_mdown_y = mouse_y; ); 42 | 43 | //-- modkeys state ----------------------------- 44 | mouse_Ctrl = mouse_cap&4; // Ctrl 45 | mouse_Shift = mouse_cap&8; // Shift 46 | mouse_Alt = mouse_cap&16; // Alt 47 | ); 48 | 49 | //------------------------------------------------------------ 50 | //-- Set(update) last state ---------------------------------- 51 | //------------------------------------------------------------ 52 | function SetMouseLastState() 53 | globals(mouse_cap, mouse_x, mouse_y, mouse_last_cap, mouse_last_x, mouse_last_y, 54 | mouse_wheel, mouse_hwheel, mouse_captimer, mouse_up, mouse_dbl) 55 | ( 56 | mouse_last_cap = mouse_cap; // upd last_cap 57 | mouse_last_x = mouse_x; // upd last_x 58 | mouse_last_y = mouse_y; // upd last_y 59 | mouse_wheel = 0; // reset mouse_wheel 60 | mouse_hwheel = 0; // reset mouse_hwheel 61 | //-------------- 62 | mouse_captimer < 12 ? mouse_captimer+=1; // upd "timer"(frame cnt) 63 | mouse_up ? mouse_dbl = 0; // reset dbl when released 64 | ); 65 | 66 | 67 | //------------------------------------------------------------------------------ 68 | //--- Get mouse (with ref to the object) functions ----------------------------- 69 | //------------------------------------------------------------------------------ 70 | //pointINrect(), mouseINrect() must be called with arguments(x,y,w,h - active rect coords). 71 | //All other functions must be called with "object" prefix. 72 | //Functions use the object coordinates - MyObj.x, MyObj.y, MyObj.w, MyObj.h. 73 | //Example: MyObj.mouseClick() ? SomethingCodeOnClick; 74 | 75 | //-- if point(p_x, p_y) in rect(x,y,w,h) area ---- 76 | function pointINrect(p_x,p_y, x,y,w,h) ( p_x>=x && p_x<=x+w && p_y>=y && p_y<=y+h; ); 77 | //-- if mouse cursor in rect(x,y,w,h) area ------- 78 | function mouseINrect(x,y,w,h) ( pointINrect(mouse_x, mouse_y, x,y,w,h); ); 79 | //-- if point(p_x, p_y) in object area ----------- 80 | function pointIN(p_x,p_y) instance(x,y,w,h) ( this.pointINrect(p_x,p_y, x,y,w,h) ); 81 | //-- if mouse cursor in object area -------------- 82 | function mouseIN() ( this.pointIN(mouse_x, mouse_y); ); 83 | 84 | 85 | //-- Left Mouse Button --------------------------- 86 | function mouseDown() (mouse_down && this.mouseIN(); ); 87 | function mouseUp() (mouse_up && this.mouseIN(); ); 88 | function mouseClick() (this.mouseUp() && this.pointIN(mouse_down_x, mouse_down_y); ); 89 | function mouseDblClick() (mouse_dbl && this.mouseClick(); ); 90 | //-- Rigth Mouse Button -------------------------- 91 | function mouseRDown() (mouse_rdown && this.mouseIN(); ); 92 | function mouseRUp() (mouse_rup && this.mouseIN(); ); 93 | function mouseRClick() (this.mouseRUp() && this.pointIN(mouse_rdown_x, mouse_rdown_y); ); 94 | //-- Middle Mouse Button ------------------------- 95 | function mouseMDown() (mouse_mdown && this.mouseIN(); ); 96 | function mouseMUp() (mouse_mup && this.mouseIN(); ); 97 | function mouseMClick() (this.mouseMUp() && this.pointIN(mouse_mdown_x, mouse_mdown_y); ); 98 | 99 | 100 | -------------------------------------------------------------------------------- /Various/Envelope-based Compressor/inc/Presets.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: EUGEN27771 3 | * Author URI: http://forum.cockos.com/member.php?u=50462 4 | * Licence: GPL v3 5 | * Version: 1.0 6 | * NoIndex: true 7 | */ 8 | 9 | //**************************************************************************************** 10 | function SetRGB(RGB, a) 11 | ( 12 | gfx_r = (RGB & 0xFF0000) / 16711680; // 256*256*255 13 | gfx_g = (RGB & 0x00FF00) / 65280; // 256*255 14 | gfx_b = (RGB & 0x0000FF) / 255; // 255 15 | gfx_a = a; 16 | ); 17 | 18 | function SetRGB(RGB) 19 | ( 20 | SetRGB(RGB, 1); 21 | ); 22 | 23 | //**************************************************************************************** 24 | //**************************************************************************************** 25 | //================================================ 26 | /*Create/update preset-list string(like gfx_showmenu() string). 27 | For example - "Name1|Name2|... etc". Return this string. 28 | Эта же строка будет использоваться для GetIdxByName, GetNameByIdx.*/ 29 | function Presets.UpdateList() 30 | local(file, pattern, line, preset_name) 31 | ( 32 | #this.list = ""; // init list 33 | this.preset_cnt = 0; // init cnt 34 | (file = fopen(#this.path, "rb")) ? ( 35 | pattern = "%s=*"; // preset line pattern 36 | line = #; // tmp str for file line 37 | preset_name = #; // tmp str for preset name 38 | while(!feof(file)) ( 39 | fgets(file, line); // get line 40 | match(pattern, line, preset_name) ? ( 41 | #this.list+=strcat(preset_name, "|"); 42 | this.preset_cnt +=1; 43 | ); 44 | ); 45 | fclose(file); 46 | ); 47 | #this.list; // ret 48 | ); 49 | 50 | //================================================ 51 | //-- устан.(не загружает!) текущий пресет(имя, отображаемое в меню) 52 | //-- if curpresetname = ""(empty string) then set "No Preset" 53 | function Presets.SetCurPresetName(preset_name) 54 | ( 55 | !strcmp(preset_name, "") ? preset_name = "No Preset"; 56 | #this.curpresetname = preset_name; 57 | ); 58 | 59 | //================================================ 60 | //-- возвр. имя пресета по индекс, если idx>кол-ва - имя последнего. 61 | function Presets.GetNameByIdx(preset_idx) 62 | local(len, pos, s, e, i) 63 | ( 64 | len = strlen(#this.list); 65 | pos = s = e = i = 0; 66 | while(pos < len && i <= preset_idx) ( 67 | str_getchar(#this.list, pos) == 124 ? (s = e; e = pos+1; i+=1;); 68 | pos += 1; 69 | ); 70 | //i == preset_idx ? 71 | strcpy_substr(#, #this.list, s, e-s-1); // ret preset_name 72 | ); 73 | 74 | //================================================ 75 | //-- возвр. индекс пресета по имени(либо -1, если не найден) 76 | function Presets.GetIdxByName(preset_name) 77 | local(len, pos, i, preset_idx, pattern) 78 | ( 79 | len = strlen(#this.list); 80 | pos = i = 0; 81 | preset_idx = -1; 82 | pattern = sprintf(#, "%s*", preset_name); 83 | match(pattern, #this.list) ? preset_idx = 0; 84 | while(pos < len && preset_idx < 0) ( 85 | str_getchar(#this.list, pos) == '|' ? ( 86 | match(pattern, strcpy_from(#, #this.list, pos+1)) ? preset_idx = i+1; 87 | i+=1; 88 | ); 89 | pos += 1; 90 | ); 91 | preset_idx; // ret idx 92 | ); 93 | 94 | //================================================ 95 | function Presets.Load(preset_name) 96 | local(preset_data) 97 | ( 98 | preset_data = #; 99 | (extension_api("BR_Win32_GetPrivateProfileString", this.section, preset_name, "", #this.path, preset_data)) ? ( 100 | Presets.SetCurPresetName(preset_name); 101 | preset_data; // ret 102 | ); 103 | ); 104 | 105 | //================================================ 106 | function Presets.Save(preset_name, preset_data) 107 | local(pos, c) 108 | ( 109 | pos = 0; 110 | while(pos < strlen(preset_name)) ( 111 | c = str_getchar(preset_name, pos); 112 | // Лучше оставить тупо буквы-цифры? 113 | c=='|' || c=='#' || c=='!' || c=='<' || c=='>' || c=='=' ? str_delsub(preset_name, pos, 1) : pos+=1; 114 | ); 115 | 116 | extension_api("BR_Win32_WritePrivateProfileString", this.section, preset_name, preset_data, #this.path) ? ( 117 | Presets.SetCurPresetName(preset_name); 118 | Presets.UpdateList(); 119 | ); 120 | ); 121 | 122 | //================================================ 123 | //--Var1(read each line) --- 124 | /* 125 | function Presets.Delete(preset_name) 126 | local(file, file_len, pattern, tmp_str, str_start, str_len) 127 | ( 128 | (file = fopen(#this.path, "rb")) ? ( 129 | pattern = sprintf(#, "%s=*", preset_name); 130 | tmp_str = #; // tmp str for operations 131 | while(!feof(file) && !match(pattern, tmp_str)) ( 132 | fgets(file, tmp_str); 133 | ); 134 | str_len = strlen(tmp_str); // preset str len 135 | str_start = ftell(file) - str_len; // preset str start 136 | fseek(file, 0, 1); // to file end 137 | file_len = ftell(file); // get file len 138 | fseek(file, 0, -1); // to file start for reading 139 | fread(file, tmp_str, file_len); // Read all to tmp_str 140 | fclose(file); 141 | 142 | (file = fopen(#this.path, "wb")) ? ( 143 | str_delsub(tmp_str, str_start, str_len); // Del preset substr 144 | fwrite(file, tmp_str, 0); // Write 145 | fflush(file); 146 | fclose(file); 147 | ); 148 | ); 149 | ); 150 | */ 151 | 152 | //================================================ 153 | // Rename or Delete preset, return true if successfully 154 | // preset_new_name = ""(EmptyString) for Delete preset 155 | function Presets.RenameOrDelete(preset_name, preset_new_name) 156 | local(file, file_data, pattern, data1, preset_data, data2) 157 | ( 158 | (file = fopen(#this.path, "rb")) ? ( 159 | file_data = #; // data tmp str 160 | fread(file, file_data, 1024^2 * 10); // Read all, max 10M 161 | fclose(file); 162 | //-- pattern for match = "%0sPresetName=%0S\n%0s" -- 163 | pattern = sprintf(#, "%s%s%s", "%0s", preset_name, "=%0S\n%0s"); 164 | data1 = #; preset_data = #; data2 = #; 165 | match(pattern, file_data, data1, preset_data, data2) ? ( 166 | (file = fopen(#this.path, "wb")) ? ( 167 | fwrite(file, data1, 0); // Write data1 168 | strcmp(preset_new_name, "") ? ( // Write preset_data, if Rename 169 | fwrite(file, sprintf(#, "%s=%s\n", preset_new_name, preset_data), 0); 170 | ); 171 | fwrite(file, data2, 0); // Write data2 172 | fflush(file); 173 | fclose(file); 174 | Presets.SetCurPresetName(preset_new_name); 175 | Presets.UpdateList(); 176 | 1; // return true if successfully 177 | ); 178 | ); 179 | ); 180 | 181 | ); 182 | 183 | 184 | //---------------------------------------------------------- 185 | //-- Init Preset Menu -------------------------------------- 186 | //---------------------------------------------------------- 187 | function Presets.MenuInit(x,y,w,h, col_bg, col_font, path) 188 | ( 189 | this.Menu.x = x; 190 | this.Menu.y = y; 191 | this.Menu.w = w; 192 | this.Menu.h = h; 193 | this.Menu.col_bg = col_bg; 194 | this.Menu.col_font = col_font; 195 | 196 | #this.path = path; // путь к файлу пресетов 197 | this.section = "Presets"; // секция с пресетами 198 | Presets.SetCurPresetName(""); // Empty str = "No Preset" 199 | Presets.UpdateList(); 200 | ); 201 | 202 | //---------------------------------------------------------- 203 | //-- Draw Preset Menu -------------------------------------- 204 | //---------------------------------------------------------- 205 | function Presets.MenuDraw() 206 | local(x,y,w,h, x1,y1,w1,h1, x2,y2,w2,h2, x3,y3,w3,h3, x4,y4,w4,h4, col_bg, col_font, 207 | idx, menu_ret, ui_retval_str, ui_ret) 208 | ( 209 | x = this.Menu.x; 210 | y = this.Menu.y; 211 | w = this.Menu.w; 212 | h = this.Menu.h; 213 | col_bg = this.Menu.col_bg; 214 | col_font = this.Menu.col_font; 215 | 216 | //-- coords ---------------- 217 | x1 = x; w1 = h; //-- prev preset btn 218 | x2 = x+h; w2 = w-h*3; //-- curpreset, list btn 219 | x3 = x+w-h*2; w3 = h; //-- next preset btn 220 | x4 = x+w-h; w4 = h; //-- menu btn 221 | // y и h - везде равны - поправить(убрать 1,2,3,4) 222 | y1 = y2 = y3 = y4 = y; 223 | h1 = h2 = h3 = h4 = h; 224 | 225 | gfx_setfont(2, "Verdana", h-7); //-- presets font 226 | 227 | SetRGB(col_bg); //-- bg color; 228 | gfx_rect(x,y,w,h, 1); //-- bg rect 229 | SetRGB(col_font, 0.15); //-- frames col 230 | gfx_rect(x1,y1,w1,h1,0); //-- prev rect 231 | gfx_rect(x2,y2,w2,h2,0); //-- cur rect 232 | gfx_rect(x3,y3,w3,h3,0); //-- next rect 233 | gfx_rect(x4,y4,w4,h4,0); //-- menu rect 234 | 235 | SetRGB(col_font); 236 | gfx_x = x1; gfx_y = y1; 237 | gfx_drawstr("<", 5, x1+w1, y1+h1); //-- prev "<" 238 | gfx_x = x2; gfx_y = y2; 239 | gfx_drawstr(#this.curpresetname, 5, x2+w2, y2+h2); //-- "curpreset" 240 | gfx_x = x3; gfx_y = y3; 241 | gfx_drawstr(">", 5, x3+w3, y4+h3); //-- next ">" 242 | gfx_x = x4; gfx_y = y4; 243 | gfx_drawstr("+", 5, x4+w4, y4+h4); //-- menu "+" 244 | 245 | 246 | //-------------------------- 247 | this.action = this.name = ""; // def state 248 | 249 | mouse_down && this.preset_cnt ? ( 250 | //-- Menu List ----------- 251 | mouseINrect(x2,y2,w2,h2) ? ( //-- mouse down in "curpreset" rect 252 | gfx_x = x2; gfx_y = y2+h2; 253 | menu_ret = gfx_showmenu(#this.list); 254 | menu_ret ? (this.action = "Load"; this.name = Presets.GetNameByIdx(menu_ret-1);); // Load 255 | ); 256 | //-- Prev Preset --------- 257 | mouseINrect(x1,y1,w1,h1) ? ( //-- mouse down in prev("<") rect 258 | idx = Presets.GetIdxByName(#this.curpresetname); 259 | idx <= 0 ? idx = this.preset_cnt; 260 | this.action = "Load"; this.name = Presets.GetNameByIdx(idx-1); // Load Prev 261 | ); 262 | //-- Next Preset --------- 263 | mouseINrect(x3,y3,w3,h3) ? ( //-- mouse down in next(">") rect 264 | idx = Presets.GetIdxByName(#this.curpresetname); 265 | idx >= this.preset_cnt-1 ? idx = -1; 266 | this.action = "Load"; this.name = Presets.GetNameByIdx(idx+1); // Load Next 267 | ); 268 | ); 269 | 270 | //-- Menu Button ----------- 271 | mouse_down && mouseINrect(x4,y4,w4,h4) ? ( //-- mouse down in menu("+") rect 272 | gfx_x = x4; gfx_y = y4+h4; 273 | menu_ret = gfx_showmenu("Save Preset|Rename Preset|Delete Preset"); 274 | ui_retval_str = strcpy(#, #this.curpresetname); // string for retval, def = curpreset 275 | menu_ret == 1 ? ( //-- Save 276 | ui_ret = GetUserInputs("Save Preset", 1, "Preset name:,extrawidth=200", ui_retval_str); 277 | ui_ret ? (this.action = "Save"; this.name = ui_retval_str); 278 | ); 279 | menu_ret == 2 ? ( //-- Rename 280 | ui_ret = GetUserInputs("Rename Preset", 1, "Preset name:,extrawidth=200", ui_retval_str); 281 | ui_ret ? (this.action = "Rename"; this.name = ui_retval_str); 282 | ); 283 | menu_ret == 3 ? ( //-- Delete 284 | this.action = "Delete"; this.name = #this.curpresetname; 285 | ); 286 | ); 287 | 288 | //-- Confirm action, name -- 289 | strcmp(this.action, "") && strcmp(#this.curpresetname, ""); // return true if need actions 290 | 291 | ); 292 | -------------------------------------------------------------------------------- /Various/Envelope-based Compressor/inc/TextField.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: EUGEN27771 3 | * Author URI: http://forum.cockos.com/member.php?u=50462 4 | * Licence: GPL v3 5 | * Version: 1.0 6 | * NoIndex: true 7 | */ 8 | 9 | //---------------------------------------------------------- 10 | //-- Simple TextField for Controls ------------------------- 11 | //---------------------------------------------------------- 12 | function TextField.Init(x,y,w,h, val) 13 | ( 14 | this.x = x; this.y = y; this.w = w; this.h = h; // coords 15 | #this.val = val; 16 | this.max_len = 64; // max symbols 17 | this.blink = 0; 18 | this.Apply = 0; 19 | ); 20 | 21 | //-------------------------------------- 22 | function TextField.GetKB() 23 | instance(x,y,w,h, #val, str_len, blink, max_len) 24 | local(str_len) 25 | ( 26 | gfx_char ? ( // gfx_char - global(можно сменить на арг. ф-и) 27 | gfx_char == 27 || gfx_char == 13 ? ( // esc, enter 28 | TextField.Apply = 1; 29 | ) : 30 | gfx_char == 8 ? ( // backspace 31 | str_len = strlen(#val); 32 | str_setlen(#val, max(str_len-1, 0)); 33 | ) : 34 | gfx_char > 31 && gfx_char < 127 ? ( 35 | //append = strlen(#val) or between (-0.5,0.0) 36 | str_len < max_len ? str_setchar(#val, -0.25, gfx_char); 37 | ); 38 | 39 | ); 40 | //------------- 41 | mouse_down && !this.mouseIN() ? TextField.Apply = 1; 42 | 43 | ); 44 | 45 | //-------------------------------------- 46 | function TextField.Draw() 47 | instance(x,y,w,h, #val, blink, str_rx) 48 | local(str_w, str_h) 49 | ( 50 | TextField.GetKB(); 51 | //-------------------------- 52 | gfx_set(0.9); 53 | gfx_rect(x,y,w,h); // bg 54 | gfx_set(0.5); 55 | gfx_rect(x,y,w,h,0); // frame 56 | //-------------------------- 57 | 58 | str_w = str_h = 0; 59 | gfx_measurestr(#val, str_w, str_h); 60 | gfx_x = x + 5; gfx_y = y; 61 | str_rx = gfx_x + min(w-10, str_w); 62 | gfx_set(0); 63 | gfx_drawstr(#val, 6, str_rx, y + h ); 64 | blink < 20 ? blink +=1 : blink = 0; 65 | blink < 10 ? gfx_line(str_rx+1, y+2, str_rx+1, y+h-4); // v1 66 | 67 | ); 68 | -------------------------------------------------------------------------------- /Various/FXRack/Images/BG_PatchWork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/BG_PatchWork.png -------------------------------------------------------------------------------- /Various/FXRack/Images/button_phase_22x22x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/button_phase_22x22x2.png -------------------------------------------------------------------------------- /Various/FXRack/Images/button_power_17x18x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/button_power_17x18x2.png -------------------------------------------------------------------------------- /Various/FXRack/Images/button_solo_22x22x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/button_solo_22x22x2.png -------------------------------------------------------------------------------- /Various/FXRack/Images/button_summing_26x17x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/button_summing_26x17x2.png -------------------------------------------------------------------------------- /Various/FXRack/Images/knob_pan_28x28x127.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/knob_pan_28x28x127.png -------------------------------------------------------------------------------- /Various/FXRack/Images/knob_vol_28x28x127.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EUGEN27771/ReaScripts/39cb0f07d46080ddcd2875ada1f4ca0d921343d9/Various/FXRack/Images/knob_vol_28x28x127.png -------------------------------------------------------------------------------- /Various/FXRack/JSUtilities/(Split)RackSplitter: -------------------------------------------------------------------------------- 1 | desc:FXRack 1.01 2 | /* 3 | Short Description: 4 | CP is channel pair, aka chain(1/2,3/4 etc) 5 | Gain = -60 - 30 (dB) 6 | // In functions names - CP = chan pair, 1 = 1/2; 2 = 3/4 etc 7 | */ 8 | 9 | //============================================================================== 10 | //-- CP 1 - 4 ---------------- 11 | slider1:Out1.Gain=0<-60,30,0.1>-Gain 1 12 | slider2:Out2.Gain=0<-60,30,0.1>-Gain 2 13 | slider3:Out3.Gain=0<-60,30,0.1>-Gain 3 14 | slider4:Out4.Gain=0<-60,30,0.1>-Gain 4 15 | 16 | //-- CP 5 - 8 ---------------- 17 | slider5:Out5.Gain=0<-60,30,0.1>-Gain 5 18 | slider6:Out6.Gain=0<-60,30,0.1>-Gain 6 19 | slider7:Out7.Gain=0<-60,30,0.1>-Gain 7 20 | slider8:Out8.Gain=0<-60,30,0.1>-Gain 8 21 | 22 | //-- Inputs -------- 23 | in_pin:input L 24 | in_pin:input R 25 | 26 | //-- Outputs ------- 27 | out_pin:out 1 L 28 | out_pin:out 1 R 29 | out_pin:out 2 L 30 | out_pin:out 2 R 31 | out_pin:out 3 L 32 | out_pin:out 3 R 33 | out_pin:out 4 L 34 | out_pin:out 4 R 35 | 36 | out_pin:out 5 L 37 | out_pin:out 5 R 38 | out_pin:out 6 L 39 | out_pin:out 6 R 40 | out_pin:out 7 L 41 | out_pin:out 7 R 42 | out_pin:out 8 L 43 | out_pin:out 8 R 44 | 45 | 46 | 47 | @init 48 | gfx_clear = 0x180E01; // bg color 49 | col1 = 0xB9C1D4; // controls color 50 | 51 | //-- Mouse ----------------------------- 52 | //-- if point(p_x, p_y) in rect(x,y,w,h) area ---- 53 | function pointINrect(p_x,p_y, x,y,w,h) ( p_x>=x && p_x<=x+w && p_y>=y && p_y<=y+h; ); 54 | //-- if mouse cursor in rect(x,y,w,h) area ------- 55 | function mouseINrect(x,y,w,h) ( pointINrect(mouse_x, mouse_y, x,y,w,h); ); 56 | //-- Left Mouse Button --------------------------- 57 | function mouseDown(x,y,w,h) ( mouse_down && mouseINrect(x,y,w,h); ); 58 | 59 | //-- Set RRGGBB color ------------------ 60 | function SetRGB(RGB) 61 | ( 62 | gfx_r = (RGB & 0xFF0000) / 16711680; // 256*256*255 63 | gfx_g = (RGB & 0x00FF00) / 65280; // 256*255 64 | gfx_b = (RGB & 0x0000FF) / 255; // 255 65 | gfx_a = 1 66 | ); 67 | 68 | //-------------------------------------- 69 | function minmax(x, minv, maxv) 70 | ( 71 | min(max(x, minv), maxv); 72 | ); 73 | 74 | //-------------------------------------- 75 | function DB2VAL(x) 76 | ( 77 | exp((x)*0.11512925464970228420089957273422); 78 | ); 79 | 80 | //-------------------------------------- 81 | //-- Splitter functions ---------------- 82 | //-------------------------------------- 83 | function CPOut_Init() 84 | instance(Gain, src_vol, tgt_vol) 85 | ( 86 | src_vol = tgt_vol = DB2VAL(Gain); 87 | ); 88 | //-------- 89 | function CPOut_Slider() 90 | instance(Gain, tgt_vol) 91 | ( 92 | tgt_vol = DB2VAL(Gain); 93 | ); 94 | //-------- 95 | function CPOut_Block() 96 | instance(d_vol, tvol, src_vol, tgt_vol) 97 | ( 98 | d_vol = (tgt_vol-src_vol)/samplesblock; 99 | tvol = src_vol; 100 | src_vol = tgt_vol; 101 | ); 102 | //-------- 103 | function CPOut_Sample() 104 | instance(d_vol, tvol, LR) 105 | ( 106 | tvol += d_vol; 107 | LR = tvol; 108 | ); 109 | 110 | 111 | //-------------------------------------- 112 | function Splitter_Init() 113 | ( 114 | Out1.CPOut_Init(); 115 | Out2.CPOut_Init(); 116 | Out3.CPOut_Init(); 117 | Out4.CPOut_Init(); 118 | Out5.CPOut_Init(); 119 | Out6.CPOut_Init(); 120 | Out7.CPOut_Init(); 121 | Out8.CPOut_Init(); 122 | ); 123 | //-------------------------------------- 124 | function Splitter_Slider() 125 | ( 126 | Out1.CPOut_Slider(); 127 | Out2.CPOut_Slider(); 128 | Out3.CPOut_Slider(); 129 | Out4.CPOut_Slider(); 130 | Out5.CPOut_Slider(); 131 | Out6.CPOut_Slider(); 132 | Out7.CPOut_Slider(); 133 | Out8.CPOut_Slider(); 134 | ); 135 | //-------------------------------------- 136 | function Splitter_Block() 137 | ( 138 | Out1.CPOut_Block(); 139 | Out2.CPOut_Block(); 140 | Out3.CPOut_Block(); 141 | Out4.CPOut_Block(); 142 | Out5.CPOut_Block(); 143 | Out6.CPOut_Block(); 144 | Out7.CPOut_Block(); 145 | Out8.CPOut_Block(); 146 | ); 147 | //-------------------------------------- 148 | function Splitter_Sample() 149 | ( 150 | Out1.CPOut_Sample(); 151 | Out2.CPOut_Sample(); 152 | Out3.CPOut_Sample(); 153 | Out4.CPOut_Sample(); 154 | Out5.CPOut_Sample(); 155 | Out6.CPOut_Sample(); 156 | Out7.CPOut_Sample(); 157 | Out8.CPOut_Sample(); 158 | ); 159 | 160 | 161 | //-------------------------------------- 162 | //-------------------------------------- 163 | Splitter_Init(); 164 | 165 | 166 | @slider 167 | Splitter_Slider(); // Update if sliders changed 168 | 169 | @block 170 | Splitter_Block(); 171 | 172 | @sample 173 | Splitter_Sample(); 174 | 175 | in1 = spl0; 176 | in2 = spl1; 177 | 178 | spl0 = in1 * Out1.LR; 179 | spl1 = in2 * Out1.LR; 180 | 181 | spl2 = in1 * Out2.LR; 182 | spl3 = in2 * Out2.LR; 183 | 184 | spl4 = in1 * Out3.LR; 185 | spl5 = in2 * Out3.LR; 186 | 187 | spl6 = in1 * Out4.LR; 188 | spl7 = in2 * Out4.LR; 189 | 190 | spl8 = in1 * Out5.LR; 191 | spl9 = in2 * Out5.LR; 192 | 193 | spl10 = in1 * Out6.LR; 194 | spl11 = in2 * Out6.LR; 195 | 196 | spl12 = in1 * Out7.LR; 197 | spl13 = in2 * Out7.LR; 198 | 199 | spl14 = in1 * Out8.LR; 200 | spl15 = in2 * Out8.LR; 201 | 202 | 203 | //================================================================================================== 204 | 205 | @gfx 480 320 206 | //========================================================== 207 | //** Simple label ****************************************** 208 | //========================================================== 209 | function SL_Label(x,y,w,h, flag, RGB, lbl) 210 | ( 211 | SetRGB(RGB); 212 | gfx_x = x + 4; gfx_y = y; 213 | gfx_drawstr(lbl, flag, x+w-4, y+h); 214 | //---------------- 215 | gfx_r *= 0.3; gfx_g *= 0.3; gfx_b *= 0.3;// bg col 216 | gfx_roundrect(x-1,y-1,w,h,2,0); // frame 217 | ); 218 | 219 | //========================================================== 220 | //** Simple slider-linked button *************************** 221 | //========================================================== 222 | function SL_BtnDraw(x,y,w,h, RGB, lbl) 223 | ( 224 | this.isChanged = 0; 225 | mouseDown(x,y,w,h) ? ( 226 | this = !this; 227 | slider_automate(this); 228 | this.isChanged = 1; 229 | ); 230 | 231 | this ? ( 232 | SetRGB(RGB); gfx_a = 0.2; 233 | gfx_rect(x,y,w,h, 1); 234 | ); 235 | 236 | SL_Label(x,y,w,h, 5, RGB, lbl); 237 | ); 238 | 239 | //========================================================== 240 | //** Simple slider-linked knob ***************************** 241 | //========================================================== 242 | function SL_KnobImage(x,y,w,h, RGB, normval) 243 | local(cx, cy, rds, offs, angmax, ang1, ang2, i) 244 | ( 245 | cx = x + w/2; cy = y + h/2; rds = w/2; 246 | angmax = 2.75*$pi; // max val ang 247 | offs = 1.25 * $pi; //$pi + $pi*0.25; 248 | ang1 = offs - 0.01; // 0.01 mini offset 249 | ang2 = offs + (1.5 * $pi) * normval; // cur val ang 250 | //------------------------- 251 | SetRGB(RGB); 252 | gfx_r *= 0.3; gfx_g *= 0.3; gfx_b *= 0.3;// bg col 253 | gfx_circle(cx, cy, rds-7, 1); 254 | //gfx_rect(x,y,w,h,0); // test rect 255 | //------------------------- 256 | i=0; 257 | loop(5, 258 | gfx_arc(cx, cy, rds-i, ang1, angmax, 1); 259 | i+=0.5; 260 | ); 261 | //------------------------- 262 | SetRGB(RGB); // val arc col 263 | i=0; 264 | loop(5, 265 | gfx_arc(cx, cy, rds-i, ang1, ang2, 1); 266 | i+=0.5; 267 | ); 268 | ); 269 | 270 | //-------------------------------------- 271 | function SL_KnobDraw(x,y,w,h, RGB, lbl, minval, maxval, valstep) 272 | local(normval, K) 273 | ( 274 | this.isChanged = 0; 275 | mouse_cap&1 && pointINrect(mouse_down_x, mouse_down_y, x,y,w,h) ? ( 276 | mouse_last_y - mouse_y ? ( 277 | mouse_cap&4 ? K = valstep : K = valstep*4; // drag coeff 278 | this = minmax(this + (mouse_last_y - mouse_y)*K, minval, maxval); 279 | slider_automate(this); 280 | this.isChanged = 1; 281 | ); 282 | ); 283 | 284 | //-- knob image ------------ 285 | normval = (this - minval) / (maxval - minval); 286 | SL_KnobImage(x,y,w,h, RGB, normval); 287 | 288 | //-- knob label ------------ 289 | lbl = sprintf(#, "%s: %.1f", lbl, this); 290 | SL_Label(x+w+5, y, 85, h, 4, RGB, lbl); 291 | 292 | ); 293 | 294 | //********************************************************** 295 | function CPOut_Draw(x, y, h, lbl) 296 | instance(Gain, Power ) 297 | local(xx, yy, w, RGB) 298 | ( 299 | RGB = col1; 300 | //-- CP knobs -------------- 301 | w = 22; 302 | xx = x; 303 | Gain.SL_KnobDraw(xx, y, w, h, RGB, "Gain", -60, 30, 0.1); 304 | 305 | //-- CP wire --------------- 306 | SetRGB(RGB); 307 | xx = x + 130; yy = y + h/2; 308 | gfx_line(xx, yy, xx + 90, yy, 0); 309 | gfx_circle(xx, yy, 2, 1); 310 | gfx_circle(xx + 90, yy, 2, 1); 311 | 312 | //-- CP label -------------- 313 | w = 45; 314 | xx = x + 240; 315 | SL_Label(xx,y,w,h, 5, RGB, lbl); 316 | 317 | 318 | //-- Update Splitter if changed ------ 319 | Gain.isChanged ? Splitter_Slider(); 320 | ); 321 | 322 | 323 | //********************************************************** 324 | function Draw() 325 | local(x, y, h, offs, xx, yy, mx, my, lbl, RGB) 326 | ( 327 | x = 20; y = 20; // Start drawing position 328 | h = 22; // CP heigth 329 | offs = h + 8; // CP vertical offset 330 | gfx_setfont(1, "Tahoma", 14); // main font 331 | RGB = col1; 332 | 333 | //-- Label --------------------------- 334 | xx = x + 140; yy = y; 335 | SL_Label(xx, yy, 285, h, 5, RGB, "FXRack Splitter"); 336 | 337 | //-- CP Outs ------------------------- 338 | xx = x + 140; yy = y; 339 | //-- 1 - 4 ------- 340 | Out1.CPOut_Draw(xx, yy+=offs, h, "1/2"); 341 | Out2.CPOut_Draw(xx, yy+=offs, h, "3/4"); 342 | Out3.CPOut_Draw(xx, yy+=offs, h, "5/6"); 343 | Out4.CPOut_Draw(xx, yy+=offs, h, "7/8"); 344 | //-- 5 - 8 ------- 345 | Out5.CPOut_Draw(xx, yy+=offs, h, "9/10"); 346 | Out6.CPOut_Draw(xx, yy+=offs, h, "11/12"); 347 | Out7.CPOut_Draw(xx, yy+=offs, h, "13/14"); 348 | Out8.CPOut_Draw(xx, yy+=offs, h, "15/16"); 349 | 350 | //-- Wires --------------------------- 351 | SetRGB(RGB); 352 | my = y + offs * 4.5 - 4; 353 | mx = x + 60; 354 | xx = x + 120 ; yy = y + offs + h/2; 355 | loop(8, 356 | gfx_x = mx; gfx_y = my; 357 | gfx_lineto(xx - 10, yy, 1); 358 | gfx_lineto(xx, yy, 1); 359 | gfx_circle(xx, yy, 2, 1); 360 | yy+=offs; 361 | ); 362 | //-- In label -------------- 363 | gfx_circle(mx, my, 2, 1); 364 | xx = x; yy = y + offs * 4; 365 | SL_Label(xx, yy, 45, h, 5, RGB, "1/2"); 366 | 367 | 368 | ); 369 | 370 | 371 | //********************************************************** 372 | mouse_down = mouse_cap&1 && !mouse_last_cap&1; 373 | mouse_down ? (mouse_down_x = mouse_x; mouse_down_y = mouse_y); 374 | 375 | Draw(); // Main Draw function 376 | 377 | mouse_last_cap = mouse_cap; 378 | mouse_last_x = mouse_x; 379 | mouse_last_y = mouse_y; 380 | -------------------------------------------------------------------------------- /Various/FXRack/Modules/FXChain.lua: -------------------------------------------------------------------------------- 1 | -- FXChain(module) 2 | -- @noindex 3 | 4 | --[[ 5 | Поскольку мы не можем редактировать непосредственно FXChain, а только в паре с чанком, пришлось заморочится. 6 | Итого, это 100% самая удобная схема. 7 | Она позволяет легко оперировать FXChain и FX внутри FXChain как на одном треке, так и между треками. 8 | То есть, в любых комбинациях и, что важно, без учета моментов взятия и установки чанка(если нужно), см. use_src_track_chunk. 9 | В функции SetTrackFXChain(track, fx_chain, use_src_track_chunk): 10 | если use_src_track_chunk = false - будет использован target track_chunk(текущий чанк трека на данный момент). 11 | если use_src_track_chunk = true - будет использован source track_chunk(полученный на момент запуска GetChain). 12 | Второй вариант быстрее, подходит для одномоментных операций, не растянутых во времени и только в рамках одного трека! 13 | Выбирать по ситуации. 14 | --]] 15 | 16 | local FXChain = {} 17 | 18 | ---============================================================================= 19 | function msg(m) reaper.ShowConsoleMsg("\n" .. tostring(m)) end 20 | -------- 21 | function TimeTest(start_time, end_time, lbl) 22 | if (not start_time and end_time) then return end 23 | msg(lbl .. end_time - start_time .. "\n") 24 | end 25 | 26 | --============================================================================== 27 | -------- Get-Set TrackChunk functions ----------------------------------------- 28 | --============================================================================== 29 | --[[ 30 | == GetSet TrackChunk mini-description ============ 31 | In standart function GetTrackStateChunk chunk size limited 4194303 = 4094*1024-1 byte 32 | На установку станд. ф-я вроде тянет более 4M, пока пробуем! Если будет косячить - вернуть WDL! 33 | Хотя по тестам - на установке время одинаково... 34 | Примечание по isundo: 35 | isundo = false or isundo = true? See: https://forum.cockos.com/showthread.php?t=181000 36 | Justin: If you use isundo=false, you will get your 4MB) ------------------ 40 | -------------------------------------------------- 41 | function GetTrackChunk(track) 42 | if not track then return end 43 | -- Try standart function ----- 44 | local ret, track_chunk = reaper.GetTrackStateChunk(track, "", false) -- isundo = false 45 | if ret and track_chunk and #track_chunk < 4194303 then return track_chunk end 46 | -- If chunk_size >= max_size, use wdl fast string -- 47 | local fast_str = reaper.SNM_CreateFastString("") 48 | if reaper.SNM_GetSetObjectState(track, fast_str, false, false) then 49 | track_chunk = reaper.SNM_GetFastString(fast_str) 50 | end 51 | reaper.SNM_DeleteFastString(fast_str) 52 | return track_chunk 53 | end 54 | 55 | -------------------------------------------------- 56 | -- Set track chunk(allow > 4MB) ------------------ 57 | -------------------------------------------------- 58 | function SetTrackChunk(track, track_chunk) 59 | if not (track and track_chunk) then return end 60 | return reaper.SetTrackStateChunk(track, track_chunk, false) 61 | --[[ 62 | if #track_chunk < 4194303 then return reaper.SetTrackStateChunk(track, track_chunk, false) end -- isundo = false 63 | -- If chunk_size >= max_size, use wdl fast string -- 64 | local fast_str, ret 65 | fast_str = reaper.SNM_CreateFastString("") 66 | if reaper.SNM_SetFastString(fast_str, track_chunk) then 67 | ret = reaper.SNM_GetSetObjectState(track, fast_str, true, false) 68 | end 69 | reaper.SNM_DeleteFastString(fast_str) 70 | return ret 71 | --]] 72 | end 73 | 74 | --============================================================================== 75 | -------- GetSetTrackFXChain functions ----------------------------------------- 76 | --============================================================================== 77 | --[[ 78 | == Get Chain mini-description ==================== 79 | Returned table description: 80 | src_track_chunk - fx chain source track_chunk (исходный чанк) 81 | _start - fx chain start position in track_chunk 82 | _end - fx chain end position in track_chunk 83 | head - fx chain header content(часть от "\n") 86 | ------ 87 | FXChain.GetEmpty - вспом. функция, вызывается из осн. функции, в случае, 88 | когда цепь либо пуста, либо отсутствует. 89 | 90 | == Set Chain mini-description ==================== 91 | Мы не можем установить FX chain отдельно от чанка трека, только совместно. 92 | Поэтому, для повышения быстродействия применяем такой метод. 93 | 1)Используем booleen use_src_track_chunk = true: 94 | Если мы уверены, что нам подходит исходный трек-чанк(в большинстве ситуаций это так), то оставляем его. 95 | 2)Используем booleen use_src_track_chunk = false: 96 | Если необходимо влепить FX chain в другой чанк(на другой трек, или текущий трек успел измениться) - берем по-новой. 97 | ------ 98 | FXChain.RebuildPLINKS - вспом. функция, вызывается из осн. функции, в случае, когда цепь содержит parameter links. 99 | Если цепь была перестроена, линки перестраиваются соответственно, чтобы сохранить правильную привязку. 100 | За вызов отвечает booleen - rebuild_plinks = true 101 | ------ 102 | Очень важный момент - в случае, когда fx-чанки содержат parameter modulation в любом виде, 103 | а в настройках Рипера стоит галка Allow live FX multiprocessing, 104 | то установка такого чанка напрямую приведет к зависону! 105 | Поэтому, такие чанки ф-я FXChain.Set специально устанавливает в два этапа!!! 106 | Сначала - чанк без " секций, а затем c ними. Это решает вопрос. 107 | Потеря производительности минимальна(не более 10%), Рипер не ставит повторно идентичные части! 108 | --]] 109 | 110 | -------------------------------------------------- 111 | -- Get FX Chain if chain empty or no exist ------- 112 | -------------------------------------------------- 113 | function FXChain.GetEmpty(track_chunk) 114 | local _start, _end, head, tail, fxs, s, e, t 115 | -------- 116 | s, e = track_chunk:find("MAINSEND.-\n") -- firstly, find "MAINSEND" string 117 | _start, _end, head = track_chunk:find("^(\n", e + 1) -- Try find empty FXCHAIN 118 | -------- 119 | if not _start then -- if empty FXCHAIN not found, use custom values 120 | _start, _end = e + 1, e -- its correct values for inserting, see FXChain.Set 121 | head = "\n)", e + 1) -- end, tail 152 | -------- 153 | local t = {src_track_chunk = track_chunk, _start = _start, _end = _end, head = head, tail = tail, fxs = fxs} 154 | return t 155 | end 156 | 157 | -------------------------------------------------- 158 | -- Rebuild PLINKS ------------------------------- 159 | -------------------------------------------------- 160 | function FXChain.RebuildPLINKS(track, fx_chain) 161 | --msg("== Rebuild Plink ==") -- Test msg!!! 162 | -- get src order ----------- 163 | local fx_cnt = reaper.TrackFX_GetCount(track) 164 | local src = {} 165 | for i = 1, fx_cnt do 166 | local guid = reaper.TrackFX_GetFXGUID(track, i-1) 167 | src[guid] = i-1 168 | end 169 | -- get dest(modifed fxchain) order --- 170 | local pattern = ".+FXID ({%x+%-%x+%-%x+%-%x+%-%x+})\n" 171 | local dest = {} 172 | for i = 1, #fx_chain.fxs do 173 | local guid = fx_chain.fxs[i]:match(pattern) 174 | dest[guid] = i-1 175 | end 176 | -- create convert table ---- 177 | local src2dest = {} 178 | for k, v in pairs(dest) do -- k = guid; v = idx 179 | local src, dest = src[k], dest[k] 180 | if src and dest then 181 | src2dest[src] = dest 182 | end 183 | end 184 | 185 | -- Replace Plinks string --- 186 | local cur_fx -- for repl function and rebuild cycle 187 | function repl(scale, host_fx, host_fx_rel, host_fxparam, offset) 188 | local old_host_fx = tonumber(host_fx) -- old host fx, it's 0-based 189 | local new_host_fx = src2dest[old_host_fx] -- new host, fx 0-based 190 | --msg("Plink OK, old_host_fx = " .. old_host_fx .. " , new_host_fx = " .. (new_host_fx or "no new_host_fx!")) -- TEST!!! 191 | -------------------------- 192 | if new_host_fx then 193 | local new_host_fx_rel = new_host_fx - cur_fx 194 | local new = new_host_fx .. ":" .. new_host_fx_rel -- new str(new_host_fx:new_host_fx_rel) 195 | local str = "PLINK " .. scale .. " " .. new .. " " .. host_fxparam .. " " .. offset .. "\n" 196 | return str 197 | else return "\n" -- del, if no new_host_fx 198 | end 199 | end 200 | ---------------------------- 201 | for i = 1, #fx_chain.fxs do 202 | cur_fx = i - 1 -- current fx, 0-based for reaper func 203 | local pattern = "PLINK (%g+) (%g+):(%g+) (%g+) (%g+)\n" 204 | fx_chain.fxs[i] = fx_chain.fxs[i]:gsub(pattern, repl) 205 | --msg(fx_chain.fxs[i]) -- TEST - don't use on long chunks!!! 206 | end 207 | 208 | end 209 | 210 | -------------------------------------------------- 211 | -- Set FX Chain, return true if succefully ------ 212 | -------------------------------------------------- 213 | -- Переделать, лишние действия!!! 214 | function FXChain.Set(track, fx_chain, use_src_track_chunk, rebuild_plinks) 215 | if not (track and fx_chain) then return end 216 | -------- 217 | local cur_fx_chain 218 | if use_src_track_chunk then cur_fx_chain = fx_chain else cur_fx_chain = FXChain.Get(track) end 219 | if not cur_fx_chain then return end 220 | -------- 221 | local s, e, track_chunk = cur_fx_chain._start - 1, cur_fx_chain._end + 1, cur_fx_chain.src_track_chunk 222 | -------- 223 | if rebuild_plinks then FXChain.RebuildPLINKS(track, fx_chain) end -- Перестраивает Plink 224 | -------- 225 | local chunk_start, chunk_end = track_chunk:sub(1, s) .. fx_chain.head, fx_chain.tail .. track_chunk:sub(e) 226 | local fx_subchunks = table.concat(fx_chain.fxs) -- full fx-subchunks 227 | local fx_subchunks_noPE, nrepl = fx_subchunks:gsub("", "") -- without PROGRAMENV 228 | -------- 229 | local track_chunk_noPE = chunk_start .. fx_subchunks_noPE .. chunk_end -- track_chunk without PROGRAMENV 230 | track_chunk = chunk_start .. fx_subchunks .. chunk_end -- full track_chunk 231 | -------- 232 | if nrepl == 0 then return SetTrackChunk(track, track_chunk) 233 | else return SetTrackChunk(track, track_chunk_noPE) and SetTrackChunk(track, track_chunk) 234 | end 235 | end 236 | 237 | --============================================================================== 238 | -------- Modify FXChain functions --------------------------------------------- 239 | --============================================================================== 240 | --[[ 241 | == Modify FXChain mini-description =============== 242 | Эти функции являются простейшими операциями с таблицами. 243 | Многое сюда может быть добавлено и упростит задачи в дальнейшем. 244 | По идее, их можно было не писать, а действовать конкретно по ситуации, но так гораздо удобнее. 245 | Все операции с чанками должны быть безошибочными - в таком виде легче тестировать и ловить косяки. 246 | ---- 247 | NOTE: idx for ALL functions 1-based(it's Lua!) !!!!!!! 248 | --]] 249 | 250 | -------------------------------------------------- 251 | -- Get fx(fx_chunk), return fx_chunk ------------ 252 | function FXChain.GetFXChunk(fx_chain, idx) 253 | return fx_chain.fxs[idx] 254 | end 255 | 256 | -------------------------------------------------- 257 | -- Set fx_chunk(from fx_chunk) ------------------- 258 | function FXChain.SetFXChunk(fx_chain, fx_chunk, idx) 259 | fx_chain.fxs[idx] = fx_chunk 260 | end 261 | 262 | -------------------------------------------------- 263 | -- Insert fx(from fx_chunk) to pos = idx --------- 264 | function FXChain.InsertFXFromChunk(fx_chain, fx_chunk, idx) 265 | table.insert(fx_chain.fxs, idx, fx_chunk) 266 | end 267 | 268 | -------------------------------------------------- 269 | -- Remove fxs from first_idx to last_idx inclusive 270 | --[[ 271 | Если last_idx не указан, last_idx = first_idx. 272 | Если first_idx не указан, first_idx = #fx_chain.fxs(последний в цепи). 273 | Если last_idx указан, first_idx должен быть указан. 274 | На практике - FXChain.RemoveFX(fx_chain) - удаляет последний FX. 275 | FXChain.RemoveFX(fx_chain, first_idx) - удаляет один FX - first_idx. 276 | Это удобно, принцип примерно как в ф-ях Lua. 277 | --]] 278 | function FXChain.RemoveFX(fx_chain, first_idx, last_idx) 279 | first_idx = first_idx or #fx_chain.fxs 280 | last_idx = last_idx or first_idx 281 | for i = first_idx, last_idx do 282 | table.remove(fx_chain.fxs, first_idx) 283 | end 284 | end 285 | 286 | -------------------------------------------------- 287 | -- Move fx = src_idx to new position = dest_idx -- 288 | -- idx-s must be idx >= 1, idx <= #fx_chain.fxs -- 289 | function FXChain.MoveFX(fx_chain, src_idx, dest_idx) 290 | table.insert(fx_chain.fxs, dest_idx, table.remove(fx_chain.fxs, src_idx)) 291 | end 292 | 293 | -------------------------------------------------- 294 | -- Copy fx = src_idx to new position = dest_idx -- 295 | -- idx-s must be idx >= 1, idx <= #fx_chain.fxs + 1 296 | function FXChain.CopyFX(fx_chain, src_idx, dest_idx) 297 | local fx_chunk = fx_chain.fxs[src_idx] 298 | fx_chunk = fx_chunk:gsub("FXID {%x+%-%x+%-%x+%-%x+%-%x+}", "FXID " .. reaper.genGuid(""), 1) -- New FXID 299 | table.insert(fx_chain.fxs, dest_idx, fx_chunk) 300 | end 301 | 302 | -------------------------------------------------- 303 | -- Exchange fxs idx1 <> idx2(меняет местами) ----- 304 | function FXChain.ExchangeFX(fx_chain, idx1, idx2) 305 | fx_chain.fxs[idx1], fx_chain.fxs[idx2] = 306 | fx_chain.fxs[idx2], fx_chain.fxs[idx1] 307 | end 308 | 309 | 310 | --================================================= 311 | return FXChain 312 | 313 | 314 | 315 | 316 | -------------------------------------------------------------------------------- /Various/FXRack/Modules/File.lua: -------------------------------------------------------------------------------- 1 | -- File(module) 2 | -- @noindex 3 | 4 | 5 | local File = {} 6 | 7 | -- RecursiveCreateDirectory ------------ 8 | function File.RecursiveCreateDirectory(path) 9 | if not path then return end 10 | return reaper.RecursiveCreateDirectory(path, 1) 11 | end 12 | 13 | -- Enum SubDirs in Dir(path) ----------- 14 | -- return dirnames table -- 15 | function File.EnumerateSubDirs(path) 16 | if not path then return end 17 | local t = {} 18 | for i = 0, math.huge do 19 | local dn = reaper.EnumerateSubdirectories(path, i) 20 | if dn and dn ~= "" then t[#t+1] = dn else break end 21 | end 22 | return t 23 | end 24 | 25 | -- Enum Files in Dir(path) ------------- 26 | -- return filenames table -- 27 | function File.EnumerateFiles(path) 28 | if not path then return end 29 | local t = {} 30 | for i = 0, math.huge do 31 | local fn = reaper.EnumerateFiles(path, i) 32 | if fn and fn ~= "" then t[#t+1] = fn else break end 33 | end 34 | return t 35 | end 36 | 37 | -- File Exists(reaper) ----------------- 38 | function File.Exists(filename) 39 | return reaper.file_exists(filename) 40 | end 41 | 42 | -- File Exists(Lua) -------------------- 43 | function File.Exists2(filename) 44 | local file = io.open(filename, "rb") 45 | if file then file:close(); return true end 46 | end 47 | 48 | -- File Remove ------------------------- 49 | function File.Remove(filename) 50 | return os.remove(filename) 51 | end 52 | 53 | -- File Rename(rename file or dir) ----- 54 | function File.Rename(oldname, newname) 55 | return os.rename(oldname, newname) 56 | end 57 | 58 | -- Read Binary ------------------------- 59 | function File.ReadBin(filename) 60 | if not filename then return end 61 | local file, data 62 | file = io.open(filename, "rb") -- read bin 63 | if file then data = file:read("a"); file:close() end 64 | return data 65 | end 66 | 67 | -- Write Binary ------------------------ 68 | function File.WriteBin(filename, data) 69 | if not (filename and data) then return end 70 | local file, ret 71 | file = io.open(filename, "wb") -- write bin 72 | if file then ret = file:write(data); file:close() end 73 | if ret then return true end -- if succefully 74 | end 75 | 76 | 77 | -- FileCopy ---------------------------- 78 | --[[copy file src_filename to file dest_filename 79 | src_filename, dest_filename - full pathes 80 | create dest directory if no exist 81 | don't use on large files! --]] 82 | function File.Copy(src_filename, dest_filename) 83 | if not(src_filename and dest_filename) or 84 | src_filename == dest_filename then return 85 | end 86 | -- Read from Source 87 | local data = File.ReadBin(src_filename) 88 | if not data then return end 89 | -- Check/Create dest directory 90 | local dest_dir = dest_filename:match("^(.*)[\\/].+") -- extract dir 91 | if not dest_dir then return end 92 | File.RecursiveCreateDirectory(dest_dir, 1) 93 | -- Write to Dest 94 | local ret = File.WriteBin(dest_filename, data) 95 | if ret then return true end -- if succefully 96 | end 97 | 98 | 99 | --====================================== 100 | return File 101 | -------------------------------------------------------------------------------- /Various/FXRack/Modules/Presets.lua: -------------------------------------------------------------------------------- 1 | -- Presets(module) 2 | -- @noindex 3 | 4 | 5 | -- Load some modules ----------------- 6 | local File = require "Modules.File" 7 | 8 | --****************************************************************************** 9 | -------------------------------------- 10 | function SetRGB(RGB, a) 11 | gfx.r = (RGB & 0xFF0000) / 16711680 -- 256*256*255 12 | gfx.g = (RGB & 0x00FF00) / 65280 -- 256*255 13 | gfx.b = (RGB & 0x0000FF) / 255 -- 255 14 | gfx.a = a or 1 15 | end 16 | 17 | --============================================================================== 18 | -- Несколько осн. мышиных функций ------ 19 | function pointIN(px, py, x,y,w,h) 20 | return px >= x and px <= x + w and py >= y and py <= y + h 21 | end 22 | ---------- 23 | function mouseIN(x,y,w,h) 24 | return pointIN(gfx.mouse_x, gfx.mouse_y, x,y,w,h) 25 | end 26 | 27 | -- LEFT ---------------------- 28 | function mouseDown(x,y,w,h) 29 | return mouse_down and mouseIN(x,y,w,h) 30 | end 31 | ---------- 32 | function mouseUp(x,y,w,h) 33 | return mouse_up and mouseIN(x,y,w,h) 34 | end 35 | ---------- 36 | function mouseClick(x,y,w,h) 37 | return mouseUp(x,y,w,h) and pointIN(mouse_down_x,mouse_down_y, x,y,w,h) 38 | end 39 | 40 | -- RIGHT --------------------- 41 | function mouseRDown(x,y,w,h) 42 | return mouse_rdown and mouseIN(x,y,w,h) 43 | end 44 | 45 | --******************************************************************** 46 | local Presets = {} 47 | 48 | -- устан. пресет-папку(fullpath), создает если не существует 49 | function Presets.SetPath(path) 50 | if File.RecursiveCreateDirectory(path) then 51 | Presets.path = path 52 | return true 53 | end 54 | end 55 | 56 | -- устан. расш. для валидных файлов пресетов 57 | -- ext - непустая строка, например, "txt", "mpr", без точек! 58 | -- лучше пробить по допустимым символам, для себя и так норм 59 | function Presets.SetExtension(ext) 60 | if Presets.ext == "" then return false 61 | else Presets.ext = ext return true 62 | end 63 | end 64 | 65 | -- создает список существующих пресетов 66 | function Presets.UpdateList() 67 | if not Presets.path then return end 68 | local t = File.EnumerateFiles(Presets.path) 69 | local ptn = "(.+)%." .. Presets.ext .. "$" -- паттерн для поиска 70 | Presets.List = {} 71 | if t then 72 | for i = 1, #t do 73 | local name = t[i]:match(ptn) -- пресет-файлы, захв. имя 74 | if name then Presets.List[#Presets.List+1] = name end 75 | end 76 | end 77 | return Presets.List 78 | end 79 | 80 | -- устан.(не загружает!) текущий пресет(имя, отображаемое в пресет-строке) 81 | function Presets.SetCurPresetName(curpresetname) 82 | if curpresetname and type(curpresetname) == "string" and #curpresetname > 0 then 83 | Presets.curpresetname = curpresetname 84 | else Presets.curpresetname = "No Preset" 85 | end 86 | end 87 | 88 | -- возвр. индекс пресета по имени(либо nil) 89 | function Presets.GetByName(presetname) 90 | if not Presets.List then return end 91 | for k, v in pairs(Presets.List) do 92 | if v == presetname then return k end 93 | end 94 | end 95 | 96 | -- возвр. имя пресета по индекс(либо nil) 97 | function Presets.GetName(presetidx) 98 | if not Presets.List then return end 99 | return Presets.List[presetidx] 100 | end 101 | 102 | -- читает и возвращает данные из файла пресета 103 | function Presets.Load(presetname) 104 | local filename = Presets.path .. "/" .. presetname .. "." .. Presets.ext 105 | return File.ReadBin(filename) -- ret data if succefully or nil 106 | end 107 | 108 | -- сохр. пресет в пресетную папку с соотв. расширением 109 | function Presets.Save(presetname, presetdata) 110 | local filename = Presets.path .. "/" .. presetname .. "." .. Presets.ext 111 | return File.WriteBin(filename, presetdata) -- ret true if succefully 112 | end 113 | 114 | -- переименовывает пресет oldname > newname 115 | function Presets.Rename(oldname, newname) 116 | oldname = Presets.path .. "/" .. oldname .. "." .. Presets.ext 117 | newname = Presets.path .. "/" .. newname .. "." .. Presets.ext 118 | return File.Rename(oldname, newname) 119 | end 120 | 121 | -- удаляет файл пресета 122 | function Presets.Delete(presetname) 123 | local filename = Presets.path .. "/" .. presetname .. "." .. Presets.ext 124 | return File.Remove(filename) -- ret true if succefully 125 | end 126 | 127 | ------------------------------------------------------------ 128 | -- Init Preset Menu ---------------------------------------- 129 | ------------------------------------------------------------ 130 | function Presets.MenuInit(x,y,w,h, col, col_font, path, ext) 131 | if Presets.SetPath(path) and 132 | Presets.SetExtension(ext) and 133 | Presets.UpdateList() then 134 | Presets.Menu = {x = x, y = y, w = w, h = h, col = col, col_font = col_font} 135 | Presets.SetCurPresetName() -- now nil, "No Preset" 136 | return true -- if succefully 137 | end 138 | end 139 | 140 | ------------------------------------------------------------ 141 | -- Verify and confirm Preset Menu actions ------------------ 142 | ------------------------------------------------------------ 143 | -- Можно поразносить по соотв. функциям проверку и подтверждение 144 | -- Это, наверное, удобнее и проще. 145 | function Presets.ConfirmAction(action, name) 146 | ------------------ 147 | if action == "Load" then 148 | if not Presets.GetByName(name) then return end 149 | end 150 | ------------------ 151 | if action == "Save" then 152 | if name ~= Presets.curpresetname and Presets.GetByName(name) then 153 | local msg = "Overwrite \"" .. name .. "\"?" 154 | if reaper.MB(msg, "Save Preset", 1) ~= 1 then return end 155 | end 156 | end 157 | ------------------ 158 | if action == "Rename" then 159 | if not Presets.GetByName(Presets.curpresetname) then return end 160 | if name ~= Presets.curpresetname and Presets.GetByName(name) then 161 | local msg = "Overwrite \"" .. name .. "\"?" 162 | if reaper.MB(msg, "Rename Preset", 1) ~= 1 then return end 163 | action = "Save" -- It's Overwrite Exist Preset! 164 | end 165 | end 166 | ------------------ 167 | if action == "Delete" then 168 | if not Presets.GetByName(name) then return end 169 | local msg = "Delete preset \"" .. name .. "\"?" 170 | if reaper.MB(msg, "Confirm Preset Delete", 1) ~= 1 then return end 171 | end 172 | ------------------ 173 | return action, name 174 | end 175 | 176 | ------------------------------------------------------------ 177 | -- Draw Preset Menu ---------------------------------------- 178 | ------------------------------------------------------------ 179 | function Presets.MenuDraw() 180 | if not Presets.List then return end 181 | local x,y,w,h = Presets.Menu.x, Presets.Menu.y, Presets.Menu.w, Presets.Menu.h 182 | local col, col_font = Presets.Menu.col, Presets.Menu.col_font 183 | -- coords -------- 184 | local x1,y1,w1,h1 = x,y,h,h -- prev preset 185 | local x2,y2,w2,h2 = x+h,y,w-h*3, h -- curpreset 186 | local x3,y3,w3,h3 = x+w-h*2, y, h, h -- next preset 187 | local x4,y4,w4,h4 = x+w-h, y, h, h -- menu btn 188 | 189 | gfx.setfont(1,"Tahoma", h - 4) -- presets font 190 | 191 | SetRGB(col) -- bg color 192 | gfx.rect(x,y,w,h, 1) -- main rect 193 | gfx.set(0.5, 0.5, 0.5, 0.15) -- frames col 194 | gfx.rect(x1,y1,w1,h1,0) -- prev rect 195 | gfx.rect(x2,y2,w2,h2,0) -- cur rect 196 | gfx.rect(x3,y3,w3,h3,0) -- next rect 197 | gfx.rect(x4,y4,w4,h4,0) -- menu rect 198 | 199 | SetRGB(col_font) 200 | gfx.x = x1; gfx.y = y1 201 | gfx.drawstr("<", 5, x1+w1, y1+h1) -- prev "<" 202 | gfx.x = x2; gfx.y = y2 203 | gfx.drawstr(Presets.curpresetname, 5, x2+w2, y2+h2) -- currrent 204 | gfx.x = x3; gfx.y = y3 205 | gfx.drawstr(">", 5, x3+w3, y4+h3) -- next ">" 206 | gfx.x = x4; gfx.y = y4 207 | gfx.drawstr("+", 5, x4+w4, y4+h4) -- menu "+" 208 | 209 | -------------------------------------- 210 | local action, name -- init state! 211 | 212 | -- Menu List --------------- 213 | if mouseDown(x2,y2,w2,h2) then -- mouse down in curpreset rect 214 | gfx.x = x2; gfx.y = y2+h2; 215 | local menu_ret = gfx.showmenu(table.concat(Presets.List,"|")) 216 | if menu_ret > 0 then action, name = "Load", Presets.List[menu_ret] end -- Load 217 | end 218 | -- Prev Preset ------------- 219 | if mouseDown(x1,y1,w1,h1) then -- mouse down in prev("<") rect 220 | local idx = Presets.GetByName(Presets.curpresetname) 221 | if not idx or idx == 1 then idx = #Presets.List+1 end 222 | action, name = "Load", Presets.List[idx-1] -- Load Prev 223 | end 224 | -- Next Preset ------------- 225 | if mouseDown(x3,y3,w3,h3) then -- mouse down in next(">") rect 226 | local idx = Presets.GetByName(Presets.curpresetname) 227 | if not idx or idx == #Presets.List then idx = 0 end 228 | action, name = "Load", Presets.List[idx+1] -- Load Next 229 | end 230 | -- Menu Button ------------- 231 | if mouseDown(x4,y4,w4,h4) then -- mouse down in menu("+") rect 232 | gfx.x = x4; gfx.y = y4+h4; 233 | local menu_ret, ui_ret 234 | menu_ret = gfx.showmenu("Save Preset|Rename Preset|Delete Preset") 235 | if menu_ret == 1 then -- Save 236 | ui_ret, name = reaper.GetUserInputs("Save Preset", 1, "Preset name:,extrawidth=200", Presets.curpresetname) 237 | if ui_ret then action = "Save" end 238 | elseif menu_ret == 2 then -- Rename 239 | ui_ret, name = reaper.GetUserInputs("Rename Preset", 1, "Preset name:,extrawidth=200", Presets.curpresetname) 240 | if ui_ret then action = "Rename" end 241 | elseif menu_ret == 3 then -- Delete 242 | action, name = "Delete", Presets.curpresetname 243 | end 244 | end 245 | 246 | -- Confirm and return action, name --- 247 | if action and name and name ~= "" then 248 | return Presets.ConfirmAction(action, name) 249 | end 250 | 251 | end 252 | 253 | --================================================ 254 | return Presets 255 | -------------------------------------------------------------------------------- /Various/FXRack/Modules/RackSplitMix.lua: -------------------------------------------------------------------------------- 1 | -- RackSplitMix(module) 2 | -- @noindex 3 | 4 | 5 | 6 | --[[Обязательно перепилить все по координатам!!! Все считать от высоты слота, ширины линейки микшера - сплиттера. 7 | Сейчас не нужна такая муть. 8 | По отрисовке объединены. Только init поправить толково и все, это правильный подход.--]] 9 | -------------------------------------------------------------------------------- 10 | --*** RACK Mixer/Splitter functions ******************************************* 11 | -------------------------------------------------------------------------------- 12 | local SplitMix = {} 13 | local Mixer = {} 14 | local Splitter = {} 15 | 16 | ------------------------------------------------------------ 17 | -- Init Mixer ---------------------------------------------- 18 | ------------------------------------------------------------ 19 | function Mixer.Init(x,y,w,h, rows, gain_png, pan_png, power_png, phase_png, solo_png, summode_png) 20 | 21 | local mix = {x = x, y = y, w = w, h = h} -- Mixer coords 22 | 23 | -- Knobs --------------------------------------- 24 | local K = {} -- knobs tmp table 25 | ---- Vol Knobs ----------- 26 | local xx, yy, ww, hh = x + 4, y + 6, 28, 28 -- Vol Knobs 27 | for i = 1, rows do 28 | local key = "Vol"..i 29 | K[key] = KnobNew(xx, yy, ww, hh, gain_png, 0.5) 30 | yy = yy + 40 31 | ------ 32 | K[key].param = (i-1)*5 + 1 -- Linked fx param idx(0-based) 33 | end 34 | 35 | ---- Pan Knobs ------------- 36 | local xx, yy, ww, hh = x + 38, y + 6, 28, 28 -- Pan Knobs 37 | for i = 1, rows do 38 | local key = "Pan"..i 39 | K[key] = KnobNew(xx, yy, ww, hh, pan_png, 0.5) 40 | yy = yy + 40 41 | ------ 42 | K[key].param = (i-1)*5 + 2 -- Linked fx param idx(0-based) 43 | end 44 | ------------- 45 | mix.knobs = K -- Set Mixer Knobs 46 | 47 | -- Buttons ------------------------------------- 48 | local B = {} -- btns tmp table 49 | ---- Power buttons --------- 50 | local xx, yy, ww, hh = x - 704, y + 11, 17, 18 51 | for i = 1, rows do 52 | local key = "Power"..i 53 | B[key] = TButtonNew(xx, yy, ww, hh, power_png, 0) 54 | yy = yy + 40 55 | ------ 56 | B[key].param = (i-1)*5 -- Linked fx param idx(0-based) 57 | end 58 | 59 | ---- Phase buttons --------- 60 | local xx, yy, ww, hh = x + 38 + 36, y + 9, 22, 22 61 | for i = 1, rows do 62 | local key = "Phase"..i 63 | B[key] = TButtonNew(xx, yy, ww, hh, phase_png, 0) 64 | yy = yy + 40 65 | ------ 66 | B[key].param = (i-1)*5 + 3 -- Linked fx param idx(0-based) 67 | end 68 | 69 | 70 | ---- Solo buttons ---------- 71 | local xx, yy, ww, hh = x + 38 + 30*2, y + 9, 22, 22 72 | for i = 1, rows do 73 | local key = "Solo"..i 74 | B[key] = TButtonNew(xx, yy, ww, hh, solo_png, 0) 75 | yy = yy + 40 76 | ------ 77 | B[key].param = (i-1)*5 + 4 -- Linked param idx(0-based) 78 | end 79 | 80 | ---- SumMode Button -------- 81 | B.SumMode = TButtonNew(x+130, y - 25, 26, 17, summode_png, 0) 82 | B.SumMode.param = 40 83 | ------------- 84 | mix.btns = B -- Set Buttons 85 | 86 | -- Labels ------------------------------------- 87 | mix.lbls = {} 88 | mix.lbls.vol = {x = x + 12, y = y + rows * 40 + 9, lbl = "Vol"} -- Vol lbl 89 | mix.lbls.pan = {x = x + 45, y = y + rows * 40 + 9, lbl = "Pan"} -- Pan lbl 90 | 91 | return mix -- return mixer table 92 | 93 | end 94 | 95 | ------------------------------------------------------------ 96 | -- Init Splitter ------------------------------------------- 97 | ------------------------------------------------------------ 98 | function Splitter.Init(x, y, w, h, rows, gain_png) 99 | 100 | local split = {x = x, y = y, w = w, h = h} -- Splitter coords 101 | 102 | -- Knobs --------------------------------------- 103 | local K = {} -- knobs tmp table 104 | ---- Gain Knobs ----------- 105 | local xx, yy, ww, hh = x + 26, y + 6, 28, 28 106 | for i = 1, rows do 107 | local key = "Gain"..i 108 | K[key] = KnobNew(xx, yy, ww, hh, gain_png, 0.5) 109 | yy = yy + 40 110 | ------ 111 | K[key].param = (i-1) -- Linked fx param idx(0-based) 112 | end 113 | ------------- 114 | split.knobs = K -- Set Knobs 115 | 116 | -- Labels ------------------------------------- 117 | split.lbls = {} 118 | split.lbls.gain = {x = x + 30, y = y + rows * 40 + 9, lbl = "Gain"} -- Gain lbl 119 | 120 | return split -- return splitter table 121 | 122 | end 123 | 124 | ------------------------------------------------------------ 125 | -- Link Splitter/Mixer To JS ------------------------------- 126 | ------------------------------------------------------------ 127 | -- Распиновка и линковка по одинаковой схеме 128 | function SplitMix.SetPinmap(track, fx_idx) -- fx_idx 1-based! 129 | local fx = fx_idx - 1 -- fx index 0-based for reaper functions! 130 | local ret, inPins, outPins = reaper.TrackFX_GetIOSize(track, fx) 131 | for i = 1, inPins do reaper.TrackFX_SetPinMappings(track, fx, 0, i-1, 2^(i-1), 0) end 132 | for i = 1, outPins do reaper.TrackFX_SetPinMappings(track, fx, 1, i-1, 2^(i-1), 0) end 133 | end 134 | 135 | ----------------------- 136 | function SplitMix.LinkToJS(obj, track, fx_idx, fxname) -- fx_idx 1-based! 137 | obj.track = track -- target track 138 | obj.fx = {idx = fx_idx, name = fxname} -- target fx datas 139 | SplitMix.SetPinmap(track, fx_idx) -- set valid pinmap 140 | end 141 | 142 | ------------------------------------------------------------ 143 | -- Splitter/Mixer Last Touched Param functions ------------- 144 | ------------------------------------------------------------ 145 | -- Init Mixer/Splitter LastTouch label --------------------- 146 | function SplitMix.LastTouchInit() 147 | ---- LastTouch lbl coords -- 148 | SplitMix.LastTouch = {x = 900, y = 6, w = 200, h = 18 } 149 | end 150 | ----------------------- 151 | function SplitMix.LastTouchDraw() 152 | if not (SplitMix.LastTouch and SplitMix.LastTouch.show) then return end 153 | local lbl = SplitMix.LastTouch.lbl 154 | local x, y = SplitMix.LastTouch.x, SplitMix.LastTouch.y 155 | local w, h = SplitMix.LastTouch.w, SplitMix.LastTouch.h 156 | gfx.x, gfx.y = x, y 157 | gfx.setfont(1, "Tahoma", 13) 158 | SetRGB(0xA7C5DB) 159 | gfx.drawstr(lbl, 4, x + w, y + h); 160 | 161 | end 162 | ----------------------- 163 | function SplitMix.LastTouchUpdate(track, key, fx, param) 164 | if not SplitMix.LastTouch then SplitMix.LastTouchInit() end 165 | ------------------ 166 | local ret, parname = reaper.TrackFX_GetParamName(track, fx, param, "") 167 | local val = reaper.TrackFX_GetParam(track, fx, param) 168 | local ret, form_val = reaper.TrackFX_FormatParamValue(track, fx, param, val, "") 169 | local lbl = parname .. ": " .. form_val 170 | if key:match("Vol") or key:match("Gain") then lbl = lbl .. " dB" 171 | elseif key:match("Pan") then lbl = lbl .. " %" 172 | end 173 | SplitMix.LastTouch.key = key 174 | SplitMix.LastTouch.lbl = lbl 175 | SplitMix.LastTouch.show = true 176 | end 177 | 178 | ------------------------------------------------------------ 179 | -- Draw Splitter/Mixer ------------------------------------- 180 | ------------------------------------------------------------ 181 | function SplitMix.Draw(obj) 182 | if not(obj.track and obj.fx and obj.fx.idx) then return end 183 | local track = obj.track 184 | local fx = obj.fx.idx - 1 -- fx = 0-based idx for reaper functions 185 | local mouse_pressed = (gfx.mouse_cap&1==1) 186 | 187 | if not reaper.TrackFX_GetEnabled(track, fx) then 188 | reaper.TrackFX_SetEnabled(track, fx, true) -- Set enabled always 189 | end 190 | 191 | -- Draw Buttons -- 192 | if obj.btns then 193 | for key, btn in pairs(obj.btns) do 194 | TButtonDraw(btn) -- Draw Button 195 | if btn.isClicked then -- to fx from script 196 | reaper.TrackFX_SetParamNormalized(track, fx, btn.param, btn.normval) 197 | SplitMix.LastTouchUpdate(track, key, fx, btn.param) 198 | else -- from fx to sript 199 | btn.normval = reaper.TrackFX_GetParamNormalized(track, fx, btn.param) 200 | end 201 | -------------- 202 | if btn.isChanged or btn.isMouseOver then 203 | SplitMix.LastTouchUpdate(track, key, fx, btn.param) 204 | end 205 | end 206 | end 207 | 208 | -- Draw Knobs ---- 209 | if obj.knobs then 210 | for key, knob in pairs(obj.knobs) do 211 | KnobDraw(knob) -- Draw Button 212 | if knob.isChanged then -- to fx from script 213 | reaper.TrackFX_SetParamNormalized(track, fx, knob.param, knob.normval) 214 | else -- from fx to sript 215 | knob.normval = reaper.TrackFX_GetParamNormalized(track, fx, knob.param) 216 | end 217 | -------------- 218 | if knob.isChanged or knob.isMouseOver then 219 | SplitMix.LastTouchUpdate(track, key, fx, knob.param) 220 | end 221 | end 222 | end 223 | 224 | -- labels -------- 225 | if obj.lbls then 226 | for key, lbl in pairs(obj.lbls) do 227 | gfx.x = lbl.x; gfx.y = lbl.y 228 | gfx.setfont(1, "Tahoma", 13) 229 | SetRGB(0xA7C5DB) 230 | gfx.drawstr(lbl.lbl) 231 | end 232 | end 233 | 234 | -- Last touch ---- 235 | SplitMix.LastTouchDraw() 236 | 237 | end 238 | 239 | --========================================================== 240 | SplitMix.Splitter = Splitter 241 | SplitMix.Mixer = Mixer 242 | --========================================================== 243 | return SplitMix 244 | -------------------------------------------------------------------------------- /Various/FXRack/Modules/SimpleControls.lua: -------------------------------------------------------------------------------- 1 | -- SimpleControls(module) 2 | -- @noindex 3 | 4 | ------------------------------------------------------------ 5 | function msg(m) reaper.ShowConsoleMsg("\n" .. m) end 6 | 7 | ------------------------------------------------------------ 8 | -- Images Functions ---------------------------------------- 9 | ------------------------------------------------------------ 10 | local Images = {} 11 | -------------------- 12 | function Images.FindFirstEmptySlot() 13 | local img 14 | for i = 0, 1023 do 15 | local w, h = gfx.getimgdim(i) 16 | if w == 0 then img = i break end 17 | end 18 | return img 19 | end 20 | -------------------- 21 | function Images.LoadToFirstEmptySlot(filename) 22 | if not filename then return end 23 | local img = Images.FindFirstEmptySlot() 24 | img = gfx.loadimg(img, filename) 25 | if img >= 0 then Images[filename] = img 26 | return img 27 | end 28 | end 29 | -------------------- 30 | function Images.FindLoadedOrLoad(filename) 31 | if Images[filename] then return Images[filename] 32 | else return Images.LoadToFirstEmptySlot(filename) 33 | end 34 | end 35 | 36 | ------------------------------------------------------------ 37 | -- Load, Set, Draw Control Image --------------------------- 38 | ------------------------------------------------------------ 39 | --[[ 40 | ШАБЛОН ДЛЯ ИМЕНОВАНИЯ imagename_(frmw)x(frmh)x(nfrms) - ЭТО ВАЖНО! 41 | Можно добавить дополнительные варианты, для удобства: 42 | Если нет результата по первому - imagename_(frmw)x(frmh) - считать nfrms через gfx.getimgdim(). 43 | Если нет результата по первому и второму - считать все через gfx.getimgdim() ориентируясь на ширину. 44 | --]] 45 | function ControlSetImage(control, img_filename) 46 | local idx = Images.FindLoadedOrLoad(img_filename) 47 | ------------------ 48 | if idx then 49 | local frmw, frmh, nfrms = img_filename:match(".-_(%d+)x(%d+)x(%d+)") 50 | if frmw and frmh and nfrms then 51 | control.img = { idx = idx, -- image idx, slot 0..1024-1 specified by image 52 | frmw = tonumber(frmw), -- image frame width 53 | frmh = tonumber(frmh), -- image frame height 54 | nfrms = tonumber(nfrms)} -- number of frames 55 | end 56 | end 57 | end 58 | 59 | ------------------------------ 60 | function ControlDrawImage(control) 61 | local x,y,w,h = control.x, control.y, control.w, control.h 62 | local normval = control.normval 63 | local img = control.img 64 | local curfrm = math.floor((img.nfrms-1) * normval) -- current frame 65 | gfx.blit(img.idx, 1, 0, 0, curfrm * img.frmh, img.frmw, img.frmh, x,y,w,h); 66 | end 67 | 68 | ------------------------------------------------------------ 69 | -- Simple Button ------------------------------------------- 70 | ------------------------------------------------------------ 71 | function TButtonNew(x,y,w,h, img_filename, normval) 72 | local btn = {x = x, y = y, w = w, h = h, normval = normval} 73 | ControlSetImage(btn, img_filename) 74 | return btn 75 | end 76 | 77 | ------------------------------ 78 | function TButtonDraw(btn) 79 | local x,y,w,h = btn.x, btn.y, btn.w, btn.h 80 | ------------------ 81 | btn.isMouseOver, btn.isClicked = false, false 82 | if mouseIN(x,y,w,h) and gfx.mouse_cap&1==0 then btn.isMouseOver = true end 83 | ------------------ 84 | if mouseDown(x,y,w,h) then 85 | if btn.normval > 0 then btn.normval = 0 else btn.normval = 1 end 86 | btn.isClicked = true 87 | end 88 | ------------------ 89 | if btn.isMouseOver then gfx.a = 1 else gfx.a = 0.7 end 90 | if btn.img then 91 | ControlDrawImage(btn) 92 | else 93 | gfx.rect(x,y,w,h, 0) 94 | gfx.x, gfx.y = x, y; gfx.a = 1 95 | gfx.drawstr("?", 231, x+w, y+h) -- либо рисовать нативно 96 | end 97 | 98 | end 99 | 100 | ------------------------------------------------------------ 101 | -- Simple Knob --------------------------------------------- 102 | ------------------------------------------------------------ 103 | function KnobNew(x, y, w, h, img_filename, normval) 104 | local knob = {x = x, y = y, w = w, h = h, normval = normval, defval = normval} 105 | ControlSetImage(knob, img_filename) 106 | return knob 107 | end 108 | 109 | ------------------------------ 110 | function KnobDraw(knob) 111 | local x,y,w,h = knob.x, knob.y, knob.w, knob.h 112 | knob.isMouseOver, knob.isChanged, knob.isReleased = false, false, false -- reset to default 113 | ------------------ 114 | if mouseIN(x,y,w,h) and gfx.mouse_cap&1==0 then knob.isMouseOver = true end 115 | ------------------ 116 | if mouseDown(x,y,w,h) then knob.isCaptured = true end -- set cap state 117 | ------------------ 118 | if knob.isCaptured and mouse_up then 119 | knob.isCaptured = nil -- reset cap state 120 | knob.isReleased = true -- knob has been released 121 | end 122 | -------- 123 | if knob.isCaptured then 124 | if mouse_move then -- change knob value via mouse 125 | local K = 600 -- Normal drag(no Ctrl) 126 | if mouse_Ctrl then K = 2000 end -- K = 1000 Precise drag(if Ctrl pressed) 127 | knob.normval = knob.normval + (mouse_last_y - gfx.mouse_y) / K 128 | knob.normval = minmax(knob.normval, 0, 1) 129 | knob.isChanged = true -- knob changed - state! 130 | end 131 | end 132 | -------- 133 | if mouseRDown(x,y,w,h) then 134 | knob.normval = knob.defval 135 | knob.isChanged = true 136 | end 137 | ------------------ 138 | if knob.isCaptured or knob.isMouseOver then gfx.a = 1 else gfx.a = 0.7 end 139 | if knob.img then 140 | ControlDrawImage(knob) 141 | else 142 | gfx.rect(x,y,w,h, 0) 143 | gfx.x, gfx.y = x, y 144 | gfx.drawstr("?", 231, x+w, y+h) -- либо рисовать нативно 145 | end 146 | 147 | end 148 | -------------------------------------------------------------------------------- /Various/gen_Create stretch-markers at transients.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name:Create stretch-markers at transients 3 | * Lua script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.01 8 | */ 9 | 10 | // -- Script creates stretch-markers at transients 11 | 12 | function slider_New(x,y,w,h, r,g,b,a, lbl, val,min_val,max_val) 13 | ( 14 | this.x = x; this.y = y; this.w = w; this.h = h; // coord 15 | this.r = r; this.g = g; this.b = b; this.a = a; // color 16 | this.lbl = lbl; 17 | this.min_val = min_val; 18 | this.max_val = max_val; 19 | this.val = val; 20 | this.norm_val = (val - min_val)/(max_val - min_val);; // norm value 21 | ); 22 | 23 | //-- Get mouse --------------- 24 | function pointIN(p_x, p_y) 25 | ( // if point in obj area 26 | p_x>=this.x && p_x <= this.x+this.w && 27 | p_y>=this.y && p_y <= this.y+this.h; 28 | ); 29 | 30 | function mouseIN() 31 | ( // if mouse in obj area 32 | mouse_cap&1==0 && this.pointIN(mouse_x, mouse_y); 33 | ); 34 | 35 | function mouseDown() 36 | ( // if mouse will be pressed in obj area 37 | mouse_cap&1==1 && this.pointIN(mouse_ox,mouse_oy); 38 | ); 39 | 40 | function mouseUp() 41 | ( // if mouse released(anywhere) and will be pressed in obj area 42 | mouse_cap&1==0 && this.pointIN(mouse_ox,mouse_oy); 43 | ); 44 | 45 | //-- Set value --------------- 46 | function set_value() 47 | local(norm_val, K ) 48 | ( 49 | K = 10; // K = coeff(when Ctrl pressed) 50 | Ctrl ? ( 51 | norm_val = this.norm_val + ((mouse_x-last_x)/(this.w*K)); 52 | ) : ( 53 | norm_val = (mouse_x-this.x)/this.w; 54 | ); 55 | 56 | this.norm_val = min( max(norm_val,0), 1 ); // verify and set value 57 | this.val = this.min_val + (this.max_val-this.min_val) * this.norm_val; 58 | ); 59 | 60 | //-- Draw slider ------------- 61 | function slider_draw() 62 | local(x,y,w,h, r,g,b,a, lbl,lbl_w,lbl_h, val,val_w,val_h) 63 | ( 64 | x=this.x; y=this.y; w=this.w; h=this.h; 65 | r=this.r; g=this.g; b=this.b; a=this.a; 66 | lbl=this.lbl; 67 | 68 | this.mouseIN() ? a=a+0.1; 69 | this.mouseDown() ? ( 70 | a=a+0.2; 71 | this.set_value(); 72 | //this.onMove(); 73 | ); 74 | 75 | this.mouseUp() ? ( 76 | //this.onUp(); 77 | RunMain = 1; 78 | mouse_ox = mouse_oy = -1; // reset mouse 79 | ); 80 | 81 | //-- draw body, frame --- 82 | gfx_set(r,g,b,a); 83 | gfx_rect(x,y,w,h, 0); 84 | gfx_rect(x,y,w*this.norm_val,h, 1); 85 | //-- draw label --------- 86 | gfx_set(0.9,0.8,0.5,1); 87 | gfx_measurestr(lbl, lbl_w, lbl_h); 88 | gfx_x = x+5; gfx_y = y+(h-lbl_h)/2; 89 | gfx_drawstr(lbl); 90 | //-- draw value --------- 91 | val = sprintf(#, "%.2f", this.val); 92 | gfx_measurestr(val, val_w, val_h); 93 | gfx_x = x+w-val_w-5; gfx_y = y+(h-val_h)/2; 94 | gfx_drawstr(val); // draw Slider Value 95 | 96 | ); 97 | 98 | //==========================================================================================================// 99 | 100 | //-- Create Sliders -------------------------- 101 | //-- args = (x,y,w,h, r,g,b,a, lbl, val,min_val,max_val) 102 | Thresh.slider_New(10,10,260,18, 0.5,0.5,0.5,0.3, "Threshold dB", -24, -60, 0 ); 103 | Sens.slider_New(10,30,260,18, 0.5,0.5,0.5,0.3, "Sensetivity dB", 4.5, 0, 18 ); 104 | Retrig.slider_New(10,50,260,18, 0.5,0.5,0.5,0.3, "Retrig ms", 20, 20, 450 ); 105 | 106 | 107 | //==========================================================================================================// 108 | 109 | //-------------------------------------------------------------------------------- 110 | //--- Simple Detect Transients Function ---------------------------------------- 111 | //-------------------------------------------------------------------------------- 112 | function DetectTransients(item, take, srate) 113 | local(Threshold_dB, Sensitivity_dB, Retrig_sec, Threshold, Sensitivity, Retrig, 114 | attTime1, relTime1, attTime2, relTime2, ga1, gr1, ga2, gr2, envOut1, envOut2 115 | item_start, item_len, sel_start, sel_end, playrate, range_start, range_len, range_end, range_len_smpls, 116 | block_size, n_blocks, rest_smples, mrk, 117 | AA, starttime_sec, samplebuffer, cur_block, smpl, input, mrk_pos, retrig_cnt) 118 | ( 119 | item_start = GetMediaItemInfo_Value(item, "D_POSITION"); // item position 120 | item_len = GetMediaItemInfo_Value(item, "D_LENGTH"); // item orig length 121 | GetSet_LoopTimeRange(0, 0, sel_start, sel_end, 0); // get time selection 122 | !(sel_end - sel_start) ? ( // if no selection 123 | sel_start = item_start; // use item start 124 | sel_end = item_start+item_len; // use item end 125 | ); 126 | sel_start = max(sel_start, item_start); // if sel_start or sel_end out of item 127 | sel_end = min(sel_end, item_start+item_len); // use item_start, item_end respectively 128 | sel_end - sel_start < 0 ? MB("Time selection out of item range!", "Note", 0); 129 | 130 | 131 | //---------------------------------------------------------------------------- 132 | sel_end - sel_start > 0 ? ( 133 | //-- If playrate != 1 ---------------------------------- 134 | playrate = GetMediaItemTakeInfo_Value(take, "D_PLAYRATE"); // get take orig playrate 135 | playrate != 1 ? ( 136 | SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", 1); // faster with playrate = 1 137 | SetMediaItemInfo_Value(item, "D_LENGTH", item_len*playrate); // len*playrate 138 | ); 139 | //-- Define range(with regard orig playrate) ----------- 140 | range_start = (sel_start-item_start)*playrate; // range start 141 | range_len = (sel_end-sel_start)*playrate; // range length 142 | range_end = range_start+range_len; 143 | range_len_smpls = floor(range_len*srate); // range length to samples 144 | block_size = 65536; // full block size(samples) 145 | n_blocks = floor(range_len_smpls/block_size); // number of full blocks 146 | rest_smples = range_len_smpls - block_size*n_blocks; // rest of samples(incomplete last block) 147 | 148 | //-- Del Old markers in range -------------------------- 149 | mrk=0; 150 | loop(GetTakeNumStretchMarkers(take), 151 | GetTakeStretchMarker(take, mrk, mrk_pos); 152 | mrk_pos>=range_start && mrk_pos<=range_end ? ( 153 | DeleteTakeStretchMarkers(take, mrk); 154 | ) : mrk+=1; 155 | ); 156 | 157 | //-- Values from sliders ------------------------------- 158 | Threshold_dB = Thresh.val; 159 | Sensitivity_dB = Sens.val; 160 | Retrig_sec = Retrig.val/1000; 161 | //Main_OnCommand(41844, 0); // remove old str-marks(All) 162 | //-- Values to norm values ----------------------------- 163 | Threshold = 10^(Threshold_dB/20); //-- Threshold_dB - to norm value 164 | Sensitivity = 10^(Sensitivity_dB/20); //-- Sensitivity_dB - to norm value 165 | Retrig = floor(Retrig_sec*srate); //-- Retrig_sec - to samples 166 | 167 | //-- Envelopes Attack, Release Time ----------------- 168 | attTime1 = 0.001; //-- Env1(fast) attack(sec) 169 | relTime1 = 0.010; //-- Env1(fast) release(sec) 170 | attTime2 = 0.007; //-- Env2(slow) attack(sec) 171 | relTime2 = 0.015; //-- Env2(slow) release(sec) 172 | 173 | //-- Compute sample frequency related coeffs -------- 174 | ga1 = exp(-1/(srate*attTime1)); //-- attack1 coeff 175 | gr1 = exp(-1/(srate*relTime1)); //-- release1 coeff 176 | ga2 = exp(-1/(srate*attTime2)); //-- attack2 coeff 177 | gr2 = exp(-1/(srate*relTime2)); //-- release2 coeff 178 | //--------------------------------------------------- 179 | envOut1 = 0; 180 | envOut2 = 0; 181 | 182 | //------------------------------------------------- 183 | AA = CreateTakeAudioAccessor(take); 184 | starttime_sec = range_start; 185 | samplebuffer = 0; 186 | cur_block = 0; 187 | 188 | // -- Detect Transients -------------------------------- 189 | loop(n_blocks+1, 190 | cur_block == n_blocks ? block_size = rest_smples; // last block = rested samples 191 | memset(0,0,block_size); // clear samplebuffer 192 | GetAudioAccessorSamples(AA, srate, 1, starttime_sec, block_size, samplebuffer); 193 | smpl=0; 194 | loop(block_size, 195 | input = abs(samplebuffer[smpl]); // abs sample value(abs envelope) 196 | // -- Envelope1(fast) -------------------------- 197 | envOut1 < input ? ( 198 | envOut1 = input + ga1*(envOut1 - input); 199 | ) : ( 200 | envOut1 = input + gr1*(envOut1 - input); 201 | ); 202 | // -- Envelope2(slow) -------------------------- 203 | envOut2 < input ? ( 204 | envOut2 = input + ga2*(envOut2 - input); 205 | ) : ( 206 | envOut2 = input + gr2*(envOut2 - input); 207 | ); 208 | // -- Trigger ---------------------------------- 209 | retrig_cnt > Retrig ? ( 210 | envOut1 > Threshold && envOut1/envOut2 > Sensitivity ? ( 211 | mrk_pos = starttime_sec + smpl/srate; // Calc mrk pos 212 | SetTakeStretchMarker(take, -1, mrk_pos); // Insert marker 213 | retrig_cnt = 0; 214 | ); 215 | ) : ( 216 | envOut2 = envOut1; // уравнивает огибающие, пока триггер неактивен(здесь важно) 217 | retrig_cnt+=1; 218 | ); 219 | 220 | smpl+=1; 221 | ); 222 | starttime_sec+=65536/srate; // To next block 223 | cur_block+=1; // block counter 224 | ); 225 | 226 | DestroyAudioAccessor(AA); 227 | playrate != 1 ? ( 228 | SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", playrate); // restore orig playrate 229 | SetMediaItemInfo_Value(item, "D_LENGTH", item_len); // restore orig length 230 | ); 231 | UpdateTimeline(); 232 | ); 233 | 234 | ); 235 | 236 | 237 | //==========================================================================================================// 238 | function MAIN() 239 | local(item, take, PCM_source, srate, Threshold_dB, Sensitivity_dB, Retrig_sec) 240 | ( 241 | item = GetSelectedMediaItem(0, 0); 242 | take = GetActiveTake(item); 243 | PCM_source = GetMediaItemTake_Source(take); 244 | srate = GetMediaSourceSampleRate(PCM_source); 245 | 246 | srate ? ( 247 | start = time_precise(); 248 | Undo_BeginBlock(); 249 | DetectTransients(item, take, srate); 250 | Undo_EndBlock("Create stretch-markers at transients", -1); 251 | //ShowConsoleMsg(sprintf(#, "%f \n", time_precise()-start); ); 252 | ); 253 | 254 | ); 255 | 256 | //---------------------------- 257 | function Draw_Sliders() 258 | ( 259 | Thresh.slider_draw(); 260 | Sens.slider_draw(); 261 | Retrig.slider_draw(); 262 | ); 263 | 264 | //-- mainloop ---------------- 265 | function mainloop() 266 | ( 267 | //-- mouse and modkeys -- 268 | (mouse_cap&1==1 && last_mouse_cap&1==0) || //-- L mouse 269 | (mouse_cap&2==2 && last_mouse_cap&2==0) || //-- R mouse 270 | (mouse_cap&64==64 && last_mouse_cap&64==0) ? ( //-- M mouse 271 | mouse_ox = mouse_x; mouse_oy = mouse_y; 272 | ); 273 | 274 | Ctrl = mouse_cap&4==4; //-- Ctrl state 275 | Shift = mouse_cap&8==8; //-- Shift state 276 | Alt = mouse_cap&16==16; //-- Shift state 277 | 278 | //-- Main functions etc -- 279 | Draw_Sliders(); 280 | RunMain ? (MAIN(); RunMain = 0;); 281 | //------------------------ 282 | last_mouse_cap = mouse_cap; 283 | last_x = mouse_x; last_y = mouse_y; 284 | char = gfx_getchar(); 285 | char >= 0 ? defer("mainloop();"); 286 | gfx_update(); 287 | ); 288 | 289 | //-- init -------------------- 290 | function init() 291 | local(width, height, dockstate, xpos, ypos) 292 | ( //-- window ----------- 293 | width = 280; height = 80; dockstate = 0; xpos = 200; ypos = 300; 294 | gfx_init("Create stretch-markers at transients(eel)",width,height,dockstate,xpos,ypos); 295 | gfx_clear = 25 + 25*256 + 25*65536; 296 | //-- Init mouse ------- 297 | last_mouse_cap = 0; 298 | last_x = last_y = 0; 299 | mouse_ox = mouse_oy = -1; 300 | 301 | gfx_setfont(1, "Arial", 15); 302 | ); 303 | 304 | RunMain = 1;// for first run 305 | init(); 306 | mainloop(); 307 | -------------------------------------------------------------------------------- /Various/gen_Retrospective Record (audio).eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name: Retrospective Record (audio) 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 3.0 8 | */ 9 | 10 | //==v20151213==Reaper v5.1,SWS 2.8.2==// 11 | //////////////////////////////////////////////////////////////////////////////////////////////// 12 | //==================JS_RRAudio TEXT(Do not change this text!!!)================================// 13 | #JS_RRAudio = " 14 | desc:ForRetroRec(Audio) v20151213(b1) 15 | options:maxmem=33554432 16 | slider1:1<0,4096,1>-Track Number 17 | slider2:0<0,1,1>-Insert Audio 18 | slider3:0<0,4095,1>-Slot 19 | slider4:0<0,33554432,1>-DATA 20 | slider5:1<0,1,1{No(As Rec Out Mode),Yes(As Rec Normal Mode)}>Compensate Latency 21 | slider6:0<0,8192,1>-data 22 | @init 23 | ext_noinit=1; 24 | buf=0; 25 | //max_buf=65536-8192*4;//MaxBuf For Experi Only,DEL IT*** 26 | max_buf=33554432-8192*4;//MaxBuf Val=33521664 27 | res_buf=8192*2;//Reserve buffer for Compensate Latency 28 | items=33550336;//Offset for DATA(last 4096 slots) 29 | Thresh=10;//Its Optimal Thresh Value 30 | items[4094]=srate;//Save Srate(4094 slot) 31 | @slider 32 | Track_Num = slider1; 33 | Insert = slider2; 34 | //==DATA Sliders==// 35 | //==Data cycle=3,Set 0,3,6,9,12 etc for Read-Set data=//=4092,4093,4094==Item Count,Total Lenhth(smpl),srate==// 36 | //==Data slider represent Item Start(in sec),other values set S_Start,S_Len for Insert Audio==// 37 | slider5 ? Lat_Offset=(slider6)*2 : Lat_Offset=0; 38 | slider4=items[slider3];//slider3=MAIN CONTROL SLIDER,slider4=MAIN DATA SLIDER!!! 39 | S_Start=items[slider3+1]+Lat_Offset;//Item buf pos-offset(Star) in smpls for export_buff() 40 | S_Len=items[slider3+2];//ITEM Lenght in smpls for export_buff() 41 | @block 42 | Start_Play_Position = play_position;//B_start 43 | //==If play position changed,Save Last Ppos,Prev Len,Start Ppos and buf pos-offset to memory==// 44 | (i>0&&i0.125 ? 45 | (items[4092]+=1;//Its New Item,Update Item_Count 46 | items[j]=i/2-items[j-1]/2;//Its PREV_ITEM Lenght(in smpls) 47 | j+=1;//To Next data Cycle 48 | items[j]=Start_Play_Position;//New ITEM start(in sec) 49 | items[j+1]=i;//Item buf pos-offset(in smpls) 50 | j+=2; 51 | );//End 52 | 53 | Last_Play_Position = Start_Play_Position+samplesblock/srate;//B_end 54 | @sample 55 | slider6==8192 ? (i=0; j=0; items[4093]=0; items[4092]=0; slider6=0;);//i,j,len,count=0 value=8192(from RRScript) 56 | play_state==0 ? (i=0; j=0;);//i,j=0 when playback stopped 57 | play_state==1||play_state==5 ? 58 | (i==0 ? (maxsamples = max(abs(spl0),abs(spl1)) * 10^16;//maxsmplval*10^16 59 | maxsamples>Thresh ? (items[4092]=1;//Its 1-st Item in Item_Count 60 | items[0]=play_position;//1-st item play_pos 61 | items[1]=0;//1-st item buf pos-offset,always=0 62 | j=2;) : items[4093]=0;);//Else reset TOTAL Lenght 63 | 64 | //==Save each Sample to buf[]==// 65 | i<=max_buf+res_buf && maxsamples>Thresh ? (buf[i]=spl0;buf[i+1]=spl1; 66 | items[4093]=i/2;//Its TOTAL Lenght 67 | //If,then Update temporary LAST_ITEM Lenght(in smpls)// 68 | i<=max_buf ? items[j]=i/2-items[j-1]/2; 69 | i+=2;); 70 | );//End 71 | //==Mute True,else Pass True(to next JS)==// 72 | i>max_buf ? (spl0=spl0;spl1=spl1;) : (spl0=0;spl1=0;); 73 | @gfx 1 1 74 | Insert==1 ? (Insert=0; export_buffer_to_project(S_Start,S_Len,2,srate,Track_Num,0,tempo); slider2=0;); 75 | 76 | " 77 | ;;;;;;////////////////////////////////////////////////////////////////////////////////////////// 78 | //////////////////////////////////////////////////////////////////////////////////////////////// 79 | 80 | function Create_JS_Utility() 81 | (GetResourcePath(#Res_Path);//Get Resouces Path 82 | #File_Patch = strcat(#JS_Folder_Name,#JS_FX_Name);//Concat strings 83 | #Full_Path = strcat(#Res_Path,#File_Patch);//Concat strings 84 | JS_FILE = fopen(#Full_Path, "w");//Create JSFX 85 | fwrite(JS_FILE,#JS_RRAudio, 0); 86 | fclose(JS_FILE); 87 | JS_FILE;//func return 88 | ); 89 | 90 | 91 | function Find_JS_Track()//==Find Track w JS-utility(uses #JS_Track_Name)==// 92 | (i=0;loop(CountTracks(0), Cur_Track_ID = GetTrack(0,i); 93 | GetSetMediaTrackInfo_String(Cur_Track_ID, "P_NAME", #Curr_Track_Name, 0); 94 | stricmp(#JS_Track_Name,#Curr_Track_Name) == 0 ? Track_ID = Cur_Track_ID;i+=1;); 95 | Track_ID;//Return 96 | ); 97 | 98 | function Insert_JS_Track()//===Insert Track(if not found);Create JS(if not Exist);Set Specific JS_Track Parameters===// 99 | ( InsertTrackAtIndex(0,Defaults);//Insert Track,Index=0 100 | Track_ID = GetTrack(0, 0); GetSetMediaTrackInfo_String(Track_ID, "P_NAME", #JS_Track_Name, 1);//Get Track_ID;Set Track Name 101 | SetMediaTrackInfo_Value(Track_ID,"B_SHOWINTCP",0);SetMediaTrackInfo_Value(Track_ID,"B_SHOWINMIXER",0);//Hide TRACK in TCP & Mixer 102 | FX_index = TrackFX_GetByName(Track_ID,#JS_FX_Name,1);//Insert JSFX and Get FX_index 103 | FX_index<0 ? (MB = MB("The desired JS-utility is not found!\nWould you like to create it?\n(In REAPER\\Effects\\utility folder)", "Info", 0); 104 | //===Create JS in Reaper resoursces folder(Patch\REAPER\Effects\midi)==// 105 | MB ? (Create_JS_Utility() ? FX_index=TrackFX_GetByName(Track_ID,#JS_FX_Name,1);//Create JS//Insert JSFX//Get index 106 | FX_index==0 ? MB("Successfully!", "Info", 0) : MB("Failed...", "Info", 0);););//Verify//End Create&Insert JSFX 107 | 108 | //==============Set Specific JS_Track Parameters==============// 109 | Track_ID>0 && FX_index==0 ? 110 | (SetMediaTrackInfo_Value(Track_ID,"I_RECARM",1);SetMediaTrackInfo_Value(Track_ID,"I_RECMON",1);//Rec-Arm = Enable//Rec-Monitor = Enable 111 | SetMediaTrackInfo_Value(Track_ID,"I_RECINPUT",Rec_IN);SetMediaTrackInfo_Value(Track_ID,"I_RECMODE",2);//Set Rec_IN and Mode=Disable(Mon Only) 112 | SetMediaTrackInfo_Value(Track_ID,"B_MAINSEND",0);//No send to master/parent track! 113 | //=====Clone JSFX(aka Buffers)-for RRAudio ONLY=====// 114 | RR_Type ? (SetOnlyTrackSelected(Track_ID);//Select Only! JS_Track 115 | Main_OnCommandEx(NamedCommandLookup("_S&M_COPYFXCHAIN5"), 0, 0);//Copy JS 116 | GetUserInputs("Set the number of buffers", 1 , "Set number of buffers(1-16):", #Buffs);//Set 117 | match("%i",#Buffs, Buffs);//as Integer = Buffs 118 | Buffs<1 ? Buffs=1; Buffs>16 ? Buffs=16;//If user set val<1 or val>16 119 | loop(Buffs-1, Main_OnCommandEx(NamedCommandLookup("_S&M_COPYFXCHAIN10"),0,0);); );//Paste(clone) JS 120 | SetMediaTrackInfo_Value(Track_ID,"I_SELECTED",0);//Unselect Track 121 | TrackList_AdjustWindows(0);//Update Tracklist 122 | MB("Done!","Info",0); );//End Set Specific JS_Track Parameters 123 | Track_ID;//Return 124 | ); 125 | //=====================================Main Operations and functions(RRAudio)=====================================// 126 | function Glue_Items() 127 | (CountSelectedMediaItems(0)>1 ? Main_OnCommandEx(40362, 0, 0);//IF count>1,Glue Sel Items 128 | items[Item_Number]=GetSelectedMediaItem(0,0);//Get-Save Glued_ID to items[] 129 | SelectAllMediaItems(0,0);//Unsel ALL Items in Project 130 | Item_Number+=1;//Next 131 | ); 132 | 133 | function Implode_Glued_Items() 134 | (New_Lenght=Max_Pos-Min_Pos;//Its Constant value For ALL Items 135 | Glued_Count=Item_Number;//Amt of Glued Items 136 | Item_Number=0; 137 | loop(Glued_Count, 138 | Glued_ID=items[Item_Number];//Get Glued_ID from items[Item_Number] 139 | Take_ID=GetActiveTake(Glued_ID);//Get Active Take_ID from Current Glued_Item 140 | Item_Start=GetMediaItemInfo_Value(Glued_ID, "D_POSITION");//Get Item Start 141 | Start_Offset=Min_Pos-Item_Start;//Calculate Offset for source Audio 142 | //==Set Item Parameters==// 143 | SetMediaItemInfo_Value(Glued_ID, "B_LOOPSRC", 0);//LoopSource=0 144 | SetMediaItemInfo_Value(Glued_ID, "D_POSITION", Min_Pos);//Set New Position 145 | SetMediaItemTakeInfo_Value(Take_ID, "D_STARTOFFS", Start_Offset);//Set Offset for Compensate Position 146 | SetMediaItemInfo_Value(Glued_ID, "D_LENGTH", New_Lenght);//Set New_Lenght for Item 147 | #NewName = #TrackName; 148 | sprintf(#Item_Number, "%d",Item_Number+1);//Num To String(and 1-based count) 149 | strcat(#NewName,#Item_Number);//Name + NUMBER 150 | GetSetMediaItemTakeInfo_String(Take_ID,"P_NAME",#NewName,1);//Rename Item to par_Track name+Num*** 151 | SetMediaItemSelected(Glued_ID,1);//Select Item 152 | Main_OnCommand(40543, 0);//Implode Selected Items into Takes 153 | Item_Number+=1; 154 | ); 155 | Main_OnCommand(NamedCommandLookup("_XENAKIOS_SELECTLASTTAKEOFITEMS"), 0);//Select Last Take in Item 156 | RESET ? (FX_index=0;loop(JS_FX_Count,TrackFX_SetParam(Track_ID,FX_index,5,8192);FX_index+=1;););//RESET JSs After Script Executed 157 | UpdateArrange();//Update the arrangement 158 | ); 159 | //====================================================================================================================// 160 | function Insert_and_Close()//execute until the condition is true 161 | (TrackFX_GetParam(Track_ID,FX_index,1,minval,maxval)>0 ? defer("Insert_and_Close();") : 162 | (TrackFX_Show(Track_ID, FX_index, 0);//Close After Insert 163 | Buf_Curr_Segm+=1; 164 | Buf_Segm_Count>Buf_Curr_Segm ? //To Next Buf Segment in Current JS 165 | defer("Set_JS_Parameters();") : //Else To Next JS 166 | (FX_index+=1;Buf_Curr_Segm=0;defer("Main();");); 167 | );//End 168 | ); 169 | 170 | function Set_JS_Parameters()//==Set Specific Parameters in JS for Insert Audio==// 171 | ( j=Buf_Curr_Segm*3;//j(3-base cycle) is special Value for Control JS parameters! 172 | TrackFX_SetParam(Track_ID, FX_index, 5, Latency);//Set SpecSlider(latency=BufOffset value) 173 | TrackFX_SetParam(Track_ID, FX_index, 2, j+2);//Set j+2 slot 174 | Lenght=TrackFX_GetParam(Track_ID,FX_index,3,minval,maxval);//Get Current Buf_Segment Length from JS(in smpls) 175 | TrackFX_SetParam(Track_ID, FX_index, 2, j);//Set j slot 176 | Buf_Start=TrackFX_GetParam(Track_ID,FX_index,3,minval,maxval)-Proj_Offset;//Get Buf_Start from JS(in sec),regard Proj_Offset 177 | //==IF Prev_End>Current_Start,Glue Prev_Selected Items(Buf_Segments)==// 178 | Buf_Curr_Segm>0 && (Buf_End-Buf_Start)>0.0001 ? Glue_Items(); 179 | Buf_End=Buf_Start+Lenght/srate;//Now Update Buf_End(in sec) 180 | //==Update Min_Pos,Max_Pos==// 181 | Min_Pos=min(Min_Pos,Buf_Start);//Update Min Position 182 | Max_Pos=max(Max_Pos,Buf_End);//Update Max Position 183 | //==Set Cursor,Call Insert_and_Close() 184 | SetEditCurPos(Buf_Start, 0, 0);//Set CursPos=Buf_Start for Insert Item 185 | TrackFX_SetParam(Track_ID, FX_index, 0, Track_Num-1);//Set Prmtr-Track number in JS 186 | TrackFX_SetParam(Track_ID, FX_index, 1, 1);//Set Prmtr-Insert Audio=1 in JS 187 | TrackFX_Show(Track_ID, FX_index, 1);//Open JS FX(it is necessary) 188 | Insert_and_Close();//Call Insert_and_Close() function 189 | ); 190 | 191 | function Main() 192 | (//==Get_Set JS Basic Parameters==// 193 | TrackFX_SetParam(Track_ID, FX_index, 2, 4092);//Set 4092 slot 194 | Buf_Segm_Count=TrackFX_GetParam(Track_ID,FX_index,3,minval,maxval);//Get Buf_Segm_Count from curr JS 195 | TrackFX_SetParam(Track_ID, FX_index, 2, 4093);//Set 4093 slot 196 | Total_Lenght=TrackFX_GetParam(Track_ID,FX_index,3,minval,maxval);//Get Total Buf Lenght from curr JS(in smpls) 197 | FX_index==0 ? (Min_Pos=65536;Max_Pos=-65536;);//Initial-reset Min-Max Positions 198 | 199 | //===Set_JS_Parameters() func , else(if ALL Inserted) Glue last items and Implode glued into Takes===// 200 | FX_index0 ? (Set_JS_Parameters();) : (Glue_Items(); Implode_Glued_Items();); 201 | 202 | ); 203 | //====================================================================================================================// 204 | 205 | //===========Basic Names and Main Data==========// 206 | #JS_FX_Name = "ForRetroRec(Audio) v20151213(b1)";//JS-utility Name 207 | #JS_Folder_Name = "/Effects/utility/";//Destination folder 208 | #JS_Track_Name = #JS_FX_Name;//JS_Track_Name(the same as JS_FX_Name) 209 | #Buffs="2";//Default Buffs Value in UserInput 210 | RR_Type = 1;//RR_FLAG(0=RRMidi;1=RRAudio) 211 | Rec_IN = 1024;//1024=Stereo Channels 212 | RESET=1;//RESET After ALL Audio Inserted(0=No,1=Yes) 213 | items = 8384512;//items offset 214 | 215 | //====Find_JS_Track====Insert,IF Track w JS-utility not Found====// 216 | Find_JS_Track() == 0 ? Insert_JS_Track();//Insert Track and JS(Create JS,if need) 217 | 218 | Sel_Track_ID = GetSelectedTrack(0,0);//Get 1-st selected Track ID(For ADD AUDIO-DATA) 219 | GetSetMediaTrackInfo_String(Sel_Track_ID, "P_NAME", #TrackName, 0);//Get Sel_Track_Name(for rename New Item-Takes) 220 | Track_Num = GetMediaTrackInfo_Value(Sel_Track_ID, "IP_TRACKNUMBER");//Get Track Number 221 | JS_FX_Count = TrackFX_GetCount(Track_ID);//Get JS_FX_Count 222 | 223 | //==Get Project Offset and Latency for RRAudio==// 224 | TrackFX_GetParam(Track_ID,FX_index,4,minval,maxval) ? //Get Comp Latency value from JS 225 | (TrackFX_SetParam(Track_ID, FX_index, 2, 4094);//Set slot 4094 226 | srate=TrackFX_GetParam(Track_ID,FX_index,3,minval,maxval);//Get Samplerate 227 | GetInputOutputLatency(In_Latency,Out_Latency);//Get Latency(in smpls) 228 | Latency=(In_Latency+Out_Latency););//Calc Total Latency(in smpls) 229 | Proj_Offset=GetProjectTimeOffset(0, rndframe);//Get Project Offset 230 | 231 | //====Insert Audio on the Track(if exist)====// 232 | Sel_Track_ID ? (SelectAllMediaItems(0,0); Main(););//Execute Main and all incusive functions 233 | -------------------------------------------------------------------------------- /Various/gen_True Stereo Takes Test.eel: -------------------------------------------------------------------------------- 1 | /* 2 | * ReaScript Name:True Stereo Takes Test 3 | * EEL script for Cockos REAPER 4 | * Author: EUGEN27771 5 | * Author URI: http://forum.cockos.com/member.php?u=50462 6 | * Licence: GPL v3 7 | * Version: 1.05 8 | */ 9 | 10 | 11 | 12 | 13 | /*---------------------------------------------------------- 14 | === Get mouse functions ==================================== 15 | ----------------------------------------------------------*/ 16 | function pointIN(p_x, p_y) 17 | instance(x,y,w,h) 18 | ( 19 | p_x >= x && p_x <= x+w && p_y >= y && p_y <= y+h; 20 | ); 21 | //------------------ 22 | function mouseIN() 23 | ( 24 | this.pointIN(mouse_x, mouse_y); 25 | ); 26 | //------------------ 27 | function mouseDown() 28 | ( 29 | mouse_down && this.mouseIN(); 30 | ); 31 | //------------------ 32 | function mouseUp() 33 | ( 34 | mouse_up && this.mouseIN(); 35 | ); 36 | //------------------ 37 | function mouseClick() 38 | ( 39 | this.mouseUp() && this.pointIN(mouse_down_x, mouse_down_y); 40 | ); 41 | 42 | /*---------------------------------------------------------- 43 | === BUTTON ================================================= 44 | ----------------------------------------------------------*/ 45 | //-- New button -------------- 46 | function button_New(x,y,w,h, r,g,b,a, lbl) 47 | ( 48 | this.x = x; this.y = y; this.w = w; this.h = h; // coord 49 | this.r = r; this.g = g; this.b = b; this.a = a; // color 50 | this.lbl = lbl; 51 | ); 52 | //-- Draw button ------------- 53 | function button_draw() 54 | instance(x,y,w,h, r,g,b,a, lbl, val) 55 | local(aa) 56 | ( 57 | aa = a; 58 | this.mouseIN() ? aa = a + 0.1; 59 | this.mouseDown() ? aa = a + 0.2; 60 | this.mouseClick() ? this.click=1 : this.click=0; 61 | 62 | //-- draw body, frame --- 63 | gfx_set(r,g,b,aa); 64 | gfx_rect(x,y,w-1,h-1, 1); 65 | gfx_rect(x,y,w,h, 0); // frame1 66 | //-- draw label --------- 67 | gfx_set(0.9,0.8,0.5,0.9); // font col 68 | gfx_x = x; gfx_y = y; 69 | gfx_drawstr(lbl, 5, x+w, y+h); 70 | 71 | ); 72 | 73 | 74 | /*---------------------------------------------------------- 75 | === SLIDER ================================================= 76 | ----------------------------------------------------------*/ 77 | //-- New slider -------------- 78 | function slider_New(x,y,w,h, r,g,b,a, lbl, val,min_val,max_val,val_unit) 79 | ( 80 | this.x = x; this.y = y; this.w = w; this.h = h; // coord 81 | this.r = r; this.g = g; this.b = b; this.a = a; // color 82 | this.lbl = lbl; 83 | this.min_val = min_val; 84 | this.max_val = max_val; 85 | this.val = val; 86 | this.val_unit = val_unit; 87 | this.norm_val = (val - min_val)/(max_val - min_val);; // norm value 88 | ); 89 | 90 | //-- set val on drag -------- 91 | function slider_set_value() 92 | instance(x,y,w,h, norm_val, val, min_val, max_val) 93 | local(K) 94 | ( 95 | K = 20; // K = coeff(when Ctrl pressed) 96 | Ctrl ? ( 97 | norm_val = norm_val + (mouse_x-mouse_last_x)/(w*K); 98 | ) : ( 99 | norm_val = (mouse_x-x)/w; 100 | ); 101 | 102 | norm_val = min( max(norm_val,0), 1 ); // verify and set value 103 | val = min_val + (max_val - min_val) * norm_val; 104 | val = floor(val); // floor for this script only 105 | ); 106 | 107 | //-- Draw slider ------------- 108 | function slider_draw() 109 | instance(x,y,w,h, r,g,b,a, lbl, norm_val, val, val_unit) 110 | local(aa, str) 111 | ( 112 | aa = a; 113 | mouse_up ? this.isCaptured = 0; 114 | this.mouseIN() ? aa = a + 0.1; 115 | this.mouseDown() ? this.isCaptured = 1; 116 | this.isCaptured ? ( 117 | aa = a + 0.2; 118 | this.slider_set_value(); 119 | ); 120 | 121 | //-- draw body, frame --- 122 | gfx_set(r, g, b, aa); 123 | gfx_rect(x, y, w, h, 0); 124 | gfx_rect(x, y, w*norm_val, h, 1); 125 | //-- draw label --------- 126 | gfx_set(0.9,0.8,0.5,0.9); // font col 127 | gfx_x = x + 5; gfx_y = y; 128 | gfx_drawstr(lbl, 4, x+w, y+h); 129 | //-- draw value --------- 130 | str = sprintf(#, "%d %s", val, val_unit); // "%d" for this script only 131 | gfx_x = x + 5; gfx_y = y; 132 | gfx_drawstr(str, 6, x+w-5, y+h); // draw Slider Value 133 | 134 | ); 135 | 136 | 137 | /*---------------------------------------------------------------------------------------- 138 | === Create controls ====================================================================== 139 | ----------------------------------------------------------------------------------------*/ 140 | 141 | //-- Create Sliders -------------------- 142 | //-- args = (x,y,w,h, r,g,b,a, lbl, val,min_val,max_val,val_unit) 143 | Diff_sldr.slider_New(10,10,240,18, 0.4,0.4,0.4,0.2, "Difference threshold ", -80, -150, -60, " dB" ); 144 | 145 | //-- Create Buttons -------------------- 146 | //-- args = (x,y,w,h, r,g,b,a, lbl) 147 | Start_btn.button_New(10,45,240,25, 0.5,0.5,0.5,0.2, "Set false-stereo to mono"); 148 | 149 | //======================================================================================// 150 | 151 | 152 | //---------------------------------------------------------- 153 | function Stereo_Test(item, take, srate, minDiff ) 154 | local(Stereo, item_len,len_smpls, 155 | block_size, n_blocks, last_block_size, AA, 156 | starttime_sec, smplbuf, cur_block, smpl) 157 | ( 158 | item_len = GetMediaItemInfo_Value(item, "D_LENGTH"); // item length 159 | //------------------------------------------------------ 160 | len_smpls = floor(item_len*srate); // length to samples 161 | block_size = 32768; // full block size(samples) 162 | n_blocks = floor(len_smpls/block_size); // number of full blocks 163 | last_block_size = len_smpls - block_size*n_blocks; // rest(incomplete last block) 164 | // ----------------------------------------------------- 165 | AA = CreateTakeAudioAccessor(take); 166 | starttime_sec = 0; // first block start 167 | smplbuf = 0; // smplbuf 168 | cur_block = 0; // cur block 169 | Stereo = 0; // init state 170 | 171 | // -- Test --------------------------------------------- 172 | while(!Stereo && cur_block <= n_blocks+1) ( 173 | memset(smplbuf, 0, block_size*2); // clear sample buffer 174 | cur_block == n_blocks ? block_size = last_block_size; // last block = rested samples 175 | 176 | // -- for each L-R sample in block ------- 177 | GetAudioAccessorSamples(AA, srate, 2, starttime_sec, block_size, smplbuf); 178 | smpl=0; 179 | loop(block_size, 180 | abs(smplbuf[smpl] - smplbuf[smpl+1]) > minDiff ? Stereo = 1; 181 | smpl+=2; 182 | ); 183 | 184 | starttime_sec+=block_size/srate; // next block starttime 185 | cur_block+=1; // block counter 186 | 187 | ); 188 | 189 | DestroyAudioAccessor(AA); 190 | 191 | Stereo; // return 192 | ); 193 | 194 | // --------------------------------------------------------- 195 | function RunTest() 196 | local(minDiff, item_cnt, i, item, take, PCM_source, srate, n_chans,chan_mode, mute_state, fake_stereo) 197 | ( 198 | minDiff = 10^(Diff_sldr.val/20); // dB to norm value 199 | item_cnt = CountSelectedMediaItems(0); 200 | fake_stereo = 0; 201 | Undo_BeginBlock(); 202 | i = 0; 203 | loop(item_cnt, 204 | //-- item, take data ----- 205 | item = GetSelectedMediaItem(0, i); // get sel item 206 | take = GetActiveTake(item); // active take 207 | PCM_source = GetMediaItemTake_Source(take); // source 208 | srate = GetMediaSourceSampleRate(PCM_source); // source srate(MIDI ret zero) 209 | 210 | //---------------------- 211 | srate ? ( 212 | n_chans = GetMediaSourceNumChannels(PCM_source); // source num channels 213 | chan_mode = GetMediaItemTakeInfo_Value(take, "I_CHANMODE"); // current chan mode 214 | //-------------------- 215 | n_chans == 2 && chan_mode == 0 ? ( 216 | mute_state = GetMediaItemInfo_Value(item, "B_MUTE"); // item mute_state 217 | mute_state ? SetMediaItemInfo_Value(item, "B_MUTE", 0); // unmute for test if muted 218 | !Stereo_Test(item, take, srate, minDiff) ? ( 219 | fake_stereo += 1; 220 | SetMediaItemTakeInfo_Value(take, "I_CHANMODE", 3); // set to "mono (left)" 221 | UpdateItemInProject(item); 222 | ); 223 | mute_state ? SetMediaItemInfo_Value(item, "B_MUTE", 1); // restore orig mute_state 224 | ); 225 | 226 | ); 227 | //---------------------- 228 | 229 | i+=1; 230 | ); 231 | Undo_EndBlock("True Stereo Takes Test", -1); 232 | 233 | fake_stereo; // ret 234 | ); 235 | 236 | //--------------------------------------------------------- 237 | function Info(msg, upd_gfx) 238 | ( 239 | gfx_x = 15; gfx_y = 85; 240 | gfx_drawstr(msg); 241 | upd_gfx ? gfx_update(); 242 | ); 243 | 244 | //---------------------------- 245 | function Draw_Controls() 246 | local(fake_stereo) 247 | ( 248 | //-- sliders --------------- 249 | Diff_sldr.slider_draw(); 250 | //-- buttons --------------- 251 | Start_btn.button_draw(); 252 | Start_btn.click ? ( 253 | info_msg = "Test running, expect..."; 254 | Info(info_msg, 1); 255 | fake_stereo = RunTest(); 256 | info_msg = sprintf(#,"%s %d %s", "Test finished,", fake_stereo, "takes fixed!"); 257 | ); 258 | Info(info_msg, 0) 259 | ); 260 | 261 | //-- mainloop ---------------- 262 | function mainloop() 263 | ( 264 | //-- get mouse ------- 265 | mouse_down = (mouse_cap&1) && !(mouse_last_cap&1); // L mouse 266 | mouse_up = (mouse_last_cap&1) && !(mouse_cap&1); // L mouse 267 | mouse_down ? (mouse_down_x = mouse_x; mouse_down_y = mouse_y;); 268 | Ctrl = mouse_cap&4; 269 | 270 | //--------------------- 271 | Draw_Controls(); 272 | 273 | //-- upd last mouse --- 274 | mouse_last_cap = mouse_cap; // upd last_cap 275 | mouse_last_x = mouse_x; // upd last_x 276 | mouse_last_y = mouse_y; // upd last_y 277 | 278 | //--------------------- 279 | char = gfx_getchar(); 280 | char ==26 ? Main_OnCommandEx(40029, 0, 0); //-- undo 281 | char == 32 ? Main_OnCommandEx(40044, 0, 0); //-- play 282 | char >= 0 ? defer("mainloop();"); //-- defer 283 | gfx_update(); 284 | ); 285 | 286 | //-- init -------------------- 287 | function Init() 288 | local(width, height, dockstate, xpos, ypos) 289 | ( //-- window ----------- 290 | width = 260; height = 120; dockstate = 0; xpos = 650; ypos = 350; 291 | gfx_init("True Stereo Takes Test",width,height,dockstate,xpos,ypos); 292 | gfx_clear = 20 + 20*256 + 20*65536; // bg 293 | gfx_setfont(1, "Tahoma", 14); 294 | info_msg = "Press button for run test!"; 295 | ); 296 | 297 | /*--------------------------------------- 298 | --- Start Script ------------------------ 299 | ---------------------------------------*/ 300 | Init(); 301 | mainloop(); 302 | --------------------------------------------------------------------------------