|
-
Sep 27th, 2009, 08:35 AM
#1
Thread Starter
Addicted Member
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.
-
Sep 28th, 2009, 07:46 AM
#2
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
-
Sep 28th, 2009, 09:11 AM
#3
Thread Starter
Addicted Member
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.
-
Sep 28th, 2009, 03:31 PM
#4
Thread Starter
Addicted Member
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.
-
Sep 30th, 2009, 03:05 PM
#5
Thread Starter
Addicted Member
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.
-
Oct 1st, 2009, 06:46 AM
#6
Member
Re: Need help with audio/sound detection
-
Oct 1st, 2009, 06:50 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|