Shortcut To Native Trackdsp Shortcuts? (Solved)

Hi. Is there a way of polling the Native TrackDSP names and to wrap the results to shortcuts? I just did this monkeywork

[details=“Click to view contents”]

renoise.tool():add_keybinding {  
name = "Global:Track Devices:Load Bus Compressor",   
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Bus Compressor",2)   
end }  
renoise.tool():add_keybinding {  
name = "Global:Track Devices:Load Cabinet Simulator",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Cabinet Simulator",2)   
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Chorus",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Chorus",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Comb Filter",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Comb Filter",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Compressor",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Compressor",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load DC Offset",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/DC Offset",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Delay",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Delay",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Distortion",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Distortion",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load EQ 10",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/EQ 10",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load EQ 5",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/EQ 5",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Filter",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Filter",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Flanger",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Flanger",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Gainer",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Gainer",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Gate",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Gate",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load LofiMat",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/LofiMat",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Maximizer",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Maximizer",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Mixer EQ",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Mixer EQ",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load mpReverb",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/mpReverb",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Phaser",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Phaser",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Reverb",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Reverb",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load RingMod",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/RingMod",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Scream Filter",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Scream Filter",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Stereo Expander",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/Stereo Expander",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load #Line Input",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ #Receive/#Line Input",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load #ReWire Input",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ #Receive/#ReWire Input",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load #Multiband Send",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ #Send/#Multiband Send",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load #Send",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ #Send/#Send",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Hydra",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Hydra",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Instr. Automation",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Instr. Automation",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Instr. MIDI Control",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Instr. MIDI Control",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Key Tracker",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Key Tracker",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/LFO",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*LFO",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Signal Follower",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Signal Follower",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/Velocity Tracker",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*Velocity Tracker",2)  
end }  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load Meta/XY Pad",  
invoke = function() renoise.song().selected_track:insert_device_at("Audio/Effects/ *Meta/*XY Pad",2)  
end }  
  
``` [/details]  
  
And it most certainly works, however, if Renoise suddenly gets more Native TrackDSPs, I'll have to issue an update.  
  
So  
1) How do I "just read" the Native TrackDSP-devices and output the results to keybinds  
2) How do I also invoke a second function so that it changes to displaying track_dsp view (I noticed that these shortcuts work even if TrackDSP is not displayed, but I think it'll be better for the user to just be able to press a shortcut and see trackdsp-view and see the track-dspdevice being added.  
  
To answer 2), I did, of course, get this to work:  
```lua  
renoise.tool():add_keybinding {  
name="Global:Track Devices:Load EQ 10",  
invoke = function() renoise.app().window.lower_frame_is_visible=true  
renoise.app().window.active_lower_frame=1  
renoise.song().selected_track:insert_device_at("Audio/Effects/ Native/EQ 10",2)  
end }  

However, while it’s possible for me to do more monkeywork and just copypaste those 2 definitions to each and every keybind, it just makes me wonder if it is a bit redundant.

Okay… Now it seems that the next step is to

get either a list going or a something so that both add_menu_entries adn add_keybinds can be done out of the rprint result.
Because noone’s going to write them by hand especially if there’s then going to be changes to it in such a way as to define where in the track dsp “window” they are in.
I’m currently bruteforcing setting every shortcut to adding it to 2, and if there’s to be menu entries in the track dsp view then it’ll have to be place-sensitive. Can that be done?

You can get a list of available devices (including VST/AU plug-ins) like so:

  
print('Listing all devices...')  
for device_index, device_name in ipairs(renoise.song().selected_track.available_devices) do  
 print(device_index .. ' = ' .. device_name)  
end  
  

If you’re only interested in the native devices, then you can try this:

  
print('Listing all native devices...')  
local native_device_prefix = "Audio/Effects/ "  
for device_index, device_name in ipairs(renoise.song().selected_track.available_devices) do  
 if (device_name:find(native_device_prefix) ~= nil) then  
 print(device_index .. ' = ' .. device_name)  
 else  
 print('End of native devices')  
 break  
 end  
end  
  

Ok, so my question is - where is this “saved” to? Can it be retained as a list of stuff, which can then be for’d into the required_amount of keyentries and menuentries?

It’s not saved anywhere. It’s up to you to actually do something useful with the information :)

But here’s a hint for you. You could put something like this inside the device name loop:

  
renoise.tool():add_keybinding {  
 name = "Global:Track Devices:Load " .. device_name,  
 invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2) end   
}  
  

Thanks dBlue! I got it working like this:

  
function listnatives()  
print('Listing all native devices...')  
local native_device_prefix = "Audio/Effects/ "  
for device_index, device_name in ipairs(renoise.song().selected_track.available_devices) do  
 if (device_name:find(native_device_prefix) ~= nil) then  
 print(device_index .. ' = ' .. device_name)  
 renoise.tool():add_keybinding {  
 name = "Global:Track Devices:Load " .. device_name,  
 invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2) end   
}   
renoise.tool():add_menu_entry {  
name = "Sample Editor:InsertDevice " .. device_name,  
invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2) end  
}  
 else  
 print('End of native devices')  
 break  
 end  
end  
end  
  
renoise.tool():add_keybinding {  
 name = "Global:Impulse:Read Natives",  
 invoke = function() listnatives()  
 end  
 }  

Once the shortcut has been jumped, the result is:

!! It’s v. nice. However, it’ll immediately stop working once there’s new stuff added, because the keybinder adder gives an error at Bus Compressor if re-run, because it already exists :)


:walkman:

  
if (not renoise.tool():has_keybinding('foo')) then  
 renoise.tool():add_keybinding {  
 name = 'foo',  
 invoke = function() ... end  
 }  
end  
  

Or if you wanted to remove the existing one and replace it:

  
if (renoise.tool():has_keybinding('foo')) then  
 renoise.tool():remove_keybinding('foo')  
 renoise.tool():add_keybinding {  
 name = 'foo',  
 invoke = function() ... end  
 }  
end  
  

:)

Perhaps I’m going about it the wrong way?

function listnatives()  
print('Listing all native devices...')  
local native_device_prefix = "Audio/Effects/ "  
for device_index, device_name in ipairs(renoise.song().selected_track.available_devices) do  
 if (device_name:find(native_device_prefix) ~= nil) then  
 print(device_index .. ' = ' .. device_name)  
 if (renoise.tool():has_keybinding("Global:Track Devices:Load " .. device_name)) then  
 renoise.tool():remove_keybinding("Global:Track Devices:Load " .. device_name)  
 renoise.tool():add_keybinding {  
 name = "Global:Track Devices:Load " .. device_name,  
 invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2)  
 renoise.app():show_status("Shortcut for " .. device_name .. "loaded") end}  
else  
 renoise.tool():add_keybinding {  
 name = "Global:Track Devices:Load " .. device_name,  
 invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2)  
 renoise.app():show_status("Shortcut for " .. device_name .. "loaded")   
 end }   
  
 end  
renoise.tool():add_menu_entry {  
name = "Track DSPs Chain:NativeFX..:Load " .. device_name,  
invoke = function() renoise.song().selected_track:insert_device_at(device_name, 2)   
 renoise.app():show_status("Context Menu for " .. device_name .. "loaded")   
  
end  
}  
 else  
 print('End of native devices')  
 break  
 end  
end  
end  
  
renoise.tool():add_keybinding {  
 name = "Global:Impulse:Read Natives",  
 invoke = function() listnatives()  
 end  
 }  

Seems fine, but could be a bit more organised and cleaner overall.

Try this:

  
local function insert_device(device_name)  
 renoise.song().selected_track:insert_device_at(device_name, 2)  
end  
  
local function list_native_devices()  
  
 local app = renoise.app()  
 local tool = renoise.tool()  
 local track = renoise.song().selected_track  
 local prefix = "Audio/Effects/ "  
  
 -- Iterate through available devices  
 for _, device_name in ipairs(track.available_devices) do  
  
 -- Only match native devices  
 if (device_name:find(prefix) ~= nil) then  
  
 -- Keybinding name  
 local keybinding_name = "Global:Track Devices:Load " .. device_name  
  
 -- Remove keybinding if it already exists  
 if (tool:has_keybinding(keybinding_name)) then  
 tool:remove_keybinding(keybinding_name)  
 app:show_status("Keybinding Removed: " .. keybinding_name)  
 end  
  
 -- Add keybinding  
 tool:add_keybinding {  
 name = keybinding_name,  
 invoke = function()   
 insert_device(device_name)   
 end  
 }  
 app:show_status("Keybinding Added: " .. keybinding_name)  
  
 -- Menu entry name  
 local menu_name = "Track DSPs Chain:NativeFX..:Load " .. device_name  
  
 -- Remove menu entry if it already exists  
 if (tool:has_menu_entry(menu_name)) then  
 tool:remove_menu_entry(menu_name)  
 app:show_status("Menu Entry Removed: " .. menu_name)  
 end  
  
 -- Add menu entry  
 tool:add_menu_entry {  
 name = menu_name,  
 invoke = function()  
 insert_device(device_name)  
 end  
 }  
 app:show_status("Menu Entry Added: " .. menu_name)  
  
 else  
  
 -- No more native devices to process  
 break  
  
 end  
  
 end  
  
end  
  
renoise.tool():add_keybinding {  
 name = "Global:Impulse:List Native Devices",  
 invoke = function()   
 list_native_devices()  
 end  
}  
  

After loads of help from dBlue I’m really glad to say that the Native FX now are rightclickable from Mixer-view, TrackDSP view, and shortcuttable.
Every toggle however loads it as the first (second) channel. But that’s definitely good already. Woo!

Here’s a little TrackDSP shortcut wigout.
http://www.youtube.com/watch?v=vq3F89Q-4MY

You can find the script at impulsecomplex

Now I just need to figure out how to modify that script so that it lists VST/AU and retains them. Interestingly enough I haven’t been able to do that, which is weird in itself, maybe the code is too advanced for me still :)