annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirgetdata.m @ 0:e9a9cd732c1e tip

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