comparison core/magnatagatune/AudioFeatureRAW.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 AudioFeatureRAW < MTTAudioFeature & handle
8
9
10 properties(Constant = true)
11
12 end
13
14 properties
15 % ---
16 % Set default parameters
17 % ---
18 my_params = struct([]);
19
20 end
21 % ---
22 % member functions
23 % ---
24 methods
25
26 % ---
27 % constructor: pointer to feature in database
28 % ---
29 function feature = AudioFeatureRAW(varargin)
30
31 feature = feature@MTTAudioFeature(varargin{:});
32
33 end
34
35 function [a1, a2, a3] = visualise(feature)
36 % ---
37 % plots the different data types collected in this feature
38 % ---
39 for i = 1:numel(feature)
40 clip = feature(i).data.info.owner;
41
42 % ---
43 % labels for chroma data
44 % ---
45 chroma_labels = {'c', 'c#', 'd','d#', 'e', 'f','f#', 'g','g#', 'a','a#', 'b'};
46 mode_labels = {'minor', 'major'};
47
48 % hange labels to reflect detected mode
49 chroma_labels{feature(i).data.key + 1} = ...
50 sprintf('(%s) %s',mode_labels{feature(i).data.mode + 1}, chroma_labels{feature(i).data.key + 1});
51
52
53 secs = [feature(i).data.sections_start; feature(i).data.sections_duration];
54
55 h = figure;
56
57 % number of subplots
58 n = 3;
59
60 % ---
61 % chroma feature display
62 % ---
63 subplot(n,1,1);
64
65 % get segment times and fix for same lengths for all plots
66 % ---
67 % NOTE: Last segment will appear longer
68 % ---
69 segments = [feature(i).data.segments_start];
70 segments(end) = feature(i).data.duration;
71
72 % display chroma vectors
73 uimagesc(segments, 0:11, [feature(i).data.segments_pitches]);
74
75 set(gca,'YTick',[0:11], 'YTickLabel', chroma_labels);
76
77 axis xy
78 colormap(hot)
79 %colorbar;
80 ylabel('chroma class');
81 title(sprintf('clip %d: %s by %s, chromagram', ...
82 clip.id, clip.title(),clip.artist()));
83
84 % added sections
85 axis([0 feature(i).data.duration -1 11.5]);
86 hl = line([secs(1,:); sum(secs,1)],ones(2, size(secs,2)) * -0.8);
87 set(hl,'LineWidth',6);
88
89 a1 = gca;
90
91 % ---
92 % mfcc feature display
93 %
94 % NOTE: the first position of timbre is reduced in energy,
95 % as this seems to introduce some corruption in lots of data
96 % ---
97 timbre = feature(i).data.segments_timbre(:,1);
98 timbre = timbre/ max(max(abs(timbre))) * ...
99 mean( mean( abs( feature(i).data.segments_timbre(:,2:min(end,5)))));
100
101 subplot(n,1,2);
102 uimagesc(segments, 0:11, [timbre feature(i).data.segments_timbre(:,2:end)]);
103
104 axis xy
105 %colorbar;
106 xlabel('time[s]');
107 ylabel('mfcc coeff');
108 title(sprintf('mfcc timbre features'));
109
110 a2 = gca;
111
112 % ---
113 % beats and sections
114 % ---
115
116 subplot(n,1,3);
117 axis([0 feature(i).data.duration -0.6 1.2]);
118
119 hl = line([0 feature(i).data.duration],[0 0]);
120 set(hl, 'Color','g');
121
122 a3 = gca;
123
124 if ~isfield(feature.data,'bars');
125 return;
126 end
127
128 beats = feature.data.beats;
129 bars = feature.data.bars;
130 tatums = feature.data.tatums;
131 % tatums
132 hl = line([tatums(1,:); tatums(1,:)],[ones(1, size(tatums,2)) * -0.2; max(-0.1,tatums(2,:))]);
133 set(hl,'LineWidth',1);
134 set(hl, 'Color','k');
135
136 % beats
137 hl = line([beats(1,:); beats(1,:)],[ones(1, size(beats,2)) * -0.4; max(-0.1,beats(2,:))]);
138 set(hl,'LineWidth',2);
139 set(hl, 'Color','b');
140
141 % bars
142 hl = line([bars(1,:); bars(1,:)],[ones(1, size(bars,2)) * -0.5; max(-0.1,bars(2,:))]);
143 set(hl,'LineWidth',4);
144 set(hl, 'Color','r');
145
146 % sections
147 hl = line([secs(1,:); sum(secs,1)],ones(2, size(secs,2)) * -0.5);
148 set(hl,'LineWidth',6);
149
150 ylabel('confidence');
151 title(sprintf('rhythmic features @%3.1f BPM, %d/4 meter',...
152 feature(i).data.tempo, feature(i).data.timeSignature));
153
154 end
155 end
156 end
157
158 end