<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I updated the sources.<br><br>One question. In jcapture, I printf the meter in the console with vertical bars '|' as usual. I calculate an average from 5 callback calls, and I printf the meter inside the callback functions, that is not real safe. Where to printf the meter? Must be inside the infinite loop for(;;)... this way is real safe?<br><br>Joan Quintana<br><br>--- On <b>Fri, 2/24/12, Robin Gareus <i><robin@gareus.org></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Robin Gareus <robin@gareus.org><br>Subject: Re: [LAD] Tutorial for programming with JACK<br>To: "Joan Quintana" <joan_quintana@yahoo.com><br>Cc: Linux-audio-dev@lists.linuxaudio.org, "Harry Van Haaren" <harryhaaren@gmail.com><br>Date: Friday, February 24, 2012, 5:07 PM<br><br><div
 class="plainMail">Hi Joan,<br><br>Thanks for sharing those!<br><br>On 02/24/2012 11:12 AM, Joan Quintana wrote:<br>> Related with this topic, I would like to contribute with 3 pieces of code made with an educational point of view (though I don't teach audio processing and I don't consider an expert myself). These examples use libsndfile library, that is important if the source or the destination of your audio data is a wav file.<br>> <br>> a) jcapture:<br>> *<a href="http://wiki.joanillo.org/images/0/07/Jcapture-1.0.0.tar.gz" target="_blank">http://wiki.joanillo.org/images/0/07/Jcapture-1.0.0.tar.gz</a> <br>> reads the data coming from the microphone, and saves a wav file. Shows a textual signal meter in the console. (I know the existance of jack-capture. I didn't look at jack-capture code, sure that has better performance and lots of options, I just wanted the minimal code)<br><br>The linked tar-ball includes jcapture-0.0.1.cpp that does
 not save any<br>.wav file.<br><br>Calling printf() in the jack-callback function is not realtime safe;<br>[but it's perfectly valid for debugging/development purposes and] I<br>guess you simply mixed up the files.<br><br>FWIW<br><a href="https://github.com/jackaudio/example-clients/blob/master/capture_client.c" target="_blank">https://github.com/jackaudio/example-clients/blob/master/capture_client.c</a><br>is very close to the minimal code required to do disk I/O. It does not<br>include a meter, but supports multiple-channel.<br><br>> b) jplay-sndfile-simple:<br>> *<a href="http://wiki.joanillo.org/images/1/1e/Jplay-sndfile-simple-1.0.0.tar.gz" target="_blank">http://wiki.joanillo.org/images/1/1e/Jplay-sndfile-simple-1.0.0.tar.gz</a><br>> It's just a playback wav file. In the callback function there are two possibilities: copying blocks of memory; or copying sample by sample, and this permits a little signal processing (in this simple case just
 divide the signal by 2).<br>> I borrowed code from sndfile-jackplay.c (sndfile-tools-1.03, Erik de Castro Lopo & Jonatan Liljedahl), where is interesting the thread implementation  (playing while reading the file) that I didn't implemented.<br><br>neat. There's some cruft in it (unused variables, binary (&) vs boolean<br>(&&) AND in line 89) - compile with `-Wall` option: g++ will tell you.<br><br>Otherwise it'd make a nice addition to<br><a href="https://github.com/harryhaaren/Linux-Audio-Programming-Documentation" target="_blank">https://github.com/harryhaaren/Linux-Audio-Programming-Documentation</a><br><br>> c) jplay-sndfile:<br>> *<a href="http://wiki.joanillo.org/images/e/e6/Jplay-sndfile-1.0.0.tar.gz" target="_blank">http://wiki.joanillo.org/images/e/e6/Jplay-sndfile-1.0.0.tar.gz</a><br>> This is more interesting and not simple like the previous. A part of playing back the file, it permits frequency shifting and
 frequency sweeping in a range between .5 and 2.<br><br>see previous email (reply to Harry).<br><br>> Hope this helps to somebody,<br>> Joan Quintana<br>> <br>> <br><br>best,<br>robin<br></div></blockquote></td></tr></table>