问题
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"
Then I tried
[audio_samples,fs] = wavread("myaudio.wav"); playsound (audio_samples);
To this I get following from octave -
error: Invalid call to playaudio.
- 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