Results 1 to 7 of 7

Thread: Need help with audio/sound detection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Need help with audio/sound detection

    Hi all,

    I am starting a project from scratch and need help with where to start (with my limited VB6 knowledge!) on how to either:

    1) Detect the audio level on the Line Out of a sound card (which will be in use) and have that level as a varaible to use.

    OR

    2) Assuming that detecting the level on the Line Out will not be possible as it is in use (I may be wrong), detect the audio level on Line In of a sound card, and again, get this back as a variable to use.

    If anyone has any pointers in the right direction or indeed any source code they are willing to share, it would be greatly appreciated.


    Thanks in advance.

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Need help with audio/sound detection

    If you just want to know if there is sound on the line, then just get the largest value of the buffer.

    For example:
    Code:
    For K = 0 To UBound(Buffer)
       If Buffer(K) > Max_Val Then Max_Val = Buffer(K)
    Next K
    Then to get a percentage, just divide the max value to the largest possible value. So if you are recording in 8 Bit, then the largest value is 255, if 16 Bit then 2^15=32768
    So lets say it's 16 Bit, then:
    SoundPercent = Max_Val / 32768

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Need help with audio/sound detection

    Hi CVMichael,

    I seem to have got the info from your fantastic tutorial (many thanks for sharing it), but im not using that example.

    I haven't got the code here at work, but i'll take a look later and tyr your suggestion to see if I can get a better result. I am happy with the one I have, but it does seem a bit 'hit and miss' with regards to the resultin level obtained.

    Thanks again.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Need help with audio/sound detection

    Hi, I get similar results to what I am already getting with this...

    I have discovered that playing with the actual recording level on the mixer fixes most of my issues, thank you again.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Need help with audio/sound detection

    Hi CVMichael,

    I'm using the 'myval' vairalbe to get my level from the code in your tutorial, hsoudl i try something different?

    thanks

    Code:
        For Q = 0 To HBuffer - 2 Step Stp
               K = Q
               K = K - (K Mod 2)
               LVal = DataBuff(K + 1) / 65536# - 0.5
               RVal = DataBuff(K) / 65536# + 0.5
               myvalue = ((RVal * 100 - 55) + 1) * 2
               If myvalue < 0 Then myvalue = myvalue * -1
               If myvalue > 100 Then myvalue = 100
               myvalue2 = ((LVal * 100 + 50) + 1) * 2
               If myvalue2 < 0 Then myvalue2 = myvalue2 * -1
               If myvalue2 > 100 Then myvalue2 = 100
    Last edited by omega1; Sep 30th, 2009 at 03:09 PM.

  6. #6
    Member
    Join Date
    Oct 2001
    Posts
    47

    Re: Need help with audio/sound detection


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: Need help with audio/sound detection

    Hi, thanks, but i get page not found?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width