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