none
How to control volume of a mciSendString in deciBel? RRS feed

  • Question

  • Hello dear reader

    I am wondering how to capture the volume increase or decrease measured in decibel...

    I use code like this to play sounds where the volume of the sound ranges from 1-1000.... anyone knows how this is related to dBs as i cant figure it really out with a sound level meter nearby....

    Greetings Joska

        Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
        REM ************************************************************************************************************************************
        Private Sub btnPlaySound1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound1.Click
            Dim musicAlias As String = "sound1"
            Dim musicPath As String = Me.txtGeluidenbibliotheek.Text & Me.cbxSounds1.Text
            mciSendString("Open " & Chr(34) & musicPath & Chr(34) & " alias " & musicAlias, CStr(0), 0, 0)
            mciSendString("play " & musicAlias, CStr(0), 0, 0)
            Dim Volume As Integer = (Me.tbSoundLevel1.Value)
            mciSendString("setaudio " & musicAlias & " volume to " & Volume, CStr(0), 0, 0)
        End Sub

        Private Sub tbSoundLevel1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbSoundLevel1.ValueChanged
            Dim musicAlias As String = "sound1"
            Dim musicPath As String = Me.txtGeluidenbibliotheek.Text & Me.cbxSounds1.Text
            Dim Volume As Integer = (Me.tbSoundLevel1.Value)
            mciSendString("setaudio " & musicAlias & " volume to " & Volume, CStr(0), 0, 0)
        End Sub

    Saturday, April 12, 2014 3:25 AM

Answers

  • Perhaps the following links can assist you on knowing what the Decible level is compared to the tbSoundLevel value if you do the math for whatever is necessary to compare the two.

    Default Audio Volume Settings

    Audio-Tapered Volume Controls

    Image from first link

    Image from second link


    Hello. I'm old and retired. I like to program if you could call what I do programming. However I'd like to code for you! If you've got the dime then I've got the time. Call me, landline, @ BR-549.

    Saturday, April 12, 2014 3:48 AM