首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在麦克风降噪输入前后绘制wav文件的谱图和图形

如何在麦克风降噪输入前后绘制wav文件的谱图和图形
EN

Stack Overflow用户
提问于 2015-05-24 10:07:30
回答 1查看 611关注 0票数 0

我的降噪项目。

1.这里我从麦克风输入的代码并保存到.wav

在文件中读

代码语言:javascript
运行
复制
clear all;

close all;

mic1= dsp.AudioRecorder;
hmfw = dsp.AudioFileWriter('myspeech.wav','FileFormat','WAV');
disp('Speak into microphone now');
time_end = 10;
tic;
while toc <= time_end
    step(hmfw, step(mic1));
end

release(mic1);
release(hmfw);`

disp('Recording complete');
[f,fs] = audioread('C:\Users\Admin\Documents\MATLAB\myspeech.wav');`

在记录之前,我怎样才能绘制一张谱图

时间= 10频率=0- 8000

2.如何绘制频率为500 ~ 2000 Hz的降噪后的谱图。

就像这张图,光谱图和光谱

这里链接

spectrogram.jpg%3Bhttp%253A%252F%252Fwww.aquaphoenix.com%252Flecture%252Fmatlab10%252Fpage4.html%3B960%3B768

这是我的过滤码。

代码语言:javascript
运行
复制
n = 7;
beginFreq = 500 / (fs/2);
endFreq = 2000 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'bandpass');

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-24 10:38:29

试试这个:

代码语言:javascript
运行
复制
**** The previous part of your code goes here ***
disp('Recording complete');
[y,fs] = audioread('myspeech.wav');

y = y(:,1); % Take only one channel from the recording


n = 7;
beginFreq = 500 / (fs/2);
endFreq = 2000 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'bandpass');

%
dt = 1/fs;
L = size(y,1);                    % Length of signal
t = (0:L-1)'*dt;                  % Time vector

figure(1)

plot(t,y(:,1))
title('Recording')
xlabel('time (milliseconds)')

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y(:,1),NFFT)/L;
f = fs/2*linspace(0,1,NFFT/2+1);

% Plot spectrum of channel 1 from the original signal
figure()
plot(f,2*abs(Y(1:NFFT/2+1))); hold on
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

% Filter the two channels
filt_y = filter(b,a,y);

filt_Y = fft(filt_y,NFFT)/L;

% Plot the filtered spectrum of channel 1 from the original signal
plot(f,2*abs(filt_Y(1:NFFT/2+1))) 
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30422285

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档