Solved

sound play in delphi

Posted on 2004-03-24
7
205 Views
Last Modified: 2010-04-05
Dear all

I want to record the sound and play it from the recorded  one.
as like in window ...


If anybody have  the sample exe would be highly appreciated.
0
Comment
Question by:ravisiva
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
You could use the TMedia Player (System Tab of component pallette) .

If you dont want to have it viewable, set its visible property = False;

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
The Only issue with TMediaPlayer is,  

to do what you want - you have to give the TMediaPlayeran existing WAV file to start with.
That's not so bad though.  You can fake it by giving it a temp file with just enough header info to
get you started.  Here's what I've done:

procedure TMainForm.NewAudio1Click(Sender: TObject);
var NewWave: TextFile;
begin
  MediaPlayer1.Close;
  IF FileExists(StrPas(TempFileName)) then
   DeleteFile(StrPas(TempFileName));
   GetTempFilename('C','RRA',0,TempFileName);      
  {This creates a file in my Windows TEMP directory called
   RRAxxxx.TMP...  TempFileName is declared globally as a PChar}
   AssignFile(NewWave,StrPas(TempFileName));
   Rewrite(NewWave);
{This next line contains the header info with NO DATA for an 8bit
22khz mono sample.  I'm sure the file formats for others can be easily
obtained from the net or just by examining a valid file with a hex
editor or something.}
     WriteLn(NewWave,'RIFF'+#$34+#$00+#$00+#$00+'WAVEfmt '+
     #$12+#$00+#$00+#$00+#$01+#$00+#$01+#$00+
     #$22+#$56+#$00+#$00+#$22+#$56+#$00+#$00+
     #$01+#$00+#$08+#$00+#$28+#$00+'fact'+
     #$04+#$00+#$00+#$00+#$01+#$00+#$00#$00+'data'+
     #$01+#$00+#$00+#$00+#$80+#$00);
     CloseFile(NewWave);
     MediaPlayer1.FileName := StrPas(TempFileName);
     MediaPlayer1.Open;
     ShowMessage('Record mode enabled.  Press record to start.');
end;


Then when you're finished recording, use MediaPlayer1.Filename :=
'whatever.wav' to change the filename, MediaPlayer1.Save to save the
new data to that new filename, then delete the temp file you created
using the same DeleteFile line from above.

It works.

Shane
0
 

Author Comment

by:ravisiva
Comment Utility
Dear shaneholmes

I start with the existing wav file .
But sound is not recorded

It plays the old sound ( ie default sound in .wav file)

Why?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:ravisiva
Comment Utility
Dear shaneholmes

If we press record button the sound files are
store in a defaultfile or

we shoule explicitly  give ...save... command
0
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
It is stored int he Default file (Fake)

Shane
0
 

Author Comment

by:ravisiva
Comment Utility
Dear shaneholmes

If we reorded   sound   in the default file
it can overwrite the default sound?
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 20 total points
Comment Utility
Yes!

Shane
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now