MATLAB: Does the SOUND function on MATLAB 6.5 (R13) for Linux produce poor quality sound

frequencylinuxMATLABnoisyqualitysamplingsound

I am trying to play sound from MATLAB 6.5 (R13) under Linux RedHat 8.0 and I do not know why the sound produced is not the one expected. It is very noisy and has a low tone. I am using the SOUND command in MATLAB, for example:
load handel;
sound(y, Fs) ;
I also noticed that whatever sampling frequency I use, the produced sound remains the same.
If I play a sound from any other music program on my Linux computer it sounds just fine. I can also play my sound file on a Windows machine and it works too.
On a Windows machine, a nice 'hallelujah' sound is produced. Now, if I run this same set of commands on my Linux machine, the sound is not pleasant, it is very noisy and I can hardly recognize the original 'hallelujah'. Furthermore, there is no change in sound speed, pitch, or quality when I change the sampling frequency (e.g. sound (y, 2*Fs)).
I also tried this on another Linux machine and the same poor quality sound was produced.

Best Answer

This bug has been fixed in MATLAB 7.3 (R2006b). For previous product releases, read below for any possible workarounds:
This issue exists in the sound quality generated by MATLAB 6.5 (R13) for Linux.
To workaround this issue, try the following:
1. Use the AUDIOPLAYER and AUDIORECORDER functions in MATLAB 7.0 (R14) and later versions to avoid this issue as follows:
load handel;
player = audioplayer(y, Fs);
play(player,[1 (get(player, 'SampleRate')*3)]);
stop(player);
For more information on the functions AUDIOPLAYER and AUDIORECORDER refer the links below:
2. For releases previous to MATLAB 7.0 (R14), if the system is running MATLAB with Java Virtual Machine 1.3 or higher, try this as a possible workaround:
load handel;
p = com.mathworks.toolbox.audio.JavaAudioPlayer(y, Fs, 16);
p.play;
%p.stop;
%p.pause;
% etc.
Note that "y" must be scaled between the ranges of [-1 1] for the files to play clearly.