annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirattacktime.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 = mirattacktime(orig,varargin)
Daniel@0 2 % a = mirattacktime(x) returns the duration (in s.) of each note attack.
Daniel@0 3 % Optional arguments:
Daniel@0 4 % a = mirattacktime(x,l) specifies whether to consider the duration in s.
Daniel@0 5 % (l='Lin') or the logarithm of that duration (l='Log') following the
Daniel@0 6 % approach proposed in Krimphoff et al. (1994).
Daniel@0 7 % Default value: l='Lin'.
Daniel@0 8 %
Daniel@0 9 % Krimphoff, J., McAdams, S. & Winsberg, S. (1994), Caractérisation du
Daniel@0 10 % timbre des sons complexes. II : Analyses acoustiques et quantification
Daniel@0 11 % psychophysique. Journal de Physique, 4(C5), 625-628.
Daniel@0 12
Daniel@0 13 scale.type = 'String';
Daniel@0 14 scale.choice = {'Lin','Log'};
Daniel@0 15 scale.default = 'Lin';
Daniel@0 16 option.scale = scale;
Daniel@0 17
Daniel@0 18 specif.option = option;
Daniel@0 19
Daniel@0 20 varargout = mirfunction(@mirattacktime,orig,varargin,nargout,specif,@init,@main);
Daniel@0 21
Daniel@0 22
Daniel@0 23 function [o type] = init(x,option)
Daniel@0 24 o = mironsets(x,'Attack');
Daniel@0 25 type = mirtype(x);
Daniel@0 26
Daniel@0 27
Daniel@0 28 function at = main(o,option,postoption)
Daniel@0 29 if iscell(o)
Daniel@0 30 o = o{1};
Daniel@0 31 end
Daniel@0 32 po = get(o,'PeakPosUnit');
Daniel@0 33 pa = get(o,'AttackPosUnit');
Daniel@0 34 at = mircompute(@algo,po,pa,option.scale);
Daniel@0 35 fp = mircompute(@frampose,pa,po);
Daniel@0 36 at = mirscalar(o,'Data',at,'FramePos',fp,'Title','Attack Time');
Daniel@0 37 at = {at,o};
Daniel@0 38
Daniel@0 39
Daniel@0 40 function fp = frampose(pa,po)
Daniel@0 41 pa = sort(pa{1});
Daniel@0 42 po = sort(po{1});
Daniel@0 43 fp = [pa';po'];
Daniel@0 44
Daniel@0 45
Daniel@0 46 function at = algo(po,pa,sc)
Daniel@0 47 po = sort(po{1});
Daniel@0 48 pa = sort(pa{1});
Daniel@0 49 at = po-pa;
Daniel@0 50 if strcmpi(sc,'Log')
Daniel@0 51 at = log10(at);
Daniel@0 52 end
Daniel@0 53 at = at';