tags:

views:

88

answers:

3

Alright, I'm having trouble getting started on this one. I'm trying to use the soundsc function in Octave, but I keep getting this error:

error: sound.m: No command line utility found for sound playing

I've searched around some on the net but couldn't find out what to do. Here's a link to the source code of the file I found on the net that contains the error: http://octave-audio.sourcearchive.com/documentation/1.1.3/sound_8m-source.html

The error I think comes from here:

  ## What do we use for playing?
  global sound_play_utility;
  if ~isempty(sound_play_utility),
    ## User specified command
  elseif  (file_in_path(EXEC_PATH, "ofsndplay"))
    ## Mac
    sound_play_utility = "ofsndplay -"
  elseif (file_in_path(EXEC_PATH, "play"))
    ## Linux (sox)
    sound_play_utility = "play -t AU -";
  else
    error("sound.m: No command line utility found for sound playing");
  endif

I just so happen to be using Windows 7, so I guess I have to specify the path somehow my self? Change the source code? I have no idea what I'm suppose to do to get this to work! Can anyone tell me?

+2  A: 

The file you linked to includes documentation at the top, which includes the following:

## This function writes the audio data through a pipe to the program
## "play" from the sox distribution.

So you need to install sox, for starters. This will include play.exe. Then you have to either set the value of the global variable sound_play_utility in Octave to reflect where you installed sox, or make sure the file_in_path(EXEC_PATH) stuff can find play.exe. Looking a few lines down from the snippet you posted, it looks like the file passes that variable to popen, which is supposed to launch a new process. I've never done anything like that on Octave on a Windows machine, so I can't help you on the exact details.

mtrw
+1  A: 

You can basically see what you have to do by just looking at the code. The Octave module first checks if you set the global sound_play_utility to an utility that you want to use to play sounds. This really is your choice, actually, any audio player on Windows should work (mplayer, foobar, Winamp, whatever really).

Only if this variable is empty will the other checks fail, so just export a global and set it to the path of a player you have installed.

Jim Brissom
I think, though I'm not sure, that the code expects to pass the audio data to a pipe, not as a file (see the `fwrite` lines). I don't know if Winamp etc. can handle that. But then, I also don't know if `sox` will behave as expected on Windows.
mtrw
I was just talking about playing audio. For anything else that this module is offering, yes, you need to install sox. You should consider upvoting / accepting mtrw's answer, which is dead on in this regard.
Jim Brissom
+2  A: 

I don't know if this works for Windows 7 too, but that's how I managed to get soundsc, sox and octave running on Windows XP: Assuming that you have octave already installed,

  1. Download and install sox for Win32: http://sox.sourceforge.net/
  2. Go to the directory where you have sox installed to (C:\sox-14-3-1 for example), make a copy "sox.exe" and rename the copy as "play". IMPORTANT: You have to remove the ".exe" filename extension! Make sure you have set the settings in the explorer to show the file extensions.
  3. start Octave with commandline parameter --exec-path C:\sox-14-3-1 (Or whatever path you have chosen to install sox to). (If you're using qtoctave as GUI you can set this also in the settings in the "Octave" Tab in the settings under "Octave arguments")

Now octave should find the "play" executable to play sounds.

You can try it with the following code, which should produce some ugly beeps ;-)

% Sampling theorem - mirror frequency
% s3s11_1.m * mw * 11/17/2007
FS = 8000;    % sampling frequency in Hz
t = 0:1/FS:1; % normalized time
x = [];
for k = 1:7
x  = [x sin(2*pi*k*1e3*t)]; % signal 1...7 kHz
end
soundsc(x,FS) % sound

Hope that helps :-).

Stefan D.
It worked for me
Jader Dias