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