Record voice to mp3 stream

This one is very important so I'm going to make it worth while. What I need to do is record from microphone to mp3 stream and write the stream to file.  I would like some example code for this one. I need record, stop, and playback capabilities.  Please don't just point me to a website ( these answers will be rejected ), i must have some example code, and if 3rd party components are used, I will need to know where to obtain them.  Thanx in advance.

Who is Participating?
special formats are declared in the mmreg.h header
listening ... for moment
Listening too :)
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.


If you want to know more about wav2mp3 then you really ought to take a look at this paper:

It will at least show you what you are up against.

Reject this as you like... you have no quick fix!

The first part (Demo2.dpr) acts as a server. It has a server socket listening on port 6565 for new connections. At the same time it takes audio in from the MIC, converts it into MP3 16BIT 8Khz MONO (2k/second) and pipes it out.
Downloadable demo code here:

The above is useful reading.Not meant as an answwer to your question, simply a source of info.

(recording from pc mic in delphi is not as straight forward as you might think) You'll need to convert to mp3 anyway. you can download encoders/decoders at the above URL

If I find any relevant code to assist you, I'll post it

Good luck
Stormmin66Author Commented:
Yes, I realize there is no quick fix for this. I can take the input from the microphone and create a wav file, but i don't want to have to go thru converting it to mp3, I would like to record the stream as mp3.
i think it's better to first recrd to a wav stream and afther that convert it into mp3, since the encoding process takes up a lot of time. Or you state in your hardware requirements that a strong machine is nessesery.
As far as i know it's still impossible to encode wav to mp3 realtime.

still if you want to bypass this problem you should buffer the wave file and feed blocks to the encoder. (as far as i know mp3 is a format designed for streaming.)
Hello ginsonic... we meet yet again.

Now, Stormmin66, I think it IS possible to acheive what you ar planning. I don't have the knowhow - in fact few people on this planet do because it's very sohpisicated - but if you go to the people behind LAME encoder, you can get well along the road there. LAME, like BladeEnc, is a MPEG1 Layer3 encoder/decoder subject to the General Public License. Unlike BladeEnc its performance is musically perfect. Source code is available via CVS. Like the others it only works on files, but I see no reason why, if you mess with the code (which I think is in C++, if I remember correctly) you can't substitute file input with RAM input. MPEG always segments or windows the input into tiny packets called frames, so what you're doing will not be too difficult. The LAME project will probably appreciate any contribution you can make.

a real simple way would be to use the ACM Components from
they're free with source and use the MS ACM
you can also checkout my demo of VoIP to see how to use them
to make the mp3 work you need to wrap it in this structure :

  MP3_wfe_tag = packed record
    wID: WORD;
    fdwFlags: DWORD;
    nBlockSize: WORD;
    nFramesPerBlock: WORD;
    nCodecDelay: WORD;

  // addons for extra codecs
  WAVE_FORMAT_MSG723 = 66;



  msg723_mn: array[0..9]of Byte = (2, 0, $ce, $9a, $32, $f7, $a2, $ae, $de, $ac);
  mpgl3_mn: MP3_wfe_tag = (
    nBlockSize: 0;
    nFramesPerBlock: 1;
    nCodecDelay: $0571);

acm components have the abilitiy to use extended formats
you simple add the constant mpgl3_mn format to the end of the WaveFormatEx strucutre of the acmconverter component

// acmConvIn is TACMConvertor
const offset = SizeOf(TWaveFormatEx);
with acmConvIn.FormatOut do
       if Format.wFormatTag = WAVE_FORMAT_MSG723 then
          Move(msg723_mn, RawData[offset], 10);

you do the same for mp3
Hi Lee Nover

You gave him the same URL I gave him a ½ dozen posts ago!
ahhh ... didn't see the whole link .. just the .. :)
Stormmin66Author Commented:
Lee, i'll give this a try and see if i follow what you are saying, may be back for more details.
Hi lee...
I tryied out your VoIP Sample and could not get it to work on my Win98 peer-to-peer LAN

I type the IP address of the other machine on mine and press enter, the program goes trought a long time-out and enables again! No sound on the other side!

Am I doing something wrong?

VSF - dunno, it works for me on win2k, I've tested it with some other ppl on different oses and it worked
it's merely a demo of how to make a voip app
I made it to test the system before I implemented it into a bigger project - didn't want to recompile the client and the server everytime :)
what if you use localhost ?
and on lan you can use the computers name
you can also leave the box empty - then it will broadcast into the LAN
all of the VoIP apps in the network will receive the broadcast
you can mail me regarding the VoIP app -
Stormmin66Author Commented:
Sorry took so long to reply, been on vacation.  Code really helped out, thanx.
about these Components .. you don't have to use anything extra with mp3 if you use the professional version of the Fraunhoffer codec which can also be downloaded at that site
I don't know what I did wrong before but now it works without any modifications
that little 'hack' is still needed for MS G.723.1

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.