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 AudioFeatureRAW < MTTAudioFeature & handle wolffd@0: wolffd@0: wolffd@0: properties(Constant = true) wolffd@0: wolffd@0: end wolffd@0: wolffd@0: properties wolffd@0: % --- wolffd@0: % Set default parameters wolffd@0: % --- wolffd@0: my_params = struct([]); 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 = AudioFeatureRAW(varargin) wolffd@0: wolffd@0: feature = feature@MTTAudioFeature(varargin{:}); wolffd@0: wolffd@0: end wolffd@0: wolffd@0: function [a1, a2, a3] = visualise(feature) wolffd@0: % --- wolffd@0: % plots the different data types collected in this feature wolffd@0: % --- wolffd@0: for i = 1:numel(feature) wolffd@0: clip = feature(i).data.info.owner; wolffd@0: wolffd@0: % --- wolffd@0: % labels for chroma data wolffd@0: % --- wolffd@0: chroma_labels = {'c', 'c#', 'd','d#', 'e', 'f','f#', 'g','g#', 'a','a#', 'b'}; wolffd@0: mode_labels = {'minor', 'major'}; wolffd@0: wolffd@0: % hange labels to reflect detected mode wolffd@0: chroma_labels{feature(i).data.key + 1} = ... wolffd@0: sprintf('(%s) %s',mode_labels{feature(i).data.mode + 1}, chroma_labels{feature(i).data.key + 1}); wolffd@0: wolffd@0: wolffd@0: secs = [feature(i).data.sections_start; feature(i).data.sections_duration]; wolffd@0: wolffd@0: h = figure; wolffd@0: wolffd@0: % number of subplots wolffd@0: n = 3; wolffd@0: wolffd@0: % --- wolffd@0: % chroma feature display wolffd@0: % --- wolffd@0: subplot(n,1,1); wolffd@0: wolffd@0: % get segment times and fix for same lengths for all plots wolffd@0: % --- wolffd@0: % NOTE: Last segment will appear longer wolffd@0: % --- wolffd@0: segments = [feature(i).data.segments_start]; wolffd@0: segments(end) = feature(i).data.duration; wolffd@0: wolffd@0: % display chroma vectors wolffd@0: uimagesc(segments, 0:11, [feature(i).data.segments_pitches]); wolffd@0: wolffd@0: set(gca,'YTick',[0:11], 'YTickLabel', chroma_labels); wolffd@0: wolffd@0: axis xy wolffd@0: colormap(hot) wolffd@0: %colorbar; wolffd@0: ylabel('chroma class'); wolffd@0: title(sprintf('clip %d: %s by %s, chromagram', ... wolffd@0: clip.id, clip.title(),clip.artist())); wolffd@0: wolffd@0: % added sections wolffd@0: axis([0 feature(i).data.duration -1 11.5]); wolffd@0: hl = line([secs(1,:); sum(secs,1)],ones(2, size(secs,2)) * -0.8); wolffd@0: set(hl,'LineWidth',6); wolffd@0: wolffd@0: a1 = gca; wolffd@0: wolffd@0: % --- wolffd@0: % mfcc feature display wolffd@0: % wolffd@0: % NOTE: the first position of timbre is reduced in energy, wolffd@0: % as this seems to introduce some corruption in lots of data wolffd@0: % --- wolffd@0: timbre = feature(i).data.segments_timbre(:,1); wolffd@0: timbre = timbre/ max(max(abs(timbre))) * ... wolffd@0: mean( mean( abs( feature(i).data.segments_timbre(:,2:min(end,5))))); wolffd@0: wolffd@0: subplot(n,1,2); wolffd@0: uimagesc(segments, 0:11, [timbre feature(i).data.segments_timbre(:,2:end)]); wolffd@0: wolffd@0: axis xy wolffd@0: %colorbar; wolffd@0: xlabel('time[s]'); wolffd@0: ylabel('mfcc coeff'); wolffd@0: title(sprintf('mfcc timbre features')); wolffd@0: wolffd@0: a2 = gca; wolffd@0: wolffd@0: % --- wolffd@0: % beats and sections wolffd@0: % --- wolffd@0: wolffd@0: subplot(n,1,3); wolffd@0: axis([0 feature(i).data.duration -0.6 1.2]); wolffd@0: wolffd@0: hl = line([0 feature(i).data.duration],[0 0]); wolffd@0: set(hl, 'Color','g'); wolffd@0: wolffd@0: a3 = gca; wolffd@0: wolffd@0: if ~isfield(feature.data,'bars'); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: beats = feature.data.beats; wolffd@0: bars = feature.data.bars; wolffd@0: tatums = feature.data.tatums; wolffd@0: % tatums wolffd@0: hl = line([tatums(1,:); tatums(1,:)],[ones(1, size(tatums,2)) * -0.2; max(-0.1,tatums(2,:))]); wolffd@0: set(hl,'LineWidth',1); wolffd@0: set(hl, 'Color','k'); wolffd@0: wolffd@0: % beats wolffd@0: hl = line([beats(1,:); beats(1,:)],[ones(1, size(beats,2)) * -0.4; max(-0.1,beats(2,:))]); wolffd@0: set(hl,'LineWidth',2); wolffd@0: set(hl, 'Color','b'); wolffd@0: wolffd@0: % bars wolffd@0: hl = line([bars(1,:); bars(1,:)],[ones(1, size(bars,2)) * -0.5; max(-0.1,bars(2,:))]); wolffd@0: set(hl,'LineWidth',4); wolffd@0: set(hl, 'Color','r'); wolffd@0: wolffd@0: % sections wolffd@0: hl = line([secs(1,:); sum(secs,1)],ones(2, size(secs,2)) * -0.5); wolffd@0: set(hl,'LineWidth',6); wolffd@0: wolffd@0: ylabel('confidence'); wolffd@0: title(sprintf('rhythmic features @%3.1f BPM, %d/4 meter',... wolffd@0: feature(i).data.tempo, feature(i).data.timeSignature)); wolffd@0: wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: end