annotate core/magnatagatune/MTTMixedFeatureGenreBasicSm.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 classdef MTTMixedFeatureGenreBasicSm < 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$', 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 'MTTAudioFeatureBasicSm', ...
wolffd@0 23 ... % ---
wolffd@0 24 ... % following are GenreBasic parameters
wolffd@0 25 ... % ---
wolffd@0 26 'pct_genres', 1 ... % 1/100 percentile genre tags used
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 = MTTMixedFeatureGenreBasicSm(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 Basic Summary audio features. this includes possible
wolffd@0 50 % local normalisations
wolffd@0 51 % ---
wolffd@0 52 basicsm = clip.audio_features_basicsm(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 genrebasic = clip.genre_features_basic(feature.my_params);
wolffd@0 59
wolffd@0 60 % save to features data field
wolffd@0 61 data.audio = basicsm;
wolffd@0 62 data.tags = genrebasic;
wolffd@0 63
wolffd@0 64 % prepare field for final features
wolffd@0 65 data.final.vector = [];
wolffd@0 66 data.final.vector_info = struct();
wolffd@0 67 data.final.dim = 0;
wolffd@0 68
wolffd@0 69 % save info data
wolffd@0 70 data.info.type = 'MTTMixedFeatureGenreBasicSm';
wolffd@0 71 data.info.owner_id = clip.id;
wolffd@0 72 data.info.creatorrev = feature.my_revision;
wolffd@0 73
wolffd@0 74 % save parameters
wolffd@0 75 data.info.params = feature.my_params;
wolffd@0 76 end
wolffd@0 77
wolffd@0 78 function define_global_transform(features)
wolffd@0 79 % calculate and set normalization factors from the group of
wolffd@0 80 % input features. These features will be set for the full database
wolffd@0 81
wolffd@0 82 if numel(features) == 1
wolffd@0 83 error ('Insert feature array for this method');
wolffd@0 84 end
wolffd@0 85
wolffd@0 86 % ---
wolffd@0 87 % We collect all the relevant basicsm
wolffd@0 88 % features and get the transform on this basis.
wolffd@0 89 % ---
wolffd@0 90 for i = 1:numel(features)
wolffd@0 91 basicsm(i) = features(i).data.audio;
wolffd@0 92 end
wolffd@0 93
wolffd@0 94 % call the features own transsform function
wolffd@0 95 basicsm.define_global_transform();
wolffd@0 96
wolffd@0 97 % ---
wolffd@0 98 % We collect all the relevant genretag
wolffd@0 99 % features and get the transform on this basis.
wolffd@0 100 % ---
wolffd@0 101 for i = 1:numel(features)
wolffd@0 102 genrebasic(i) = features(i).data.tags;
wolffd@0 103 end
wolffd@0 104
wolffd@0 105 % call the features own transsform function
wolffd@0 106 genrebasic.define_global_transform();
wolffd@0 107
wolffd@0 108 % ---
wolffd@0 109 % set common feature values for mixed features
wolffd@0 110 % ---
wolffd@0 111 features(1).my_db.set_common([1]); %trivial common
wolffd@0 112 end
wolffd@0 113
wolffd@0 114
wolffd@0 115 function finalise(feature)
wolffd@0 116 % applies a final transformation and collects the
wolffd@0 117 % information of this feature within a single vector
wolffd@0 118 % see info for types in specific dimensions
wolffd@0 119
wolffd@0 120 for i = 1:numel(feature)
wolffd@0 121
wolffd@0 122 % check for neccesary parameters
wolffd@0 123 if isempty(feature(i).my_db.commondb)
wolffd@0 124
wolffd@0 125 error('Define the global transformation first');
wolffd@0 126 end
wolffd@0 127
wolffd@0 128 % ---
wolffd@0 129 % finalise audio feature and get vector
wolffd@0 130 % ---
wolffd@0 131 basicsm = feature(i).data.audio;
wolffd@0 132 basicsm.finalise();
wolffd@0 133
wolffd@0 134 % finalise tag features
wolffd@0 135 genrebasic = feature(i).data.tags;
wolffd@0 136 genrebasic.finalise;
wolffd@0 137
wolffd@0 138 % ---
wolffd@0 139 % final data assembly
wolffd@0 140 % ---
wolffd@0 141
wolffd@0 142 % concatenate vectors
wolffd@0 143 feature(i).data.final.vector = ...
wolffd@0 144 [basicsm.vector() ; genrebasic.vector()];
wolffd@0 145
wolffd@0 146 % add feature dimensions
wolffd@0 147 feature(i).data.final.dim = basicsm.dim + genrebasic.dim;
wolffd@0 148
wolffd@0 149 % concatenate labels
wolffd@0 150 feature(i).data.final.vector_info.labels = ...
wolffd@0 151 {basicsm.data.final.vector_info.labels{:}, ...
wolffd@0 152 genrebasic.data.final.vector_info.labels{:}};
wolffd@0 153 end
wolffd@0 154 end
wolffd@0 155
wolffd@0 156 % ---
wolffd@0 157 % destructor: do we really want to remove this
wolffd@0 158 % from the database? No, but
wolffd@0 159 % TODO: create marker for unused objects in db, and a cleanup
wolffd@0 160 % function
wolffd@0 161 % ---
wolffd@0 162 function delete(feature)
wolffd@0 163
wolffd@0 164 end
wolffd@0 165
wolffd@0 166 function visualise(feature)
wolffd@0 167 % ---
wolffd@0 168 % plots the different data types collected in this feature
wolffd@0 169 % ---
wolffd@0 170 for i = 1:numel(feature)
wolffd@0 171 clip = MTTClip(feature(i).owner_id());
wolffd@0 172 end
wolffd@0 173 end
wolffd@0 174 end
wolffd@0 175 end