[ANSWERED] Ranking values Q
-
Hey all
I'm building a patch that listens to audio input for a user defined amount of time and records the "db" as a value (0-100).
The audio input/microphone is "opened' with a gate actor each time and the max value is fed to a separate Hold Value actor - each time the gate is opened a new hold value is used. The gate is then closed, so the max volume over a user defined period of time is recorded.
In the current patch I've got 3 separate Hold Value actors, but this could go up to 10 or more. There will be a different external trigger (most likely an OSC signal) for each gate into hold value.
Is there an actor/setup that can then rank those values highest to lowest? Ideally I want the user to be able to see the highest value and which opened gate that corresponds to quickly - that value might then get fed elsewhere and presented as a 'winner'.
Hope that makes sense, any thoughts very welcome!
Simon
-
JavaScript would be your best bet
-
As Woland mentioned, you can accomplish this in Javascript.
You likely want to build a 2D array (https://www.w3schools.com/js/j...) such that the Array is made of short arrays that contain the Value & the Position.. So you might have [50.33,2] where 50.33 is the max volume, and 2 the position it is in.So your array may look like this (if it has 5 positions) [[50.33,1],[20,2],[10,3],[15,4],[30,5]]
You could then use the Array Sort feature on this array (https://www.w3schools.com/js/j...) to sort by the Volume level (first value in each sub-array).
This could give you this array: [[50.33,1],[30,5],[20,2],[15,4],[10,3]]
See how the value levels are now in descending order: 50.33, 30, 20, 15, 10
In this way, you can determine that the highest value came from output position 1, and the second highest volume came from output position 5
Hopefully that gets you started.