1.16.0 VU meter code - possible error? (1 Viewer)

JimCatMP

Documentation Group
  • Team MediaPortal
  • April 1, 2010
    652
    283
    Leeds
    Home Country
    United Kingdom United Kingdom
    I noted some time ago VU meters only registers values upto about 10 [version 1.4 -> 1.5, Oct 2013].

    From SRCS.

    https://github.com/MediaPortal/Medi...rtal/Core/MusicPlayer/BASS/BassAudioEngine.cs

    ----
    public void RMS(out double dbLevelL, out double dbLevelR)

    snip....

    level = BassMix.BASS_Mixer_ChannelGetLevel(stream.BassStream);
    }
    }
    if (Config.MusicPlayer != AudioPlayer.Asio) // For Asio, we already got the peaklevel above
    {
    peakL = Un4seen.Bass.Utils.LowWord32(level); // the left level
    peakR = Un4seen.Bass.Utils.HighWord32(level); // the right level
    dbLeft = Un4seen.Bass.Utils.LevelToDB(peakL, 65535);
    dbRight = Un4seen.Bass.Utils.LevelToDB(peakR, 65535);
    }
    dbLevelL = dbLeft;
    dbLevelR = dbRight;
    }

    ---

    Given that :Un4seen.Bass.Utils.[Low|High]Word32 return max value of 32768 <http://www.bass.radio42.com/help/html/93156b76-c9f3-f754-4474-c9cac4d29721.htm>

    and Un4seen.Bass.Utils.LevelToDB <http://www.bass.radio42.com/help/html/b6c55d8c-5a05-3c4c-30b2-18ae4eb45c96.htm> states a Max value of 32768 for stream source [not 65535].

    If I'm reading this correctly, the dB value returned would be based around source value of effectively 1/2 it's true value and as Vout -> dB is none linear function, it would seem to fit the observed behaviour.

    Allowing for the fact I'm no C# coder by any means, so I may be missing something blindingly obvious:eek: in code or in Un4seen documentation.

    TTFN - JCMP.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    I noted some time ago VU meters only registers values upto about 10 [version 1.4 -> 1.5, Oct 2013].
    If we are talking about pictures (VU1..VU15), then I often see pictures up to 15 (MP 1.14, WASAPI). Or is it another matter?
     

    JimCatMP

    Documentation Group
  • Team MediaPortal
  • April 1, 2010
    652
    283
    Leeds
    Home Country
    United Kingdom United Kingdom
    If we are talking about pictures (VU1..VU15), then I often see pictures up to 15 (MP 1.14, WASAPI). Or is it another matter?


    No - it's the VU pics displayed, using BASE and MP 1.14 or earlier I first noted the change. :(

    Cheers - J.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    No - it's the VU pics displayed, using BASE and MP 1.14 or earlier I first noted the change.
    Apparently I do not understand the problem ... I read it 3 times, I still do not understand. Sory :(
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    @hwahrmann
    In BASS Documentation:
    C#:
    public static double LevelToDB(
        int level,
        int maxLevel
    )
    Parameters
    level
    Type: System.Int32
    The integer level to convert.
    maxLevel
    Type: System.Int32
    The maximum value allowed as an integer level value (e.g. use 32768 for stream levels)
    Return Value
    Type: Double
    The dB value (from 0dB to -infinite).
    Remarks

    If you pass a level greater than maxLevel positive dB values will be returned.

    Ie result of LevelToDB from -infinite to 0, but in MP code: MediaPortal-1/BassAudioEngine.cs at master · MediaPortal/MediaPortal-1 · GitHub and MediaPortal-1/GUIMusicPlayingNow.cs at master · MediaPortal/MediaPortal-1 · GitHub
    if ((int) dbLevelL < -15) ... ((int) dbLevelL < 3) and else { file = "VU15.png"; }

    The pictures (VU12, VU13, VU14, VU15) should not be visible. Because they compare with a value greater than zero.

    I do not read the documentation correctly? Or am I missing something?

    PS: Thank you for the clarification.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    So are you ok now
    Probably ... but once I make a change, I can immediately correct this mistake, if it makes sense to correct ... But here I also do not know. :):whistle::coffee:

    PS: The pictures (VU12, VU13, VU14, VU15) should not be visible. Because they compare with a value greater than zero. Or did I not correctly read the documentation? VU meter code - possible error?
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    @hwahrmann
    Plz help :) I read the documentation and can not understand anything.
    RMS Function in MP: MediaPortal-1/BassAudioEngine.cs at master · MediaPortal/MediaPortal-1 · GitHub
    Used:
    1. First: BASS_Mixer_ChannelGetLevel or BASS_WASAPI_GetLevel, both return values for Left, Right channel (Left - LowWord, Rigth - HiWord) and value by channel from 0 to 32768. MediaPortal-1/BassAudioEngine.cs at master · MediaPortal/MediaPortal-1 · GitHub
    If successful, the level of the left channel is returned in the low word (low 16-bits, use LowWord32(Int32)), and the level of the right channel is returned in the high word (high 16-bits, use HighWord32(Int32)). If the channel is mono, then the low word is duplicated in the high word. The level ranges linearly from 0 (silent) to 32768 (max). 0 will be returned when a channel is stalled.
    2. Then LevelToDB(peakL, 65535) - from un4seen forum dB to BASS volume? this function work as: 20 * log10( level / maxLevel ) and for 32768 return -6.020461 and for 1 return -96.478175, for 0 return -infinity
    3. Then in MediaPortal-1/GUIMusicPlayingNow.cs at master · MediaPortal/MediaPortal-1 · GitHub both channel value Increase by an absolute value multiplied by 0.5 and start to coincide with values from < -15 (VU1.png) to >= 3 (VU15.png). MediaPortal-1/GUIMusicPlayingNow.cs at master · MediaPortal/MediaPortal-1 · GitHub
    Ie:
    ~Min: 1 -> -96.478175 -> -96.478175+(96.478175*0.5) -> -48.239087
    Max: 32768
    -> -6.020461 -> -6.020461+(6.020461*0.5) -> -3.010231
    and
    Min -48.239087 < -15 Then return VU1.png
    Max
    -3.010231 < -2 Then return VU9.png but how about VU10..VU15? :(

    I did not calculate correctly? Or I did not understand the documentation correctly? Or do we still have a problem with displaying the level through the channels? Or we do not have a problem and then please tell me where I was wrong? :whistle::coffee:

    Thankful in advance for the answer.
     
    Last edited:

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine
    Next:
    Assume that the return values are greater than 32768, ie from 0 .. 65535, then LevelToDB(peakL, 65535) return values from -infinity,-96 .. 0. And LevelToDB(peakL, 32768) return values from -infinity,-90 .. 6.
    @hwahrmann Can it be worth introducing a corrective value to get the right readings? Ie +6

    But LevelToDb return Int16, ie -32768 .. 32768 ... Min 0 for dB* and max 32768 for dB, after LevelToDb we get: -96 ..-6 :(
     
    Last edited:

    Users who are viewing this thread

    Top Bottom