[Stk] GUI + real-time sound analysis

Erik Jalevik Erik Jalevik" <erikjalevik@fastmail.fm
Mon, 10 May 2004 20:03:36 +0100


Sounds like an interesting project. Would you mind telling us some more
details?

> I have
> - a RtWvIn object to get sound from my sound card or a
> player (WinAmp, etc)
> -  a WvOut object that records the input to a file frame
> by frame.
> - a Graphic User Interface developed with Wxwindows
> (www.wxwindows.org - cross platform GUI C++ classes) with
> a "start recording" button and a "stop recording" button.
>
> PROBLEM: Once I push the button "start recording", the
> application is recording the sound input into a file, but
> when I push the STOP button, the GUI is not responding
> anymore.

I'm using a very similar setup, STK with wxWindows and some other libraries.

Your problem is not really STK-related but rather a question of design. When
you press the start button, the flow of control goes into a loop of reading
input and outputting it to a file. Unless you explicitly exit that loop,
there is no way for the GUI to detect the Stop button presses.

There are two ways to solve this. Either use multiple threads with one
thread controlling the user interface and another the audio work.

An easier option would be to just have the audio reading loop give up its
control at regular intervals. If all you need is for the Stop button to be
polled, you just need to insert calls to ::wxYield() every now and then.

Hope this helps and that I didn't misunderstand your question.

Erik