Thread Subject: Simulink: playing and recording audio at the same time

Subject: Simulink: playing and recording audio at the same time

From: Free

Date: 27 Oct, 2009 19:05:04

Message: 1 of 3

Hi

I setup a simple simulink circuit consisting of a sine wave generator, a speaker ('to audio device' - block), a microphone ('from audio device' - block) and a 'To workspace' - block. The purpose is to play the sinus trough my loudspeaker, recording it AT THE SAME TIME with my microphone and then write the recorded signal to the MATLAB workspace. This all goes well but when I plot the recorded signal in MATLAB I get alternating zero - sine wave - zero - sine wave - zero - and so on... This while I expect a continuous (noisy) sine wave...

What could be the problem? I'm working under Linux. Maybe it is because of the linux scheduler which gives both tasks (play & record) alternating some processor time. Has anybody a solution?

Thanks

Subject: Simulink: playing and recording audio at the same time

From: Free

Date: 3 Nov, 2009 22:53:01

Message: 2 of 3

Finally I found the solution by myself after searching for more then a week. Matlab is using the open source library "portaudio" (http://www.portaudio.com/) for the "to/from audio devices". Originally this library is compiled for the linux "open sound system" (OSS) driver while I was using ALSA. So you have to download the source code for portaudio from the website, compile it and then copy the library into your matlab install directory (matlab_install_dir/bin/glnx86).

Procedure:
- Download and unpack portaudio source code
- In portaudio dir type:
./configure && make
make install
(The driver you are using will automatically be found)
- Copy libportaudio.so to matlab_install_dir/bin/glnx86

Subject: Simulink: playing and recording audio at the same time

From: Free

Date: 3 Nov, 2009 22:54:02

Message: 3 of 3

Finally I found the solution by myself after searching for more then a week. Matlab is using the open source library "portaudio" (http://www.portaudio.com/) for the "to/from audio devices". Originally this library is compiled for the linux "open sound system" (OSS) driver while I was using ALSA. So you have to download the source code for portaudio from the website, compile it and then copy the library into your matlab install directory (matlab_install_dir/bin/glnx86).

Procedure:
- Download and unpack portaudio source code
- In portaudio dir type:
./configure && make
make install
(The driver you are using will automatically be found)
- Copy libportaudio.so to matlab_install_dir/bin/glnx86

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
audio devices Free 3 Nov, 2009 17:54:04
alsa Free 3 Nov, 2009 17:54:04
portaudio Free 3 Nov, 2009 17:54:04
audio Free 27 Oct, 2009 15:09:07
simulink Free 27 Oct, 2009 15:09:07
parallel Free 27 Oct, 2009 15:09:07
playing Free 27 Oct, 2009 15:09:07
recording Free 27 Oct, 2009 15:09:07
linux Free 27 Oct, 2009 15:09:06
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com