wolffd@0: % -- wolffd@0: % This class loads and hanles the aufdio features included with the MTT wolffd@0: % Library wolffd@0: % --- wolffd@0: wolffd@0: wolffd@0: classdef MTTAudioFeatureRAW < AudioFeatureRAW & handle wolffd@0: wolffd@0: wolffd@0: properties(Constant = true) wolffd@0: wolffd@0: my_revision = str2double(substr('$Rev: 2284 $', 5, -1)); wolffd@0: end wolffd@0: wolffd@0: properties wolffd@0: % --- wolffd@0: % Set default parameters wolffd@0: % --- wolffd@0: wolffd@0: end 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 = MTTAudioFeatureRAW(varargin) wolffd@0: wolffd@0: feature = feature@AudioFeatureRAW(varargin{:}); wolffd@0: wolffd@0: end wolffd@0: wolffd@0: % --- wolffd@0: % load feature data from xml file wolffd@0: % --- wolffd@0: function data = extract(feature, clip) wolffd@0: % load feature data by parsing xml wolffd@0: wolffd@0: global globalvars; wolffd@0: wolffd@0: % fprintf('parsing features for clip %d \n',clip.id()); wolffd@0: wolffd@0: % parse feature wolffd@0: data = xml_parse_mtt(clip.featurefile_full()); wolffd@0: wolffd@0: % precombine the segmentst information for better wolffd@0: % interoperability with MSD data later wolffd@0: wolffd@0: data.segments_pitches = [data.segments(:).pitches]; wolffd@0: data.segments_timbre = [data.segments(:).timbre]; wolffd@0: wolffd@0: data.segments_duration = [data.segments(:).duration]; wolffd@0: data.segments_start = [data.segments(:).start]; wolffd@0: wolffd@0: data.sections_start = [data.sections(:).start]; wolffd@0: data.sections_duration = [data.sections(:).duration]; wolffd@0: wolffd@0: data.segments_duration = [data.segments(:).duration]; wolffd@0: wolffd@0: data.segments_loudness_max_time = [data.segments(:).loudness_max_time]; wolffd@0: data.segments_loudness_max = [data.segments(:).loudness_max]; wolffd@0: data.segments_loudness = [data.segments(:).loudness]; wolffd@0: wolffd@0: % --- wolffd@0: % TODO: feature.data.bars wolffd@0: % --- wolffd@0: [data.bars, data.beats, data.tatums] = MTTAudioFeatureRAW.infer_bar_times(data.bars); wolffd@0: wolffd@0: % save info data wolffd@0: data.info.type = 'MTTAudioFeatureRAW'; wolffd@0: data.info.owner = clip; wolffd@0: data.info.owner_id = clip.id; wolffd@0: data.info.creatorrev = feature.my_revision; wolffd@0: wolffd@0: data.info.params = feature.my_params; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: methods(Static) wolffd@0: function [bars, beats, tatums] = infer_bar_times(bar) wolffd@0: % [bars, beats, tatums] = infer_bar_times(feature) wolffd@0: % wolffd@0: % extract bar and beat starting times from tatums wolffd@0: beats = []; wolffd@0: bars = []; wolffd@0: tatums = []; wolffd@0: wolffd@0: % bars wolffd@0: for i = 1:numel(bar) wolffd@0: % beats wolffd@0: for j = 1:numel(bar(i).beat) wolffd@0: % tatums wolffd@0: for k = 1:numel(bar(i).beat(j).tatum) wolffd@0: tatum = bar(i).beat(j).tatum(k); wolffd@0: wolffd@0: % collect tatums and confidence wolffd@0: tatums(1:2,end+1) = [tatum.time,tatum.confidence]; wolffd@0: wolffd@0: wolffd@0: % --- wolffd@0: % save beat if this is the first tatum in it wolffd@0: % --- wolffd@0: if k == 1 wolffd@0: beats(1:2,end+1) = [tatum.time,... wolffd@0: bar(i).beat(j).confidence]; wolffd@0: wolffd@0: % --- wolffd@0: % save bar if this is the first tatum in it wolffd@0: % --- wolffd@0: if j == 1 wolffd@0: bars(1:2,end+1) = [tatum.time,... wolffd@0: bar(i).confidence]; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % end function wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: end