Global array support for LittleFoot

#1

Hi

The JUCE 5.4.0 Releases notes mention that support for global arrays was added for LittleFoot. Can anyone explain how this works as I’ve been unable to find docs or examples.

Thanks

1 Like

#2

Good question!

This could be referring to vectors in the metadata section, e.g. you can declare something like this in the beginning of the script

/*
<metadata>
    <variables>
        <vector count="8" wantsGetFunctions="true" wantsSetFunctions="true">
            <variable  name="Position"
                        type="float"
                        min="-15.0"
                        max="15.0"
                        value="0.0"
                        visible="false" />
        </vector>
    </variables>
</metadata>
*/

and then use it in the program with the automatically generated setter and getter:

x = getPosition(i);
setPosition(i, 5.2);      // i - array index, 5.2 - value

However, I thought that metadata vectors existed before 5.4.0, so it could be something different entirely.

0 Likes

#3

@AnthonyAlfimov. That’s pretty cool. I was really hoping for some kind of data structure support in Littlefoot.

What surprises me is that nothing of this seems documented when it adds so much value to Littlefoot. At least I googled like hell for variables, dynamics parameters, vectors or scripts and found nothing. I still don’t know what type of variables can be declared in the metadata section.

0 Likes

#4

Bear in mind that Littlefoot is designed to run on a very limited hardware that wasn’t originally supposed to support a scripting language. If you are curious how it all came to be, check out this ADC talk: Only an idiot would write a new C-like language in 2016, Jules Storer
So the language had to be tiny and ended up quite limited as a result, e.g. no data structures beyond these metadata vectors (to my knowledge).

By the way, note that metadata vectors use up a significant amount of memory on the Block. Managing “arrays” manually on the heap using getHeapByte(), getHeapInt(), setHeapByte(), setHeapInt() is much more memory-efficient.

The documentation for deeper Littlefoot features is lacking indeed. The only way I find my way around it is by examining factory scripts and experimenting. If you’re on Mac, the up-to-date factory scripts can be found inside the Dashboard app bundle, in Contents/Resources (on Windows they should be somewhere inside the Dashboard installation directory).
Also, the Insert menu in BLOCKS Code has templates for a few metadata objects, albeit not very clearly labeled. Every option from “Insert metadata” until “Function divider” is an object to be placed inside the metadata section.

And I would be happy to help with what I’ve learned so far myself.

1 Like

#5

@jaymann oh, and also check out the old factory scripts here. The old Drum Block script is the only place I found an example of a on-variable-change script. To get Littlefoot code with onChange script in metadata section working properly, upload it from Dashboard rather than from BLOCKS Code.

These are your basic metadata variable types:

/*
<metadata>
    <variables>
       <variable name="myInt" displayName="Value" type="int" min="0" max="255" value="0" />
       <variable name="myFloat" displayName="Value" type="float" min="0" max="255" value="0" />
       <variable name="myBool" displayName="Value" type="bool" value="true" />
       <variable name="myColour" displayName="Value" type="colour" value="0xFF0000" />
       <variable name="myOption" displayName="Option" type="option" value="Option 1" options="Option 1;Option 2;Option 3;" />
       <variable name="myMidiNote" displayName="Note" type="midiNote" value="C3" />
    </variables>
</metadata>
*/

There are some additional attributes for metadata variables that I’ve encountered, like

visible="true", "false" // whether variable should be visible in Dashboard
enabled="true", "false" // whether variable should be active in Dashboard
displayMode="multiline", "bipolar", ... // how to display the variable in Dashboard GUI

Probably there are other variable types and attributes in the factory scripts that I can’t remember off the top of my head.

1 Like

#6

@AnthonyAlfimov thank you so much. I’m going through all these materials, and hopefully will understand a lot better what can be done with Littlefoot.

0 Likes

#7

@jaymann I’m glad I could help! This list of community Littlefoot projects might also be useful, there are some interesting examples there.

And if you get any more questions, I’ll try my best to help.

0 Likes

#8

Isn’t there a way to get a confirmation from someone from ROLI or JUCE about how global arrays for Littlefoot work?

Aren’t there any admins reading these posts?

2 Likes

#9

Sorry for the delay in getting back to you. Your question sparked a bug hunt which we wanted to fix first.

We’re going to discourage people from using the metadata tags as, as you’ve discovered, they’re not well documented and will likely be deprecated from Dashboard in the future.

Littlefoot arrays are not yet supported in the current Dashboard or Blocks Code releases. You can expect them in the next release, but I can’t give an estimate for when that might be.

2 Likes

Littlefoot: metadata variables, vectors and onChange scripts
#10

Great news!
When talking about deprecating metadata tags in the future, do you mean just the vectors, or variables as well? In the latter case, what are you planning for parameters editable via Dashboard UI?

0 Likes

#11

@t0m thanks for the update. The thing is that I need some kind of data structure support. If arrays are not yet supported, I’ll have to use vectors then. I understand I’ll have to update my code in the future.

0 Likes