comparison core/magnatagatune/MTTAudioFeatureRAW.m @ 0:e9a9cd732c1e tip

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