<div dir="ltr">Hi,<div><br></div><div><font size="4" color="#000000" style="background-color:rgb(255,255,255)">I'm useing "<span style="font-family:'Source Code Pro'">pulseaudio.</span><span style="font-family:'Source Code Pro'">lib_pulseaudio" </span><span style="font-family:'Source Code Pro'">to record sound from a the internal source "</span><span style="font-family:'Source Code Pro'">alsa_output.pci-0000_00_1b.0.analog-stereo". But form some reason I'm only getting the sound from the right channel. I'm sure ?im missconfiguring something but I really don't know what could it be. I would appreciate any insight you might give me because I can't find any exmaples or tutorials about this theme.</span></font></div><div><font size="4" color="#000000" style="background-color:rgb(255,255,255)"><span style="font-family:'Source Code Pro'"><br></span></font></div><div><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="background-color:rgb(255,255,255)"><font color="#000000">samplespec = pa_sample_spec()<span style="font-style:italic"><br></span>samplespec.channels = 2<br>samplespec.format = PA_SAMPLE_U8<br>samplespec.rate = self.rate<br><br>pa_stream = pa_stream_new(context, "peak detect demo", samplespec, None)<br>pa_stream_set_read_callback(pa_stream,<br>                            self._stream_read_cb,<br>                            sink_info.index)<br>pa_stream_connect_record(pa_stream,<br>                         sink_info.monitor_source_name,<br>                         None,)<br>                         PA_STREAM_NOFLAGS)</font></span></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="background-color:rgb(255,255,255)"><font color="#000000">And here I access</font></span></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><pre style="color:rgb(169,183,198);font-family:'Source Code Pro';font-size:14pt;background-color:rgb(43,43,43)"><span style="color:rgb(204,120,50);font-weight:bold">def </span><span style="font-weight:bold">stream_read_cb</span>(<span style="color:rgb(148,85,141)">self</span><span style="color:rgb(204,120,50)">, </span>stream<span style="color:rgb(204,120,50)">, </span>length<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(128,128,128)">index_incr</span>):<br>    data = c_void_p()<br>    pa_stream_peek(stream<span style="color:rgb(204,120,50)">, </span>data<span style="color:rgb(204,120,50)">, </span>c_ulong(length))<br><br>    data = cast(data<span style="color:rgb(204,120,50)">, </span>POINTER(c_ubyte))<br>    <span style="color:rgb(204,120,50);font-weight:bold">for </span>i <span style="color:rgb(204,120,50);font-weight:bold">in </span><span style="color:rgb(136,136,198)">xrange</span>(length):<br>        <span style="color:rgb(128,128,128)"># When PA_SAMPLE_U8 is used, samples values range from 128<br></span><span style="color:rgb(128,128,128)">        # to 255 because the underlying audio data is signed but<br></span><span style="color:rgb(128,128,128)">        # it doesn't make sense to return signed peaks.<br></span><span style="color:rgb(128,128,128)">        #self._samples.put(data[i] - 128)<br></span><span style="color:rgb(128,128,128)">        </span><span style="color:rgb(148,85,141)">self</span>._samples.put(data[i])<br>    pa_stream_drop(stream)</pre></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="color:rgb(0,0,0);font-size:14pt"><br></span></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="color:rgb(0,0,0);font-size:14pt">And here I get the audio everytime a need another sample:</span></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><pre style="color:rgb(169,183,198);font-family:'Source Code Pro';font-size:14pt;background-color:rgb(43,43,43)"><span style="color:rgb(204,120,50);font-weight:bold">def </span><span style="font-weight:bold">getAudio</span>(<span style="color:rgb(148,85,141)">self</span>):<br>    <span style="color:rgb(98,151,85);font-style:italic">"""get a single buffer size worth of audio."""</span><span style="color:rgb(128,128,128)"><br></span><span style="color:rgb(128,128,128)">    </span><span style="color:rgb(204,120,50);font-weight:bold">return </span><span style="color:rgb(148,85,141)">self</span>.<span style="color:rgb(178,0,178)">__iter__</span>().next()</pre></pre><pre style="font-family:'Source Code Pro';font-size:14pt"><span style="color:rgb(0,0,0);font-size:14pt">Thank you and hope to hear from you soon</span><br></pre></div></div>