annotate core/magnatagatune/MTTMixedFeatureStober11Slaney08GenreBasicSm.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 MTTMixedFeatureStober11Slaney08GenreBasicSm < 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: 638 $', 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 'MTTMixedFeatureSlaney08GenreBasicSm', ...
wolffd@0 23 ... % ---
wolffd@0 24 ... % these are Stober11 parameters
wolffd@0 25 ... % ---
wolffd@0 26 'stob_lowaudio', 1, ...
wolffd@0 27 'stob_highaudio', 1, ... %
wolffd@0 28 'stob_tags', 1, ...
wolffd@0 29 'stob_norm', 1 ...
wolffd@0 30 ... % ---
wolffd@0 31 );
wolffd@0 32 end
wolffd@0 33
wolffd@0 34 % ---
wolffd@0 35 % member functions
wolffd@0 36 % ---
wolffd@0 37 methods
wolffd@0 38
wolffd@0 39 % ---
wolffd@0 40 % constructor: pointer to feature in database
wolffd@0 41 % ---
wolffd@0 42 function feature = MTTMixedFeatureStober11Slaney08GenreBasicSm(varargin)
wolffd@0 43
wolffd@0 44 feature = feature@MTTAudioFeature(varargin{:});
wolffd@0 45 end
wolffd@0 46
wolffd@0 47 % ---
wolffd@0 48 % extract feature data by combining genre adn stob features
wolffd@0 49 % ---
wolffd@0 50 function data = extract(feature, clip)
wolffd@0 51
wolffd@0 52 % ---
wolffd@0 53 % get Basic Summary audio features. this includes possible
wolffd@0 54 % local normalisations
wolffd@0 55 % ---
wolffd@0 56 stob = clip.features('MTTMixedFeatureStober11',feature.my_params);
wolffd@0 57
wolffd@0 58 % ---
wolffd@0 59 % get genre tag features
wolffd@0 60 % ---
wolffd@0 61 genrebasicsm = clip.features('MTTMixedFeatureSlaney08GenreBasicSm',feature.my_params);
wolffd@0 62
wolffd@0 63 % save to features data field
wolffd@0 64 data.stob = stob;
wolffd@0 65 data.tags = genrebasicsm;
wolffd@0 66
wolffd@0 67 % prepare field for final features
wolffd@0 68 data.final.vector = [];
wolffd@0 69 data.final.vector_info = struct();
wolffd@0 70 data.final.dim = 0;
wolffd@0 71
wolffd@0 72 % save info data
wolffd@0 73 data.info.type = 'MTTMixedFeatureStober11Slaney08GenreBasicSm';
wolffd@0 74 data.info.owner_id = clip.id;
wolffd@0 75 data.info.creatorrev = feature.my_revision;
wolffd@0 76
wolffd@0 77 % save parameters
wolffd@0 78 data.info.params = feature.my_params;
wolffd@0 79 end
wolffd@0 80
wolffd@0 81 function define_global_transform(features)
wolffd@0 82 % calculate and set normalization factors from the group of
wolffd@0 83 % input features. These features will be set for the full database
wolffd@0 84
wolffd@0 85 if numel(features) == 1
wolffd@0 86 error ('Insert feature array for this method');
wolffd@0 87 end
wolffd@0 88
wolffd@0 89 % ---
wolffd@0 90 % We collect all the relevant stob
wolffd@0 91 % features and get the transform on this basis.
wolffd@0 92 % ---
wolffd@0 93 for i = 1:numel(features)
wolffd@0 94 stob(i) = features(i).data.stob;
wolffd@0 95 end
wolffd@0 96
wolffd@0 97 % call the features own transsform function
wolffd@0 98 stob.define_global_transform();
wolffd@0 99
wolffd@0 100 % ---
wolffd@0 101 % We collect all the relevant genretag
wolffd@0 102 % features and get the transform on this basis.
wolffd@0 103 % ---
wolffd@0 104 for i = 1:numel(features)
wolffd@0 105 genrebasicsm(i) = features(i).data.tags;
wolffd@0 106 end
wolffd@0 107
wolffd@0 108 % call the features own transsform function
wolffd@0 109 genrebasicsm.define_global_transform();
wolffd@0 110
wolffd@0 111 % ---
wolffd@0 112 % set common feature values for mixed features
wolffd@0 113 % ---
wolffd@0 114 features(1).my_db.set_common([1]); %trivial common
wolffd@0 115 end
wolffd@0 116
wolffd@0 117
wolffd@0 118 function finalise(feature)
wolffd@0 119 % applies a final transformation and collects the
wolffd@0 120 % information of this feature within a single vector
wolffd@0 121 % see info for types in specific dimensions
wolffd@0 122
wolffd@0 123 for i = 1:numel(feature)
wolffd@0 124
wolffd@0 125 % check for neccesary parameters
wolffd@0 126 if isempty(feature(i).my_db.commondb)
wolffd@0 127
wolffd@0 128 error('Define the global transformation first');
wolffd@0 129 end
wolffd@0 130
wolffd@0 131 % ---
wolffd@0 132 % finalise audio feature and get vector
wolffd@0 133 % ---
wolffd@0 134 stob = feature(i).data.stob;
wolffd@0 135 stob.finalise();
wolffd@0 136
wolffd@0 137 % finalise tag features
wolffd@0 138 genrebasicsm = feature(i).data.tags;
wolffd@0 139 genrebasicsm.finalise();
wolffd@0 140
wolffd@0 141 % ---
wolffd@0 142 % final data assembly
wolffd@0 143 % ---
wolffd@0 144
wolffd@0 145 % concatenate vectors
wolffd@0 146 feature(i).data.final.vector = ...
wolffd@0 147 [stob.vector() ; genrebasicsm.vector()];
wolffd@0 148
wolffd@0 149 % add feature dimensions
wolffd@0 150 feature(i).data.final.dim = stob.dim + genrebasicsm.dim;
wolffd@0 151
wolffd@0 152 % concatenate labels
wolffd@0 153 feature(i).data.final.vector_info.labels = ...
wolffd@0 154 {stob.data.final.vector_info.labels{:}, ...
wolffd@0 155 genrebasicsm.data.final.vector_info.labels{:}};
wolffd@0 156 end
wolffd@0 157 end
wolffd@0 158
wolffd@0 159 % ---
wolffd@0 160 % destructor: do we really want to remove this
wolffd@0 161 % from the database? No, but
wolffd@0 162 % TODO: create marker for unused objects in db, and a cleanup
wolffd@0 163 % function
wolffd@0 164 % ---
wolffd@0 165 function delete(feature)
wolffd@0 166
wolffd@0 167 end
wolffd@0 168
wolffd@0 169 function visualise(feature)
wolffd@0 170 % ---
wolffd@0 171 % plots the different data types collected in this feature
wolffd@0 172 % ---
wolffd@0 173 for i = 1:numel(feature)
wolffd@0 174 clip = MTTClip(feature(i).owner_id());
wolffd@0 175 end
wolffd@0 176 end
wolffd@0 177 end
wolffd@0 178 end