I obtain with these installed functions to call codec however my question is as to pass codec chosen to StockAudioRecorder using the chosen compression?
Functions:
function TForm1.AllocWaveFormatEx : Integer;
begin
FWaveFormat.cbSize
if acmMetrics(nil, ACM_METRIC_MAX_SIZE_FORMAT, FMaxFmtSize) <> 0 then begin
showmessage('Error getting the max compression format size.');
Result := -1;
Exit;
end;
GetMem(FWaveFormat, FMaxFmtSize);
if FWaveFormat = nil then begin
showmessage('Error allocating local memory for WaveFormatEx structure.');
Result := -2;
Exit;
end;
// initialize the format to standard PCM...
FillChar(FWaveFormat^, FMaxFmtSize, 0);
FWaveFormat.wFormatTag := WAVE_FORMAT_PCM;
FWaveFormat.nChannels := 1;
FWaveFormat.nSamplesPerSec := 11025;
FWaveFormat.nAvgBytesPerSec := 11025;
FWaveFormat.nBlockAlign := 1;
FWaveFormat.wBitsPerSample := 8;
FWaveFormat.cbSize := 0;
// store the format and tag decription strings...
GetFormatTagDetails(FWaveFormat.wFormatTag);
GetFormatDetails(FWaveFormat);
Result := 0;
end;
function TForm1.GetWaveFormat : integer;
var
acmopt : TACMFORMATCHOOSE;
err : MMRESULT;
ptmpfmt : PWAVEFORMATEX;
begin
GetMem(ptmpfmt, FMaxFmtSize);
if ptmpfmt = nil then begin
showmessage('Error allocating temporary format buffer.');
Result := -1;
Exit;
end;
Move(FWaveFormat^, ptmpfmt^, FMaxFmtSize);
// setup ACM choose fields and display the dialog...
FillChar(acmopt, sizeof(acmopt), 0); // zero out
acmopt.cbStruct := sizeof(acmopt);
acmopt.fdwStyle := ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
acmopt.hwndOwner := Handle;
acmopt.pwfx := FWaveFormat;
acmopt.cbwfx := FMaxFmtSize;
acmopt.pszTitle := 'Select Compression';
acmopt.fdwEnum := ACM_FORMATENUMF_INPUT;
err := acmFormatChoose(acmopt);
// if the same format was selected we don't want to reset FTotalWaveSize
// below, so act like a cancel...
if CompareMem(FWaveFormat, ptmpfmt, sizeof(TWAVEFORMATEX)) then
err := ACMERR_CANCELED;
if err <> MMSYSERR_NOERROR then begin
Move(ptmpfmt^, FWaveFormat^, FMaxFmtSize);
FreeMem(ptmpfmt);
if err = ACMERR_CANCELED then begin
Result := 0;
Exit;
end;
showmessage('Error in FormatChoose function');
Result := -2;
Exit;
end;
// store the format description...
FFormatDesc := acmopt.szFormat;
// get the format tag details, we don't need to call acmGetFormatDetails since
// that information was supplied by the choose function...
GetFormatTagDetails(acmopt.pwfx.wFormatTag);
FreeMem(ptmpfmt);
// now set the play button to a grayed state cause we don't want
// to try to play the recorded data with a different format...
FTotalWaveSize := 0;
Result := 0;
end;
function TForm1.GetFormatDetails(pfmtin : PWAVEFORMATEX) : integer;
var
acmfmtdetails : TACMFORMATDETAILS;
begin
// zero out struct...
FillChar(acmfmtdetails, sizeof(acmfmtdetails), 0);
acmfmtdetails.cbStruct := sizeof(acmfmtdetails);
acmfmtdetails.pwfx := pfmtin;
acmfmtdetails.dwFormatTag := pfmtin.wFormatTag;
acmfmtdetails.cbwfx := sizeof(TWAVEFORMATEX) + pfmtin.cbSize;
if acmFormatDetails(nil, acmfmtdetails,
ACM_FORMATDETAILSF_FORMAT) <> 0 then begin
showmessage('Warning, FormatDetails function failed');
Result := -1;
Exit;
end;
// store the format details description string...
FFormatDesc := acmfmtdetails.szFormat;
Result := 0;
end;
I tried using onFormat but I did not obtain, then I ask: It has as to pass codec chosen for the StockAudioRecorder?
Thank's and sorry for insistence.
Jean
jeanrl@netsite.com.br