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

Contact us at files@mathworks.com