1.16.0 - VU meter code - possible error?

Discussion in 'Archive' started by JimCatMP, July 30, 2016.

  1. JimCatMP
    • Team MediaPortal

    JimCatMP Documentation Group

    Joined:
    April 1, 2010
    Messages:
    647
    Likes Received:
    153
    Gender:
    Male
    Location:
    Leeds
    Ratings:
    +282 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    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.
     
    • Like Like x 2
    • Agree Agree x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    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?
     
  4. JimCatMP
    • Team MediaPortal

    JimCatMP Documentation Group

    Joined:
    April 1, 2010
    Messages:
    647
    Likes Received:
    153
    Gender:
    Male
    Location:
    Leeds
    Ratings:
    +282 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs

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

    Cheers - J.
     
  5. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    Apparently I do not understand the problem ... I read it 3 times, I still do not understand. Sory :(
     
  6. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    @hwahrmann
    In BASS Documentation:
    Code (C#):
    1. public static double LevelToDB(
    2.     int level,
    3.     int maxLevel
    4. )
    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.
     
  7. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    In BASS Overview: BASS.NET Overview
    Example for Calculating the audio level for a stereo 32-bit float channel :)
     
  8. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,497
    Likes Received:
    1,639
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,266 / 1
    Home Country:
    Austria Austria
    So are you ok now?
     
  9. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    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?
     
  10. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    @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
    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: June 23, 2017
    • Like Like x 1
    • Thank You! Thank You! x 1
  11. ajs
    • Team MediaPortal

    ajs Development Group

    Joined:
    February 29, 2008
    Messages:
    8,706
    Likes Received:
    2,693
    Gender:
    Male
    Occupation:
    IT
    Location:
    Kyiv
    Ratings:
    +4,658 / 30
    Home Country:
    Ukraine Ukraine
    Show System Specs
    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: June 23, 2017
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!