Multidimensional Mixed List

Since I’m not really sure how to explain or do it i’ll just try and give you an idea of what I’d like to do

I’d like to have an object like

instruments = [[1, false, “one”], [9, true, “nine”]]

with mixed types in it, and then be able to access it with instruments[i][1] etc like you’d do it with a multidimensional array.

All those values also need to be observable (bindable).

What’s the best/proper way to do something like this?

By using documents within a document maybe?

Can you use more words to describe what exactly you wish to do, in relation to Renoise?

How do you want to access this instruments[i][1] , what does the “i” mean? is this inside a for-loop?

It would be like a multidimensional array or matrix… or nested objects or documents or whatever you want to call it :)
So ‘instruments’ (could be anything) is just an object that contains other objects with values and those are the ones I’d like to get at.

The ‘i’ corresponds to a specific object in the list and would be handy as an identifier (many uses), but yeah one of the most common uses for it would be to loop/iterate through the list.

So instruments[1][1] for instance would be the first value (of serveral mixed values, i.e. boolean, number, string, etc) of the first object in the list.

I hope that makes some sort of sense.

i was hoping you would describe what you want it to do. multidimensional array and matrix -words don’t really explain any way as to what it would do in renoise.
how do you want to use renoise? what do you wish to accomplish with renoise, that this would allow you to do?
describe your workflow of how you would use this, give examples.

You’re pretty much already there.

local instruments = { {1, false, "one"}, {9, true, "nine"} }  


[1] => table  
 [1] => 1  
 [2] => false  
 [3] => one  
[2] => table  
 [1] => 9  
 [2] => true  
 [3] => nine  

More info on Lua tables:

But the values would need to be viewbuilder-bindable, and a document node (which would give the bind-feature) won’t accept mixed type lists…

Ah yes, forgive me, I somehow didn’t even see the stuff about them being bindable document properties. D’oh!

I forgot to mention that this is within the scope of Document.create or DocumentNode and the values need to be observable (so I can bind vb controls to them).

If I use a table like this it won’t work within that scope, and I can get the values but they aren’t observable, so. something like

vb:valuebox {
min = 0,
max = 255,
bind = instruments[1][1]

won’t work. Just wondering then if there is any way to do that, or some way to work around it.

@esaruoho, this is more geared at understanding how to approach nested data objects, but for instance with this you could easily create a dialog where controls were bound to the values of those nested data objects. It could be a list for anything, like effects or notes or whatever, and these lists could then be saved/recalled as presets.

EDIT: yeah what KMaki said :)

The values that you want to get aren’t observalbe or the parameters that holds them aren’t observable?
In the latter case it would be tough luck, in the first case you might want an observable function allow to to updating the binding list.

Yeah, what vV said.

I don’t know what insrtuments[1][1] is supposed to be, but as far as I understand you can only bind to _observable elements.

In the docs, if there isn’t an _observable keyword next to it, then it can’t be bound.

If you want to build your own observables, there’s more info in the docs here:

@vvois, as tables {{a, b, c}, {a, b, c}} etc they’re not observable AFAICT, which is why I’m wondering if there is some other way stuff like this is commonly done.

@Conner_Bw, it’s just nested data like what you’d do with a multidimensional (more specifically 2D) array like this

I’m not married to that idea at all but it’s the best way I can explain what I’m after.

Thanks I’ll look into making custom observables and see if that can work.

The example you wrote in response to my querying for examples was intriguing, but I really feel like this thread would benefit if you fleshed out your ideas and were more verbose about them. You are currently describing only the back-end, so to speak of it. Not how you would use it.
At first I thought there might be some relationship between what you are saying and creating a gui with knobs, and being able to, on-the-fly define which functions those knobs do, from a dropdown menu. Then I wasn’t too sure.

Yeah, cheers, I knew that. What I meant was if your insrtuments[1][1] doesn’t point to an observable object, it will never bind.

The caveat is that “'observable and node names can not start with a number (like XML keys).”

Here’s a hack I tried, works.

my_array = renoise.Document.create("MyDoc") {   
 _1 = {  
 _1 = renoise.Document.ObservableNumber(1),  
 _2 = renoise.Document.ObservableNumber(2),  
 _3 = renoise.Document.ObservableNumber(3),  
 _2 = {  
 _1 = renoise.Document.ObservableNumber(1),  
 _2 = renoise.Document.ObservableNumber(2),  
 _3 = renoise.Document.ObservableNumber(3),  
function get_observable(x, y)   
 local my_string = "my_array._" .. x .. "._" .. y  
 return assert(loadstring("local my_return_func = " .. my_string .. "; return my_return_func"))()   
function set_observable_value(x, y, val)   
 local my_string = "my_array._" .. x .. "._" .. y .. ".value = " .. val   

Then you could do something like this:

 -- GUI  
 local vb = renoise.ViewBuilder()   
 local dialog_content = vb:column {   
 vb:chooser {  
 id = "chooser",  
 items = {"First", "Second", "Third"},  
 bind = get_observable(1,1) -- THIS IS THE IMPORTANT LINE!  
 }"Test", dialog_content)   

This assigns your [1][1] observable to the GUI object.

Later you do


And the GUI will change to: 3.

Good luck.