Reading and playing sound in Octave on Fedora12

若如初见. 提交于 2019-12-25 04:19:29

问题


I would like to read a wav file and play it in octave. I am using octave 3.4.0 on fedora 12. This is my code -

1.

[audio_samples,fs] = wavread("myaudio.wav"); sound(audio_samples,fs);

To this octave complained that "Sound function is not implemented"

  1. Then I tried

    [audio_samples,fs] = wavread("myaudio.wav"); playsound (audio_samples);

To this I get following from octave -

error: Invalid call to playaudio.

  1. Upon some preliminary debugging for #2 above I see that playaudio(x) function first checkswhether x is a vector or not. For me this check is failing, because I see that isvector(audio_samples) returns zero. My question to experts is - "how can I convert (typecast) my variable audio_samples, to be a vector so that my playaudio function works ?

回答1:


Wavread should return a matrix with one column per audio channel. To listen to the first channel, you could therefore call:

  playaudio(audio_samples(:,1), fs);


来源:https://stackoverflow.com/questions/5130942/reading-and-playing-sound-in-octave-on-fedora12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!