Question on OSC /meters data

M/X Air Digital Mixer Series
kmitchell
Posts: 248
Joined: Fri Apr 16, 2021 6:15 pm

Re: Question on OSC /meters data

Post by kmitchell »

@pmaillot The meter data from /meters/0 (individual channels) and /meters/1 (all channels) appears to be consistent between the two. I can get readings as low as -95dB before I get 0x8000, which appears to indicate -oo. The top end does appear to be 0dB even though the meter scale next to the faders goes to +10dB in X-Air Edit. The meter scale on the "Channel" tab for the individual channels only goes to +0dB.

This is what I'm using to convert from db-to-float and it appears to be very close to what X-Air Edit shows. Sorry, the code is in Lua, since that's what TouchOSC uses.

Code: Select all

function dbToFloat(d)
  if (d < -90) then -- Don't go below -90
    d = -90 
  end
  
  if (d < -60) then
    f = (d+90)/480
  elseif (d < -30) then
    f = (d+70)/160
  elseif (d < -10) then
    f = (d+50)/80
  elseif (d <= 10) then
    f = (d+30)/40
  end
    return (f)
end
User avatar
pmaillot
Posts: 661
Joined: Wed Apr 14, 2021 1:32 pm

Re: Question on OSC /meters data

Post by pmaillot »

Thanks for the precisions.

In the x32 doc, you can find the following which match to the approximative log curve used for fader moves:

I believe ot's pretty much the same, in C.

// float to dB
// “f” represents OSC float data. f: [0.0, 1.0]
// “d” represents the dB float data. d:[-oo, +10]
if (f >= 0.5) d = f * 40. - 30.; // max dB value: +10.
else if (f >= 0.25) d = f * 80. - 50.;
else if (f >= 0.0625) d = f * 160. - 70.;
else if (f >= 0.0) d = f * 480. - 90.; // min dB value: -90 or -oo29.
// dB to float
// “d” represents the dB float data. d:[-90, +10]
// “f” represents OSC float data. f: [0.0, 1.0]
if (d < -60.) f = (d + 90.) / 480.;
else if (d < -30.) f = (d + 70.) / 160.;
else if (d < -10.) f = (d + 50.) / 80.;
else if (d <= 10.) f = (d + 30.) / 40.;
// Optionally round “f” to a X32 known value
f = roundf(f * 1023) / 1023;
kmitchell
Posts: 248
Joined: Fri Apr 16, 2021 6:15 pm

Re: Question on OSC /meters data

Post by kmitchell »

Thanks Patrick.

Yes, I used the same logic in my code that you used on page 132 of your x32 doc. Seems to be working well.
Post Reply

Return to “M/X-Air Digital Mixers”