Hi Joan,
Thanks for sharing those!
On 02/24/2012 11:12 AM, Joan Quintana wrote:
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.
a) jcapture:
*http://wiki.joanillo.org/images/0/07/Jcapture-1.0.0.tar.gz
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)
The linked tar-ball includes jcapture-0.0.1.cpp that does not save any
.wav file.
Calling printf() in the jack-callback function is not realtime safe;
[but it's perfectly valid for debugging/development purposes and] I
guess you simply mixed up the files.
FWIW
https://github.com/jackaudio/example-clients/blob/master/capture_client.c
is very close to the minimal code required to do disk I/O. It does not
include a meter, but supports multiple-channel.
b) jplay-sndfile-simple:
*http://wiki.joanillo.org/images/1/1e/Jplay-sndfile-simple-1.0.0.tar.gz
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).
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.
neat. There's some cruft in it (unused variables, binary (&) vs boolean
(&&) AND in line 89) - compile with `-Wall` option: g++ will tell you.
Otherwise it'd make a nice addition to
https://github.com/harryhaaren/Linux-Audio-Programming-Documentation
c) jplay-sndfile:
*http://wiki.joanillo.org/images/e/e6/Jplay-sndfile-1.0.0.tar.gz
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.
see previous email (reply to Harry).
Hope this helps to somebody,
Joan Quintana
best,
robin