annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirkeysom/mirkeysom.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 = mirkeysom(orig,varargin)
Daniel@0 2 % ks = mirkeysom(x) projects a chromagram on a self-organizing map.
Daniel@0 3 % Creates a pseudocolor map showing the projection of chromagram onto a
Daniel@0 4 % self-organizing map trained with the Krumhansl-Kessler profiles (modified
Daniel@0 5 % for chromagrams). Colors correspond to Pearson correlation values.
Daniel@0 6 % References:
Daniel@0 7 % Toiviainen, P. & Krumhansl, C. L. (2003). Measuring and modeling
Daniel@0 8 % real-time responses to music: the dynamics of tonality induction.
Daniel@0 9 % Perception, 32(6), 741-766.
Daniel@0 10 % Krumhansl, C. L., & Toiviainen, P. (2001) Tonal cognition.
Daniel@0 11 % In R. J. Zatorre & I. Peretz (Eds.), The Biological Foundations of Music.
Daniel@0 12 % Annals of the New York Academy of Sciences.
Daniel@0 13
Daniel@0 14 % filename.key = 'File';
Daniel@0 15 % filename.type = 'String';
Daniel@0 16 % filename.default = 0;
Daniel@0 17 % option.filename = filename;
Daniel@0 18
Daniel@0 19 specif.option = struct;
Daniel@0 20 specif.defaultframelength = 1;
Daniel@0 21 specif.defaultframehop = .5;
Daniel@0 22
Daniel@0 23 varargout = mirfunction(@mirkeysom,orig,varargin,nargout,specif,@init,@main);
Daniel@0 24
Daniel@0 25
Daniel@0 26 function [c type] = init(orig,option)
Daniel@0 27 c = mirchromagram(orig,'Normal');
Daniel@0 28 type = 'mirkeysom';
Daniel@0 29
Daniel@0 30
Daniel@0 31 function s = main(c,option,postoption)
Daniel@0 32 if iscell(c)
Daniel@0 33 c = c{1};
Daniel@0 34 end
Daniel@0 35 load keysomaudiodata;
Daniel@0 36 m = get(c,'Magnitude');
Daniel@0 37 disp('Projecting the chromagram to a self-organizing map...')
Daniel@0 38 z = cell(1,length(m));
Daniel@0 39 p = cell(1,length(m));
Daniel@0 40 for i = 1:length(m)
Daniel@0 41 mi = m{i};
Daniel@0 42 if not(iscell(mi))
Daniel@0 43 mi = {mi};
Daniel@0 44 end
Daniel@0 45 zi = cell(1,length(mi));
Daniel@0 46 pi = cell(1,length(mi));
Daniel@0 47 for j = 1:length(mi)
Daniel@0 48 mj = mi{j};
Daniel@0 49 zj = zeros(24,size(mj,2),size(mj,3),36);
Daniel@0 50 pi{j} = zeros(24,size(mj,2),size(mj,3),36);
Daniel@0 51 for k = 1:size(mj,2)
Daniel@0 52 for l = 1:size(mj,3)
Daniel@0 53 for kk=1:36
Daniel@0 54 for ll=1:24
Daniel@0 55 tmp = corrcoef([mj(:,k,l) somw(:,kk,ll)]);
Daniel@0 56 zj(ll,k,l,kk) = tmp(1,2);
Daniel@0 57 end
Daniel@0 58 end
Daniel@0 59 end
Daniel@0 60 end
Daniel@0 61 zi{j} = zj;
Daniel@0 62 end
Daniel@0 63 z{i} = zi;
Daniel@0 64 p{i} = pi;
Daniel@0 65 end
Daniel@0 66 s = class(struct,'mirkeysom',mirdata(c));
Daniel@0 67 s = purgedata(s);
Daniel@0 68 s = set(s,'Title','Key SOM','Abs','','Ord','','Weight',z,'Pos',p);
Daniel@0 69 %if option.filename
Daniel@0 70 % mov = display(s,option.filename);
Daniel@0 71 %else
Daniel@0 72 % mov = display(s);
Daniel@0 73 %end
Daniel@0 74 %s = {s,mov};