comparison core/magnatagatune/MTTMixedFeatureGenreRandom.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 MTTMixedFeatureGenreRandom < 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: 455 $', 5, -1));
15 end
16
17 properties
18 % ---
19 % Set default parameters
20 % ---
21 my_params = MTTAudioFeature.inherited_params(...
22 'MTTTagFeatureGenreBasic', ...
23 ... % ---
24 ... % following are Random parameters
25 ... % ---
26 'nrandoms', 100 ...
27 );
28 end
29
30 % ---
31 % member functions
32 % ---
33 methods
34
35 % ---
36 % constructor: pointer to feature in database
37 % ---
38 function feature = MTTMixedFeatureGenreRandom(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 MTTMixedFeatureGenreBasicSm this includes possible
50 % local normalisations
51 % ---
52 data.tags = clip.features('MTTTagFeatureGenreBasic',feature.my_params);
53
54 % ---
55 % get genre tag features
56 % ---
57
58 data.random = clip.features('MTTRandomFeature',feature.my_params);
59
60
61 % prepare field for final features
62 data.final.vector = [];
63 data.final.vector_info = struct();
64 data.final.dim = 0;
65
66 % save info data
67 data.info.type = class(feature);
68 data.info.owner_id = clip.id;
69 data.info.creatorrev = feature.my_revision;
70
71 % save parameters
72 data.info.params = feature.my_params;
73 end
74
75 function define_global_transform(features)
76 % calculate and set normalization factors from the group of
77 % input features. These features will be set for the full database
78
79 if numel(features) == 1
80 error ('Insert feature array for this method');
81 end
82
83 % ---
84 % We collect all the relevant tag
85 % features and get the transform on this basis.
86 % ---
87 for i = 1:numel(features)
88 tags(i) = features(i).data.tags;
89 end
90
91 % call the features own transsform function
92 tags.define_global_transform();
93
94 % ---
95 % Random features have no global transform
96 % ---
97
98 % ---
99 % set common feature values for mixed features
100 % ---
101 features(1).my_db.set_common([1]); %trivial common
102 end
103
104
105 function finalise(feature)
106 % applies a final transformation and collects the
107 % information of this feature within a single vector
108 % see info for types in specific dimensions
109
110 for i = 1:numel(feature)
111
112 % check for neccesary parameters
113 if isempty(feature(i).my_db.commondb)
114
115 error('Define the global transformation first');
116 end
117
118 % ---
119 % final data assembly
120 % ---
121 % concatenate vectors
122 feature(i).data.final.vector = ...
123 [feature(i).data.tags.vector() ;...
124 feature(i).data.random.vector()];
125
126 % add up feature dimensions
127 feature(i).data.final.dim = feature(i).data.tags.dim...
128 + feature(i).data.random.dim;
129
130 % concatenate labels
131 lbl1 = feature(i).data.tags.labels();
132 lbl2 = feature(i).data.random.labels();
133 feature(i).data.final.vector_info.labels = ...
134 {lbl1{:}, lbl2{:}};
135 end
136 end
137
138 % ---
139 % destructor: do we really want to remove this
140 % from the database? No, but
141 % TODO: create marker for unused objects in db, and a cleanup
142 % function
143 % ---
144 function delete(feature)
145
146 end
147 end
148 end