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