# VBForums UtilityBank > UtilityBank - Other >  MP3 Encoder with Blade encoder

## CVMichael

OK, this is something I'm sure all of you will like...

This is basically what I've done in this thread 2 years ago.
http://www.vbforums.com/showthread.php?t=163097

This app, records sound with DirectXSound, and encodes it REAL TIME to an MP3 file, no other files in between...

You can record to MP3 in Mono or Stereo, sample rates of 48000, 44100 and 32000, and with those bitrates: 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320

First of all, download the BladeEnc.dll from this website:
http://home.swipnet.se/~w-82625/skeleton/DL.html
This is the website I found by searching on the net, there are probaly many other places where you will also find the dll.
Unzip the dll in your system folder

From the ZIP attached, place the BladeEncVB\Release\BladeEncVB.dll in the system folder also.
I made the BladeEncVB.dll because you cannot reference the BladeEnc.dll directly from Visual Basic, so I had to make something in between.
I also added a digital volume, and will amplify the sound up to however much you like, in the app i made the limit up to 600%, but you can change the code to amplify much more than that.

Now you can run the application, record away !  :Smilie:

----------


## CVMichael

A screen shot...

----------


## si_the_geek

The code/files within this thread (submitted: 03-07-2004) have been checked for malware by a moderator.

Disclaimer: _This does not necessarily mean that any compiled files (DLL/EXE/OCX etc) are completely safe, but any supplied code does not contain any obvious malware.  It also does not imply that code is error free, or that it performs exactly as described.

It is recommended that you manually check any code before running it, and/or use an automated tool such as Source Search by Minnow (available here or here).  
If you find any serious issues (ie: the code causes damage or some sort), please contact a moderator of this forum.

Usage of any code/software posted on this forum is at your own risk._

----------


## CDRIVE

Michael, I followed this post & link which brought me here. 
http://www.vbforums.com/showthread.p...ht=sound+event
While I realize that these are very old posts of yours, I'm interested in doing the same thing that the OP wanted to do. Namely. I want to trigger an event when audio level from the mic input is above a predetermined level. 

My question is... There are two files listed at the link to *BladeEnc*. 
http://home.swipnet.se/~w-82625/skeleton/DL.html

One is *BladeEnc082.zip* and *BladeDLL-082-intel.zip*. Which of these files should I download, or is it both?

Thanks

----------


## CVMichael

For your last question... I don't remember... I made this project a while ago, I don't remember having as many options as there are listed now  :Embarrassment:   :Smilie: 

I would go for: BladeDLL-082-intel.zip and if it does not work, then try the other one, you don't have to install the DLL, therefore, if it does not work, you can just delete it, and try the other one. I will try it myself later....

To encode to MP3 I now use the Lame ACM codec, I don't use the BladeEncoder anymore. I did not have time to make a project to put it in the CodeBank (or tutorial) using the Lame ACM.

Anyways....

But for your first question... you don't need to encode to MP3 in order to get the sound level... you only need DirectX... At the time I posted in the thread 
"How get voice-key event in VB6?" I did not have my sound tutorial.

Here's what to do:
Download the attachment from Post #5 from my sound tutorial: From Here

This code is a "clean" code on how to record, just remove the code where it saves to the wav file.

Now replace the DisplayWaveData16 from the tutorial with the ShowWAVData16Bit from the MP3Encoder, of course you will have to make a few modifications to make it work.

What you need is the LAve & RAve from the ShowWAVData16Bit sub.
In fact you can strip all the code from the function except where the LAve is calculated.
Or... you could see how LAve is calculated, and just modify the code in the tutorial to calculate the LAve.....

LAve stands for Left channel average, and RAve stans for Right channel average. But since you will record in Mono (microphone is mono), you only need the "LAve".

Now all you have to do is something like:
If LAve > your_threashold Then RaiseEvent...

I did not do this for you because I think it will help you understand what is going on in the project better, since your gonna work with the code.

But if you have any problems, I will make a project for you that does what you need.

----------


## CDRIVE

Michael, it's 0130hrs and I need to get to bed, but I wanted to get this posted befor I hit the sack. What can I say .... IT'S GREAT!! I love it! I won't pretend to understand all the code but I'm just dangerous enough to plod through others code to make it do what I want. I added this test code in the Private Sub DisplayWaveData16(DataBuff() loop. 



```
Label1.Caption = RY     '  Display input level digitaly
       If RY >= 0.8 Then Label2.Caption = "Threshold Reached"  'Display Threshold level reached
```

Ultimately I will be including a timer that will be enabled by an input level that is greater than my threshold value and be disabled when a second audio value exceeds a similar value.
Thank you so much for your knowledge and skill. :wave:   :Big Grin:   :Thumb:   :Thumb:   :Thumb:  
Chris

----------


## CVMichael

Ow... I now understand what you wanted... I was telling you to basicaly get the average of the whole buffer, and check the peek of that... but you actually want to see if any sample within the buffer is over the peek....

----------


## CDRIVE

> Ow... I now understand what you wanted... I was telling you to basicaly get the average of the whole buffer, and check the peek of that... but you actually want to see if any sample within the buffer is over the peek....


That's correct Michael. I'm an EE working in the Biomedical Electronics field. Just about any topic that interfaces the PC and or VB to the outside world interest me. My interest in this topic was tweeked from a post on DevX Forums. 
http://news.devx.com/showthread.php?t=167138
The OP is an archer who wanted to measure elapsed time from arrow launch to arrow impact on the target. As you will see from the link the OP has not posted a reply since my last post. No matter though, as I can apply this concept to all sorts of things to amuse myself! 

When I finish this project it will display and save elapsed time & ft/sec in a text or excel file. I'm certain that a similar question will again be posted some day. When it is I will post what I've created with full credit going to you for creating the bulk and heart of the program. 

If I have any further questions for you I will post them.

Thank you again for your time and a great app!! :wave:   :Thumb:

----------


## gtsdigital

> For your last question... I don't remember... I made this project a while ago, I don't remember having as many options as there are listed now  
> 
> I would go for: BladeDLL-082-intel.zip and if it does not work, then try the other one, you don't have to install the DLL, therefore, if it does not work, you can just delete it, and try the other one. I will try it myself later....
> 
> To encode to MP3 I now use the Lame ACM codec, I don't use the BladeEncoder anymore. I did not have time to make a project to put it in the CodeBank (or tutorial) using the Lame ACM.
> 
> Anyways....
> 
> But for your first question... you don't need to encode to MP3 in order to get the sound level... you only need DirectX... At the time I posted in the thread 
> ...




CVMichael,

   I know that some time ago but you do not program in VB6, but help me, change your project using the Lame ACM MP3 and WAV to please.
 :Frown:

----------


## CVMichael

Did you see this thread ?

http://www.vbforums.com/showthread.php?t=358703

and this ?

http://www.vbforums.com/showthread.php?t=390620

----------


## gtsdigital

> OK, this is something I'm sure all of you will like...
> 
> This is basically what I've done in this thread 2 years ago.
> http://www.vbforums.com/showthread.php?t=163097
> 
> This app, records sound with DirectXSound, and encodes it REAL TIME to an MP3 file, no other files in between...
> 
> You can record to MP3 in Mono or Stereo, sample rates of 48000, 44100 and 32000, and with those bitrates: 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320
> 
> ...


Michael,

  I wish your project utilized the "Lame ACM" and not "Blade encoder", you have to change, please?

please
please
please
please :Blush:

----------


## gtsdigital

> Did you see this thread ?
> 
> http://www.vbforums.com/showthread.php?t=358703
> 
> and this ?
> 
> http://www.vbforums.com/showthread.php?t=390620


Michael,

  I wanted you to modify their excellent design and utilizes the above encoder Lame ACM "and not" Blade encoder, "is how you change for me, please?

   Its design is the best I've ever seen, but I can not modify it to use the Lame ACM, keeping charts.

please
please
please
 :Confused:

----------


## CVMichael

Sorry but what you are asking will take days of work. Even if you pay me $100 per hour I will still not do it... Working with ACM is not nearly as easy as the Blade Encoder.

Your only chance is to learn programming and do it for yourself. If I can do it, you can do it too...

[Edit]
By the way... I also turned off the Private Messaging on my profile because of you...

----------


## Bellapattins

Hi,I use windows 7 x64.
I just figured out in order to use LAME as an MP3 encoder within virtualdub, I'd need the 64 bit version of virtualdub, and the 64 bit version of LAME ACM.
I tried frameserving video into virtualdub using directshowsource. It is x264 video contained in an mkv container, with ac3 audio. It said the audio and the video were not supported formats.
I didn't have that problem with 32 bit avisynth, 32 bit virtualdub.
so I uninstall ffdshow 32 bit, and find/install 64 bit ffdshow, reboot, and I get the same thing??
I am so confused. my ffdshow clearly works since I can play the file in MPC-HC x64, but virtualdub refuses to see it. :Alien Frog:

----------


## Melinda23

I've been trying to install the Lame ACM encoder on my Vista 64 bit OX but it just won't install properly. I know that I have to use a slightly different method of installing 32bit encoders on a 64 bit OS. I've managed to successfully install Huffyuv and Lagarith (both 32 bit) on my system by:

1. Opening up a command prompt by typing "cmd" in the run box and pressing Ctrl+Shift+Enter (to run as Administrator).
2. Changing directories to sysWOW64 ("cd C:\windows\syswow64")
3. Typing the following (example_path replaced with the actual path to the extracted files), then hit enter: rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 0 c:\Temp_Folder_Path\codecXXX.inf :Eek Boom:

----------

