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

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

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

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

Joe

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

Member Avatar for AlanC

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

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

THANK YOU.

Joe

Member Avatar for 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 :) :)

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

Joe

Member Avatar for AlanC

Joe

Thanks! Glad to have been of assistance.

Alan

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?

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.

Member Avatar for AlanC

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

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.

Member Avatar for AlanC

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

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

Member Avatar for 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

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

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

Member Avatar for 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

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

Member Avatar for AlanC

Hi Soorya

I'll check it. What you describe sounds very like the vu meter is working OK though, particularly the 20% bit. You can get rid of this by changing the code in the sub LevelMeters() to subtract 128 instead of 127-

'half-wave rectify the audio
intAudioL = (InData(i * 2) - 128)
If intAudioL < 0 Then intAudioL = 0
intAudioR = (InData((i * 2) + 1) - 128)
If intAudioR < 0 Then intAudioR = 0
etc
etc

The fact that you get this effect says that you are capturing samples.

So please double check the settings on the mixer. What happens if you play a CD in the computer, selecting the CD Audio input on the Windows recording mixer, or, connect your personal CD via a suitable cable to the line in jack at the back of your PC, and on the Windows recording mixer, select 'line'. Which version of Windows are you running- you might have to recompile the app rather than use the .exe I supplied as the API (winmm.dll) could be a different release.

Pic in the attachment shows it running with a CD playing so you can see the settings.

Take care AlanC

:D :D :D
Dear AlanC,

Finaly u made me smiling :)
working great !

as per ur advice i just ticked "Wave Out Mix" in the Recording Mixer, This is the Magic/Logic/Trick etc....

Now it started working great...
why it is not told by any one in the net?
many experts makes vu meter coding and finally it does'nt works apart from their PC.
when user/other ask the solution they just blame sound card.

any how Thanks a lot AlanC !
very kind of you...

Now let me make my own control...

btw
what area ur specialized in VB6?
I am into Video playbacks...
If u need any help pls. contact me at
soorya@vsnl.com

I use WinXP SP2

soorya :D


Hi Soorya

I'll check it. What you describe sounds very like the vu meter is working OK though, particularly the 20% bit. You can get rid of this by changing the code in the sub LevelMeters() to subtract 128 instead of 127-

'half-wave rectify the audio
intAudioL = (InData(i * 2) - 128)
If intAudioL < 0 Then intAudioL = 0
intAudioR = (InData((i * 2) + 1) - 128)
If intAudioR < 0 Then intAudioR = 0
etc
etc

The fact that you get this effect says that you are capturing samples.

So please double check the settings on the mixer. What happens if you play a CD in the computer, selecting the CD Audio input on the Windows recording mixer, or, connect your personal CD via a suitable cable to the line in jack at the back of your PC, and on the Windows recording mixer, select 'line'. Which version of Windows are you running- you might have to recompile the app rather than use the .exe I supplied as the API (winmm.dll) could be a different release.

Pic in the attachment shows it running with a CD playing so you can see the settings.

Take care AlanC

Why would I get "Retained is an invakid key" when trying to open this project.

Member Avatar for AlanC

Hi nsliep
You get this error when you open a VB6 project in VB5. To correct it, open the project .vbp file in Notepad, and about 3 lines up fro the bottom you'll see the line 'Retained = 0'. Just delete this line, and save the file. It'll now load up.
Hope this helps,
rgds,
AlanC

Thanks, I have done it and it works.

I used sleep, now everything is fine, 4% load tops. I also made some refinements to the code so it double buffers. Before it was loosing 5ms between buffers which may not be important for most people but it was for me since I was also recording the sound.

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.

Member Avatar for AlanC

Cool. I was aware of the potential performance issues with this approach, good to know you sorted it. How does the double buffer work?
Rgds
AlanC

I used sleep, now everything is fine, 4% load tops. I also made some refinements to the code so it double buffers. Before it was loosing 5ms between buffers which may not be important for most people but it was for me since I was also recording the sound.

Dear handkraft,
glad to see u are using double buffer...
could u pls. send me a sample code to soorya@vsnl.com ?

btw, can some one help me how to programatically select
WaveOut Mix option in Recording mixer, so that this VU meter
works fine.

thanks
soorya

Cool. I was aware of the potential performance issues with this approach, good to know you sorted it. How does the double buffer work?
Rgds
AlanC

Dear AlanC,
Can u help me how to programatically select
WaveOut Mix option in Recording mixer, so that this VU meter
works fine.

Thanks
soorya

Member Avatar for AlanC

Hi Soorya

This thread just lives on and on!

This is maybe possible but its difficult to do. I've been able to programmatically adjust the master volume but not much else. The fundamental issue is that there is a lot of variation between sound cards. To give you an idea of this, you can have a one-of-n selection switch for record source (e.g Soundblaster) or multiple selections (e.g. ESS chipsets); and the 'Stereo Mix' line you refer to can be called different things or may not exist at all.

Practically, the Win32 API allows you to enumerate the lines and controls in the recording mixer and you have then to make a decision about what you want to do. This will, I believe, be different from one card to another.

I've got a lot on at the moment but I'll have a look at some point.

I did make a start on my audio tutorial but this is a huge task too. I need to ask the moderators what I need to do to to post it up on DaniWeb- I'm sure it'd get loads of hits.

Best regards,
AlanC

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.