Store the highest value of incoming OSC Value (per Channel)

Hi,

using open stage control in conjunction with reaper, and other software.
Thanks to @jean-emmanuel i now have a colored meter depending on the incoming value (0 - 1).
Now i would like to show the peak level of a the meter (per channel, in the label field of the parent strip).
(in reaper this is from -72db to +6db -> value 0 to 1 in open stage control).

I thought about set the default value of the strip to 0, and then via " JS{{}}" update the label when the value(of the meter) is higher, but it needs to be calculated to db too…

thanks for any help
klaus

Here is a session to get you started, the logic is handled in the script widget. The input’s label is used to display the value converted in dB, you’ll need to adapt the formula to match reaper’s. You could have the peak color change beyond a threshold by adding some conditional css to the input:

JS{{

if (@{this} > 0.9) {
  return "color:red"
}

}}

peak.json (3.6 KB)

Another solution, better imo, would be using a custom module to filter incoming meter messages and do the maths:

// this will hold peak valus
var peaks = {}

// conversion utility
function dB(v) {
    // not the good formula
    return 20 * Math.log(v/1)
}

module.exports = {

    oscInFilter:function(data){

        var {address, args, host, port} = data

        if (address == '/meter') {

            // assuming the 1st arg is the strip's number
            // and the 2nd is the value
            
            var strip = args[0].value,
                val = args[1].value

            // if received value > stored peak value
            if (val > (peaks[strip] || 0)) {
                // store new peak value
                peaks[strip] = val
                // send peak value to the gui
                receive('/peak', strip, dB(val))
            }
            
        
        }



        return {address, args, host, port}

    }


}

With this method you could even add a timer to reset peak values periodically.

thanks for your help, i am nearly there…

with reaper i just get a floating point value at addr.: /track/1/vu , so args[1].value will not work here, instead i have to fiddle the track number out of the addr. string …(address == ‘/track/[number]/vu) and receive(’/faderstrip’ + [number], dB(val)) )

Apart from that i need to get out a floating point value of MATH … (it returns just whole numbers, and is not accurate as you stated -> “not the good formula”) , needs investigation…

I am not sure on how to implement the reset of the peak value, it would be easy to reset on PLAY or STOP, not sure how it would work with a timer.

Noticed further when there is a strip in a strip, there is no width attribute, means, when you main strip is at the moment where you add another strip into a strip it gets “width” and “min.width” derived. (and you can’t correct “min-width”, manual correction is overriden at next startup).
Can also be seen in my progress example strip: "faderstrip1"redesign_v12.json (164.4 KB)

with reaper i just get a floating point value at addr.: /track/1/vu , so args[1].value will not work here,

You'll need to adapt the condition then:

var trackVuMatch = address.match(/\/track\/([0-9]+)\/vu/)
if (trackVuMatch) {
  var strip = trackVuMatch[1]
}

The receive part would need to be adapted too of course.

Apart from that i need to get out a floating point value of MATH … (it returns just whole numbers, and is not accurate as you stated -> “not the good formula”) , needs investigation…

The above dB function returns floating point numbers, not integers. As for finding the correct formula, I leave it to you and other reaper users :wink:

Noticed further when there is a strip in a strip, there is no width attribut

The width attribute doesn't make sense here unless the parent strip is horizontal (in which case it's the height attribute that's disabled)/