Example code for 2d matrix

Hi @Alias,
The .05 coefficient was way too high, and would only work with very loud volumes. The code works for me for a fairly quiet audio when I adjust the coefficient to a low value e.g.:

export var frequencyData

export function render2D(index, x, y) {
  h = 1
  s = 1
  fx = frequencyData[x*32]
  v = fx > y * 0.003 ? 1 : 0
  hsv(h, s, v)
}

This is where automatic gain control could help. The reason you have a line with a flicker on the second line is that y starts out zero, so fx is almost always > 0 on the first line, except for loud frequencies.

To answer your second question, the pixel map is scaled to world units. More information can also be found in the Mapper tab documentation, just below the editor. All coordinates are scaled to a value between 0.0 and 1.0, so x will always be less than 5. The idea is that patterns can be written to scale to any map, and wouldn’t have to be changed to work on different sized matrices (or any other layout).

If you want to go back to pixels, you can multiply by the width - 1, and round to the closest integer value like so:

xpx = floor(x*15 + .5) //xpx will be between 0 and 15 inclusive
1 Like