wolffd@0: classdef MTTMixedFeatureGenreBasicSm < 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$', 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: 'MTTAudioFeatureBasicSm', ... wolffd@0: ... % --- wolffd@0: ... % following are GenreBasic parameters wolffd@0: ... % --- wolffd@0: 'pct_genres', 1 ... % 1/100 percentile genre tags used 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 = MTTMixedFeatureGenreBasicSm(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 Basic Summary audio features. this includes possible wolffd@0: % local normalisations wolffd@0: % --- wolffd@0: basicsm = clip.audio_features_basicsm(feature.my_params); wolffd@0: wolffd@0: % --- wolffd@0: % get genre tag features wolffd@0: % --- wolffd@0: wolffd@0: genrebasic = clip.genre_features_basic(feature.my_params); wolffd@0: wolffd@0: % save to features data field wolffd@0: data.audio = basicsm; wolffd@0: data.tags = genrebasic; 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 = 'MTTMixedFeatureGenreBasicSm'; 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 basicsm wolffd@0: % features and get the transform on this basis. wolffd@0: % --- wolffd@0: for i = 1:numel(features) wolffd@0: basicsm(i) = features(i).data.audio; wolffd@0: end wolffd@0: wolffd@0: % call the features own transsform function wolffd@0: basicsm.define_global_transform(); wolffd@0: wolffd@0: % --- wolffd@0: % We collect all the relevant genretag wolffd@0: % features and get the transform on this basis. wolffd@0: % --- wolffd@0: for i = 1:numel(features) wolffd@0: genrebasic(i) = features(i).data.tags; wolffd@0: end wolffd@0: wolffd@0: % call the features own transsform function wolffd@0: genrebasic.define_global_transform(); 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: % finalise audio feature and get vector wolffd@0: % --- wolffd@0: basicsm = feature(i).data.audio; wolffd@0: basicsm.finalise(); wolffd@0: wolffd@0: % finalise tag features wolffd@0: genrebasic = feature(i).data.tags; wolffd@0: genrebasic.finalise; wolffd@0: wolffd@0: % --- wolffd@0: % final data assembly wolffd@0: % --- wolffd@0: wolffd@0: % concatenate vectors wolffd@0: feature(i).data.final.vector = ... wolffd@0: [basicsm.vector() ; genrebasic.vector()]; wolffd@0: wolffd@0: % add feature dimensions wolffd@0: feature(i).data.final.dim = basicsm.dim + genrebasic.dim; wolffd@0: wolffd@0: % concatenate labels wolffd@0: feature(i).data.final.vector_info.labels = ... wolffd@0: {basicsm.data.final.vector_info.labels{:}, ... wolffd@0: genrebasic.data.final.vector_info.labels{:}}; 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: wolffd@0: function visualise(feature) wolffd@0: % --- wolffd@0: % plots the different data types collected in this feature wolffd@0: % --- wolffd@0: for i = 1:numel(feature) wolffd@0: clip = MTTClip(feature(i).owner_id()); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end