Solved

sound play in delphi

Posted on 2004-03-24
7
207 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
ID: 10668641
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
ID: 10668695
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
ID: 10674597
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:ravisiva
ID: 10674630
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
ID: 10676339
It is stored int he Default file (Fake)

Shane
0
 

Author Comment

by:ravisiva
ID: 10685772
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
ID: 10686792
Yes!

Shane
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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