Page 1 of 1

WaveAudio: how to mix recording and playback sounds

PostPosted: May 30th, 2010, 11:09 am
by u2227
Hello please help with WaveAudio.
I need to record voice from microphone, and play audio at the same time, and the played audio and voice should be mixed together into the recorded stream. I was reading the documentation carefully and inspecting the existing components, but I cannot find how to achieve this.

Thank you

Re: WaveAudio: how to mix recording and playback sounds

PostPosted: May 30th, 2010, 10:47 pm
by Kambiz
The Mix method of TWaveStreamAdapter class can mix PCM waves of the same format.

For example:

Code: Select all
function MixWaveFiles(const Src1, Src2, Dest: String): Boolean;
var
  W1, W2, WM: TWaveFile;
begin
  W1 := TWaveFile.Create(Src1, fmOpenRead or fmShareDenyWrite);
  W2 := TWaveFile.Create(Src2, fmOpenRead or fmShareDenyWrite);
  WM := TWaveFile.Create(Dest, fmCreate);
  Result := WM.Mix([W1, W2])
  WM.Free;
  W2.Free;
  W1.Free;
end;