Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirfeatures.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function r = mirfeatures(x,varargin) | |
2 % f = mirfeatures(x) computes a large set of features from one or several | |
3 % audio files. x can be either the name of an audio file, or the | |
4 % 'Folder' keyword. | |
5 % mirfeatures(...,'Stat') returns the statistics of the features instead | |
6 % of the complete features themselves. | |
7 % mirfeatures(...,'Segment',t) segments the audio sequence at the | |
8 % temporal positions indicated in the array t (in s.), and analyzes | |
9 % each segment separately. | |
10 | |
11 %(not available yet) | |
12 % mirfeatures(...,'Filterbank',nc) computes the analysis on each channel | |
13 % of a filterbank decomposition. | |
14 % Default value: nc = 5 | |
15 % mirfeatures(...,'Frame',...) | |
16 % mirfeatures(...,'Normal') | |
17 % mirfeatures(...,'Sampling',s) | |
18 % miraudio options (Extract, ...) | |
19 | |
20 [stat,nchan,segm,feat] = scanargin(varargin); | |
21 | |
22 if isa(x,'miraudio') || isa(x,'mirdesign') | |
23 a = miraudio(x,'Normal'); % normalize with respect to RMS energy | |
24 % in order to consider timbre independently of | |
25 % energy | |
26 else | |
27 a = miraudio('Design','Normal'); | |
28 end | |
29 | |
30 if not(isempty(segm)) | |
31 a = mirsegment(a,segm); | |
32 end | |
33 | |
34 | |
35 | |
36 % DYNAMICS | |
37 % -------- | |
38 | |
39 r.dynamics.rms = mirrms(a,'Frame'); | |
40 % Perceived dynamics: spectral slope? | |
41 | |
42 % RHYTHM | |
43 % ------ | |
44 | |
45 r.fluctuation = mirstruct; | |
46 r.fluctuation.tmp.f = mirfluctuation(a,'Summary'); | |
47 r.fluctuation.peak = mirpeaks(r.fluctuation.tmp.f,'Total',1);%only one? | |
48 r.fluctuation.centroid = mircentroid(r.fluctuation.tmp.f); | |
49 | |
50 r.rhythm = mirstruct; | |
51 r.rhythm.tmp.onsets = mironsets(a); | |
52 | |
53 %r.rhythm.eventdensity = ... | |
54 | |
55 r.rhythm.tempo = mirtempo(r.rhythm.tmp.onsets,'Frame'); | |
56 %r.rhythm.pulseclarity = mirpulseclarity(r.tmp.onsets,'Frame'); | |
57 % Should use the second output of mirtempo. | |
58 | |
59 attacks = mironsets(r.rhythm.tmp.onsets,'Attacks'); | |
60 r.rhythm.attack.time = mirattacktime(attacks); | |
61 r.rhythm.attack.slope = mirattackslope(attacks); | |
62 | |
63 % TIMBRE | |
64 % ------ | |
65 | |
66 f = mirframe(a,.05,.5); | |
67 r.spectral = mirstruct; | |
68 r.spectral.tmp.s = mirspectrum(f); | |
69 %pitch = mirpitch(a,'Frame',.05,.5); | |
70 | |
71 r.spectral.centroid = mircentroid(r.spectral.tmp.s); | |
72 r.spectral.brightness = mirbrightness(r.spectral.tmp.s); | |
73 r.spectral.spread = mirspread(r.spectral.tmp.s); | |
74 r.spectral.skewness = mirskewness(r.spectral.tmp.s); | |
75 r.spectral.kurtosis = mirkurtosis(r.spectral.tmp.s); | |
76 r.spectral.rolloff95 = mirrolloff(r.spectral.tmp.s,95); | |
77 r.spectral.rolloff85 = mirrolloff(r.spectral.tmp.s,85); | |
78 r.spectral.spectentropy = mirentropy(r.spectral.tmp.s); | |
79 r.spectral.flatness = mirflatness(r.spectral.tmp.s); | |
80 | |
81 r.spectral.roughness = mirroughness(r.spectral.tmp.s); | |
82 r.spectral.irregularity = mirregularity(r.spectral.tmp.s); | |
83 %r.spectral.inharmonicity = mirinharmonicity(r.spectral.tmp.s,'f0',pitch); | |
84 | |
85 r.spectral.mfcc = mirmfcc(r.spectral.tmp.s); | |
86 r.spectral.dmfcc = mirmfcc(r.spectral.mfcc,'Delta'); | |
87 r.spectral.ddmfcc = mirmfcc(r.spectral.dmfcc,'Delta'); | |
88 | |
89 r.timbre.zerocross = mirzerocross(f); | |
90 r.timbre.lowenergy = mirlowenergy(f); | |
91 r.timbre.spectralflux = mirflux(f); | |
92 | |
93 % PITCH | |
94 % ----- | |
95 | |
96 r.tonal = mirstruct; | |
97 r.tonal.tmp.chromagram = mirchromagram(a,'Frame','Wrap',0,'Pitch',0); | |
98 r.tonal.chromagram.peak=mirpeaks(r.tonal.tmp.chromagram,'Total',1); | |
99 r.tonal.chromagram.centroid=mircentroid(r.tonal.tmp.chromagram); | |
100 | |
101 % TONALITY/HARMONY | |
102 % ---------------- | |
103 | |
104 keystrengths = mirkeystrength(r.tonal.tmp.chromagram); | |
105 [k r.tonal.keyclarity] = mirkey(keystrengths,'Total',1); | |
106 %r.tonal.keyclarity = k{2}; | |
107 r.tonal.mode = mirmode(keystrengths); | |
108 r.tonal.hcdf = mirhcdf(r.tonal.tmp.chromagram); | |
109 | |
110 if stat | |
111 r = mirstat(r); | |
112 % SHOULD COMPUTE STAT OF CURVES FROM FRAMED_DECOMPOSED HIGH FEATURES | |
113 end | |
114 | |
115 if not(isa(x,'miraudio')) && not(isa(x,'mirdesign')) | |
116 r = mireval(r,x); | |
117 end | |
118 | |
119 | |
120 function [stat,nchan,segm,feat] = scanargin(v) | |
121 stat = 0; | |
122 nchan = 1; | |
123 segm = []; | |
124 feat = {}; | |
125 i = 1; | |
126 while i <= length(v) | |
127 arg = v{i}; | |
128 if ischar(arg) && strcmpi(arg,'Filterbank') | |
129 i = i+1; | |
130 if i <= length(v) | |
131 nchan = v{i}; | |
132 else | |
133 nchan = 10; | |
134 end | |
135 elseif ischar(arg) && strcmpi(arg,'Stat') | |
136 i = i+1; | |
137 if i <= length(v) | |
138 stat = v{i}; | |
139 else | |
140 stat = 1; | |
141 end | |
142 elseif ischar(arg) && strcmpi(arg,'Segment') | |
143 i = i+1; | |
144 if i <= length(v) | |
145 segm = v{i}; | |
146 else | |
147 segm = 1; | |
148 end | |
149 else | |
150 feat{end+1} = arg; | |
151 end | |
152 i = i+1; | |
153 end |