annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirbrightness.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function varargout = mirbrightness(x,varargin)
wolffd@0 2 % b = mirbrightness(s) calculates the spectral brightness, i.e. the amount
wolffd@0 3 % of spectral energy corresponding to frequencies higher than a given
wolffd@0 4 % cut-off threshold.
wolffd@0 5 % Optional arguments:
wolffd@0 6 % b = mirbrightness(s,'CutOff',f) specifies the frequency cut-off
wolffd@0 7 % threshold in Hz.
wolffd@0 8 % Default value: f = 1500 Hz.
wolffd@0 9 %
wolffd@0 10 % Typical values for the frequency cut-off threshold:
wolffd@0 11 % 3000 Hz in Juslin 2000, p. 1802.
wolffd@0 12 % 1000 Hz and 500 Hz in Laukka, Juslin and Bresin 2005.
wolffd@0 13 %
wolffd@0 14 % Juslin, P. N. (2000). Cue utilization in communication of emotion in
wolffd@0 15 % music performance: relating performance to perception. Journal of
wolffd@0 16 % Experimental Psychology: Human Perception and Performance, 26(6), 1797?813.
wolffd@0 17 % Laukka, P., Juslin, P. N., and Bresin, R. (2005). A dimensional approach
wolffd@0 18 % to vocal expression of emotion. Cognition and Emotion, 19, 633?653.
wolffd@0 19
wolffd@0 20
wolffd@0 21 cutoff.key = 'CutOff';
wolffd@0 22 cutoff.type = 'Integer';
wolffd@0 23 cutoff.default = 1500;
wolffd@0 24 option.cutoff = cutoff;
wolffd@0 25
wolffd@0 26 specif.option = option;
wolffd@0 27 specif.defaultframelength = .05;
wolffd@0 28 specif.defaultframehop = .5;
wolffd@0 29
wolffd@0 30
wolffd@0 31 varargout = mirfunction(@mirbrightness,x,varargin,nargout,specif,@init,@main);
wolffd@0 32
wolffd@0 33
wolffd@0 34 function [x type] = init(x,option)
wolffd@0 35 if not(isamir(x,'mirspectrum'))
wolffd@0 36 x = mirspectrum(x);
wolffd@0 37 end
wolffd@0 38 type = 'mirscalar';
wolffd@0 39
wolffd@0 40
wolffd@0 41 function b = main(s,option,postoption)
wolffd@0 42 if iscell(s)
wolffd@0 43 s = s{1};
wolffd@0 44 end
wolffd@0 45 m = get(s,'Magnitude');
wolffd@0 46 f = get(s,'Frequency');
wolffd@0 47 w = warning('query','MATLAB:divideByZero');
wolffd@0 48 warning('off','MATLAB:divideByZero');
wolffd@0 49 v = mircompute(@algo,m,f,option.cutoff);
wolffd@0 50 warning(w.state,'MATLAB:divideByZero');
wolffd@0 51 b = mirscalar(s,'Data',v,'Title','Brightness');
wolffd@0 52
wolffd@0 53
wolffd@0 54 function v = algo(m,f,k)
wolffd@0 55 if not(any(max(f)>k))
wolffd@0 56 warning('WARNING in MIRBRIGHTNESS: Frequency range of the spectrum too low for the estimation of brightness.');
wolffd@0 57 end
wolffd@0 58 sm = sum(m);
wolffd@0 59 v = sum(m(f(:,1,1) > k,:,:)) ./ sm;