audio level detection

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Closed Thread

Join Date: Nov 2005
Posts: 4
Reputation: hardkraft is an unknown quantity at this point 
Solved Threads: 0
hardkraft hardkraft is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #11
Nov 8th, 2005
Originally Posted by AlanC
Larmit..

Please see the attached zipped VB6 project. The code is thoroughly commented so hopefully should be easy to use...

The pre-compiled exe was compiled on a Win98SE system and because of the nature of the API used (winmm.dll) you will need to compile it again if the target system is NT/W2000/XP.

If it doesn't run as expected, I can do a version for you with lots of diagnostics in so we can see at which point it is failing.

Don't forget that this works by putting the sound driver in record mode, so you'll need to set up the Windows audio recording mixer to actually give you an input..

Let me know how you get on.

Usual disclaimers apply about this developmental software...

Regards
Alan
Hi, I am wondering if you are still listening on this thread. I downloaded your program because it seemed like the answer to my problems. Unfortunately it doesn't quite work. All that ever gets captured in the buffer is 128s and 127s which I guess is a low level noise. I checked the mic setings and everything seems to be ok. The program also fails on another win xp machine with a different audio card.

Any ideas?
Quick reply to this message  
Join Date: Nov 2005
Posts: 4
Reputation: hardkraft is an unknown quantity at this point 
Solved Threads: 0
hardkraft hardkraft is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #12
Nov 8th, 2005
OK, sorry to have bothered you. I think my mic level was too low. It was in the middle which I thought was enough. Now it's all the way up and I still have to speak right into the mic to get results.
Thanks for a nice piece of code.
Quick reply to this message  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: audio level detection

 
0
  #13
Nov 10th, 2005
Just as I was about to reply...

Glad you're sorted with the code... I thought about the mic gain problem though,

Check in Control Panel to see if you've got a setup utility for your sound card, or try enabling 'Advanced Controls' on the Windows recording mixer. A lot of modern cards have a '+20dB' box to check which gives you a 100x boost in mic sensitivity.

If this fails try another mic.

Hope this helps
Alan
Quick reply to this message  
Join Date: Nov 2005
Posts: 4
Reputation: hardkraft is an unknown quantity at this point 
Solved Threads: 0
hardkraft hardkraft is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #14
Nov 21st, 2005
Everything is working fine now, that is except for the cpu loads which are at 100%. I tracked it to the idle loop that waits for the buffer to fill. Would you have any suggestions on how to reduce that? I am thinking about using a timer.
Quick reply to this message  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: audio level detection

 
0
  #15
Nov 23rd, 2005
Hi Hardkraft

Umm, I guess it will do this...:-(

Timer may be fine as you're not interested in precision timing, only killing time until the buffer's full. Let me know how you get on!

Alan
Quick reply to this message  
Join Date: Dec 2005
Posts: 7
Reputation: soorya is an unknown quantity at this point 
Solved Threads: 0
soorya soorya is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #16
Dec 19th, 2005
hi,
i need a vu meter for video file playback.
i hope video file playback is controled by wave in/out.
can u pls. help me how to view the moving vu meter for video file playback, so that i can control wave slider in the audio mixer and control the sound level.

regards
soorya
soorya@vsnl.com
Quick reply to this message  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: audio level detection

 
0
  #17
Dec 20th, 2005
Hi Soorya!

I did some work on this myself because I needed an 'automatic level control' for an mp3 based disco application I was writing, and wanted to to equalise the level at which different mp3 files played. As I understand it, audio/video- it makes no difference as far as the way the sound is handled is concerned.

As for the answer, here's a few pointers:
VU meters (in sound card terms) aren't a good idea as they aren't implemented in any standard way on different cards and some low end chip sets don't have them at all. With these, what you get is a 'snapshot' of the sample values at regularly repeating intervals. When this is displayed on a bar graph, the peak value the samples get to is visible by persistance of vision. This is really all the usual displays (like on the Windows mixer) do. However, it's neither a 'VU meter' in the true sense of the word nor a measurement you can export without some additional maths. The sound card VU meter gives a 16-bit number where 16383 is 'zero' and 0 and 32767 are positive and negative max. respectively. See what I mean?!

Incidentally, a true VU meter is logarithmic and has defined attack and decay times.

Controlling the volume sliders in the sound card is difficult. There is a lot of API programming and it's necessary to enumerate the sources, destinations, 'controls' and 'lines' in the sound card, and their names and capabilities, to sort out what is what.
The following link is to a VB5/6 project that is a vaulable development tool for anyone playing with audio, it enumerates and displays all of the facilities in the card.

http://www.shrinkwrapvb.com/mixer.htm

The good news is, once you've been through the grief of identifying the control you want to change, writing a new value to it (a 16 bit number between 0 and 32767) is easy enough.

Here's some pitfalls:
Some of the DirectX controls seem to bypass part of the sound card, or do their D/A conversion in a different way, so that VU meter on the wave out line doesn't work. An example of this is using msdxm.ocx to play an mp3.

I hope this helps. I might write a tutorial on using audio if I ever get time...

Regards, AlanC
Quick reply to this message  
Join Date: Dec 2005
Posts: 7
Reputation: soorya is an unknown quantity at this point 
Solved Threads: 0
soorya soorya is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #18
Dec 20th, 2005
Thanks a lot AlanC,
I agree what u say...

but i have seen DXVU Meter activeX written in VB6 works really great. It has more fetaures than i wanted.
I generally don't use third party tool in my application.
so i prefer writting my own control.
but i could'nt find any sample code to make VU meter by using DirectX.

if u come across any sample, pls. let me know.
Thanks again for the time you have spent for me.

soorya
soorya@vsnl.com


Originally Posted by AlanC
Hi Soorya!

I did some work on this myself because I needed an 'automatic level control' for an mp3 based disco application I was writing, and wanted to to equalise the level at which different mp3 files played. As I understand it, audio/video- it makes no difference as far as the way the sound is handled is concerned.

As for the answer, here's a few pointers:
VU meters (in sound card terms) aren't a good idea as they aren't implemented in any standard way on different cards and some low end chip sets don't have them at all. With these, what you get is a 'snapshot' of the sample values at regularly repeating intervals. When this is displayed on a bar graph, the peak value the samples get to is visible by persistance of vision. This is really all the usual displays (like on the Windows mixer) do. However, it's neither a 'VU meter' in the true sense of the word nor a measurement you can export without some additional maths. The sound card VU meter gives a 16-bit number where 16383 is 'zero' and 0 and 32767 are positive and negative max. respectively. See what I mean?!

Incidentally, a true VU meter is logarithmic and has defined attack and decay times.

Controlling the volume sliders in the sound card is difficult. There is a lot of API programming and it's necessary to enumerate the sources, destinations, 'controls' and 'lines' in the sound card, and their names and capabilities, to sort out what is what.
The following link is to a VB5/6 project that is a vaulable development tool for anyone playing with audio, it enumerates and displays all of the facilities in the card.

http://www.shrinkwrapvb.com/mixer.htm

The good news is, once you've been through the grief of identifying the control you want to change, writing a new value to it (a 16 bit number between 0 and 32767) is easy enough.

Here's some pitfalls:
Some of the DirectX controls seem to bypass part of the sound card, or do their D/A conversion in a different way, so that VU meter on the wave out line doesn't work. An example of this is using msdxm.ocx to play an mp3.

I hope this helps. I might write a tutorial on using audio if I ever get time...

Regards, AlanC
Quick reply to this message  
Join Date: Jul 2005
Posts: 31
Reputation: AlanC is an unknown quantity at this point 
Solved Threads: 1
AlanC's Avatar
AlanC AlanC is offline Offline
Light Poster

Re: audio level detection

 
0
  #19
Dec 22nd, 2005
Soorya,

Please try the project attached below. It's a VU meter using the principle I worked on for level detection, i.e. it puts the sound card in record, grabs samples, and measures them. Its all VB6 with no 3rd party controls.

This works even using DirectX components for play, but will only work if your sound card's full duplex (most are now aren't they?) You'll need to select 'wave' on your recording mixer as the source.

This is a first stab attempt and I roughly calibrated it to 0dB full scale with a given level setting but it'll depend on your system. Attack/decay timing will depend on the speed of your computer. As it's logarithmic even tiny signals and any noise or offset will give a slight reading with no sound.

I also have a tone generator app for calibrating such things if you need it.

Take care and have a good Christmas.
AlanC
Attached Files
File Type: zip AudioVU.zip (9.0 KB, 624 views)
Quick reply to this message  
Join Date: Dec 2005
Posts: 7
Reputation: soorya is an unknown quantity at this point 
Solved Threads: 0
soorya soorya is offline Offline
Newbie Poster

Re: audio level detection

 
0
  #20
Dec 22nd, 2005
Thanks a miilion !

I got the code and tried...

It is not working in my PC.
always the level seems 20% flat, even without any signal.
(Sound card device is detected correctly)

when I play video file/wave audio file, no difference at all...
I tried adjusting wave mixer control level....

I am not sure about my sound card, it is built-in sound card with Intel P4 Mother Board.

i can't suspect ur great coding... u might have checked it in ur system. i think some small trick is needed to make it working perfect with all system.

DXVU Meter ActiveX and AC3 DS Filter VU meter works fine with my system. so i can't doubt my sound card also.

pls. spend some more time to fix this issue.

Again my hearties Thanks for ur interest on my need.

regards
soorya



Originally Posted by AlanC
Soorya,

Please try the project attached below. It's a VU meter using the principle I worked on for level detection, i.e. it puts the sound card in record, grabs samples, and measures them. Its all VB6 with no 3rd party controls.

This works even using DirectX components for play, but will only work if your sound card's full duplex (most are now aren't they?) You'll need to select 'wave' on your recording mixer as the source.

This is a first stab attempt and I roughly calibrated it to 0dB full scale with a given level setting but it'll depend on your system. Attack/decay timing will depend on the speed of your computer. As it's logarithmic even tiny signals and any noise or offset will give a slight reading with no sound.

I also have a tone generator app for calibrating such things if you need it.

Take care and have a good Christmas.
AlanC
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 24071 | Replies: 32
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC