ChatGTP for Simple Tools

So I’m pretty sure Chatgtp just wrote the entire script for a load of keyboard shortcuts that I’ve been wanting. Did Chatgtp get anything wrong?

– Script Name: Sampler Shortcuts
– Version: 1.0
– Author: Your Name

– Function to set loop mode for the highlighted sample
local function setLoopMode(mode)
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].loop_mode = mode
end
end

– Function to set modulation for the highlighted sample
local function setModulation(modulation)
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].modulation_set_number = modulation
end
end

– Function to set FX for the highlighted sample
local function setFX(fx)
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index].fx_set_number = fx
end
end

– Function to toggle Quick Fade for the highlighted sample
local function toggleQuickFade()
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
local sample = renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index]
sample.use_quickfade = not sample.use_quickfade
end
end

– Function to toggle Velocity Tracking for the highlighted sample
local function toggleVelocityTracking()
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
local sample = renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index]
sample.use_velocity_tracking = not sample.use_velocity_tracking
end
end

– Function to apply the specified operation to all samples
local function applyOperationToAll(operationFunction)
if renoise.app().window.active_middle_frame == renoise.AppWindow.MIDDLE_FRAME_SAMPLER then
for _, sample in ipairs(renoise.song().instruments[renoise.song().selected_instrument_index].samples) do
operationFunction(sample)
end
end
end

– Function to set loop mode for all samples
local function setLoopModeAll(mode)
applyOperationToAll(function(sample) sample.loop_mode = mode end)
end

– Function to set modulation for all samples
local function setModulationAll(modulation)
applyOperationToAll(function(sample) sample.modulation_set_number = modulation end)
end

– Function to set FX for all samples
local function setFXAll(fx)
applyOperationToAll(function(sample) sample.fx_set_number = fx end)
end

– Function to toggle Quick Fade for all samples
local function toggleQuickFadeAll()
applyOperationToAll(function(sample) sample.use_quickfade = not sample.use_quickfade end)
end

– Function to toggle Velocity Tracking for all samples
local function toggleVelocityTrackingAll()
applyOperationToAll(function(sample) sample.use_velocity_tracking = not sample.use_velocity_tracking end)
end

– Register the tool in the Renoise menu
renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Loop Off”,
invoke = function() setLoopMode(renoise.Sample.LOOP_MODE_OFF) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Loop Forward”,
invoke = function() setLoopMode(renoise.Sample.LOOP_MODE_FORWARD) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Loop Backward”,
invoke = function() setLoopMode(renoise.Sample.LOOP_MODE_BACKWARD) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Loop Ping Pong”,
invoke = function() setLoopMode(renoise.Sample.LOOP_MODE_PING_PONG) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Disable Loop Exit”,
invoke = function() renoise.song().samples[renoise.song().selected_sample_index].loop_release = false end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Enable Loop Exit”,
invoke = function() renoise.song().samples[renoise.song().selected_sample_index].loop_release = true end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Mod None”,
invoke = function() setModulation(0) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Mod 1”,
invoke = function() setModulation(1) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Mod 2”,
invoke = function() setModulation(2) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set Mod 3”,
invoke = function() setModulation(3) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set FX None”,
invoke = function() setFX(0) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set FX 1”,
invoke = function() setFX(1) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set FX 2”,
invoke = function() setFX(2) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Set FX 3”,
invoke = function() setFX(3) end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Disable Quick Fade”,
invoke = function() toggleQuickFade() end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Enable Quick Fade”,
invoke = function() toggleQuickFade() end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Disable Velocity Tracking”,
invoke = function() toggleVelocityTracking() end
}

renoise.tool():add_menu_entry {
name = “Main Menu:Tools:Enable Velocity Tracking”,
invoke = function() toggleVelocityTracking() end
}

– Register shortcuts for all samples
renoise.tool():add_keybinding {
name = “Global:Tools:Set Loop Off ALL”,
invoke = function() setLoopModeAll(renoise.Sample.LOOP_MODE_OFF) end
}

renoise.tool():add_keybinding {
name = “Global:Tools:Set Loop Forward ALL”,
invoke = function() setLoopModeAll(renoise.Sample.LOOP_MODE_FORWARD) end
}

renoise.tool():add_keybinding {
name = “Global:Tools:Set Loop Backward ALL”,
invoke = function() setLoopMode

2 Likes

Interesting. Following the discussion out of curiosity!

If I were more experienced i would be able to see an error if there was one.

I’ll get a chance this weekend to test this as well as a few simpler scripts to see if ChatGTP is legit or not

I’m not sure if it works cause I’m to n00b to wrap this in a tool, but I suggest you ask chatgpt to create a version that can run testpad.lua from the scripting editor, that way you can quickly check ideas without having to actually create a tool for them right away.

1 Like

I don’t want to discourage you, but this is a waste of time.
It’s better to learn the API and use it as you like. This will just spit out a piece of something at you and you will only find fault with it. But if you don’t know the API, you won’t even find the error. I only use ChatGPT as an extended internet search :). As for some generated programs, it’s just a repayment of everything he finds. unfortunately or rather ‘it’s good’ :slight_smile:
I don’t know how the paid version is, I don’t use it.

2 Likes

Some things are wrong in terms of constants and property names.

With the latest ChatGPT 4 features (“custom GPT”), I wonder if it’s possible to feed it the API docs to avoid these errors.

1 Like

I asked it a few questions that I knew the answer to like “does the api give access to____ “ and it seemed spot on I did have to tell to rewrite a few times because when I looked at the script I could clearly see some hogwash.

Edit: I also asked it if it’s information could be updated via the user or fed new information and sadly it said no

Why not just write your own scripts? :upside_down_face:

1 Like

I’m no good, the best thing I can program is a command line calculator in c++ :sweat_smile:

I’m learning more and more though

2 Likes