Solved

Record voice to mp3 stream

Posted on 2002-05-20
15
882 Views
Last Modified: 2010-05-18
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.

Stormmin
0
Comment
Question by:Stormmin66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +4
15 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 7023277
listening ... for moment
0
 
LVL 3

Expert Comment

by:tongalite
ID: 7023637
Listening too :)
0
 
LVL 3

Expert Comment

by:tongalite
ID: 7023667


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

http://delphi.about.com/library/bluc/text/uc050501a.htm

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

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

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

http://delphi.about.com/gi/dynamic/offsite.htm?site=http://www.stuckindoors.com/delphi/acm/downloads.html

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
t.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Stormmin66
ID: 7023956
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.
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 7024181
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.)
0
 

Expert Comment

by:HorridMan
ID: 7024445
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.

Website...  http://www.sulaco.org/mp3/
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7024653
a real simple way would be to use the ACM Components from http://www.stuckindoors.com/delphi
they're free with source and use the MS ACM
you can also checkout my demo of VoIP to see how to use them
http://lee.nover.has.his.evilside.org/isapi/pas2html.dll/pas2html?File=/delphi/projects/VoIP
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;
  end;


  // addons for extra codecs
  WAVE_FORMAT_MSG723 = 66;
  WAVE_FORMAT_MPEGLAYER3 = $0055;
  MPEGLAYER3_WFX_EXTRA_BYTES = 12;

  MPEGLAYER3_ID_UNKNOWN = 0;
  MPEGLAYER3_ID_MPEG = 1;
  MPEGLAYER3_ID_CONSTANTFRAMESIZE = 2;

  MPEGLAYER3_FLAG_PADDING_ISO = $00000000;
  MPEGLAYER3_FLAG_PADDING_ON = $00000001;
  MPEGLAYER3_FLAG_PADDING_OFF = $00000002;

  msg723_mn: array[0..9]of Byte = (2, 0, $ce, $9a, $32, $f7, $a2, $ae, $de, $ac);
  mpgl3_mn: MP3_wfe_tag = (
    wID: MPEGLAYER3_ID_MPEG;
    fdwFlags: MPEGLAYER3_FLAG_PADDING_OFF;
    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);
begin
with acmConvIn.FormatOut do
       if Format.wFormatTag = WAVE_FORMAT_MSG723 then
          Move(msg723_mn, RawData[offset], 10);

you do the same for mp3
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 500 total points
ID: 7024658
special formats are declared in the mmreg.h header
0
 
LVL 3

Expert Comment

by:tongalite
ID: 7025288
Hi Lee Nover

You gave him the same URL I gave him a ½ dozen posts ago!
T.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7025366
ahhh ... didn't see the whole link .. just the about.com .. :)
0
 

Author Comment

by:Stormmin66
ID: 7027395
Lee, i'll give this a try and see if i follow what you are saying, may be back for more details.
0
 
LVL 3

Expert Comment

by:VSF
ID: 7027735
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
www.victory.hpg.com.br
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7028428
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 - Lee_Nover@delphi-si.com
0
 

Author Comment

by:Stormmin66
ID: 7044828
Sorry took so long to reply, been on vacation.  Code really helped out, thanx.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7044866
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

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question