neat, this is pretty hot, this means that i can create a secondary shortcut where no 1-5 is defined, and i can then have that hide, or display volume, panning, delay columns! or reset them, or something.
So I made a switch, and I hope it’ll work - still not sure about the panning segment of this.
if thing == 1 then
--delay column
renoise.song().tracks[currTrak].delay_column_visible=true
nc.delay_value = math.max(0, math.min(255, columns[thing] + chg))
elseif thing == 2 then
--panning column
renoise.song().tracks[currTrak].panning_column_visible=true
--if panning_string is ".." replace it with "40" (so panning is centered) - this should mean that where we start panning from
--is always center.
if nc.panning_string==".." then nc.panning_value = 40 else end
--controls for going between -10 and 128 in panning (00-80)
nc.panning_value = math.max(-10, math.min(128, columns[thing] + chg))
-- if panning_value is below 0, write ".." as panning_string.
if nc.panning_value < 0 then nc.panning_string=".." else end
elseif thing == 3 then
--volume column
renoise.song().tracks[currTrak].volume_column_visible=true
nc.volume_value = math.max(0, math.min(128, columns[thing] + chg))
elseif thing == 4 then
--effect number column
renoise.song().patterns[currPatt].tracks[currTrak].lines[currLine].effect_columns[1].number_value = math.max(0, math.min(255, columns[thing] + chg))
elseif thing == 5 then
--effect amount column
-- renoise.song().tracks[currTrak].sample_effects_column_visible=true
renoise.song().patterns[currPatt].tracks[currTrak].lines[currLine].effect_columns[1].amount_value = math.max(0, math.min(255, columns[thing] + chg))
else
-- default, shows panning, delay, volume columns.
renoise.song().tracks[currTrak].delay_column_visible=true
renoise.song().tracks[currTrak].panning_column_visible=true
renoise.song().tracks[currTrak].volume_column_visible=true
end
I’m still not sure how to proceed with a table with selected_note_column or selected_effect_column, cos neither exists if the other is selected. Kinda hard?
thanks joule for the response btw!
Some suggestions related to optimization / reading / abbreviate:
-
Do not call so many times renoise.song().Instead, define at the beginning of the function: **song = renoise.song()**and then use song all the time ( song , or rns , or s… the name you want).For the names I recommend using 3 letters.
-
Instead ofrenoise.song().tracks[currTrak].delay_column_visible = true,use song.selected_track.delay_column_visible = true, It is not necessary to define the value of the index (currTrack) if you can call the object (selected_track).Do the same with similar cases.
3.1) Branches the functions: if nc.panning_value < 0 then nc.panning_string=“…” else end better so, to be easier to read for you:
if ( nc.panning_value < 0 ) then
nc.panning_string = “…”
end
3.2) else is useless in front of an end.Supposedly, are you going to add something between them?Otherwise, delete else
3.3) nc.panning_value < 0 ??? if the function is reading the value in the pattern editor it will never give < 0
-
instead nc.panning_string=“…” you can use nc.panning_value = 255 (empty).It is not necessary to mix the .string with the .value in a condition
-
insteadrenoise.song().patterns[currPatt].tracks[currTrak].lines[currLine].effect_columns[1].number_value = math.max(0, math.min(255, columns[thing] + chg)), you can use:
song.selected_pattern_track.selected_line:effect_column(1).number_value = math.max(0, math.min(255, columns[thing] + chg))
6)Can the value thing be greater than 5?If it can not be greater than 5it does not make sense to write this:
…
else
– default, shows panning, delay, volume columns.
renoise.song().tracks[currTrak].delay_column_visible=true
renoise.song().tracks[currTrak].panning_column_visible=true
renoise.song().tracks[currTrak].volume_column_visible=true
end
I think something will not work well in this function. Some things are not coherent.I do not usually try to improve others’ codes.But it helps me to practice the code.I am also in continuous learning.If something is wrong, someone can always comment on the error.
For example the case 6), look at the red lines:
if thing == 1 then
–delay column
renoise.song().tracks[currTrak].delay_column_visible=true
nc.delay_value = math.max(0, math.min(255, columns[thing] + chg))
elseif thing == 2 then
–panning column
renoise.song().tracks[currTrak].panning_column_visible=true
–if panning_string is “…” replace it with “40” (so panning is centered) - this should mean that where we start panning from
–is always center.
if nc.panning_string==“…” then nc.panning_value = 40 else end
–controls for going between -10 and 128 in panning (00-80)
nc.panning_value = math.max(-10, math.min(128, columns[thing] + chg))
– if panning_value is below 0, write “…” as panning_string.
if nc.panning_value < 0 then nc.panning_string=“…” else end
elseif thing == 3 then
–volume column
renoise.song().tracks[currTrak].volume_column_visible=true
nc.volume_value = math.max(0, math.min(128, columns[thing] + chg))
elseif thing == 4 then
–effect number column
renoise.song().patterns[currPatt].tracks[currTrak].lines[currLine].effect_columns[1].number_value = math.max(0, math.min(255, columns[thing] + chg))
elseif thing == 5 then
–effect amount column
– renoise.song().tracks[currTrak].sample_effects_column_visible=true
renoise.song().patterns[currPatt].tracks[currTrak].lines[currLine].effect_columns[1].amount_value = math.max(0, math.min(255, columns[thing] + chg))
else
– default, shows panning, delay, volume columns.
renoise.song().tracks[currTrak].delay_column_visible=true
renoise.song().tracks[currTrak].panning_column_visible=true
renoise.song().tracks[currTrak].volume_column_visible=true
end
Does that work well?