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