I’m trying to build a function that manages to swap two consecutive note columns (only inside a line, not the entire note column).For the moment, I have built a function that changes the selected note’s position, specifically in the right note column.
function pht_msc3_move_note_r()
local snci = song().selected_note_column_index
local clm = snci + 1
if ( clm <= 12 ) and ( song().selected_effect_column == nil ) then
if not ( song().selected_note_column.is_empty ) then
if ( song().selected_track.visible_note_columns < clm ) then
song().selected_track.visible_note_columns = clm
end
song().selected_line:note_column( clm ):copy_from( song().selected_note_column )
song().selected_note_column:clear()
song().selected_note_column_index = clm
else
pht_change_status( "No data to move!" )
end
else
pht_change_status( "Select a valid note column (< 12) to move data!" )
end
end
But I have already tried to build a function derived from it that allows to invert the values of both note columns.For example, if the original data is these:
F-5 01 72 00 00* - C-4 03 56 00 00
The result would be this:
C-4 03 56 00 00 - F-5 01 72 00 00*
(*this selected)
To do this I create two tables to store the data, or even copy the entire line in a data buffer. But, if I change one of the columns of value notes, it is also saved in that buffer.How can I generate a data buffer that will not change once the data is stored in it? I could use another line or another “temporal track” to duplicate the data there, but I do not like this solution at all.
This is another almost absurd example. The function rotates itself by modifying the data. It is clear that it is badly focused:
function pht_msc3_move_note_r()
local snci = song().selected_note_column_index
local clm = snci + 1
local buffer_pos_1 = song().selected_note_column
local buffer_pos_2 = song().selected_line:note_column( clm )
if ( clm <= 12 ) and ( song().selected_effect_column == nil ) then
if not ( song().selected_note_column.is_empty ) then
if ( song().selected_track.visible_note_columns < clm ) then
song().selected_track.visible_note_columns = clm
end
song().selected_line:note_column( clm ).note_value = buffer_pos_1.note_value
song().selected_line:note_column( clm ).instrument_value = buffer_pos_1.instrument_value
song().selected_line:note_column( clm ).volume_value = buffer_pos_1.volume_value
song().selected_line:note_column( clm ).panning_value = buffer_pos_1.panning_value
song().selected_line:note_column( clm ).delay_value = buffer_pos_1.delay_value
song().selected_line:note_column( clm ).effect_number_value = buffer_pos_1.effect_number_value
song().selected_line:note_column( clm ).effect_amount_value = buffer_pos_1.effect_amount_value
---
song().selected_note_column.note_value = buffer_pos_2.note_value
song().selected_note_column.instrument_value = buffer_pos_2.instrument_value
song().selected_note_column.volume_value = buffer_pos_2.volume_value
song().selected_note_column.panning_value = buffer_pos_2.panning_value
song().selected_note_column.delay_value = buffer_pos_2.delay_value
song().selected_note_column.effect_number_value = buffer_pos_2.effect_number_value
song().selected_note_column.effect_amount_value = buffer_pos_2.effect_amount_value
--song().selected_line:note_column( clm ):copy_from( song().selected_note_column )
--song().selected_note_column:clear()
--song().selected_note_column_index = clm
else
pht_change_status( "No data to move!" )
end
else
pht_change_status( "Select a valid note column (< 12) to move data!" )
end
end
(It is possible to do the same without breaking down so much data, copying the entire table from note_column).
So, where do I duplicate the data in order to keep them?The fact is that, after modifying any original data in the two columns of notes, keep having the old data stored somewhere. Any ideas?
Thanks!
Note: do not confuse this issue withrenoise.song().tracks[]:swap_note_columns_at(index1, index2),that changes the entire note columns. I just want to interact within a line inside the note_columns.