Plotting wav sound file onto graph

28 次查看(过去 30 天)
Hey I am trying to plot a wav file in the time domain that I recorded from my own microphone onto a graph in matlab, I am reading in the file using audioread, and when I am plotting it, I am getting this weird orange superimposition over my graph. However, when I am using an audio clip from online and plotting it, it seems to be completely blue. What is the difference between the blue and the orange graphs? Is the orange portion ambient noise from my microphone? Here is my code
%filename is where I am getting the sound wav file from on my cpu,
[y,Fs] = audioread(filename);
%sound(y,Fs);
size(filename);
length(y)
whos y;
whos Fs;
TotalTime = length(y)./Fs;
t = 0:TotalTime/(length(y)):TotalTime-TotalTime/length(y);
plot(t,y)
Also as a follow up question, when I am going about finding the fft of these two waveforms, is it as simple as the following statements.
nfft = fft(y);
F = 1./t;
plot(F,y)
Any help is appreciated. Thanks.

采纳的回答

Star Strider
Star Strider 2016-9-15
The sound you recorded from your microphone is in stereo (by default, however you can make it single-channel monophonic if you want), so the plot is plotting both channels. The sound is stored in a (Nx2) matrix, with the left channel the first column and the right channel the second column. You can plot only one channel, or plot each in a separate figure (consider using subplot).
The sound you got from your online source is likely monophonic, and the plot displays only the one channel.
  2 个评论
Brendan Zotto
Brendan Zotto 2016-9-15
This community is great, this was the mistake. I used this code to fix the error.
Mono = (y(:,1)+y(:,2))/2;
How would I use the subplot method you mention? Thanks for the answer by the way, I really appreciate it.
Star Strider
Star Strider 2016-9-15
My pleasure.
You could also calculate the mean as:
Mono = mean(y,2);
I would do the subplots as:
figure(1)
subplot(2,1,1)
plot(t, y(:,1))
grid
subplot(2,1,2)
plot(t, y(:,2))
grid

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by