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