Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Recording a wave file

Posted on 1998-11-23
7
Medium Priority
?
223 Views
Last Modified: 2010-04-04
Hi

How can I record a new WAV file from the mic and save it into a new file?

Saar
0
Comment
Question by:saar2
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Expert Comment

by:msac_m
ID: 1347664
There are a lot of sound components in the Delphi Super page
and they are capable of getting the sound from the Sound Card,
and capable of giving them in the buffers.

 When the buffer is filled, the component fires the onbufferarrive or something like that. In the event handler of this event simply write the arrived buffer to the HD.(I think that some of these components must have the ability of directly writing to a wav file.
)
If they lack this ability(recording to wav file), you must add a header to very first beginning of the file.

As you know WAV file has header, which holds the size of the file , the sampling frequency used and the things like that, So you must arrange the header.

To have the header done;
1- first write the header section to the HD. (Before writing anything to HD.)
2- Start recording, add the coming data to the end of the header that you wrote.
2- After completing the record , return the header section and write the correct values for the file size, frequecy ..


Regards,


0
 
LVL 4

Author Comment

by:saar2
ID: 1347665
Where is the Delphi Super page ?

Could you please give me the source code for the header writing?

Thank you,
Saar
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1347666
saar2,

 this article is already a good start :

 http://www.undu.com/DN970901/00000022.htm

 It is for D1 so you'll need to change some code.

 DSP : http://sunsite.icm.edu.pl/delphi/

 and another good one :

 Torry : http://www.torry.ru/index.htm

Regards, Zif.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Accepted Solution

by:
trillo earned 300 total points
ID: 1347667
The easiest way is using the low level API using the "mciSendString" function.

For example: place some buttons on your form and write this code.

-------Record button-------
        i =: mciSendString('open new type waveaudio alias anyname', 0, 0, 0);
        i =: mciSendString('record anyname to 20000', 0, 0, 0);

------Stop button----------
        i =: mciSendString('stop anyname', 0, 0, 0);

--------Play button-------
        i =: mciSendString('play anyname from 1 wait', 0, 0, 0);

------Save button---------
        i =: mciSendString('save anyname c:\wave.wav', 0, 0, 0);
        i =: mciSendString('close anyname', 0, 0, 0);

Note: This example uses 20000 miliseconds as the maximum recording time, you can increase this value on the record command (see the code on the record button). The recording stops on two cases. Whe the maximum time is reached or when the user selects the stop button (the one that happens first)

Other note: The "open" and "close" commands are relative to the device, you have to use the "open" command prior to any wave operation (record, play, save, etc..) and use the "close" command when you have finished. Remember all your wave operations must happen between the "open" and "close" MCI commands.

Trillo
0
 

Expert Comment

by:msac_m
ID: 1347668
As ZifNab stated
 the edlphi uper page URL is
 http://sunsite.icm.edu.pl/delphi/

Regards
0
 
LVL 4

Author Comment

by:saar2
ID: 1347669
msac_m, I looked at the Delphi Super Page and I didn't find any free component which let me create and save a file. I tried to download some files but the links were broken.

trillo, I don't know much about Delphi. Do I need to create Tmediaplayer object?
How do I use the Open/Close commands? What is the "i" variable?

Thank you all,
Saar
0
 
LVL 2

Expert Comment

by:trillo
ID: 1347670
Ok.... let's see:
The code I posted here makes use of API functions, this means that you don't have to create a TMedaPlayer component, reducing the memory and executable space needed.

The open, close, save (and others) are called MCI commands ("multimedia command interface"), and the are used with the mciSendString APi function. This is a powerful function that allows you to manipulate almost any kind of multimedia type (audio, midi, avi video, CD, etc..)
What is the "i" variable.... It's optional but it's always useful. The mciSendString functions always return a value depending on the string used, but in all cases when the functions is succesfull it returns 0. This will allow you to trap errors, if "i" is different from 0 an error occurred.

There are a lot of these MCI command strings and the keywords and syntax depend on each command and device. You can find the documentation of MCI commands on help files, or if you don't have them you have two choices: Searching on the Web or just write "Trillo, tell e more about MCI", OK?
I hope this helped you a little bit.
Trillo
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

604 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