Direct file conversion to standard PCM format

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Direct file conversion to standard PCM format

Postby xusc » June 22nd, 2011, 7:04 pm

Hi,

I tried your WaveAudio demo and impressed!

I have a problem in my application to read in a wave file which is in floating point format.

I tested that your player component can play floating point wave and how can I output to a standard PCM format?

I wish I can first convert the floating point formatted wave file to a standard PCM format and then read into my program.

Thanks very much for your time to my question!

Best Regards,
xusc
xusc
Member
Member
 
Posts: 2
Joined: June 22nd, 2011, 6:54 pm

Re: Direct file conversion to standard PCM format

Postby Kambiz » June 23rd, 2011, 10:41 am

Hi,

Use ConvertTo method of TWaveStreamAdapter (or its descendents) to convert your wave audio.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Direct file conversion to standard PCM format

Postby xusc » June 23rd, 2011, 2:21 pm

Hi Kambiz,

I placed a TWaveStorage component on the design form , and load a wave file called 'mywave.wav' in IEEE floating format in design time.

Then in a button I write the code:

procedure TForm1.Button1Click(Sender: TObject);
var NewWaveFormat: TWaveFormatEx;
begin
SetPCMAudioFormatS(@NewWaveFormat,Stereo16bit44100Hz);
WaveStorage1.Wave.Stream.Position:=0;
WaveStorage1.Wave.ConvertTo(@NewWaveFormat);
end;

Then I have no idea how to save the converted file as I read the Converto function in the wavestroage unit it returns boolean result.

Any hints or code?

Thanks very much for your help!

xusc
xusc
Member
Member
 
Posts: 2
Joined: June 22nd, 2011, 6:54 pm

Re: Direct file conversion to standard PCM format

Postby Kambiz » June 23rd, 2011, 6:29 pm

If ConvertTo returns true, the content of the Wave object is in the new format. Simply call WaveStorage1.Wave.SaveToFile to save the converted audio.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron