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