comparison core/magnatagatune/MTTMixedFeatureGenreBasicSm.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 MTTMixedFeatureGenreBasicSm < 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 = MTTAudioFeature.inherited_params(...
22 'MTTAudioFeatureBasicSm', ...
23 ... % ---
24 ... % following are GenreBasic parameters
25 ... % ---
26 'pct_genres', 1 ... % 1/100 percentile genre tags used
27 );
28 end
29
30 % ---
31 % member functions
32 % ---
33 methods
34
35 % ---
36 % constructor: pointer to feature in database
37 % ---
38 function feature = MTTMixedFeatureGenreBasicSm(varargin)
39
40 feature = feature@MTTAudioFeature(varargin{:});
41 end
42
43 % ---
44 % extract feature data by combining genre adn basicsm features
45 % ---
46 function data = extract(feature, clip)
47
48 % ---
49 % get Basic Summary audio features. this includes possible
50 % local normalisations
51 % ---
52 basicsm = clip.audio_features_basicsm(feature.my_params);
53
54 % ---
55 % get genre tag features
56 % ---
57
58 genrebasic = clip.genre_features_basic(feature.my_params);
59
60 % save to features data field
61 data.audio = basicsm;
62 data.tags = genrebasic;
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 = 'MTTMixedFeatureGenreBasicSm';
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 basicsm
88 % features and get the transform on this basis.
89 % ---
90 for i = 1:numel(features)
91 basicsm(i) = features(i).data.audio;
92 end
93
94 % call the features own transsform function
95 basicsm.define_global_transform();
96
97 % ---
98 % We collect all the relevant genretag
99 % features and get the transform on this basis.
100 % ---
101 for i = 1:numel(features)
102 genrebasic(i) = features(i).data.tags;
103 end
104
105 % call the features own transsform function
106 genrebasic.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 % finalise audio feature and get vector
130 % ---
131 basicsm = feature(i).data.audio;
132 basicsm.finalise();
133
134 % finalise tag features
135 genrebasic = feature(i).data.tags;
136 genrebasic.finalise;
137
138 % ---
139 % final data assembly
140 % ---
141
142 % concatenate vectors
143 feature(i).data.final.vector = ...
144 [basicsm.vector() ; genrebasic.vector()];
145
146 % add feature dimensions
147 feature(i).data.final.dim = basicsm.dim + genrebasic.dim;
148
149 % concatenate labels
150 feature(i).data.final.vector_info.labels = ...
151 {basicsm.data.final.vector_info.labels{:}, ...
152 genrebasic.data.final.vector_info.labels{:}};
153 end
154 end
155
156 % ---
157 % destructor: do we really want to remove this
158 % from the database? No, but
159 % TODO: create marker for unused objects in db, and a cleanup
160 % function
161 % ---
162 function delete(feature)
163
164 end
165
166 function visualise(feature)
167 % ---
168 % plots the different data types collected in this feature
169 % ---
170 for i = 1:numel(feature)
171 clip = MTTClip(feature(i).owner_id());
172 end
173 end
174 end
175 end