views:

1289

answers:

3

Octave appears to assume that a specific sound playing utility will be available on a system but doesn't seem to provide the ability to specify an alternate. In the error below, Octave is looking for ofsndplay, which is not a utility available on all systems.

octave:38> sound(beamformed_20)

sh: ofsndplay: command not found

Is there an Octave configuration setting or code fragment that I can use to specify an system-appropriate utility?

+2  A: 

Install alsa-utils or pulseaudio-utils and put the following in your ~/.octaverc:

global sound_play_utility = 'aplay';

or

global sound_play_utility = 'paplay';
rcs
FYI: this does not work on a Fedora 11 system. The default octave install seems to override the setting for sound_play_utility
Bob Cross
+1  A: 

On one of my Linux machines, I created the following ofsndplay script to work around the hard-wired dependency:

$ cat /usr/bin/ofsndplay

#!/bin/sh
## Coping with stupid dependency on ofsndplay in octave
play -t au -

This particular script uses the SoX play utility.

Admittedly, the comment is unnecessary for the functionality but it certainly made me feel better....

Bob Cross
+1  A: 

On OSX, this is what I did to get sound working:

from the sound command help:

This function writes the audio data through a pipe to the program "play" from the sox distribution. sox runs pretty much anywhere, but it only has audio drivers for OSS (primarily linux and freebsd) and SunOS. In case your local machine is not one of these, write a shell script such as ~/bin/octaveplay, substituting AUDIO_UTILITY with whatever audio utility you happen to have on your system: #!/bin/sh cat > ~/.octave_play.au SYSTEM_AUDIO_UTILITY ~/.octave_play.au rm -f ~/.octave_play.au and set the global variable (e.g., in .octaverc) global sound_play_utility="~/bin/octaveplay";

I named the following script "octaveplay" and put it in ~/bin:

cat > ~/.octave_play.aif
afplay ~/.octave_play.aif
rm -f ~/.octave_play.aif

Then I created .octaverc and added: global sound_play_utility="~/bin/octaveplay";

Voila!

msutherl