annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirgetdata.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 [d,d2] = mirgetdata(x,varargin)
Daniel@0 2 % d = mirgetdata(x) return the data contained in the object x in a
Daniel@0 3 % structure that can be used for further computation outside MIRtoolbox.
Daniel@0 4 % If x corresponds to one non-segmented audio sequence, the result is
Daniel@0 5 % returned as a matrix. The columns of the matrix usually
Daniel@0 6 % correspond to the successive frames of the audio signal. The
Daniel@0 7 % third dimension of the matrix corresponds to the different
Daniel@0 8 % channels of a filterbank.
Daniel@0 9 % If x is a keystrength curve, the fourth dimension distinguishes
Daniel@0 10 % between major and minor keys. i.e. d(:,:,:,1) is the
Daniel@0 11 % keystrength for the major keys, and d(:,:,:,2) is the
Daniel@0 12 % keystrength for the minor keys.
Daniel@0 13 % If x is a key estimation, two output are returned: the first one
Daniel@0 14 % gives the keys (from 1 to 12) and the second one indicates the
Daniel@0 15 % modes (1 for major, 2 for minor).
Daniel@0 16 %
Daniel@0 17 % If x corresponds to a set of audio sequences, and if each sequence
Daniel@0 18 % has same number of frames, the corresponding resulting matrices
Daniel@0 19 % are concatenated columnwise one after the other. If the number
Daniel@0 20 % of raws of the elementary matrices varies, the missing values
Daniel@0 21 % are replaced by NaN in the final matrix. On the contrary, if
Daniel@0 22 % the number of columns (i.e., frames) differs, then the result
Daniel@0 23 % remains a cell array of matrices.
Daniel@0 24 % Idem if x corresponds to one or several segmented audio
Daniel@0 25 % sequence(s).
Daniel@0 26 %
Daniel@0 27 % If x is the result of a peak detection,
Daniel@0 28 % [px,py] = getdata(x) return the position of the peaks (px) and the
Daniel@0 29 % value corresponding to these peaks (py), in the units
Daniel@0 30 % predefined for this data.
Daniel@0 31
Daniel@0 32 if isempty(x)
Daniel@0 33 d = {};
Daniel@0 34 d2 = {};
Daniel@0 35 return
Daniel@0 36 end
Daniel@0 37
Daniel@0 38 if isstruct(x)
Daniel@0 39 fields = fieldnames(x);
Daniel@0 40 for f = 1:length(fields)
Daniel@0 41 d.(fields{f}) = mirgetdata(x.(fields{f}));
Daniel@0 42 end
Daniel@0 43 d2 = {};
Daniel@0 44 return
Daniel@0 45 end
Daniel@0 46
Daniel@0 47 if iscell(x)
Daniel@0 48 x = x{1};
Daniel@0 49 end
Daniel@0 50 v = get(x,'Data');
Daniel@0 51 if isa(x,'mirscalar')
Daniel@0 52 m = get(x,'Mode');
Daniel@0 53 end
Daniel@0 54 d2 = {};
Daniel@0 55
Daniel@0 56 if isa(x,'mirclassify')
Daniel@0 57 d = get(x,'Data');
Daniel@0 58 return
Daniel@0 59 end
Daniel@0 60
Daniel@0 61 if isa(x,'mirsimatrix')
Daniel@0 62 pt = [];
Daniel@0 63 else
Daniel@0 64 pt = get(x,'PeakPrecisePos');
Daniel@0 65 end
Daniel@0 66 pv = get(x,'PeakPreciseVal');
Daniel@0 67 if not(isempty(pt)) && not(isempty(pt{1})) && not(isempty(pt{1}{1}))
Daniel@0 68 d = uncell(pt);
Daniel@0 69 d2 = uncell(pv);
Daniel@0 70 if not(isempty(d))
Daniel@0 71 return
Daniel@0 72 end
Daniel@0 73 end
Daniel@0 74
Daniel@0 75 if isa(x,'mirsimatrix')
Daniel@0 76 pt = [];
Daniel@0 77 else
Daniel@0 78 pt = get(x,'PeakPosUnit');
Daniel@0 79 end
Daniel@0 80 pv = get(x,'PeakVal');
Daniel@0 81 if not(isempty(pt)) && not(isempty(pt{1})) && not(isempty(pt{1}{1}))
Daniel@0 82 d = uncell(pt);
Daniel@0 83 d2 = uncell(pv);
Daniel@0 84 if not(isempty(d))
Daniel@0 85 return
Daniel@0 86 end
Daniel@0 87 end
Daniel@0 88
Daniel@0 89 d = uncell(v,isa(x,'mirscalar'));
Daniel@0 90 if iscell(d) && not(isempty(d)) && nargin == 1
Daniel@0 91 disp('The result is an array of cell.')
Daniel@0 92 disp(['If d is the name of the output variable, ',...
Daniel@0 93 'the successive cells can be accessed by typing d{1}, d{2}, etc.']);
Daniel@0 94 end
Daniel@0 95 if exist('m')==1 && not(isempty(m)) && not(isempty(m{1}))
Daniel@0 96 d2 = uncell(m);
Daniel@0 97 end