WAV read and play in a 16-bit (8kHz sampling rate) .wav file
Show older comments
Hi,
I got a problem on "WAV read and play in a 16-bit (8kHz sampling rate) .wav file".
The voice (sound of heart and lungs, for 14 seconds, 235KB size) wav file was record from a microphone device and could be play in Windows. When I try to play and plot the wav file in Matlab, the error message shows as below:
"??? Frequency must be a scalar
Error in ==> sound at 36 playsnd(y,fs,bits);"
----------------------------------------------------------------
Is anything wrong or missed on below source code:
----------------------------------------------------------------
clear all;close all;clc;
%=================================plot=====================================
fs = 8000;
y = wavread(C:\sound.wav);
[y,fs,16] = wavread(C:\sound.wav);
wavplay(1*y,fs,'sync');
plot(y);
title('Waveform')
%==========================================================================
Please someone helps on this problem, thanks in advance.
3 Comments
Carlos
on 14 Mar 2013
In this line
[y,fs,16] = wavread(C:\sound.wav);
The problem might be that 16 should be something wavread returns, not something you have to specify. Even though the error message does not seem to be related with that.It is just an idea,try
[y,fs,nbits] = wavread(C:\sound.wav);
instead of
[y,fs,16] = wavread(C:\sound.wav);
Walter Roberson
on 14 Mar 2013
Which MATLAB version was being used?
What does size(y) and sie(Fs) report ?
Answers (1)
Wayne King
on 14 Mar 2013
1 vote
Carlos is correct that you should not have not have an actual scalar value as the target of an assignment. It should be nbits or some similarly named output.
Actually I am very surprised that you did not get the error:
??? Error: An array for multiple LHS assignment cannot contain numeric value.
when you tried to execute that command.
Furthermore, did you leave the single quotes off C:\sound.wav? That also should have thrown an error.
Categories
Find more on Subspace Methods in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!