Find energy for each second of audio file

23 Ansichten (letzte 30 Tage)
Giggs B.
Giggs B. am 25 Jul. 2021
Kommentiert: Star Strider am 26 Jul. 2021
Hi,
I have an audio signal which has 44.1 KHz sampling rate, which would be stored as an array. I am trying to find energy for each second using:
sum(x.^2);
Can someone help me how to do that? Thanks

Akzeptierte Antwort

Star Strider
Star Strider am 25 Jul. 2021
Use the buffer function:
Fs = 44.1E+3; % Sampling Frequency
s = randn(Fs*5.2,1); % Signal
seconds_sampled = 1; % Desired Smaple Length
sec1 = Fs*seconds_sampled; % Corresponding Samples
s_sections = buffer(s,sec1)
s_sections = 44100×6
1.5751 1.0628 0.3946 0.6711 -0.3298 -2.0274 1.5076 1.0714 0.6997 -1.6182 -0.7092 0.3166 -0.9737 0.2084 0.1273 -0.9344 0.6038 -0.0711 0.2128 0.7510 0.3992 -0.5763 -0.0085 -0.7977 -0.8026 1.5172 -0.1044 0.7109 0.4487 1.7293 0.1842 -0.8955 0.0778 -0.2759 -0.5885 1.3357 -0.7606 0.9031 -0.5579 -0.3093 -1.3640 0.1967 0.1805 1.6719 -0.8658 1.0763 0.9120 0.9080 0.0411 -0.1559 -0.9230 -1.8707 -0.3266 -1.5487 -1.1568 0.2762 0.5586 -0.8734 0.1023 1.6655
Check = size(s_sections)
Check = 1×2
44100 6
Energy = sum(s_sections.^2)
Energy = 1×6
1.0e+04 * 4.4284 4.3893 4.4579 4.4808 4.4129 0.9051
.
  4 Kommentare
Giggs B.
Giggs B. am 26 Jul. 2021
Got it, Thank you!
Star Strider
Star Strider am 26 Jul. 2021
As always, my pleasure!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Signal Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by