Setting "New Phrase Preferences" using LUA

How to use the LUA API to specify preferences for Phrases? i.e. when you create a new phrase, it will always have: sample_effects_column_visible=false panning_column_visible=false delay_column_visible=false visible_note_columns=1

local song=renoise.song
if (song().selected_phrase) then
  local phr=song().selected_phrase
  phr.sample_effects_column_visible=true
  phr.bla_bla_bla=true
  phr.bla_bla_bla=false
  phr.bla_bla_bla=true
  ...
end

Remember first to make sure that the phrase exists!

thanks, that does seem to work.

yeah, i was hoping to automate it so that whenever i create a phrase for an instrument (like shift-alt-p or something), it’d always do these things. but am yet to figure out how to create a phrase safely onto the currently selected instrument. would be cool.

this is what i ended up using this saturday afternoon…

local phra=renoise.song().instruments[renoise.song().selected_instrument_index].phrases[renoise.song().selected_phrase_index]

phra.sample_effects_column_visible=false
phra.panning_column_visible=false
phra.delay_column_visible=false
phra.visible_note_columns=1
phra.instrument_column_visible=false

Access directly:

local phra=renoise.song().selected_phrase
phra.sample_effects_column_visible=false
phra.panning_column_visible=false
phra.delay_column_visible=false
phra.visible_note_columns=1
phra.instrument_column_visible=false

Anyway never use . [ ] (access the entire table, it is slower)
Use : ( ) (access the value directly, it is faster)

renoise.song().instrument**s**[renoise.song().selected_instrument_index]
renoise.song():instrument(renoise.song().selected_instrument_index)

And use a local

local song=renoise.song
song():instrument(song().selected_instrument_index)

I have a bad habit of using song = renoise.song()
song:instrument(........
But it is better to use song = renoise.song
song():instrument(........

You have to make as few calls as possible. This is very important when you iterate.

thanks, i started using renoise.song().selected_phrase and it seemed to feel a bit quicker. i’ll see what i can do.

i appreciate the s=renoise.song() suggestions, i just like to use non-optimized text while i’m fiddling with it (might need to paste it to the terminal… if i have shortenings, the terminal pasting will not work directly…)

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