Shell Executing 'aplay' from Node.js on Raspbian

Scott Sullivan scott-lxSQFCZeNF4 at public.gmane.org
Fri Jul 5 17:10:25 UTC 2013


On 07/05/2013 01:05 PM, Scott Elcomb 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.

Scott,

Here is my quick silly question. The Pi has both an HDMI audio device 
and an Analog audio device. Have you tested with both with real outputs 
so you can be sure it's not just playing on the wrong one?


> 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 --]
>


--
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