<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: lsof &#124;grep snd &#8212; how to free a linux sound device</title>
	<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/</link>
	<description>Diary of my Linux journeys. Everything Linux by Kamil Wójcicki</description>
	<pubDate>Thu, 09 Feb 2012 21:54:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: question</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1647</link>
		<author>question</author>
		<pubDate>Sun, 15 Jan 2012 10:51:43 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1647</guid>
		<description>yeah... and for getting answer, one must simply ask the question...
mine was provided here: http://www.realitysend.com/kirbj/devlog/linuxsound
and, after following procedures - i ended up with working system sound from java based chess program and listen music from rhythmbox.</description>
		<content:encoded><![CDATA[<p>yeah&#8230; and for getting answer, one must simply ask the question&#8230;<br />
mine was provided here: <a href="http://www.realitysend.com/kirbj/devlog/linuxsound" rel="nofollow">http://www.realitysend.com/kirbj/devlog/linuxsound</a><br />
and, after following procedures - i ended up with working system sound from java based chess program and listen music from rhythmbox.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: question</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1646</link>
		<author>question</author>
		<pubDate>Sun, 15 Jan 2012 10:24:17 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1646</guid>
		<description>Well, article is well written indeed, but...
i wish to have solution, that java program would work with gstreamer apllications simuntaneously. 

by default, ubuntu and gnome tend to provide pulseaudio. pulseaudio may be good idea in theory, but in practice pure alsa works better (doeas not glich).
so i get rid pulse by removing it by default.
 but java issue remains. 

now question, how to setup linux sound in way, that there is provided hardware sound device + at least one virtual hardware device, mixer controls to playback sound from both, for simultaneous play (java program +some other program playback)</description>
		<content:encoded><![CDATA[<p>Well, article is well written indeed, but&#8230;<br />
i wish to have solution, that java program would work with gstreamer apllications simuntaneously. </p>
<p>by default, ubuntu and gnome tend to provide pulseaudio. pulseaudio may be good idea in theory, but in practice pure alsa works better (doeas not glich).<br />
so i get rid pulse by removing it by default.<br />
 but java issue remains. </p>
<p>now question, how to setup linux sound in way, that there is provided hardware sound device + at least one virtual hardware device, mixer controls to playback sound from both, for simultaneous play (java program +some other program playback)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sander</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1640</link>
		<author>Sander</author>
		<pubDate>Mon, 09 Jan 2012 12:51:01 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1640</guid>
		<description>Great how to! This showed me what my problem is.
Unfortunately, I still can't solve it. Here is my problem:

When in Matlab I play a sound, either with 'sound', 'soundsc' or another matlab function it plays it fine, but afterwards I cannot play any other sound. The error is the following:

Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8192.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported.

I followed some this how to and discovered that matlab does not close the file used for writing the sound. Sometimes it closes eventually and sometimes I cannot listen to anything unless I close matlab first.
When I execute the 'lsof &#124; grep snd' command in a console I get the following output:

gnome-set 1506     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
pulseaudi 1521     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
pulseaudi 1521     sander   28u      CHR              116,8      0t0       7782 /dev/snd/controlC0
pulseaudi 1521     sander   35u      CHR              116,8      0t0       7782 /dev/snd/controlC0
gconf-hel 1544     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
indicator 1635     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
firefox   2178     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
MATLAB    3704     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23
MATLAB    3704     sander  mem       CHR              116,5                7777 /dev/snd/pcmC0D0p
MATLAB    3704     sander  318u      CHR              116,5      0t0       7777 /dev/snd/pcmC0D0p

There are some other processes which have opened a/some sound filedescriptors (I don't fully understand it), but these did not prevent matlab from executing the sound the first time.

So my question is: Does anyone know what is going on? Are these processes perhaps causing deadlock on the soundcard? Is there a way to forcefully close a filedescriptor or make a process release a resource? Or another more permanent solution?

Any help would be very welcome.</description>
		<content:encoded><![CDATA[<p>Great how to! This showed me what my problem is.<br />
Unfortunately, I still can&#039;t solve it. Here is my problem:</p>
<p>When in Matlab I play a sound, either with &#039;sound&#039;, &#039;soundsc&#039; or another matlab function it plays it fine, but afterwards I cannot play any other sound. The error is the following:</p>
<p>Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8192.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported.</p>
<p>I followed some this how to and discovered that matlab does not close the file used for writing the sound. Sometimes it closes eventually and sometimes I cannot listen to anything unless I close matlab first.<br />
When I execute the &#039;lsof | grep snd&#039; command in a console I get the following output:</p>
<p>gnome-set 1506     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
pulseaudi 1521     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
pulseaudi 1521     sander   28u      CHR              116,8      0t0       7782 /dev/snd/controlC0<br />
pulseaudi 1521     sander   35u      CHR              116,8      0t0       7782 /dev/snd/controlC0<br />
gconf-hel 1544     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
indicator 1635     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
firefox   2178     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
MATLAB    3704     sander  mem       REG                8,5   409528     134483 /usr/lib/libsndfile.so.1.0.23<br />
MATLAB    3704     sander  mem       CHR              116,5                7777 /dev/snd/pcmC0D0p<br />
MATLAB    3704     sander  318u      CHR              116,5      0t0       7777 /dev/snd/pcmC0D0p</p>
<p>There are some other processes which have opened a/some sound filedescriptors (I don&#039;t fully understand it), but these did not prevent matlab from executing the sound the first time.</p>
<p>So my question is: Does anyone know what is going on? Are these processes perhaps causing deadlock on the soundcard? Is there a way to forcefully close a filedescriptor or make a process release a resource? Or another more permanent solution?</p>
<p>Any help would be very welcome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Audio issues: What do I delete to make a clean start in alsa?</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1573</link>
		<author>Audio issues: What do I delete to make a clean start in alsa?</author>
		<pubDate>Sat, 05 Nov 2011 20:11:41 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1573</guid>
		<description>[...] Read this  http://linux.dsplabs.com.au/lsof-gre...nd-device-p25/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Read this  <a href="http://linux.dsplabs.com.au/lsof-gre...nd-device-p25/" rel="nofollow">http://linux.dsplabs.com.au/lsof-gre&#8230;nd-device-p25/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gato</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1471</link>
		<author>Gato</author>
		<pubDate>Fri, 11 Feb 2011 03:58:18 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1471</guid>
		<description>Thanks very much.

Very good learning!</description>
		<content:encoded><![CDATA[<p>Thanks very much.</p>
<p>Very good learning!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suhrid Karthik</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1428</link>
		<author>Suhrid Karthik</author>
		<pubDate>Tue, 05 Oct 2010 06:59:52 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1428</guid>
		<description>Great write up. Really Useful. Thanks.</description>
		<content:encoded><![CDATA[<p>Great write up. Really Useful. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stasy</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1142</link>
		<author>Stasy</author>
		<pubDate>Thu, 22 Jul 2010 07:03:33 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1142</guid>
		<description>Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: portableRIOT</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1141</link>
		<author>portableRIOT</author>
		<pubDate>Wed, 21 Jul 2010 14:38:37 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1141</guid>
		<description>so... I'm having the same troubles, I'm attempting to video chat, and I finally got my webcam to work in unbuntu, but now my mic and sound aren't accessable by aMSN. I've tried your fix in the terminal, and It's not working. Could it be because I have an older version of linux, seriously updated? (I installed it on my windows laptop because windows kept crashing on me, and I have no other options.)

PLEASE HELP!! 

and thanks :)</description>
		<content:encoded><![CDATA[<p>so&#8230; I&#039;m having the same troubles, I&#039;m attempting to video chat, and I finally got my webcam to work in unbuntu, but now my mic and sound aren&#039;t accessable by aMSN. I&#039;ve tried your fix in the terminal, and It&#039;s not working. Could it be because I have an older version of linux, seriously updated? (I installed it on my windows laptop because windows kept crashing on me, and I have no other options.)</p>
<p>PLEASE HELP!! </p>
<p>and thanks <img src='http://linux.dsplabs.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1116</link>
		<author>Charlie</author>
		<pubDate>Sun, 09 May 2010 03:50:11 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-1116</guid>
		<description>This is a very well written article - I like that it comes with an explanation as well as the commands.</description>
		<content:encoded><![CDATA[<p>This is a very well written article - I like that it comes with an explanation as well as the commands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aistis</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-681</link>
		<author>Aistis</author>
		<pubDate>Thu, 25 Feb 2010 16:57:58 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-681</guid>
		<description>I luv this tutorial.. OneMegaThanksToYou !!!</description>
		<content:encoded><![CDATA[<p>I luv this tutorial.. OneMegaThanksToYou !!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: theme</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-652</link>
		<author>theme</author>
		<pubDate>Thu, 18 Jun 2009 14:28:21 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-652</guid>
		<description>Kamil:  completely agree with you, that is a so dirty solution, but as you point it works. The pitty is that Matlab/java and/or Alsa team doen't manage to fix it. Let's hope they get any solution. Linux is for work and have fun and multitasking system so, we should be able to do both, working with matlab while enjoying great music.


Anyway thanks for the tip, i liked itvery much, sorry for the absence but i've been working in other issues, and now i've already focused again in matlab  : )

THNX again ;)</description>
		<content:encoded><![CDATA[<p>Kamil:  completely agree with you, that is a so dirty solution, but as you point it works. The pitty is that Matlab/java and/or Alsa team doen&#039;t manage to fix it. Let&#039;s hope they get any solution. Linux is for work and have fun and multitasking system so, we should be able to do both, working with matlab while enjoying great music.</p>
<p>Anyway thanks for the tip, i liked itvery much, sorry for the absence but i&#039;ve been working in other issues, and now i&#039;ve already focused again in matlab  : )</p>
<p>THNX again <img src='http://linux.dsplabs.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-643</link>
		<author>Kamil</author>
		<pubDate>Sat, 09 May 2009 02:07:25 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-643</guid>
		<description>Hi Dimitris, in all likelihood your sound card can play and record at the same time, f.e. I can use, at the same time, &lt;b&gt;mplayer&lt;/b&gt; for playback and &lt;b&gt;gnome-sound-recorder&lt;/b&gt; for recording, without errors. The only thing that can get tricky are the mixer settings. Try un-muting all devices using &lt;b&gt;alsamixer&lt;/b&gt; and set all the volumes to maximum to get started.</description>
		<content:encoded><![CDATA[<p>Hi Dimitris, in all likelihood your sound card can play and record at the same time, f.e. I can use, at the same time, <b>mplayer</b> for playback and <b>gnome-sound-recorder</b> for recording, without errors. The only thing that can get tricky are the mixer settings. Try un-muting all devices using <b>alsamixer</b> and set all the volumes to maximum to get started.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-642</link>
		<author>Dimitris</author>
		<pubDate>Fri, 08 May 2009 20:49:33 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-642</guid>
		<description>Any solution for me?</description>
		<content:encoded><![CDATA[<p>Any solution for me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-638</link>
		<author>Kamil</author>
		<pubDate>Fri, 01 May 2009 11:44:16 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-638</guid>
		<description>Good question, lets try a few things... if I play music using &lt;b&gt;mplayer&lt;/b&gt; and then use say &lt;b&gt;play&lt;/b&gt; (a &lt;b&gt;sox&lt;/b&gt; based playback script) to play another audio file. Both play fine.

If I play music using &lt;b&gt;mplayer&lt;/b&gt; and the start &lt;b&gt;matlab&lt;/b&gt; and try to play any audio (even after &lt;b&gt;mplayer&lt;/b&gt; finished) it fails like so:
&lt;i&gt;
&gt;&gt; x=wavread('sp10.wav');
Warning: The playback thread did not start within one second. 
&gt; In audioplayer.playblocking at 35
  In audiovideo/private/playsnd at 16
  In sound at 46
  In soundsc at 48
&gt;&gt; Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable
&lt;/i&gt;

To get it to work, I have to quit &lt;b&gt;matlab&lt;/b&gt; and start it again. On the other hand, if I start &lt;b&gt;matlab&lt;/b&gt; first and then try to play audio using &lt;b&gt;mplayer&lt;/b&gt;, then &lt;b&gt;mplayer&lt;/b&gt; fails to play &#8212; it simply sits there with the following prompt: &lt;i&gt;Starting playback...&lt;/i&gt;

Ok, so as mentioned previously it is &lt;b&gt;matlab&lt;/b&gt;'s java based playback libs that simply requires exclusive access to the audio device. A bit of googling confirms that this is a common problem, and that java and/or alsa are at fault for not handling these things nicely.

Alright, if I had to do it, then my hack would be as follows. I would create a &lt;b&gt;matlab&lt;/b&gt; wrapper function file called &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; somewhere in &lt;b&gt;matlab&lt;/b&gt;'s path. The content of &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; would be something like this:

&lt;b&gt;
% Saves audio data to a wav file before playback.
%
% audio     - audio samples
% fs        - sampling rate (Hz) [default: 8000]
% nbits     - precision (bits) [default: 16]
% wavfile   - filename for the wav file [default: '/tmp/tmp.wav']
%
% usage: play(audio, fs, nbits, wavfile)

function play(audio, fs, nbits, wavfile)

    % parse input arguments or use defaults
    switch(nargin)
        case 1, wavfile='/tmp/tmp.wav'; nbits=16; fs=8000;
        case 2, wavfile='/tmp/tmp.wav'; nbits=16; 
        case 3, wavfile='/tmp/tmp.wav';
        case 4,
        otherwise, error(sprintf('usage: play(audio, 8000, 16, ''/tmp/tmp.wav''\ntype: help play for further details...'));
    end

    % save audio to file, scale prior to writing to avoid clipping
    audio = 0.999*audio/max(abs(audio));
    wavwrite(audio, fs, nbits, wavfile);
    
    % playback the audio
    if(exist(wavfile, 'file'))
        syscmd = sprintf('mplayer %s', wavfile); % uses mplayer for playback
        %syscmd = sprintf('play %s', wavfile);   % uses sox play for playback
        system(syscmd);
    else
        error(sprintf('%s: file not found.', wavfile));
    end

% EOF
&lt;/b&gt;

In &lt;b&gt;matlab&lt;/b&gt;, help play gives the following:
&lt;i&gt;
&gt;&gt; help play
  Saves audio data to a wav file before playback.
 
  audio     - audio samples
  fs        - sampling rate (Hz) [default: 8000]
  nbits     - precision (bits) [default: 16]
  wavfile   - filename for the wav file [default: '/tmp/tmp.wav']
 
  usage: play(audio, fs, nbits, wavfile)
&lt;b&gt;Overloaded methods:
       audiorecorder/play
       audioplayer/play
&lt;/b&gt;&lt;/i&gt;
So make sure that your &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; is in the path before the other ones, or call it something else...

Ok, it is not pretty, but it works.

Kamil</description>
		<content:encoded><![CDATA[<p>Good question, lets try a few things&#8230; if I play music using <b>mplayer</b> and then use say <b>play</b> (a <b>sox</b> based playback script) to play another audio file. Both play fine.</p>
<p>If I play music using <b>mplayer</b> and the start <b>matlab</b> and try to play any audio (even after <b>mplayer</b> finished) it fails like so:<br />
<i><br />
>> x=wavread(&#039;sp10.wav&#039;);<br />
Warning: The playback thread did not start within one second.<br />
> In audioplayer.playblocking at 35<br />
  In audiovideo/private/playsnd at 16<br />
  In sound at 46<br />
  In soundsc at 48<br />
>> Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable<br />
</i></p>
<p>To get it to work, I have to quit <b>matlab</b> and start it again. On the other hand, if I start <b>matlab</b> first and then try to play audio using <b>mplayer</b>, then <b>mplayer</b> fails to play &mdash; it simply sits there with the following prompt: <i>Starting playback&#8230;</i></p>
<p>Ok, so as mentioned previously it is <b>matlab</b>&#039;s java based playback libs that simply requires exclusive access to the audio device. A bit of googling confirms that this is a common problem, and that java and/or alsa are at fault for not handling these things nicely.</p>
<p>Alright, if I had to do it, then my hack would be as follows. I would create a <b>matlab</b> wrapper function file called <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> somewhere in <b>matlab</b>&#039;s path. The content of <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> would be something like this:</p>
<p><b><br />
% Saves audio data to a wav file before playback.<br />
%<br />
% audio     - audio samples<br />
% fs        - sampling rate (Hz) [default: 8000]<br />
% nbits     - precision (bits) [default: 16]<br />
% wavfile   - filename for the wav file [default: &#039;/tmp/tmp.wav&#039;]<br />
%<br />
% usage: play(audio, fs, nbits, wavfile)</p>
<p>function play(audio, fs, nbits, wavfile)</p>
<p>    % parse input arguments or use defaults<br />
    switch(nargin)<br />
        case 1, wavfile=&#039;/tmp/tmp.wav&#039;; nbits=16; fs=8000;<br />
        case 2, wavfile=&#039;/tmp/tmp.wav&#039;; nbits=16;<br />
        case 3, wavfile=&#039;/tmp/tmp.wav&#039;;<br />
        case 4,<br />
        otherwise, error(sprintf(&#039;usage: play(audio, 8000, 16, &#034;/tmp/tmp.wav&#034;\ntype: help play for further details&#8230;&#039;));<br />
    end</p>
<p>    % save audio to file, scale prior to writing to avoid clipping<br />
    audio = 0.999*audio/max(abs(audio));<br />
    wavwrite(audio, fs, nbits, wavfile);</p>
<p>    % playback the audio<br />
    if(exist(wavfile, &#039;file&#039;))<br />
        syscmd = sprintf(&#039;mplayer %s&#039;, wavfile); % uses mplayer for playback<br />
        %syscmd = sprintf(&#039;play %s&#039;, wavfile);   % uses sox play for playback<br />
        system(syscmd);<br />
    else<br />
        error(sprintf(&#039;%s: file not found.&#039;, wavfile));<br />
    end</p>
<p>% EOF<br />
</b></p>
<p>In <b>matlab</b>, help play gives the following:<br />
<i><br />
>> help play<br />
  Saves audio data to a wav file before playback.</p>
<p>  audio     - audio samples<br />
  fs        - sampling rate (Hz) [default: 8000]<br />
  nbits     - precision (bits) [default: 16]<br />
  wavfile   - filename for the wav file [default: &#039;/tmp/tmp.wav&#039;]</p>
<p>  usage: play(audio, fs, nbits, wavfile)<br />
<b>Overloaded methods:<br />
       audiorecorder/play<br />
       audioplayer/play<br />
</b></i><br />
So make sure that your <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> is in the path before the other ones, or call it something else&#8230;</p>
<p>Ok, it is not pretty, but it works.</p>
<p>Kamil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: theme</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-637</link>
		<author>theme</author>
		<pubDate>Fri, 01 May 2009 09:36:08 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-637</guid>
		<description>First of all,this post is awsome and i've learned great and useful things but, i wonder if there's any way to be able to work with matlab (playing sounds) and listening music with another program (f.i. firefox and streaming) without having to kill one of both.</description>
		<content:encoded><![CDATA[<p>First of all,this post is awsome and i&#039;ve learned great and useful things but, i wonder if there&#039;s any way to be able to work with matlab (playing sounds) and listening music with another program (f.i. firefox and streaming) without having to kill one of both.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-634</link>
		<author>Dimitris</author>
		<pubDate>Thu, 23 Apr 2009 17:10:36 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-634</guid>
		<description>Indeed it worked!
This means that i can't hear music at the same time that
i want to  speak with the microphone? 

I had this problem for a long time, and after i used the commands above
for the first time my aMSN closed alone, and when i reopened it (without music)
the recording and the camera, worked properly. But when i re opened music
i had again the same error "   Could not gain access to /dev/dsp for writing." .
Do i have to follow this procedure every time that i open the music?

PLz answer to my mail or here...
Thanks in advance</description>
		<content:encoded><![CDATA[<p>Indeed it worked!<br />
This means that i can&#039;t hear music at the same time that<br />
i want to  speak with the microphone? </p>
<p>I had this problem for a long time, and after i used the commands above<br />
for the first time my aMSN closed alone, and when i reopened it (without music)<br />
the recording and the camera, worked properly. But when i re opened music<br />
i had again the same error &#034;   Could not gain access to /dev/dsp for writing.&#034; .<br />
Do i have to follow this procedure every time that i open the music?</p>
<p>PLz answer to my mail or here&#8230;<br />
Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-604</link>
		<author>Kamil</author>
		<pubDate>Wed, 21 Jan 2009 03:00:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-604</guid>
		<description>Kim, take a look at: &lt;a href="http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/" rel="nofollow"&gt;http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Kim, take a look at: <a href="http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/" rel="nofollow">http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-603</link>
		<author>Kim</author>
		<pubDate>Tue, 20 Jan 2009 22:32:12 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-603</guid>
		<description>I have no idea what Im doing here, I keep getting "no volume control gstreamer plugins and or devices found" as an error message when I click on my speaker icon!! Can anyone explain in LAYMEN terms how I fix this pleeeease????</description>
		<content:encoded><![CDATA[<p>I have no idea what Im doing here, I keep getting &#034;no volume control gstreamer plugins and or devices found&#034; as an error message when I click on my speaker icon!! Can anyone explain in LAYMEN terms how I fix this pleeeease????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wallace Silva</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-580</link>
		<author>Wallace Silva</author>
		<pubDate>Thu, 04 Dec 2008 15:43:51 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-580</guid>
		<description>solution in my pc
i did have to install libsnack to alsa

# apt-get install libsnack2-alsa

and solved.

tks.</description>
		<content:encoded><![CDATA[<p>solution in my pc<br />
i did have to install libsnack to alsa</p>
<p># apt-get install libsnack2-alsa</p>
<p>and solved.</p>
<p>tks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cynthia</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-556</link>
		<author>cynthia</author>
		<pubDate>Tue, 28 Oct 2008 12:23:11 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-556</guid>
		<description>wow!  I've been searching the net to find solution to this problem.  My transcription software sometimes runs and sometimes not.  A hassle when transcription assignment arrives; but this article saved me!  Thanks a lot and more power for giving this support!</description>
		<content:encoded><![CDATA[<p>wow!  I&#039;ve been searching the net to find solution to this problem.  My transcription software sometimes runs and sometimes not.  A hassle when transcription assignment arrives; but this article saved me!  Thanks a lot and more power for giving this support!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: craig</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-542</link>
		<author>craig</author>
		<pubDate>Fri, 17 Oct 2008 17:40:05 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-542</guid>
		<description>Thanks a bunch, I always resorted to closing down every program, or even rebooting.  More uptime for me now!</description>
		<content:encoded><![CDATA[<p>Thanks a bunch, I always resorted to closing down every program, or even rebooting.  More uptime for me now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-294</link>
		<author>Miguel</author>
		<pubDate>Tue, 01 Jul 2008 22:11:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-294</guid>
		<description>Excellent!... It worked!...
I had to do one step more: locating the program lsof using the command: whereis.</description>
		<content:encoded><![CDATA[<p>Excellent!&#8230; It worked!&#8230;<br />
I had to do one step more: locating the program lsof using the command: whereis.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-260</link>
		<author>Kamil</author>
		<pubDate>Fri, 25 Apr 2008 03:20:47 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-260</guid>
		<description>what is the laptop model number and what is the sound card type? since your audio device is does not get detected by default it will be a fair bit trickier to get it to work... where I would start is googling to see if others have done it... for example I would search for "linux audio dell 9300 audigy sound blaster".</description>
		<content:encoded><![CDATA[<p>what is the laptop model number and what is the sound card type? since your audio device is does not get detected by default it will be a fair bit trickier to get it to work&#8230; where I would start is googling to see if others have done it&#8230; for example I would search for &#034;linux audio dell 9300 audigy sound blaster&#034;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-258</link>
		<author>Anonymous</author>
		<pubDate>Fri, 25 Apr 2008 01:03:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-258</guid>
		<description>when i run this command:

cat /proc/asound/cards

the output is:

no soundcars

But i belive that i have sound card coz my laptop sound is working when i use windows

help me</description>
		<content:encoded><![CDATA[<p>when i run this command:</p>
<p>cat /proc/asound/cards</p>
<p>the output is:</p>
<p>no soundcars</p>
<p>But i belive that i have sound card coz my laptop sound is working when i use windows</p>
<p>help me</p>
]]></content:encoded>
	</item>
</channel>
</rss>

