Shell Executing 'aplay' from Node.js on Raspbian

Myles Braithwaite me-qIX3qoPyADtH8hdXm2+x1laTQe2KTcn/ at public.gmane.org
Fri Jul 5 17:43:09 UTC 2013


Have you tried manually setting the soundcard with the `-D` or `--device flag`?

You can get a list of soundcards with `aplay --list-devices`.

Also if `server.js` is running a different user is it in the group
`audio` or do they have a different `~/.asoundrc`?

On Fri, Jul 5, 2013 at 1:05 PM, Scott Elcomb <psema4-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> Hi all; the following is a message I recently sent to the node.js
> list.  Unfortunately there hasn't been any feedback as yet and I need
> to figure out where the issue is soon.  It's my hope that someone here
> may have run into something similar or an inkling of where the trouble
> is.
>
> A smaller version of the example (still in node.js but without the
> express framework) works just fine.  I can post the code if desired.
>
> I suspect it's an issue with the environment (as seen by express) but
> I'm not terribly familiar with ALSA; it may be something else
> entirely.
>
> Might be a long shot but any pointers or suggestions would be most appreciated.
>
> TIA,
> -Scott
>
> [-- Message Begins --]
>
> I'm trying to work around the lack of web audio on a Raspberry Pi +
> Chromium project and have run into a bit of trouble: I need to play a
> short sound when express responds to a route.  The app is currently
> running on node v0.6.19 & express 3.0.6.
>
> If I run the aplay command (below) from bash, the sound card is
> detected and the file is played.  When run from the express route
> handler, the sound card is not detected and no sound is played.  (It's
> the same user in both cases.)
>
> I'm not sure where the issue is - any pointers would be most appreciated.
>
> [-- example server.js starts --]
> var server = require('express')()
>   , exec = require('child_process').exec
>   , util = require('util')
> ;
>
> function puts(error, stdout, stderr) {
>     util.puts(stdout);
>     util.puts(stderr);
> }
>
> server.get('/sound', function(req, res) {
>     // env not sanitized for debugging purposes
>     exec("/usr/bin/aplay /tmp/testsound.wav"
>         , { cwd: process.env.pwd, env: process.env }
>         , function(error, stdout, stderr) {
>             puts(error, stdout, stderr);
>             res.send('ok');
>         });
> });
>
> server.listen(5151);
> [-- example server.js ends --]
>
> --
>   Scott Elcomb
>   @psema4 on Twitter / Identi.ca / Github & more
>
>   Atomic OS: Self Contained Microsystems
>   http://code.google.com/p/atomos/
>
>   Member of the Pirate Party of Canada
>   http://www.pirateparty.ca/
> --
> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists



-- 
Myles Braithwaite | http://mylesb.ca/e
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list