My wav files will be A-Law coded, so I used nonePCM PCMFormat and tried setting format in OnFormat event. This event is missing in TStockAudioRecorder! So I added following line to published section of TStockAudioRecorder class declaration
property OnFormat;
to make it published. It worked OK after that.
Another possible correction is in WaveIn.pas. When OnFormat call returns with pWaveFormat = nil in TWaveAudioIn.InternalOpen, AV is generated. So I added check:
- Code: Select all
function TWaveAudioIn.InternalOpen: Boolean;
var
pWaveFormat: PWaveFormatEx;
FreeWaveFormat: Boolean;
begin
Result := False;
if not Active then
begin
FreeWaveFormat := True;
GetWaveFormat(pWaveFormat, FreeWaveFormat);
[b] if pWaveFormat <> nil then // this is check[/b]
try
if Success(WaveInOpen(nil, DeviceID, pWaveFormat, 0, 0, WAVE_FORMAT_QUERY)) then
begin
AvgBytesPerSec := pWaveFormat^.nAvgBytesPerSec;
SamplesPerSec := pWaveFormat^.nSamplesPerSec;
BlockAlign := pWaveFormat^.nBlockAlign;
Result := Success(WaveInOpen(@fHandle, DeviceID, pWaveFormat, CallbackWND, 0, CALLBACK_WINDOW));
end;
finally
if FreeWaveFormat then
FreeMem(pWaveFormat);
end;
end
else if not Closing then
raise EWaveAudioInvalidOperation.Create('Device is aleardy open');
end;