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

JimCatMP

Documentation Group
  • Team MediaPortal
  • April 1, 2010
    649
    282
    Leeds
    United Kingdom United Kingdom
    Country flag
    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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    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
    649
    282
    Leeds
    United Kingdom United Kingdom
    Country flag
    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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    @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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    @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
    12,463
    7,157
    Kyiv
    Ukraine Ukraine
    Country flag
    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 (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    morpheus_xx [Evaluate] Checking MP2 code portability to .Net Core MediaPortal 2 11
    ajs [Proposal] WebMP source code MPExtended 12
    ajs [Proposal] MPExtended Source code... MPExtended 3
    doskabouter Small code improvements MediaPortal 1 8
    morpheus_xx [Help Me!] Where can I find source code for MPUrlSourceSplitter? Developer Discussions 3
    D Ripped movies not importing unless IMDB code is included in folder name General 4
    johns11 Looking for 1.21 source code MediaPortal 1 Talk 2
    B [further infos missing] Install failed Exit code: 0xfff7, restarting: No 2.2 Archive 1
    D IRSS Suite not learning remote codes General Support 0
    Len Lekx Two sets of digit codes? IR Server Suite (IRSS) 5
    K 1.25.0 VOD from .m3u playlist. Is possible to watch? watch/edit Videos 7
    RoChess Weird GPU crash -- possible cause: resizing media MediaPortal 1 Talk 8
    P Recordings not showing up unless re-imported and not possible to delete General 0
    emphatic Pictures in the cloud - would a plugin be possible for services like Google Photos MediaPortal 1 Plugins 1
    SpudR IS this even possible? My TVSeries 9
    Lehmden [Videos] More filename possibility for MyVideos local fanart. Improvement Suggestions 26
    S Upmixing/upconverting to Dolby Atmos possible ? General Support 1
    T [solved] "Unable To Play" (Videos) rears it's head again. Logs not possible... WatchDog error attached!! :( General Support 1
    Lehmden Manual schedule: Possibility to enter a show name Feature Requests 1
    N [Proposal] Make text input possible with remote control in SMS style MediaPortal 2 1
    N [Finished] It is possible to map the same key to the same action twice MediaPortal 2 2
    Lehmden MP2 client for Windows 10 ARM, possible? Maybe an UWP version could do the trick... MediaPortal 2 11
    porky996t DVB Sat card possibly failed General Support 1
    D MP2.2: Possible bugs 2.2 Archive 20
    T Pause a recording possible? MediaPortal 1 Talk 0
    Similar threads

























    Top Bottom