Page 1 of 1

WaveAudio tweaks

PostPosted: October 13th, 2003, 2:17 pm
by Roko
I'm trying Wave Audio components for possible usage in some upcoming project. So far they look good. Especially promising is WaveCollection in addition to Stock Recorder/Player.

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;

PostPosted: October 13th, 2003, 8:15 pm
by Kambiz
Thanks a lot! :)