Hi. I’m wondering, how do I modify a script that writes to automation, so, that it writes to Volume directly? Is there a way to talk to a specific automatable parameter directly. Currently script works like this:
won’t do anything unless if Volume is ticked (and becomes automatable parameter [1] )
requires mouse-clicking to assign automatable parameter[1] as Volume.
i’m looking to figure out how to tell the script to write the exponential curve directly into Volume, instead of having to assign the parameter as volume first. How does one do that? Here’s what I have currently:
function drawVol()
local input_min = 0
local input_max = math.pow(1.05,64)
local s=renoise.song()
local output_min = 0
local output_max = 1
local currTrak = s.selected_track_index
local currAut = s.selected_parameter_index
local currPatt = s.selected_pattern_index
renoise.song().patterns[currPatt].tracks[currTrak]:create_automation(1)
for i = 1,64 do
local input = math.pow(1.05,i)
local normalised_input = (input - 0) / (input_max - 0)
local scaled_output = output_min + (normalised_input * (output_max - output_min))
renoise.song().patterns[currPatt].tracks[currTrak].automation[1]:add_point_at(i, scaled_output)
end
end
I guess it’s because create_automation doesn’t have a specific parameter set up?
ahh, so it needs to not be a selected parameter, instead a specific parameter. that’s probably why it won’t w0rk
You’ll have to work out the correct maths function yourself but hopefully this snippet will get you towards creating the shortcuts you want to create fade ins and outs from the pattern editor and matrix.
local pos = renoise.song().transport.edit_pos
local x = renoise.song().selected_pattern_index
for i=1, renoise.song().selected_pattern.number_of_lines do
pos.line = i
renoise.song().transport.edit_pos = pos
renoise.song().selected_track.devices[1].parameters[2]:record_value(math.exp(i/renoise.song().selected_pattern.number_of_lines-1))
end
Forgot to mention the method mentioned in the above linked thread requires Edit Mode to be On to write the Automation. Hopefully this isn’t too much of an annoyance for you, especially as it is a way to access devices directly by device and parameter number, rather than by automation lane number (which changes depending on order created.)
That’s merged enough for me, I think. Okay, I did a little experiment (scuse my lua):
-- :::::Automation ExpCurve
function drawVol()
local input_min = 0
local input_max = math.pow(1.05,64)
local s=renoise.song()
local output_min = 0
local output_max = 1
local currTrak = s.selected_track_index
local currAut = s.selected_parameter_index
local currPatt = s.selected_pattern_index
local pos = renoise.song().transport.edit_pos
local scaled_output = nil
local normalised_input = nil
--renoise.song().patterns[currPatt].tracks[currTrak]:create_automation(1)
for i = 1,renoise.song().selected_pattern.number_of_lines do
pos.line= i
renoise.song().selected_track.devices[1].parameters[2]:record_value(i, scaled_output)
end
for i = 1,64 do
local input = math.pow(1.05,i)
local normalised_input = (input - 0) / (input_max - 0)
local scaled_output = output_min + (normalised_input * (output_max - output_min))
renoise.song().patterns[currPatt].tracks[currTrak].automation[1]:add_point_at(i, scaled_output)
end
end
renoise.tool():add_keybinding {name = "Global:Paketti:ExpCurveVol", invoke = function() drawVol() end}
and this line of record_value shoots an error:
*** No matching overload found, candidates:
*** void record_value(DeviceParameter&,custom [float])
tried to tick the Volume in Automation Envelope, experimented with switching edit_mode on/off, and experimented with “recorded rightclicked dsp-sliders go into envelope instead of pattern” (btw, as an aside, I’ve never clicked on this button and finally got it to save stuff into the automation editor as steps, seems real neat! (and it works step by step and during playback). Maybe there’s something to that automation after all
Anyway, so far it seems that for this regular “add point to automation[1]” is how it’s, umm, supposed to work, just need to either figure out how to replace automation[1] with “if automation[1].name = Volume then add expcurve to this, if name isn’t, create automation until it’s Volume”. not sure, just woke up
Well if you declare:
local scaled_output = nil
And you send this nil value as a parameter in renoise.song().selected_track.devices[1].parameters[2]:record_value(i, scaled_output),
then what would you expect it to do with a nil value?
Well, I did try to replicate the calculation work from the lower automation writer to what kazakore said, now, but so far it seems to not want to do anything:
function drawVol()
local input_min = 0
local input_max = math.pow(1.05,64)
local s=renoise.song()
local output_min = 0
local output_max = 1
local currTrak = s.selected_track_index
local currAut = s.selected_parameter_index
local currPatt = s.selected_pattern_index
local pos = renoise.song().transport.edit_pos
local scaled_output = nil
local normalised_input = nil
--renoise.song().patterns[currPatt].tracks[currTrak]:create_automation(1)
for i = 1,renoise.song().selected_pattern.number_of_lines do
local input = math.pow(1.05,i)
local normalised_input = (input - 0) / (input_max - 0)
local scaled_output = output_min + (normalised_input * (output_max - output_min))
--pos.line= i
renoise.song().selected_track.devices[1].parameters[2]:record_value(i, scaled_output)
end
for i = 1,64 do
local input = math.pow(1.05,i)
local normalised_input = (input - 0) / (input_max - 0)
local scaled_output = output_min + (normalised_input * (output_max - output_min))
renoise.song().patterns[currPatt].tracks[currTrak].automation[1]:add_point_at(i, scaled_output)
end
end
I suppose the for i = 1,64 woud work if i switched automation[1] to automation[currAut] and actually sent Renoise a command to select the Volume via scripting - but I really wonder what I’m missing here. Maybe it’s time for a complete rewrite – first make sure I can create Vol-automation when none exists, then make sure I can create a point in the Vol-automation even tho vol-automation is not selected or visible, then ram in the scaled output code…
The record_value(val) is looking for a single value to record at current edit point. Why are you trying to feed it two values? It’s not record at point i, hence why my For Loop is advancing Edit Position Line each iteration.
Also why not use “selected_track” rather than “patterns[currPatt].tracks[currTrak]” ??
Overall in your script change
--renoise.song().patterns[currPatt].tracks[currTrak]:create_automation(1)
for i = 1,renoise.song().selected_pattern.number_of_lines do
pos.line= i
renoise.song().selected_track.devices[1].parameters[2]:record_value(i, scaled_output)
end
for
--renoise.song().patterns[currPatt].tracks[currTrak]:create_automation(1)
for i = 1,renoise.song().selected_pattern.number_of_lines do
pos.line= i
renoise.song().transport.edit_pos = pos
renoise.song().selected_track.devices[1].parameters[2]:record_value(scaled_output)
end
and see if that works at all. Haven’t tried to read beyond the bit you say you get the reported error, which is based on my snippet.
One quick note: I’m not sure if you’re doing this on purpose, but it seems that you are using two variables named scaled_input scaled_output. I’ve picked them out in the code for easy reading. The first one is the ‘global’ one, and the second one is local within the for-loop scope. If you are intending to use the same variable, you don’t need the “local” keyword inside the for-loop.
Based on your math here is a finished snipped. All you need to do is wrap it in a function and give it a shortcut. It appears to be very close, but not exactly the same, as the ntive Renoise one where done on Pan (which seems to have a 0-1 value range.)
local pos = renoise.song().transport.edit_pos
local pos1 = renoise.song().transport.edit_pos
local edit = renoise.song().transport.edit_mode
local length = renoise.song().selected_pattern.number_of_lines
local curve = 1.105
for i=1, length do
renoise.song().transport.edit_mode = true
pos.line = i
renoise.song().transport.edit_pos = pos
renoise.song().selected_track.devices[1].parameters[2]:record_value(math.pow(curve, i) / math.pow(curve, length))
end
renoise.song().transport.edit_mode = edit
renoise.song().transport.edit_pos = pos1
You can change the sharpness of the curve by changing the curve variable.
As this record_value function seems to work on parameter values, rather than on the 0-1 range of Automation envelopes, adjustments will need to be made if you wish to scale it for other parameters. (Strangely Pan seems to be 0-1 rather than -50 - +50 so works for a comparison test to Native Exp function.)
EDIT:
curve = 1.047 will give mid point at ~3/4 of a pattern.
curve = 1.105 will give mid point at ~7/8 of a pattern.
or thereabouts.
EDIT2:
Removed unused variable x.
Added a return to original position at the end so it doesn’t always dump you on the last line.
Thanks kaz. I decided to go for [2].[1] on the device, and before that, create a native Gain as the first trackdsp - so now there’s a exponential curve in the track effect column, controlling or fading in a Gainer ever so slowly and quick at the end. this will be useful for a few things, especially older trax where i don’t use any effect columns for any efx.
hmmmmm. while i was tryin to say “cool, but” without saying “cool, but”, something else occurred to me:
can these be converted into the automation envelope editor? does renoise offer a possibility of stating that a specific bunch of track dsp changes can be transferred into the automation editor to the matching parameter?
Just changed above, noticed I had it for parameter [1] which is Pan.
Seems strange this Record function works with something approaching real values, rather than the 0-1 range Automation Envelopes themselves work in. Not sure of the best way to adjust them or convert. I have done a snippet that will work for almost all Unipolar parameters though. So far I have found it still generates out of range values for Inertia though, so needs to have an adjustment for that. I tried one adjustment and it caused it to fail when trying with Compressor Threshold so I went back (plus that bodge would set all to min in Bipolar, rather than Unipolar, parameters.)
I think a check of if the value is above or below minimum and then adjust to min/max would be suitable enough to iron out the last little bit but haven’t done so. Also felt I preferred the sharper curve of 1.105 then the one closer to Renoise’s native.
EDIT: Thought I’d iron that out and post something that should work for ALL Unipolar parameters, rather than just most
local pos = renoise.song().transport.edit_pos
local pos1 = renoise.song().transport.edit_pos
local edit = renoise.song().transport.edit_mode
local length = renoise.song().selected_pattern.number_of_lines
local min = renoise.song().selected_parameter.value_min
local max = renoise.song().selected_parameter.value_max
local range = min + max
local val = 0
local curve = (math.sqrt(1 / length)) + 1
for i=1, length do
renoise.song().transport.edit_mode = true
pos.line = i
renoise.song().transport.edit_pos = pos
val = range * (math.pow(curve, i) / math.pow(curve, length))
if val > max then val = max
elseif val < min then val = min
end
renoise.song().selected_parameter:record_value(val)
end
renoise.song().transport.edit_mode = edit
renoise.song().transport.edit_pos = pos1
I didn’t think about how much this is affected by Pattern Length. Currently trying to think if there’s any way to get it closer to uniform on any length… These numbers are for length of 64 lines.
Although not perfect you can get something that looks like it would be usable with “local curve = (math.sqrt(1 / length)) + 1”