wolffd@0
|
1 % --
|
wolffd@0
|
2 % This class loads and hanles the aufdio features included with the MTT
|
wolffd@0
|
3 % Library
|
wolffd@0
|
4 % ---
|
wolffd@0
|
5
|
wolffd@0
|
6
|
wolffd@0
|
7 classdef MTTAudioFeatureRAW < AudioFeatureRAW & handle
|
wolffd@0
|
8
|
wolffd@0
|
9
|
wolffd@0
|
10 properties(Constant = true)
|
wolffd@0
|
11
|
wolffd@0
|
12 my_revision = str2double(substr('$Rev: 2284 $', 5, -1));
|
wolffd@0
|
13 end
|
wolffd@0
|
14
|
wolffd@0
|
15 properties
|
wolffd@0
|
16 % ---
|
wolffd@0
|
17 % Set default parameters
|
wolffd@0
|
18 % ---
|
wolffd@0
|
19
|
wolffd@0
|
20 end
|
wolffd@0
|
21 % ---
|
wolffd@0
|
22 % member functions
|
wolffd@0
|
23 % ---
|
wolffd@0
|
24 methods
|
wolffd@0
|
25
|
wolffd@0
|
26 % ---
|
wolffd@0
|
27 % constructor: pointer to feature in database
|
wolffd@0
|
28 % ---
|
wolffd@0
|
29 function feature = MTTAudioFeatureRAW(varargin)
|
wolffd@0
|
30
|
wolffd@0
|
31 feature = feature@AudioFeatureRAW(varargin{:});
|
wolffd@0
|
32
|
wolffd@0
|
33 end
|
wolffd@0
|
34
|
wolffd@0
|
35 % ---
|
wolffd@0
|
36 % load feature data from xml file
|
wolffd@0
|
37 % ---
|
wolffd@0
|
38 function data = extract(feature, clip)
|
wolffd@0
|
39 % load feature data by parsing xml
|
wolffd@0
|
40
|
wolffd@0
|
41 global globalvars;
|
wolffd@0
|
42
|
wolffd@0
|
43 % fprintf('parsing features for clip %d \n',clip.id());
|
wolffd@0
|
44
|
wolffd@0
|
45 % parse feature
|
wolffd@0
|
46 data = xml_parse_mtt(clip.featurefile_full());
|
wolffd@0
|
47
|
wolffd@0
|
48 % precombine the segmentst information for better
|
wolffd@0
|
49 % interoperability with MSD data later
|
wolffd@0
|
50
|
wolffd@0
|
51 data.segments_pitches = [data.segments(:).pitches];
|
wolffd@0
|
52 data.segments_timbre = [data.segments(:).timbre];
|
wolffd@0
|
53
|
wolffd@0
|
54 data.segments_duration = [data.segments(:).duration];
|
wolffd@0
|
55 data.segments_start = [data.segments(:).start];
|
wolffd@0
|
56
|
wolffd@0
|
57 data.sections_start = [data.sections(:).start];
|
wolffd@0
|
58 data.sections_duration = [data.sections(:).duration];
|
wolffd@0
|
59
|
wolffd@0
|
60 data.segments_duration = [data.segments(:).duration];
|
wolffd@0
|
61
|
wolffd@0
|
62 data.segments_loudness_max_time = [data.segments(:).loudness_max_time];
|
wolffd@0
|
63 data.segments_loudness_max = [data.segments(:).loudness_max];
|
wolffd@0
|
64 data.segments_loudness = [data.segments(:).loudness];
|
wolffd@0
|
65
|
wolffd@0
|
66 % ---
|
wolffd@0
|
67 % TODO: feature.data.bars
|
wolffd@0
|
68 % ---
|
wolffd@0
|
69 [data.bars, data.beats, data.tatums] = MTTAudioFeatureRAW.infer_bar_times(data.bars);
|
wolffd@0
|
70
|
wolffd@0
|
71 % save info data
|
wolffd@0
|
72 data.info.type = 'MTTAudioFeatureRAW';
|
wolffd@0
|
73 data.info.owner = clip;
|
wolffd@0
|
74 data.info.owner_id = clip.id;
|
wolffd@0
|
75 data.info.creatorrev = feature.my_revision;
|
wolffd@0
|
76
|
wolffd@0
|
77 data.info.params = feature.my_params;
|
wolffd@0
|
78 end
|
wolffd@0
|
79 end
|
wolffd@0
|
80
|
wolffd@0
|
81 methods(Static)
|
wolffd@0
|
82 function [bars, beats, tatums] = infer_bar_times(bar)
|
wolffd@0
|
83 % [bars, beats, tatums] = infer_bar_times(feature)
|
wolffd@0
|
84 %
|
wolffd@0
|
85 % extract bar and beat starting times from tatums
|
wolffd@0
|
86 beats = [];
|
wolffd@0
|
87 bars = [];
|
wolffd@0
|
88 tatums = [];
|
wolffd@0
|
89
|
wolffd@0
|
90 % bars
|
wolffd@0
|
91 for i = 1:numel(bar)
|
wolffd@0
|
92 % beats
|
wolffd@0
|
93 for j = 1:numel(bar(i).beat)
|
wolffd@0
|
94 % tatums
|
wolffd@0
|
95 for k = 1:numel(bar(i).beat(j).tatum)
|
wolffd@0
|
96 tatum = bar(i).beat(j).tatum(k);
|
wolffd@0
|
97
|
wolffd@0
|
98 % collect tatums and confidence
|
wolffd@0
|
99 tatums(1:2,end+1) = [tatum.time,tatum.confidence];
|
wolffd@0
|
100
|
wolffd@0
|
101
|
wolffd@0
|
102 % ---
|
wolffd@0
|
103 % save beat if this is the first tatum in it
|
wolffd@0
|
104 % ---
|
wolffd@0
|
105 if k == 1
|
wolffd@0
|
106 beats(1:2,end+1) = [tatum.time,...
|
wolffd@0
|
107 bar(i).beat(j).confidence];
|
wolffd@0
|
108
|
wolffd@0
|
109 % ---
|
wolffd@0
|
110 % save bar if this is the first tatum in it
|
wolffd@0
|
111 % ---
|
wolffd@0
|
112 if j == 1
|
wolffd@0
|
113 bars(1:2,end+1) = [tatum.time,...
|
wolffd@0
|
114 bar(i).confidence];
|
wolffd@0
|
115 end
|
wolffd@0
|
116 end
|
wolffd@0
|
117
|
wolffd@0
|
118
|
wolffd@0
|
119 end
|
wolffd@0
|
120 end
|
wolffd@0
|
121 end
|
wolffd@0
|
122
|
wolffd@0
|
123 % end function
|
wolffd@0
|
124 end
|
wolffd@0
|
125 end
|
wolffd@0
|
126
|
wolffd@0
|
127 end |