[sndtools] sndpeek on linux, alsa only. info added. partial success

Turku Ting turkuting at gmail.com
Thu Nov 7 13:22:38 EST 2013

ok, i will answer myself one more time hoping someone can help...
i've managed to set up an alsa Loopback device on my system which works with other apps.
it's a kind of virtual second soundcard with lots of capture channels.

sndpeek however seems to insist on choosing the first capture device on the first (default) soundcard.

would it be possible to hack the source code so that it goes straight to the second card, hopefully finding the capture audio stream?

i guess some changes would have to be made in RtAudio.cpp...?

 basically i want sndpeek to analyze what is playing through alsa.
 sndpeek _is_ able to listen to my laptops mic if capture is active.
 i'm too dumb to fully understand the internals of alsa to create a pcm loopback capture.
 short question:
 can i hack soundpeek to accept raw data?
 long explanation:
 using mpd (MusicPlayerDaemon), i have various audio output possibilities to provide input forsndpeek, e.g. a fifo that works fine with e.g. 
 $ aplay  -f cd /tmp/mpd.fifo
 (Playing raw data '/tmp/mpdfifo' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo)
 $ sndpeek /tmp/mpdfifo
 [sndpeek]: opening /tmp/mpdfifo...
 [sndpeek]: error: cannot open '/tmp/mpdfifo':File contains data in an unknown format.
 [sndpeek]: exiting...
 reading the fifo with sox, transforming it to sth sndpeek understands, and feeding it into another fifo which then can be read by sndpeek kind of works - well, it works but it's really hackish, there's a noticable delay, and sndpeek kind of stutters when i pause/unpause playback. it helps to press f twice (freeze/unfreeze). 
 anyhow, here are the commands:
 $ sox -t raw -r 44100 -e signed-integer -c 2 -b 16 /tmp/mpdfifo -t wav ~/.config/mpd/wavpipe &
 $ sndpeek ~/.config/mpd/wavpipe 
 so this gives me some info about what kind of input sndpeek needs.
 thanks for reading & maybe some advice.
 > thanks tristan,
 > btw i forgot to mention that this is sndpeek compiled for alsa.
 > i grabbed the git version, now the error reads thus:
 > [sndpeek]: opening /tmp/mpd.fifo...
 > [sndpeek]: error: cannot open '/tmp/mpd.fifo':File contains data in an unknown format.
 > [sndpeek]: exiting...
 > code 253
 > the music player daemon mpd has this in its config:
 > audio_output {
 >         type            "fifo"
 >         name            "My FIFO"
 >         path            "/tmp/mpd.fifo"
 >         format          "44100:16:2"
 > }
 > so apart from these 3 numbers i don't really know what format it is.
 > what kind of adjustment would the data flowing through the fifo need to be recognizable by sndpeek?
 > or, what kind of adjustment would sndpeek need to accept/recognize it?
 > greetings,
 > tt
 > On Mon, 4 Nov 2013 17:48:53 -0500
 > Tristan Matthews <le.businessman at gmail.com> wrote:
 > > On Mon, Nov 4, 2013 at 2:36 AM, Turku Ting <turkuting at gmail.com> wrote:
 > > > hello,
 > > > i'd be happy if someone could help setting up sndpeek.
 > > > i want it to read from a fifo, createt by mpd (music player daemon).
 > > > i can access the fifo with e.g.
 > > > $ aplay -f cd /tmp/mpd.fifo
 > > > but sndpeek just throws a non-descript error:
 > > > $ sndpeek /tmp/mpd.fifo
 > > > [sndpeek]: opening /tmp/mpd.fifo...
 > > > [sndpeek]: error: cannot open '/tmp/mpd.fifo'...
 > > > [sndpeek]: exiting...
 > > > code 253
 > > >
 > > > any ideas?
 > > 
 > > You can grab this version of sndpeek, which will at least show you the
 > > error message from sf_open:
 > > https://gitorious.org/sndpeek/sndpeek
 > > 
 > > Best,
 > > Tristan
 > > 

More information about the sndtools mailing list