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