WaveAudio tweaks

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

WaveAudio tweaks

Postby Roko » October 13th, 2003, 2:17 pm

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;
Roko
Member
Member
 
Posts: 2
Joined: October 13th, 2003, 1:51 pm
Location: Khmelnitsky, Ukraine

Postby Kambiz » October 13th, 2003, 8:15 pm

Thanks a lot! :)
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