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?
I've overridden the playaudio function from octave with the following function. This will work only after installing sox.
(in ubuntu)
A similar approach will allow you to record too:
Install alsa-utils or pulseaudio-utils and put the following in your ~/.octaverc:
or
I am on a Mac (Yosemite), and discovered a simpler solution than what others have suggested. Just in case this is still relevant for anybody:
First install SoX: http://sox.sourceforge.net/
(via Homebrew)
Now on the terminal command line you can use:
...and you will hear beautiful music.
But that command does not work from within Octave. This does work:
On Octave 4.2.1. You can play a wav file as follows
Save the following code in a file playWav.m
Then you can call the function as
playWav('/path/to/wavfile');
from Octave commandline.Tested on Windows 7.
On one of my Linux machines, I created the following ofsndplay script to work around the hard-wired dependency:
This particular script uses the SoX
play
utility.Admittedly, the comment is unnecessary for the functionality but it certainly made me feel better....
On OSX, this is what I did to get sound working:
from the
sound
command help:I named the following script "octaveplay" and put it in ~/bin:
Then I created .octaverc and added:
global sound_play_utility="~/bin/octaveplay";
Voila!