Page 1 of 1

Direct file conversion to standard PCM format

PostPosted: June 22nd, 2011, 7:04 pm
by xusc
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

Re: Direct file conversion to standard PCM format

PostPosted: June 23rd, 2011, 10:41 am
by Kambiz
Hi,

Use ConvertTo method of TWaveStreamAdapter (or its descendents) to convert your wave audio.

Re: Direct file conversion to standard PCM format

PostPosted: June 23rd, 2011, 2:21 pm
by xusc
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

Re: Direct file conversion to standard PCM format

PostPosted: June 23rd, 2011, 6:29 pm
by Kambiz
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.