Exported number variable sometimes shows as an array?

Hey folks,

Starting work on an audio reactive animation and wanted to compute the difference between two sets of frequencyData. But in setting this up i noticed that for some weird reason when I compute the difference of two values from the frequencyData array and a past copy of the array, I get an occasional bug where the exported value of the variable flickers into an array!?

Here’s a simple test case, when I run this with some audio running through the sensor boards 3.5mm jack I get occasional flickers in the exported variable list in the ui and you can just about see the a variable gets turned into an array value for like a single frame.


// Sensor board variable
export var frequencyData = array(32)
export var energyAverage = 0

// --- Internal State ---
export var lastFrequencyData = array(32);

// =================================================================
// MAIN LOGIC LOOP
// =================================================================
export var a = 0;
export var last = 0;
export var value = 0;
export function beforeRender(delta) {
  last = lastFrequencyData[2]
  value = frequencyData[2]
  
  a = value - last;
  
  frequencyData.mapTo(lastFrequencyData, (value) => value);
}

// =================================================================
// VISUALIZATION
// =================================================================

export function render(index) {
  var h = 1;
  var s = 1;
  var v = 1;
  hsv(h, s, clamp(v, 0, 1));
}


This is normal, a bit of a leftover artifact of how getVars API guesses type. Very small numbers can sometimes be mistaken for arrays. A workaround would be to e.g. add 1 to a and then it will stop glitching the UI, or use a showNumber or gauge UI control to keep an eye on it instead of the Vars Watch.

Ah ok good to know I’m chasing a red herring!