Mercurial > hg > camir-aes2014
comparison core/magnatagatune/MTTMixedFeatureSlaney08GenreBasicSm.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 classdef MTTMixedFeatureSlaney08GenreBasicSm < MTTAudioFeature & handle | |
2 % --- | |
3 % | |
4 % | |
5 % The usual worklow for these features constist of three steps | |
6 % 1. extract: extracts the basic single-file dependent features | |
7 % 2. define_global_transform: calculates the global feature | |
8 % transformation parameters | |
9 % 3. finalise: applies the common transformations to a specific feature | |
10 % --- | |
11 | |
12 properties(Constant = true) | |
13 | |
14 % svn hook | |
15 my_revision = str2double(substr('$Rev$', 5, -1)); | |
16 end | |
17 | |
18 properties | |
19 % --- | |
20 % Set default parameters | |
21 % --- | |
22 my_params = MTTAudioFeature.inherited_params(... | |
23 'MTTMixedFeatureGenreBasicSm', ... | |
24 ... % --- | |
25 ... % following are Slaney08 parameters | |
26 ... % --- | |
27 'norm_mttstats', 1, ... % | |
28 'whiten_mttstats', 0, ... % NOTE: whitening as in slaney?? | |
29 'select_mttstats', 1 ...% select certain features | |
30 ); | |
31 end | |
32 | |
33 % --- | |
34 % member functions | |
35 % --- | |
36 methods | |
37 | |
38 % --- | |
39 % constructor: pointer to feature in database | |
40 % --- | |
41 function feature = MTTMixedFeatureSlaney08GenreBasicSm(varargin) | |
42 | |
43 feature = feature@MTTAudioFeature(varargin{:}); | |
44 end | |
45 | |
46 % --- | |
47 % extract feature data by combining genre adn basicsm features | |
48 % --- | |
49 function data = extract(feature, clip) | |
50 | |
51 % --- | |
52 % get MTTMixedFeatureGenreBasicSm this includes possible | |
53 % local normalisations | |
54 % --- | |
55 data.genrebasicsm = clip.features('MTTMixedFeatureGenreBasicSm',feature.my_params); | |
56 | |
57 % --- | |
58 % get genre tag features | |
59 % --- | |
60 | |
61 data.mttstats = clip.features('MTTAudioFeatureSlaney08',feature.my_params); | |
62 | |
63 | |
64 % prepare field for final features | |
65 data.final.vector = []; | |
66 data.final.vector_info = struct(); | |
67 data.final.dim = 0; | |
68 | |
69 % save info data | |
70 data.info.type = class(feature); | |
71 data.info.owner_id = clip.id; | |
72 data.info.creatorrev = feature.my_revision; | |
73 | |
74 % save parameters | |
75 data.info.params = feature.my_params; | |
76 end | |
77 | |
78 function define_global_transform(features) | |
79 % calculate and set normalization factors from the group of | |
80 % input features. These features will be set for the full database | |
81 | |
82 if numel(features) == 1 | |
83 error ('Insert feature array for this method'); | |
84 end | |
85 | |
86 % --- | |
87 % We collect all the relevant genrebasicsm | |
88 % features and get the transform on this basis. | |
89 % --- | |
90 for i = 1:numel(features) | |
91 genrebasicsm(i) = features(i).data.genrebasicsm; | |
92 end | |
93 | |
94 % call the features own transsform function | |
95 genrebasicsm.define_global_transform(); | |
96 | |
97 % --- | |
98 % We collect all the relevant mttstats | |
99 % features and get the transform on this basis. | |
100 % --- | |
101 for i = 1:numel(features) | |
102 mttstats(i) = features(i).data.mttstats; | |
103 end | |
104 | |
105 % call the features own transsform function | |
106 mttstats.define_global_transform(); | |
107 | |
108 % --- | |
109 % set common feature values for mixed features | |
110 % --- | |
111 features(1).my_db.set_common([1]); %trivial common | |
112 end | |
113 | |
114 | |
115 function finalise(feature) | |
116 % applies a final transformation and collects the | |
117 % information of this feature within a single vector | |
118 % see info for types in specific dimensions | |
119 | |
120 for i = 1:numel(feature) | |
121 | |
122 % check for neccesary parameters | |
123 if isempty(feature(i).my_db.commondb) | |
124 | |
125 error('Define the global transformation first'); | |
126 end | |
127 | |
128 % --- | |
129 % final data assembly | |
130 % --- | |
131 % concatenate vectors | |
132 feature(i).data.final.vector = ... | |
133 [feature(i).data.genrebasicsm.vector() ;... | |
134 feature(i).data.mttstats.vector()]; | |
135 | |
136 % add up feature dimensions | |
137 feature(i).data.final.dim = feature(i).data.genrebasicsm.dim... | |
138 + feature(i).data.mttstats.dim; | |
139 | |
140 % concatenate labels | |
141 lbl1 = feature(i).data.genrebasicsm.labels(); | |
142 lbl2 = feature(i).data.mttstats.labels(); | |
143 feature(i).data.final.vector_info.labels = ... | |
144 {lbl1{:}, lbl2{:}}; | |
145 end | |
146 end | |
147 | |
148 % --- | |
149 % destructor: do we really want to remove this | |
150 % from the database? No, but | |
151 % TODO: create marker for unused objects in db, and a cleanup | |
152 % function | |
153 % --- | |
154 function delete(feature) | |
155 | |
156 end | |
157 | |
158 end | |
159 end |