annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirdata/get.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 val = get(a, propName)
wolffd@0 2 % GET Get properties from the MIRdata object
wolffd@0 3 % and return the value
wolffd@0 4
wolffd@0 5 switch propName
wolffd@0 6 case 'Pos'
wolffd@0 7 val = a.pos;
wolffd@0 8 case 'Data'
wolffd@0 9 val = a.data;
wolffd@0 10 case 'Unit'
wolffd@0 11 val = a.unit;
wolffd@0 12 case 'FramePos'
wolffd@0 13 val = a.framepos;
wolffd@0 14 case 'Framed'
wolffd@0 15 val = a.framed;
wolffd@0 16 case 'Sampling'
wolffd@0 17 val = a.sr;
wolffd@0 18 case 'NBits'
wolffd@0 19 val = a.nbits;
wolffd@0 20 case 'Name'
wolffd@0 21 val = a.name;
wolffd@0 22 case 'Name2'
wolffd@0 23 val = a.name2;
wolffd@0 24 case 'Label'
wolffd@0 25 val = a.label;
wolffd@0 26 case 'Channels'
wolffd@0 27 val = a.channels;
wolffd@0 28 case 'Clusters'
wolffd@0 29 val = a.clusters;
wolffd@0 30 case 'MultiData'
wolffd@0 31 val = a.multidata;
wolffd@0 32 case 'PeakPos'
wolffd@0 33 val = a.peak.pos;
wolffd@0 34 case {'PeakPosUnit','AttackPosUnit','ReleasePosUnit'}
wolffd@0 35 switch propName
wolffd@0 36 case 'PeakPosUnit'
wolffd@0 37 pp = a.peak.pos;
wolffd@0 38 case 'AttackPosUnit'
wolffd@0 39 pp = a.attack.pos;
wolffd@0 40 case 'ReleasePosUnit'
wolffd@0 41 pp = a.release.pos;
wolffd@0 42 end
wolffd@0 43 po = a.pos;
wolffd@0 44 d = a.data;
wolffd@0 45 val = cell(1,length(pp));
wolffd@0 46 if isempty(d)
wolffd@0 47 return
wolffd@0 48 end
wolffd@0 49 for k = 1:length(pp)
wolffd@0 50 val{k} = cell(1,length(pp{k}));
wolffd@0 51 if isempty(pp{k})
wolffd@0 52 nseg = 0;
wolffd@0 53 elseif iscell(pp{k}{1})
wolffd@0 54 nseg = length(pp{k});
wolffd@0 55 else
wolffd@0 56 nseg = 1;
wolffd@0 57 end
wolffd@0 58 for i = 1:nseg
wolffd@0 59 ppi = pp{k}{i};
wolffd@0 60 if isempty(po)
wolffd@0 61 poi = (1:size(d{k}{i},2))';
wolffd@0 62 elseif iscell(po{k})
wolffd@0 63 if isempty(po{k})
wolffd@0 64 poi = mean(a.framepos{k}{1})';
wolffd@0 65 elseif isempty(a.pos)
wolffd@0 66 poi = po{k}{i}';
wolffd@0 67 elseif ischar(po{k}{1})
wolffd@0 68 poi = (1:length(po{k}))';
wolffd@0 69 else
wolffd@0 70 poi = po{k}{i};
wolffd@0 71 end
wolffd@0 72 else
wolffd@0 73 for j = 1:size(po,3)
wolffd@0 74 poi(:,:,j) = po{k}(:,:,j)';
wolffd@0 75 end
wolffd@0 76 end
wolffd@0 77 val{k}{i} = cell(size(ppi));
wolffd@0 78 for h = 1:size(ppi,3)
wolffd@0 79 for j = 1:size(ppi,2)
wolffd@0 80 if size(poi,3) > 1 && size(poi,1) == 1
wolffd@0 81 val{k}{i}{1,j,h} = ppi{1,j,h};
wolffd@0 82 else
wolffd@0 83 val{k}{i}{1,j,h} = poi(ppi{1,j,h},1);
wolffd@0 84 end
wolffd@0 85 end
wolffd@0 86 end
wolffd@0 87 end
wolffd@0 88 end
wolffd@0 89 case 'PeakPrecisePos'
wolffd@0 90 val = a.peak.precisepos;
wolffd@0 91 case 'PeakVal'
wolffd@0 92 val = a.peak.val;
wolffd@0 93 case 'PeakPreciseVal'
wolffd@0 94 val = a.peak.preciseval;
wolffd@0 95 case 'PeakMaxVal'
wolffd@0 96 pv = a.peak.val;
wolffd@0 97 val = cell(1,length(pv));
wolffd@0 98 for h = 1:length(pv)
wolffd@0 99 val{h} = cell(1,length(pv{h}));
wolffd@0 100 for i = 1:length(pv{h})
wolffd@0 101 pvi = pv{h}{i};
wolffd@0 102 %if iscell(pvi)
wolffd@0 103 % pvi = pvi{1}; % Segmented data not taken into consideration yet.
wolffd@0 104 %end
wolffd@0 105 val{h}{i} = zeros(1,length(pvi));
wolffd@0 106 for j = 1:length(pvi)
wolffd@0 107 if isempty(pvi{j})
wolffd@0 108 val{h}{i}(1,j) = NaN;
wolffd@0 109 else
wolffd@0 110 val{h}{i}(1,j) = max(pvi{j});
wolffd@0 111 end
wolffd@0 112 end
wolffd@0 113 end
wolffd@0 114 end
wolffd@0 115 case 'PeakMode'
wolffd@0 116 val = a.peak.mode;
wolffd@0 117 case 'AttackPos'
wolffd@0 118 if isempty(a.attack)
wolffd@0 119 val = [];
wolffd@0 120 else
wolffd@0 121 val = a.attack.pos;
wolffd@0 122 end
wolffd@0 123 case 'ReleasePos'
wolffd@0 124 if isempty(a.release)
wolffd@0 125 val = [];
wolffd@0 126 else
wolffd@0 127 val = a.release.pos;
wolffd@0 128 end
wolffd@0 129 case 'TrackPos'
wolffd@0 130 if isempty(a.track)
wolffd@0 131 val = [];
wolffd@0 132 else
wolffd@0 133 val = a.track.pos;
wolffd@0 134 end
wolffd@0 135 case 'TrackPosUnit'
wolffd@0 136 if isempty(a.track)
wolffd@0 137 val = [];
wolffd@0 138 else
wolffd@0 139 pp = a.track.pos;
wolffd@0 140 po = a.pos;
wolffd@0 141 d = a.data;
wolffd@0 142 val = cell(1,length(pp));
wolffd@0 143 for k = 1:length(pp)
wolffd@0 144 val{k} = cell(1,length(pp{k}));
wolffd@0 145 if isempty(pp{k})
wolffd@0 146 nseg = 0;
wolffd@0 147 elseif iscell(pp{k}{1})
wolffd@0 148 nseg = length(pp{k});
wolffd@0 149 else
wolffd@0 150 nseg = 1;
wolffd@0 151 end
wolffd@0 152 for i = 1:nseg
wolffd@0 153 ppi = pp{k}{i}{1};
wolffd@0 154 if isempty(po)
wolffd@0 155 poi = (1:size(d{k}{i},2))';
wolffd@0 156 elseif iscell(po{k})
wolffd@0 157 if isempty(po{k})
wolffd@0 158 poi = mean(a.framepos{k}{1})';
wolffd@0 159 elseif isempty(a.pos)
wolffd@0 160 poi = po{k}{i}';
wolffd@0 161 elseif ischar(po{k}{1})
wolffd@0 162 poi = (1:length(po{k}))';
wolffd@0 163 else
wolffd@0 164 poi = po{k}{i};
wolffd@0 165 end
wolffd@0 166 else
wolffd@0 167 for j = 1:size(po,3)
wolffd@0 168 poi(:,:,j) = po{k}(:,:,j)';
wolffd@0 169 end
wolffd@0 170 end
wolffd@0 171 val{k}{i}{1} = zeros(size(ppi));
wolffd@0 172 if size(poi,3) > 1 && size(poi,1) == 1
wolffd@0 173 val{k}{i}{1} = ppi;
wolffd@0 174 else
wolffd@0 175 for h = 1:size(ppi,2)
wolffd@0 176 for j = 1:size(ppi,1)
wolffd@0 177 if ppi(j,h)
wolffd@0 178 val{k}{i}{1}(j,h) = poi(ppi(j,h),1);
wolffd@0 179 else
wolffd@0 180 val{k}{i}{1}(j,h) = 0;
wolffd@0 181 end
wolffd@0 182 end
wolffd@0 183 end
wolffd@0 184 end
wolffd@0 185 end
wolffd@0 186 end
wolffd@0 187 end
wolffd@0 188 case 'TrackVal'
wolffd@0 189 if isempty(a.track)
wolffd@0 190 val = [];
wolffd@0 191 else
wolffd@0 192 val = a.track.val;
wolffd@0 193 end
wolffd@0 194 case 'TrackPrecisePos'
wolffd@0 195 if isempty(a.track)
wolffd@0 196 val = [];
wolffd@0 197 else
wolffd@0 198 val = a.track.precisepos;
wolffd@0 199 end
wolffd@0 200 case 'TrackPreciseVal'
wolffd@0 201 if isempty(a.track)
wolffd@0 202 val = [];
wolffd@0 203 else
wolffd@0 204 val = a.track.preciseval;
wolffd@0 205 end
wolffd@0 206 case 'Title'
wolffd@0 207 val = a.title;
wolffd@0 208 case 'Abs'
wolffd@0 209 val = a.abs;
wolffd@0 210 case 'Ord'
wolffd@0 211 val = a.ord;
wolffd@0 212 case 'InterChunk'
wolffd@0 213 val = a.interchunk;
wolffd@0 214 case 'TmpIdx'
wolffd@0 215 val = a.tmpidx;
wolffd@0 216 case 'AcrossChunks'
wolffd@0 217 val = a.acrosschunks;
wolffd@0 218 case 'Interpolable'
wolffd@0 219 val = a.interpolable;
wolffd@0 220 case 'TmpFile'
wolffd@0 221 val = a.tmpfile;
wolffd@0 222 case 'Index'
wolffd@0 223 val = a.index;
wolffd@0 224 otherwise
wolffd@0 225 error([propName,' is not a valid MIRdata property'])
wolffd@0 226 end