linux - 如何在 Octave 音程中演奏 A

标签 linux octave audio

<分区>

如何使用 playaudio() 函数在 Octave 中播放 A(第 3 个 Octave )?我使用 Ubuntu Linux。它的频率是 440 赫兹。

最佳答案

有一段时间没有接触 Octave,记得在 OSX 上遇到过声音问题(显然 audio 包在 Linux 上运行良好)。音频包应该有一个 sound() 函数将使您的任务变得简单:

%sample rate - 22050
sr = [0:1/22050:1];
% A - 440Hz using sine
a = sin(2*pi*440*sr);
%play
sound(a)

不幸的是 playaudio() 在我的机器上不工作:

octave-3.0.3:15> playaudio(x)
sh: /dev/dsp: Permission denied

不过,我已经测试了 sound() 并得到了音调。 如果您对 sound() 函数有疑问,可以尝试使用自定义 sound() 函数:

function sound(x, fs)
  if(nargin == 1 || isempty(fs))
    fs = 8000;
  endif
  if(rows(x) != length(x))
    x = x'
  endif
  if(playrec('isInitialised'))
    playrec('reset');
  endif

  playrec('init', fs, 3, 1);

  playrec('play', x, 1:size(x,2));
endfunction

HTH,因为 Octave 不是我的专业领域。

关于linux - 如何在 Octave 音程中演奏 A,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8022401/

相关文章:

linux - 汇编程序 sysTime 在执行时给出错误

linux - 使用 shell,如何跳到 for 循环中的下一个元素?

linux - 如何使用WD My Book Live共享作为Raspberry PI owncloud服务器数据目录?

matlab - 生成位矩阵

flash - 如何使用http播放wave文件?

iphone - 具有良好内存管理功能的声音引擎 (iPhone/iPad)

javascript - jplayer 多个实例一页 - 但是数量是可变的

c++ - 哪个库需要满足 #include <linux/videodev.h>

matlab - 来自 PostgreSQL 的 Octave 数据库包时间戳

cygwin - Octave 无法绘制加载到不同地址的 : cygoctave-1. dll