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

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