Start/ End selection

Hello people, does scripting api gives access to the begin/ end selection via code?

Thank you!

1 Like

This function set a specific range. You have to know where the selection ends and where it begins. What I want to do, is to use a midi controller to set a range.
Press a button to start selection, navigate the cursor using the controller and press another button to end selection.
Maybe it could be performed with a state variable in the script needed to run (something like “save value” and after that, “recall value”), but I dont know if that is possible.

You have the necessary indexes to do that:

  • selected_line_index
  • selected_track_index
  • selected_note_column_index
  • selected_effect_column_index
  • There is no access to change the position in the sub_columns.

Therefore, you can do everything you want with line, track or column, even just using a button to set the start and end (minus MIDI assignments).

I don’t understand, say that I have the start index of the track and the column. How do I set the ending indexes?

Here is an example that I just programmed:

--define a table
local TBL_SEL={
    start_line=nil,
    start_track=nil,
    start_column=nil,

    end_line=nil,
    end_track=nil,
    end_column=nil
}

--define a start seleccion function
local function start()
  local song=renoise.song()
  --save the table
  TBL_SEL.start_line=song.selected_line_index
  TBL_SEL.start_track=song.selected_track_index
  TBL_SEL.start_column=1 --song.selected_track.visible_note_columns

  TBL_SEL.end_line=song.selected_line_index
  TBL_SEL.end_track=song.selected_track_index
  TBL_SEL.end_column=song.selected_track.visible_note_columns + song.selected_track.visible_effect_columns
  
  --select the current line inside the current track
  song.selection_in_pattern={
    start_line=TBL_SEL.start_line,
    start_track=TBL_SEL.start_track,
    start_column=TBL_SEL.start_column,

    end_line=TBL_SEL.end_line,
    end_track=TBL_SEL.end_track,
    end_column=TBL_SEL.end_column
  }
end

--bang!
start()

You will see that there is a local table “TBL_SEL” where you can save the values you want to use them later.

The start () function first stores the convenient values in the table (all 6) and then makes the selection. This function will select the entire current line contained in the current track. This would be your initial selection.

Then you can create another end() function, for example, by taking advantage of the values previously saved in the table, conveniently. You should know how to deduce it yourself.

?

This is what I would do. But first, you try to play with the values, to deduce it yourself. It is possible to make different types of selections.

--define a table
local TBL_SEL={
  state=false,
  start_line=nil,
  start_track=nil,
  start_column=nil,

  end_line=nil,
  end_track=nil,
  end_column=nil
}
--define a start seleccion function
local function start_end()
  local song=renoise.song()
  if not TBL_SEL.state then
    TBL_SEL.state=true
    --save the table
    TBL_SEL.start_line=song.selected_line_index
    TBL_SEL.start_track=song.selected_track_index
    TBL_SEL.start_column=1 --song.selected_track.visible_note_columns
  
    TBL_SEL.end_line=song.selected_line_index
    TBL_SEL.end_track=song.selected_track_index
    TBL_SEL.end_column=song.selected_track.visible_note_columns + song.selected_track.visible_effect_columns
    
    --select the current line inside the current track
    song.selection_in_pattern={
      start_line=TBL_SEL.start_line,
      start_track=TBL_SEL.start_track,
      start_column=TBL_SEL.start_column,
  
      end_line=TBL_SEL.end_line,
      end_track=TBL_SEL.end_track,
      end_column=TBL_SEL.end_column
    }
  else
    TBL_SEL.state=false
    --select the current line inside the current track
    song.selection_in_pattern={
      start_line=TBL_SEL.start_line,
      start_track=TBL_SEL.start_track,
      start_column=TBL_SEL.start_column,
  
      end_line=song.selected_line_index,
      end_track=song.selected_track_index,
      end_column=TBL_SEL.end_column
    } 
  end
end

--bang!
start_end()
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.