🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages Started by Isaac . Fri, 10 Oct 2003 12:07
Simultaneous Playing and Recording of WAV Audio
#585
Author: Isaac .
Date: Fri, 10 Oct 2003 12:07
12 lines
1109 bytes
Hi,

I know how to play/record wav audio, but what I'd like to try now
is simultaneously record and play wav audio.  I'm using win32
api calls.  I'm wondering if I must to do this through multi-
threading or can it be done sequentially.

I'm new at this multimedia programming, so any help will really
be great.  Thanks in advance!

Isaac
Re: Simultaneous Playing and Recording of WAV Audio
#586
Author: Aleksandr Shamray
Date: Sun, 12 Oct 2003 08:14
49 lines
2787 bytes
Basically you would need to spawn one thread for recording and
one for playback. Each thread will run a simple loop like this:

while (!done) {
  if (WAIT_OBJECT_0 == WaitForSingleObject(event, timeout))
      ProcessBuffers();
}

event is a Windows event object, which will be signaled every time
device has processed another buffer. Other methods of being notified
are also available (callbacks, messages).

ProcessBuffers() is where you copy data from buffer being recorded,
or feed playback queue with another portion of data.

To ensure you will not get cuts in recording/playback it is a good
idea to set the priority of both threads to THREAD_PRIORITY_TIME_CRITICAL.

I believe this could be done sequentially in main application thread,
using WaitForMultipleObjects() for example, but sooner or later you
will discover that managing separate threads is much easy.

Note, that VCL is not multi-thread safe, and my usual mistake was to
display some nice statistics on a form's canvas inside ProcessBuffers().
This often crashes the whole application in a very mysterious way.

-- 
With best wishes,
Aleksandr Shamray

Stream your audio today.
http://lakeofsoft.com/


<Isaac .> wrote in message news:3f86a0fc$1@newsgroups.borland.com...
> 
> Hi,
> 
> I know how to play/record wav audio, but what I'd like to try now
> is simultaneously record and play wav audio.  I'm using win32
> api calls.  I'm wondering if I must to do this through multi-
> threading or can it be done sequentially.
> 
> I'm new at this multimedia programming, so any help will really
> be great.  Thanks in advance!
> 
> Isaac
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads