-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpectralEntropy.m
More file actions
83 lines (73 loc) · 2.35 KB
/
SpectralEntropy.m
File metadata and controls
83 lines (73 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function [ E ] = SpectralEntropy(s)
% SpectralEntropy( s, Fs )
%
% Compute the spectral entropy
%
% Implementation based on [Automatic Music Detection in television productions, Seyerlehner, Pohle, Schedl, Widmer. Dafx'07]
%
% =========================================================================
% Objective Characterization of Audio Signal Quality
% Application to Music Collection Description
%
% Implementation inspired by:
% Dominique Fourer and Geoffroy Peeters,
% "Objective Characterization of Audio Signal Quality: Application to
% Music Collection Description,"
% Proc. IEEE 42nd International Conference on Acoustics, Speech and Signal
% Processing (ICASSP), March 2017, New Orleans, USA.
%
% Author: Dominique Fourer (dominique@fourer.fr)
%
% Description:
% This code implements feature extraction and/or analysis methods described
% in the above paper, with a focus on objective audio quality characterization.
% It may include descriptors related to spectral, temporal, and perceptual
% properties of audio signals, and can be used for tasks such as:
% - Audio quality assessment
% - Music collection description
% - Audio processing characterization (e.g., DRC discrimination)
%
% Notes:
% - This is a research-oriented implementation and may not exactly reproduce
% the original results.
% - Ensure proper citation if used in academic work.
%
% License:
% License: Creative Commons Attribution-NonCommercial 4.0 International
% (CC BY-NC 4.0)
%
% You are free to:
% - Share: copy and redistribute the material
% - Adapt: remix, transform, and build upon the material
%
% Under the following terms:
% - Attribution: You must give appropriate credit.
% - NonCommercial: You may not use the material for commercial purposes.
%
% Full license text:
% https://creativecommons.org/licenses/by-nc/4.0/
%
% =========================================================================
if min(size(s)) ~= size(s,1)
s = s.';
end
L = size(s,1); %% number of channels
Sw = spectrogram(s(1, :));
[M, nb_trames] = size(Sw);
Mh = round(M / 2);
E = zeros(L, nb_trames);
for l = 1:L
if l > 1
Sw = spectrogram(s(l, :));
end
X = abs(Sw(1:Mh, :)).^2;
% imagesc(10 * log10(X))
% pause
for n = 1:nb_trames
%% transform X to pdf
Px = X(:, n) ./ (eps+sum(X(:, n)));
%% Compute the entropy
E(l, n) = - sum(Px .* log2(eps+Px));
end
end
end