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