I’m really struggling to understand how all of this works. Here’s what I’ve tried in the terminal:
inst_a = renoise.song().instruments[2].samples
inst_b = renoise.song().instruments[3].samples
table.insert(inst_a, inst_b[1])
Now, I’d assume that this would insert the first sample of instrument B into instrument A, right? So why doesn’t it work? When I rprint inst_a, it indeed does have a new sample, but the instrument in Renoise still only has two. What’s going on?
I feel like I’m late here, but I’ll try to explain what happens, as I see it.
I have not yet studied the manipulation of samples within instruments to create scripts with LUA, but I have noticed that the behavior of “how things are done” with Renoise to create scripts is very similar, regardless of what you are using.
Having said that, A new project has 10 tracks by default (0 to 9) can create up to 255 slots.I’m going to assume things now. I understand that this means that in order to add samples within the instrument number 10 or 11 (which does not exist), first it will be necessary to create an empty instrument in said slot.The same thing will happen with the samples.If you create a new empty instrument (without samples), it will be necessary first to insert an empty sample into the first slot, so that it can contain a sample. A single instrument can have hundreds of slots of samples. Using logic, I do not believe that an empty instrument (without sample slots) has a table prepared with those hundreds of empty sample slots ready to use. I suppose it will be necessary to first create the empty sample slot, and then fill it with the sample.
Therefore, to access the position of an instrument in the Renoise instrument table, you have to use .instruments [number of slot of instrument], but if an instrument does not exist, it will probably return an error. It will play to create an empty instrument first to be able to access it later.The same will happen with the samples. It will be necessary to first include the empty slot of the sample within the instrument already created.
Therefore, to access the sample you use the table instrument . Samples [number of slot of sample]
So this does not seem to make sense:
inst_a = renoise.song().instruments[2].samples
inst_b = renoise.song().instruments[3].samples
table.insert(inst_a, inst_b[1])
If we break it down, you are putting this:table.insert( renoise.song().instruments[2]. samples , renoise.song().instruments[3].samples[1])
"samples"you are referencing all the slots in the samples
"samples[1]"you only reference the first sample slot of the slot instrument 3.
Does the code intend to copy all instrument samples 2 into the first sample slot of instrument 3?This should not be possible.That’s why the API has this:
– Insert a blank sample object
renoise.song().instruments[2]:insert_sample_at(inst2_sample_slot)
In short, it is necessary to think that in order to insert something, first it is necessary to prepare the space where to insert it. This happens in the automation editor, in the instrument box, in the samples of each instrument, etc.
A clear example is: you can not put a sequencer track inside another group track, if the group track is not created first.I guess it’s a logical form used in many parts of Renoise.Therefore, when you save a large project with tracks, instruments and others, but without samples, the project takes up much more space than an empty project, because it is full of slots prepared everywhere, be it of points, either of instruments, or of samples…
From what I understand, moving a slot instrument is a bit heavy for Renoise. That allocation of a slot number in a table does not seem to be fast when it is changed. Possibly for this reason, Renoise does not have an option to select several instruments and drag them in the instrument box. It would be a heavy operation.
All these comments are deductions. I’m not yet familiar with the code to manipulate samples using LUA scripts.The same with phrases, DSP devices on the tracks etc.You need to create your empty slot to be able to use it,and you can only copy in it what it really can contain.
The summary is very fast. Understand what a “slot” is…