Daniel@0: function varargout = mirkeysom(orig,varargin) Daniel@0: % ks = mirkeysom(x) projects a chromagram on a self-organizing map. Daniel@0: % Creates a pseudocolor map showing the projection of chromagram onto a Daniel@0: % self-organizing map trained with the Krumhansl-Kessler profiles (modified Daniel@0: % for chromagrams). Colors correspond to Pearson correlation values. Daniel@0: % References: Daniel@0: % Toiviainen, P. & Krumhansl, C. L. (2003). Measuring and modeling Daniel@0: % real-time responses to music: the dynamics of tonality induction. Daniel@0: % Perception, 32(6), 741-766. Daniel@0: % Krumhansl, C. L., & Toiviainen, P. (2001) Tonal cognition. Daniel@0: % In R. J. Zatorre & I. Peretz (Eds.), The Biological Foundations of Music. Daniel@0: % Annals of the New York Academy of Sciences. Daniel@0: Daniel@0: % filename.key = 'File'; Daniel@0: % filename.type = 'String'; Daniel@0: % filename.default = 0; Daniel@0: % option.filename = filename; Daniel@0: Daniel@0: specif.option = struct; Daniel@0: specif.defaultframelength = 1; Daniel@0: specif.defaultframehop = .5; Daniel@0: Daniel@0: varargout = mirfunction(@mirkeysom,orig,varargin,nargout,specif,@init,@main); Daniel@0: Daniel@0: Daniel@0: function [c type] = init(orig,option) Daniel@0: c = mirchromagram(orig,'Normal'); Daniel@0: type = 'mirkeysom'; Daniel@0: Daniel@0: Daniel@0: function s = main(c,option,postoption) Daniel@0: if iscell(c) Daniel@0: c = c{1}; Daniel@0: end Daniel@0: load keysomaudiodata; Daniel@0: m = get(c,'Magnitude'); Daniel@0: disp('Projecting the chromagram to a self-organizing map...') Daniel@0: z = cell(1,length(m)); Daniel@0: p = cell(1,length(m)); Daniel@0: for i = 1:length(m) Daniel@0: mi = m{i}; Daniel@0: if not(iscell(mi)) Daniel@0: mi = {mi}; Daniel@0: end Daniel@0: zi = cell(1,length(mi)); Daniel@0: pi = cell(1,length(mi)); Daniel@0: for j = 1:length(mi) Daniel@0: mj = mi{j}; Daniel@0: zj = zeros(24,size(mj,2),size(mj,3),36); Daniel@0: pi{j} = zeros(24,size(mj,2),size(mj,3),36); Daniel@0: for k = 1:size(mj,2) Daniel@0: for l = 1:size(mj,3) Daniel@0: for kk=1:36 Daniel@0: for ll=1:24 Daniel@0: tmp = corrcoef([mj(:,k,l) somw(:,kk,ll)]); Daniel@0: zj(ll,k,l,kk) = tmp(1,2); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: zi{j} = zj; Daniel@0: end Daniel@0: z{i} = zi; Daniel@0: p{i} = pi; Daniel@0: end Daniel@0: s = class(struct,'mirkeysom',mirdata(c)); Daniel@0: s = purgedata(s); Daniel@0: s = set(s,'Title','Key SOM','Abs','','Ord','','Weight',z,'Pos',p); Daniel@0: %if option.filename Daniel@0: % mov = display(s,option.filename); Daniel@0: %else Daniel@0: % mov = display(s); Daniel@0: %end Daniel@0: %s = {s,mov};