How to find spectrum envelope from wav file

41 ビュー (過去 30 日間)
Daemian
Daemian 2014 年 12 月 26 日
コメント済み: Daemian 2015 年 1 月 9 日
How do I measure the energy change of the spectrum envelope 20 - 40 hz from from a wav file and plot it to graph? my recording is in 8000 sampling rate 16bits mono.
I would like to get something like this
Thanks for great help, wish you all merry Christmas and happy new year :)
  1 件のコメント
Image Analyst
Image Analyst 2014 年 12 月 28 日
編集済み: Image Analyst 2014 年 12 月 28 日
Daemian, perhaps you overlooked this big hint given in Star's answer "I don’t have your signal, so I can’t test the filter I designed for you with it." HINT, HINT. What do you think you should do now?
Also, please read this.

サインインしてコメントする。

回答 (2 件)

Star Strider
Star Strider 2014 年 12 月 26 日
If you have the Signal Processing Toolbox, such a bandpass filter is easy to design. First (to make things easier) convert your 16-bit signed integer signal (that I call ‘x’ here) to double:
xd = double(x); % Convert to ‘double’
Fs = 8000; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Fpb = [20 40]/Fn; % Passband
Fsb = [15 50]/Fn; % Stopband
[n,Wn] = buttord(Fpb, Fsb, 1, 10); % Filter Order, With Rp = 1, Rs = 10
[b,a] = butter(n,Wn); % Create Filter Transfer Function
[sos,g] = tf2sos(b,a); % Second-Order-Section Implementation
figure(1)
freqz(b,a) % Transfer Function Plot
figure(2) % Second-Order-Section Plot
freqz(sos)
yd = filtfilt(sos, g, xd); % Filter ‘xd’ To Get ‘y’
where ‘xd’ is your .wav signal and ‘yd’ is the filtered output. The filtfilt function will filter both channels of your signal at the same time (assuming your mono signal could have two channels, with the same information in both channels), so this code will work regardless of its having 1 or 2 channels. You can then change ‘yd’ to 16-bits with the int16 function if you want to.
Have fun with this!
Merry Christmas (belatedly) and happy New Year to you, too!
  15 件のコメント
Star Strider
Star Strider 2015 年 1 月 1 日
My pleasure!
Happy New Year to you, too!
Daemian
Daemian 2015 年 1 月 9 日
Hey Star Strider, I found this pdf talking about spectral envelopes I not too sure is it helpful, can you help me take a look?
Thanks!

サインインしてコメントする。


Youssef  Khmou
Youssef Khmou 2014 年 12 月 28 日
編集済み: Youssef Khmou 2014 年 12 月 28 日
Hilbert Transformation is used to obtain the envelope of signal, here is an example :
The envelope is decreasing exponential,
Fs=80;
F=10;
t=0:1/Fs:4-1/Fs;
x=exp(-t).*real(exp(j*2*pi*F*t));
figure; plot(t,x);
Y=abs(hilbert(x));
hold on;
plot(t,Y,'r');
fx=fftshift(abs(fft(x))); fx=fx(floor(end/2:end));
fY=fftshift(abs(fft(Y))); fY=fY(floor(end/2:end));
figure; plot(fx); hold on
plot(fY,'r')
  2 件のコメント
Image Analyst
Image Analyst 2014 年 12 月 30 日
Cool - I didn't know hilbert() did that. Does it always get the envelope no matter what x looks like (like how fast it oscillates)? Why does it get a little squirrely around t=4?
Youssef  Khmou
Youssef Khmou 2014 年 12 月 30 日
編集済み: Youssef Khmou 2014 年 12 月 30 日
According to theory yes, oscillation in borders can be interpreted as Gibbs effect.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by