Question: How to LUA up a loaded instrument with a regular phrase?

Hi, I’ve been trying to solve this pickle for a few hours now and I’m not sure where to go next.

I can load a sample into the Instrument Box a-ok.
I can then run a script that does this[]:insert_phrase_at(1)  

but after that, the phrase editor still doesn’t actually show which phrase has been selected, and I’m still only (i guess) 5% of the way there.

What exactly should I do? (the objective is to make it possible to load a sample, create a phrase for it’s instrument, and then, later on, be able to alter the length of the phrase and the LPB of the phrase).

I already have F2 mapped so that when I press F2, it takes me to Pattern Editor, when I press F2 again, it takes me to the Phrase editor, and then when I press F2 again it takes me back to the Pattern Editor - thus making the editing of phrases during pattern editor editing pretty much transparent.

The only thing that’s missing is being able to create a phrase without having to move the mouse.

Hopefully yours,

– Currently selected phrase the instrument’s phrase map piano
– view. Can be nil., _observable
-> [read-only, renoise.InstrumentPhrase object or nil]

– Returns true if a new phrase can be inserted at the given index.
– Phrase note mappings may not overlap and are sorted by note, so there
– can be max 119 phrases per instrument when each phrase is mapped to
– a single key only. To make up room for new phrases, access phrases by
– index, adjust their note_range, then call ‘insert_phrase_at’ again.[]:can_insert_phrase_at(index)
-> [boolean]
– Insert a new phrase behind the given phrase index (0 for the first one).
– The new phrase will by default use the entire free (note) range between
– the previous and next phrase (if any). To adjust the note range of the
– new phrase change its ‘phrase.mapping.note_range’ property.[]:insert_phrase_at(index)
-> [returns newly created renoise.InstrumentPhrase]
– Delete a new phrase at the given phrase index.[]:delete_phrase_at(index)

All the exact documentation changes can be found in the Renoise its scripts folder in its own program folder. It seems that Renoise does not update the scripting documentation in the scripts folder of the appdata or home section of Renoise after it duplicated the old 2.8 config so you will have to manually copy it there to get it up to date.

is it true that the Lua API does not (CURRENTLY) allow for selecting the Instrument Phrase?
that there is no way of selecting which phrase to display in the instrument phrase?

how should I go about conquering this limitation – have a template XRNS with a sample containing silence, in the instrument box, and a phrase created for it, and copying that phrase before opening the phrase display? or will that still force me to click on a phrase with the mouse?

Objectively, I’m just trying to accomplish this:

1- Disk Browser, Load Sample.
2- Go To Pattern Editor.
3- Input a note
4- Select the not
5- Press a key
6- Blammo, you are in the Instrument’s first Phrase, which works.

You don’t need to have the phrase visible or selected to alter its contents:

If you want to copy phrases you can easily use the copy function for that:
– Copy contents from another phrase.[].phrases[]:copy_from(
other renoise.InstrumentPhrase object)

but how do i first create a phrase, then make it be visible on the phrase editor? i’m not looking to (at least not yet) alter the phrase at all, i just am trying to auto-create a phrase with C-4 on it, and make it mapped across the whole octave space of Renoise, and thus be able to access it simply by having an instrument selected and pressing a specific shortcut that switches between pattern editor and phrase editor.

– how do i select a phrase in the phrase editor with LUA api, please?
i think even copying a phrase won’t make it be selected in the phrase editor.

No indeed and when creating it, it doesn’t get selected either.
Selecting a phrase visually is not possible, you would then need something like selected_phrase_index which does not exist. I do get what you want though: visually focus on the phrase attached to the pattern note or range the note of the attached phrase falls in and this sounds like a plausible feature.

The “Create Phrase” button remains visible after a phrase has been added through Lua which i do think is a bug.

actually, the create phrase button vanishes after a phrase has been created and the phrase editor made visible. there’s really no way of knowing that there’s a phrase at all there.

so, what’s the other alternative? making a phrase, saving a template and making a copy of the phrase everytime a notifier for “sample has been loaded” has been sprung?

“this sounds like a plausible feature”…
to be brutally frank and honest, i don’t know what this could possibly mean.

That it should be a native option that you can jump directly to a phrase that is connected to a note which triggers the phrase from the pattern editor and nobody should be having to write a tool for that

ahh, auto-select phrase just like with autoselect sample, that’d be a clever thing to do.
but i guess that requires an additional post on the forum, right?