annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirspread.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 = mirspread(orig,varargin)
Daniel@0 2 % S = mirspread(x) calculates the spread of x, which can be either:
Daniel@0 3 % - a spectrum (spectral spread),
Daniel@0 4 % - an envelope (temporal spread), or
Daniel@0 5 % - any histogram.
Daniel@0 6
Daniel@0 7
Daniel@0 8 varargout = mirfunction(@mirspread,orig,varargin,nargout,struct,@init,@main);
Daniel@0 9
Daniel@0 10
Daniel@0 11 function [x type] = init(x,option)
Daniel@0 12 if not(isamir(x,'mirdata')) || isamir(x,'miraudio')
Daniel@0 13 x = mirspectrum(x);
Daniel@0 14 end
Daniel@0 15 type = 'mirscalar';
Daniel@0 16
Daniel@0 17
Daniel@0 18 function S = main(x,option,postoption)
Daniel@0 19 if iscell(x)
Daniel@0 20 x = x{1};
Daniel@0 21 end
Daniel@0 22 y = peaksegments(@spread,get(x,'Data'),...
Daniel@0 23 get(x,'Pos'),...
Daniel@0 24 get(mircentroid(x),'Data'));
Daniel@0 25 if isa(x,'mirspectrum')
Daniel@0 26 t = 'Spectral spread';
Daniel@0 27 elseif isa(x,'mirenvelope')
Daniel@0 28 t = 'Temporal spread';
Daniel@0 29 else
Daniel@0 30 t = ['Spread of ',get(x,'Title')];
Daniel@0 31 end
Daniel@0 32 S = mirscalar(x,'Data',y,'Title',t);
Daniel@0 33
Daniel@0 34
Daniel@0 35 function s = spread(d,p,c)
Daniel@0 36 s = sqrt( sum((p-c).^2.*d) ) ./ sum(d);