User avatar
jezmck
Posts: 24
Joined: Sat Sep 10, 2011 4:34 pm
Contact: Website

Error when using PHP to run Shell script to play whitenoise

Tue Mar 08, 2016 8:16 pm

Hi,

I have the following PHP:

Code: Select all

if (...) {
  $path = '/home/pi/noise.sh';
  echo `sh $path 2>&1`;
}
and bash script:

Code: Select all

#!/bin/bash
len=${1-00:00:05}
play --single-threaded -t sl - synth $len whitenoise band -n 1200 200 tremolo 20 .1 < /dev/zero
and these two give me the rather saddening
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM default
play FAIL sox: Sorry, there is no default audio device configured
when run via a browser.

Running the bash script directly works fine.

The apache server runs as www-data.
Changing the permissions make no difference.

I've run raspi-config to (re-?) set the default audio to the 3.5mm jack.

I'm all out of ideas now!

Any help much appreciated.

User avatar
jezmck
Posts: 24
Joined: Sat Sep 10, 2011 4:34 pm
Contact: Website

Re: Error when using PHP to run Shell script to play whiteno

Tue Mar 08, 2016 8:21 pm

I should have waited a little longer before posting!

I'll leave the answer I found here for anyone else though.

http://sox.10957.n7.nabble.com/Execute- ... p1078.html

Code: Select all

sudo usermod -a -G audio www-data
sudo apachectl restart

Return to “Troubleshooting”