wolffd@0: classdef MTTMixedFeatureGenreRandom < MTTAudioFeature & handle wolffd@0: % --- wolffd@0: % wolffd@0: % The usual worklow for these features constist of three steps wolffd@0: % 1. extract: extracts the basic single-file dependent features wolffd@0: % 2. define_global_transform: calculates the global feature wolffd@0: % transformation parameters wolffd@0: % 3. finalise: applies the common transformations to a specific feature wolffd@0: % --- wolffd@0: wolffd@0: properties(Constant = true) wolffd@0: wolffd@0: % svn hook wolffd@0: my_revision = str2double(substr('$Rev: 455 $', 5, -1)); wolffd@0: end wolffd@0: wolffd@0: properties wolffd@0: % --- wolffd@0: % Set default parameters wolffd@0: % --- wolffd@0: my_params = MTTAudioFeature.inherited_params(... wolffd@0: 'MTTTagFeatureGenreBasic', ... wolffd@0: ... % --- wolffd@0: ... % following are Random parameters wolffd@0: ... % --- wolffd@0: 'nrandoms', 100 ... wolffd@0: ); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % member functions wolffd@0: % --- wolffd@0: methods wolffd@0: wolffd@0: % --- wolffd@0: % constructor: pointer to feature in database wolffd@0: % --- wolffd@0: function feature = MTTMixedFeatureGenreRandom(varargin) wolffd@0: wolffd@0: feature = feature@MTTAudioFeature(varargin{:}); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % extract feature data by combining genre adn basicsm features wolffd@0: % --- wolffd@0: function data = extract(feature, clip) wolffd@0: wolffd@0: % --- wolffd@0: % get MTTMixedFeatureGenreBasicSm this includes possible wolffd@0: % local normalisations wolffd@0: % --- wolffd@0: data.tags = clip.features('MTTTagFeatureGenreBasic',feature.my_params); wolffd@0: wolffd@0: % --- wolffd@0: % get genre tag features wolffd@0: % --- wolffd@0: wolffd@0: data.random = clip.features('MTTRandomFeature',feature.my_params); wolffd@0: wolffd@0: wolffd@0: % prepare field for final features wolffd@0: data.final.vector = []; wolffd@0: data.final.vector_info = struct(); wolffd@0: data.final.dim = 0; wolffd@0: wolffd@0: % save info data wolffd@0: data.info.type = class(feature); wolffd@0: data.info.owner_id = clip.id; wolffd@0: data.info.creatorrev = feature.my_revision; wolffd@0: wolffd@0: % save parameters wolffd@0: data.info.params = feature.my_params; wolffd@0: end wolffd@0: wolffd@0: function define_global_transform(features) wolffd@0: % calculate and set normalization factors from the group of wolffd@0: % input features. These features will be set for the full database wolffd@0: wolffd@0: if numel(features) == 1 wolffd@0: error ('Insert feature array for this method'); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % We collect all the relevant tag wolffd@0: % features and get the transform on this basis. wolffd@0: % --- wolffd@0: for i = 1:numel(features) wolffd@0: tags(i) = features(i).data.tags; wolffd@0: end wolffd@0: wolffd@0: % call the features own transsform function wolffd@0: tags.define_global_transform(); wolffd@0: wolffd@0: % --- wolffd@0: % Random features have no global transform wolffd@0: % --- wolffd@0: wolffd@0: % --- wolffd@0: % set common feature values for mixed features wolffd@0: % --- wolffd@0: features(1).my_db.set_common([1]); %trivial common wolffd@0: end wolffd@0: wolffd@0: wolffd@0: function finalise(feature) wolffd@0: % applies a final transformation and collects the wolffd@0: % information of this feature within a single vector wolffd@0: % see info for types in specific dimensions wolffd@0: wolffd@0: for i = 1:numel(feature) wolffd@0: wolffd@0: % check for neccesary parameters wolffd@0: if isempty(feature(i).my_db.commondb) wolffd@0: wolffd@0: error('Define the global transformation first'); wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % final data assembly wolffd@0: % --- wolffd@0: % concatenate vectors wolffd@0: feature(i).data.final.vector = ... wolffd@0: [feature(i).data.tags.vector() ;... wolffd@0: feature(i).data.random.vector()]; wolffd@0: wolffd@0: % add up feature dimensions wolffd@0: feature(i).data.final.dim = feature(i).data.tags.dim... wolffd@0: + feature(i).data.random.dim; wolffd@0: wolffd@0: % concatenate labels wolffd@0: lbl1 = feature(i).data.tags.labels(); wolffd@0: lbl2 = feature(i).data.random.labels(); wolffd@0: feature(i).data.final.vector_info.labels = ... wolffd@0: {lbl1{:}, lbl2{:}}; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % destructor: do we really want to remove this wolffd@0: % from the database? No, but wolffd@0: % TODO: create marker for unused objects in db, and a cleanup wolffd@0: % function wolffd@0: % --- wolffd@0: function delete(feature) wolffd@0: wolffd@0: end wolffd@0: end wolffd@0: end