954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

audio level detection

I was wondering if anybody has used the audio level detection software available at http://www.vbcodesource.com/downloads/audiolevel.zip
When I download the source code and run it I get two errors:
"Couldn't get wavein meter"
"Couldn't get waveout meter"

I am a beginner programmer and appreciate any advice or suggestions.

Thanks!

Joe

PS I am running Windows 2000 on an IBM Thinkpad

larmit
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

The only thing I get is an EXE, which I will NOT run unless I have the source code (then I'll compile it and run it).

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

The exe is compressed zip. Seems safe enough. I see if i can get the error.

jwshepherd
Junior Poster
123 posts since Jun 2005
Reputation Points: 20
Solved Threads: 5
 

I've uploaded the source files so you don't need to use the .exe to unzip.

Joe

Attachments volume.zip (13.71KB)
larmit
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

I just found out that the program only works on certain sound cards. Would you mind running it and if it works letting me know what model sound card you have? Thank you!

Joe

larmit
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Larmit,

Many sound cards don't have vu meters.

Have you considered putting the card in recording mode and grabbing some samples? You could loop round until an input is detected, or just use it as an indicator.. if you use 8-bit mode it makes it dead easy as the samples will be 127 if there's no input and anything else if there is. Hope this makes sense..

I've got some code somewhere that will do this if you need it.

Best of luck
Alan

AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

Yes, I'd greatly appreciate it if you could share your code that accomplishes this.

THANK YOU.

Joe

larmit
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

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 :) :)

Attachments Project1.zip (11.77KB)
AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

Alan,
You are awesome! Thank you so much. Your program works beautifully. This is most helpful.

Joe

larmit
Newbie Poster
7 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Joe

Thanks! Glad to have been of assistance.

Alan

AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

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?

hardkraft
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

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.

hardkraft
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

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

AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

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.

hardkraft
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

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

AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

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
[email]soorya@vsnl.com[/email]

soorya
Newbie Poster
7 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

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

AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

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
[email]soorya@vsnl.com[/email]

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

soorya
Newbie Poster
7 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

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

Attachments AudioVU.zip (9.02KB)
AlanC
Light Poster
31 posts since Jul 2005
Reputation Points: 13
Solved Threads: 1
 

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

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

soorya
Newbie Poster
7 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You