[sample_data, sample_rate] = audioread(“audio_sample.wav”);
sample_period = 1 / sample_rate;
t = (0: sample_period:(长度(sample_data) 1) / sample_rate);
次要情节(2、2、1)
情节(t, sample_data)
标题(“时域表示-未过滤的声音”)
包含(的时间(秒))
ylabel (“振幅”)
xlim ([0 t(结束)))
m =长度(sample_data);
n = pow2 (nextpow2 (m));
Y = fft(sample_data, n);
f = (0: n - 1) * (sample_rate / n);
振幅= abs (y) / n;
次要情节(2 2 2)
情节(f(1:地板(n / 2)),振幅(1:地板(n / 2)))
标题(“频域表示-未过滤的声音”)
包含(“频率”)
ylabel (“振幅”)
订单= 7;
[b] =黄油(订单,1000 / (sample_rate / 2)“低”);
filtered_sound =过滤器(b, a, sample_data);
声音(filtered_sound sample_rate)
t1 = (0: sample_period:(长度(filtered_sound) 1) / sample_rate);
次要情节(2,2,3)
情节(t1, filtered_sound)
标题(“时域表示-过滤的声音”)
包含(的时间(秒))
ylabel (“振幅”)
xlim ([0 t1(结束)])
m1 =长度(sample_data);
n1 = pow2 (nextpow2 (m1));
Y1 = fft(filtered_sound, n1);
f = (0: n1-1) * (sample_rate / n1);
振幅= abs (y1) / n1;
次要情节(2,2,4)
情节(f(1:地板(n)),振幅(1:地板(n)))
标题(“频域表示法-过滤声音”)
包含(“频率”)
ylabel (“振幅”)