Solved

sound play in delphi

Posted on 2004-03-24
7
210 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
[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
  • 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
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: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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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