Renoise.song().selection_in_pattern not work initially

It seems that the selection does not appear in the pattern editor despite defining the entire table in selection_in_pattern, if the user does not make a first selection with the mouse pointer first (or some selection keyboard command).

So the table may exist but the selection in the pattern editor is missing.

Steps to reproduce it:

  1. Create a tool with an X function that correctly defines the entire table:

    renoise.song().selection_in_pattern = {
      a=b,
      c=d,
      bla bla = bla
    }
    
  2. Create a button to execute that function.

  3. Create a new song (File/New Song). In the new song the table selection_in_pattern is “nil”. Do not touch anything in the pattern editor with the mouse!

  4. Execute the X function.

What happens

Function X will define the table (the table exist), but Renoise will not be able to display the selection in the pattern editor.

The problem is that first it will be necessary for the user to make a selection with the mouse pointer (or some selection keyboard command) and that is not desirable. The selection should appear from the beginning.

1 Like

This works here, whether run in testpad or in a button function of a tool gui.

Fresh song, no selection as you say:

local tab = { start_line = 1, start_track = 1, end_line = 4, end_track = 1 }
renoise.song().selection_in_pattern = tab

keyboard shortcut: Test Selection

ledger.scripts.TestSelection_V1.xrnx (2.0 KB)

Line 104 for the inline notifier function

Sorry. I did not indicate that I am on Renoise 3.2.2 and W10 x64.

I have tested your tool and it doesn’t work either.

I am talking about the first selection. The user needs to “wake up” the selection with an action (either by selecting with the mouse or keyboard commands), for the selection to be displayed in the pattern editor. Once the user has done that by ignoring the tool, then the tool will work.

selection fail
This gif has been captured after doing File / New Song

It may be necessary to use an observable, but it would only work for the first time. For the rest it would be useless.

It is as if Renoise changed the state of some variable from disable to enable when the user intervenes when selecting for the first time and the API fails to do so.

Just quickly mention, idk seems to work here under Linux x64 (no heavy tools running) Renoise 3.2.2.
file

Yeah, it works here too. Maybe it’s another tool that causes the disturbance? (the selection actually being made but reset before becoming visible)

hmm, it is a strange one!

I also tried with no luck:

  • disabling ‘Lock Keyboard Focus’
  • Loading ‘New Song (No Template)’ in menu

Maybe it is another tool like joule and 4tey say. A next step could be to search your tool folder for renoise.tool() notifiers being added like:

renoise.tool().app_new_document_observable

note: best to leave out ‘renoise.tool()’ in the search in case someone did local x = renoise.tool() before invoking.

If you use something like Notepad++ you can do this fairly quickly with a Ctrl + Shift + F search and point the search to your whole renoise tool folder using the Directory field

/////

Other potential searches below if you have the time and will power! Some may be more relevant than others. Again I’d leave out ‘renoise.tool()’ part in the search.

click here

-------- Properties

– Full absolute path and name to your tool’s bundle directory.
renoise.tool().bundle_path
-> [read-only, string]

– Invoked when the tool finished loading/initializing and no errors happened. When
– the tool has preferences, they are loaded here as well when the notification fires,
– but ‘renoise.song()’ may not yet be available.
– See also ‘renoise.tool().app_new_document_observable’.
renoise.tool().tool_finished_loading_observable
-> [renoise.Document.Observable object]

– Invoked right before a tool gets unloaded: either because it got disabled, reloaded
– or the application exists. You can cleanup resources or connections to other devices
– here if necessary.
renoise.tool().tool_will_unload_observable
-> [renoise.Document.Observable object]

– Invoked as soon as the application becomes the foreground window.
– For example, when you ATL-TAB to it, or activate it with the mouse
– from another app to Renoise.
renoise.tool().app_became_active_observable
-> [renoise.Document.Observable object]

– Invoked as soon as the application looses focus and another app
– becomes the foreground window.
renoise.tool().app_resigned_active_observable
-> [renoise.Document.Observable object]

– Invoked periodically in the background, more often when the work load
– is low, less often when Renoise’s work load is high.
– The exact interval is undefined and can not be relied on, but will be
– around 10 times per sec.
– You can do stuff in the background without blocking the application here.
– Be gentle and don’t do CPU heavy stuff please!
renoise.tool().app_idle_observable
-> [renoise.Document.Observable object]

– Invoked each time before a new document gets created or loaded: this is the
– last time renoise.song() still points to the old song before a new one arrives.
– You can explicitly release notifiers to the old document here, or do your own
– housekeeping. Also called right before the application exits.
renoise.tool().app_release_document_observable
-> [renoise.Document.Observable object]

– Invoked each time a new document (song) is created or loaded. In other words:
– each time the result of renoise.song() is changed. Also called when the script
– gets reloaded (only happens with the auto_reload debugging tools), in order
– to connect the new script instance to the already running document.
renoise.tool().app_new_document_observable
-> [renoise.Document.Observable object]

– invoked each time the app’s document (song) is successfully saved.
– renoise.song().file_name will point to the filename that it was saved to.
renoise.tool().app_saved_document_observable
-> [renoise.Document.Observable object]

/////

EDIT: Forgot the most obvious one to search for: .selection_in_pattern

Thank you very much for all the help!

After investigating I have already found the error.

The error is in the index of “end_column”. I’ll explain what happens, but I think this is poorly designed under Renoise’s hood, and should be resolved.

To select only the first note column, this doesn’t work:

renoise.song().selection_in_pattern={
  start_line=1,
  end_line=16,
  start_track=1,
  end_track=1,
  start_column=1,
  end_column=1 --index 1 not work!
}

It works like this:

renoise.song().selection_in_pattern={
  start_line=1,
  end_line=16,
  start_track=1,
  end_track=1,
  start_column=1,
  end_column=2 --index >1, inconsistent with the selection range!
}

This makes it impossible to select the last effect column. Because the index of “end_column” would be higher than the valid range(1), and it returns error.

(1)
Column indexes are valid from 1 to
(renoise.song().tracks[].visible_note_columns + renoise.song().tracks[].visible_effect_columns)

For example, if the selected track is 1, and it only has 1 visible note column and 8 visible effect columns, this doesn’t work:

renoise.song().selection_in_pattern={
  start_line=1,
  end_line=16,
  start_track=1,
  end_track=1,
  start_column=9,
  end_column=10 --index 10 return error!
}

Should be valid:

renoise.song().selection_in_pattern={
  start_line=1,
  end_line=16,
  start_track=1,
  end_track=1,
  start_column=9,
  end_column=9 --but index 9 not show the selection!
}

It clearly looks like a design error in setting the starting and ending index of the column. Can anyone confirm this?

As I think it should be…
For the correct selection of the first note column, it should be:

start_column = 1
end_column = 1

For column 3:

start_column = 3
end_column = 3

For note column 12:

start_column = 12
end_column = 12

For the first effect column with 1 visible note column:

start_column = 1 + 1
end_column = 1 + 1

For the last effect column with 1 visible note column:

start_column = 1 + 8
end_column = 1 + 8

I doubt that @taktik is not aware of this. I assume he have defined the range this way allowing for that little bug that prevents selecting only the last effect column. It is a “fairly hidden” matter.

Edit:

Apparently, this error will only happen if the user does not make a first selection with the mouse or keyboard commands. If you do, the indexes will already work correctly. There also appears to be an initial mismatch in the selection area.

There seems to be an initial problem with the index of end_column. This messes up the programming of any tool that uses end_column so that it works correctly from the beginning.

Does anyone want to play around with this by programming a test tool to see if it comes to the same conclusion? This is a somewhat confusing topic.

Ok, can replicate this now.

Didn’t notice at the time that you had no effects columns showing when trying the tool:

i.e. when tool won't work

raul selection


I can also replicate problems with a missing column selection case too.

  • Here you can load a default renoise song and add the extra fx column manually with col [+] button. Making sure you don’t accidently make a selection in the pattern editor.
  • Run the code in the terminal and you get the missing end column selection.
  • Make a selection in renoise manually, re-run the testpad and works as expected.

missing col selection

After manually changing selection in pattern editor an re-run code, col 3 is now selected:

second run

testpad code:

renoise.song().selection_in_pattern ={
  start_line=1,
  end_line=16,
  start_track=1,
  end_track=1,
  start_column=1,
  end_column=3 
}

Even more fun:

Have some notes in the pattern and cut the block using a shortcut. Suddenly the selection switches, and becomes 2,5 (granular) columns. I can only imagine that Renoise uses some float value that isn’t properly initialized, or something like that :slight_smile:

I tried this because I have noticed some block selection gfx glitches under special circumstances.

Yep, simply using ctrl + x after the first run of the testpad gives:

2.5

It seems that everything is caused by the same error. Maybe it has to do with bridging the selection area between the note columns and the effect columns depending on the visible columns together. Something is wrong here from the start…

Using a song template

There is another situation where it will fail. If the user uses a custom song template, loading only tracks without effect columns. For example, with only one note column visible and no effect column visible. Here the start_column / end_column index range will fail from the beginning.

There is probably no problem with the indices and it is just a graphical problem. Simply, in the pattern editor the graphical selection area fails, it does not coordinate with the indexes correctly in multiple scenarios (column configuration). The API seems to work fine here, just the selection area fails. It’s probably a problem under Renoise’s hood and @taktik won’t need to touch anything from the API.

The problem is subtle enough to drive you crazy programming a tool that configures the selection area, including start_column / end_column.

Apparently there are more problems with the selection area without the use of tools…

As it’s reproducible, I’m sure taktik will have no problem to hunt it down and do the necessary fix. I imagine it’s something fairly simple internally.

Yes. Thanks to all of you for all the details. Will be fixed in the next update.

4 Likes

Thanks taktik!