简体   繁体   English

在Windows 7上使用Octave中的soundsc

[英]Using soundsc in Octave, on Windows 7

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: 我试图在Octave中使用soundsc函数,但我一直收到此错误:

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 这是我在网上找到的包含错误的文件的源代码的链接: 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? 我只是碰巧使用Windows 7,所以我想我必须以某种方式指定自己的路径? Change the source code? 更改源代码? I have no idea what I'm suppose to do to get this to work! 我不知道我想要做些什么才能让它发挥作用! Can anyone tell me? 有人能告诉我吗?

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, 我不知道这是否适用于Windows 7,但这就是我设法在Windows XP上运行soundsc,sox和octave:假设你已经安装了八度,

  1. Download and install sox for Win32: http://sox.sourceforge.net/ 下载并安装Win32的sox: 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". 转到安装了sox的目录(例如C:\\ sox-14-3-1),复制“sox.exe”并将副本重命名为“play”。 IMPORTANT: You have to remove the ".exe" filename extension! 重要说明:您必须删除“.exe”文件扩展名! 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). 使用命令行参数启动Octave --exec-path C:\\ sox-14-3-1(或者您选择安装sox的路径)。 (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") (如果您使用qtoctave作为GUI,您也可以在“八度参数”下的设置中的“八度”选项卡中的设置中进行设置)

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 :-). 希望有所帮助:-)。

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. 所以你需要为初学者安装sox This will include play.exe . 这将包括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 . 然后你必须在Octave中设置全局变量sound_play_utility的值以反映你安装sox ,或者确保file_in_path(EXEC_PATH)东西可以找到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. 从您发布的代码片段向下看几行,看起来该文件将该变量传递给popen ,它应该启动一个新进程。 I've never done anything like that on Octave on a Windows machine, so I can't help you on the exact details. 我在Windows机器上从未在Octave上做过类似的事情,所以我无法帮助您了解具体细节。

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. Octave模块首先检查您是否将全局sound_play_utility设置为要用于播放声音的实用程序。 This really is your choice, actually, any audio player on Windows should work (mplayer, foobar, Winamp, whatever really). 这真的是你的选择,实际上,Windows上的任何音频播放器都应该工作(mplayer,foobar,Winamp,无论如何)。

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. 仅当此变量为空时,其他检查才会失败,因此只需导出全局并将其设置为已安装的播放器的路径。

I don't believe that all audio players will work. 我不相信所有音频播放器都能正常工作。 They have to be able to play AU files via a pipe to standard input. 他们必须能够通过管道将AU文件播放到标准输入。 Here are the Octave commands, I use to enable playing through VLC. 以下是Octave命令,我用它来启用VLC播放。 You may need to adjust the path to the VLC program in the VLC_PROGRAM variable. 您可能需要在VLC_PROGRAM变量中调整VLC程序的路径。

VLC_PROGRAM="c:/Program Files (x86)/VideoLan/VLC/vlc";
VLC_OPTIONS="-q --play-and-exit -";    
sound_play_utility=["cmd /c \"" VLC_PROGRAM "\" " VLC_OPTIONS];    
clear VLC_PROGRAM VLC_OPTIONS;

I recommend placing these commands in your .octaverc startup file so that your sound player is automatically configured everytime you start Octave. 我建议将这些命令放在.octaverc启动文件中,以便每次启动Octave时自动配置声音播放器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM