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a set of getters functions to access the fields
|
7 |
+
from an HDF5 song file (regular file with one song or
|
8 |
+
aggregate / summary file with many songs)
|
9 |
+
|
10 |
+
This is part of the Million Song Dataset project from
|
11 |
+
LabROSA (Columbia University) and The Echo Nest.
|
12 |
+
|
13 |
+
|
14 |
+
Copyright 2010, Thierry Bertin-Mahieux
|
15 |
+
|
16 |
+
This program is free software: you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License as published by
|
18 |
+
the Free Software Foundation, either version 3 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
+
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
+
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
+
"""
|
29 |
+
|
30 |
+
|
31 |
+
import tables
|
32 |
+
|
33 |
+
|
34 |
+
def open_h5_file_read(h5filename):
|
35 |
+
"""
|
36 |
+
Open an existing H5 in read mode.
|
37 |
+
Same function as in hdf5_utils, here so we avoid one import
|
38 |
+
"""
|
39 |
+
return tables.open_file(h5filename, mode='r')
|
40 |
+
|
41 |
+
|
42 |
+
def get_num_songs(h5):
|
43 |
+
"""
|
44 |
+
Return the number of songs contained in this h5 file, i.e. the number of rows
|
45 |
+
for all basic informations like name, artist, ...
|
46 |
+
"""
|
47 |
+
return h5.root.metadata.songs.nrows
|
48 |
+
|
49 |
+
def get_artist_familiarity(h5,songidx=0):
|
50 |
+
"""
|
51 |
+
Get artist familiarity from a HDF5 song file, by default the first song in it
|
52 |
+
"""
|
53 |
+
return h5.root.metadata.songs.cols.artist_familiarity[songidx]
|
54 |
+
|
55 |
+
def get_artist_hotttnesss(h5,songidx=0):
|
56 |
+
"""
|
57 |
+
Get artist hotttnesss from a HDF5 song file, by default the first song in it
|
58 |
+
"""
|
59 |
+
return h5.root.metadata.songs.cols.artist_hotttnesss[songidx]
|
60 |
+
|
61 |
+
def get_artist_id(h5,songidx=0):
|
62 |
+
"""
|
63 |
+
Get artist id from a HDF5 song file, by default the first song in it
|
64 |
+
"""
|
65 |
+
return h5.root.metadata.songs.cols.artist_id[songidx]
|
66 |
+
|
67 |
+
def get_artist_mbid(h5,songidx=0):
|
68 |
+
"""
|
69 |
+
Get artist musibrainz id from a HDF5 song file, by default the first song in it
|
70 |
+
"""
|
71 |
+
return h5.root.metadata.songs.cols.artist_mbid[songidx]
|
72 |
+
|
73 |
+
def get_artist_playmeid(h5,songidx=0):
|
74 |
+
"""
|
75 |
+
Get artist playme id from a HDF5 song file, by default the first song in it
|
76 |
+
"""
|
77 |
+
return h5.root.metadata.songs.cols.artist_playmeid[songidx]
|
78 |
+
|
79 |
+
def get_artist_7digitalid(h5,songidx=0):
|
80 |
+
"""
|
81 |
+
Get artist 7digital id from a HDF5 song file, by default the first song in it
|
82 |
+
"""
|
83 |
+
return h5.root.metadata.songs.cols.artist_7digitalid[songidx]
|
84 |
+
|
85 |
+
def get_artist_latitude(h5,songidx=0):
|
86 |
+
"""
|
87 |
+
Get artist latitude from a HDF5 song file, by default the first song in it
|
88 |
+
"""
|
89 |
+
return h5.root.metadata.songs.cols.artist_latitude[songidx]
|
90 |
+
|
91 |
+
def get_artist_longitude(h5,songidx=0):
|
92 |
+
"""
|
93 |
+
Get artist longitude from a HDF5 song file, by default the first song in it
|
94 |
+
"""
|
95 |
+
return h5.root.metadata.songs.cols.artist_longitude[songidx]
|
96 |
+
|
97 |
+
def get_artist_location(h5,songidx=0):
|
98 |
+
"""
|
99 |
+
Get artist location from a HDF5 song file, by default the first song in it
|
100 |
+
"""
|
101 |
+
return h5.root.metadata.songs.cols.artist_location[songidx]
|
102 |
+
|
103 |
+
def get_artist_name(h5,songidx=0):
|
104 |
+
"""
|
105 |
+
Get artist name from a HDF5 song file, by default the first song in it
|
106 |
+
"""
|
107 |
+
return h5.root.metadata.songs.cols.artist_name[songidx]
|
108 |
+
|
109 |
+
def get_release(h5,songidx=0):
|
110 |
+
"""
|
111 |
+
Get release from a HDF5 song file, by default the first song in it
|
112 |
+
"""
|
113 |
+
return h5.root.metadata.songs.cols.release[songidx]
|
114 |
+
|
115 |
+
def get_release_7digitalid(h5,songidx=0):
|
116 |
+
"""
|
117 |
+
Get release 7digital id from a HDF5 song file, by default the first song in it
|
118 |
+
"""
|
119 |
+
return h5.root.metadata.songs.cols.release_7digitalid[songidx]
|
120 |
+
|
121 |
+
def get_song_id(h5,songidx=0):
|
122 |
+
"""
|
123 |
+
Get song id from a HDF5 song file, by default the first song in it
|
124 |
+
"""
|
125 |
+
return h5.root.metadata.songs.cols.song_id[songidx]
|
126 |
+
|
127 |
+
def get_song_hotttnesss(h5,songidx=0):
|
128 |
+
"""
|
129 |
+
Get song hotttnesss from a HDF5 song file, by default the first song in it
|
130 |
+
"""
|
131 |
+
return h5.root.metadata.songs.cols.song_hotttnesss[songidx]
|
132 |
+
|
133 |
+
def get_title(h5,songidx=0):
|
134 |
+
"""
|
135 |
+
Get title from a HDF5 song file, by default the first song in it
|
136 |
+
"""
|
137 |
+
return h5.root.metadata.songs.cols.title[songidx]
|
138 |
+
|
139 |
+
def get_track_7digitalid(h5,songidx=0):
|
140 |
+
"""
|
141 |
+
Get track 7digital id from a HDF5 song file, by default the first song in it
|
142 |
+
"""
|
143 |
+
return h5.root.metadata.songs.cols.track_7digitalid[songidx]
|
144 |
+
|
145 |
+
def get_similar_artists(h5,songidx=0):
|
146 |
+
"""
|
147 |
+
Get similar artists array. Takes care of the proper indexing if we are in aggregate
|
148 |
+
file. By default, return the array for the first song in the h5 file.
|
149 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
150 |
+
"""
|
151 |
+
if h5.root.metadata.songs.nrows == songidx + 1:
|
152 |
+
return h5.root.metadata.similar_artists[h5.root.metadata.songs.cols.idx_similar_artists[songidx]:]
|
153 |
+
return h5.root.metadata.similar_artists[h5.root.metadata.songs.cols.idx_similar_artists[songidx]:
|
154 |
+
h5.root.metadata.songs.cols.idx_similar_artists[songidx+1]]
|
155 |
+
|
156 |
+
def get_artist_terms(h5,songidx=0):
|
157 |
+
"""
|
158 |
+
Get artist terms array. Takes care of the proper indexing if we are in aggregate
|
159 |
+
file. By default, return the array for the first song in the h5 file.
|
160 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
161 |
+
"""
|
162 |
+
if h5.root.metadata.songs.nrows == songidx + 1:
|
163 |
+
return h5.root.metadata.artist_terms[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:]
|
164 |
+
return h5.root.metadata.artist_terms[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:
|
165 |
+
h5.root.metadata.songs.cols.idx_artist_terms[songidx+1]]
|
166 |
+
|
167 |
+
def get_artist_terms_freq(h5,songidx=0):
|
168 |
+
"""
|
169 |
+
Get artist terms array frequencies. Takes care of the proper indexing if we are in aggregate
|
170 |
+
file. By default, return the array for the first song in the h5 file.
|
171 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
172 |
+
"""
|
173 |
+
if h5.root.metadata.songs.nrows == songidx + 1:
|
174 |
+
return h5.root.metadata.artist_terms_freq[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:]
|
175 |
+
return h5.root.metadata.artist_terms_freq[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:
|
176 |
+
h5.root.metadata.songs.cols.idx_artist_terms[songidx+1]]
|
177 |
+
|
178 |
+
def get_artist_terms_weight(h5,songidx=0):
|
179 |
+
"""
|
180 |
+
Get artist terms array frequencies. Takes care of the proper indexing if we are in aggregate
|
181 |
+
file. By default, return the array for the first song in the h5 file.
|
182 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
183 |
+
"""
|
184 |
+
if h5.root.metadata.songs.nrows == songidx + 1:
|
185 |
+
return h5.root.metadata.artist_terms_weight[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:]
|
186 |
+
return h5.root.metadata.artist_terms_weight[h5.root.metadata.songs.cols.idx_artist_terms[songidx]:
|
187 |
+
h5.root.metadata.songs.cols.idx_artist_terms[songidx+1]]
|
188 |
+
|
189 |
+
def get_analysis_sample_rate(h5,songidx=0):
|
190 |
+
"""
|
191 |
+
Get analysis sample rate from a HDF5 song file, by default the first song in it
|
192 |
+
"""
|
193 |
+
return h5.root.analysis.songs.cols.analysis_sample_rate[songidx]
|
194 |
+
|
195 |
+
def get_audio_md5(h5,songidx=0):
|
196 |
+
"""
|
197 |
+
Get audio MD5 from a HDF5 song file, by default the first song in it
|
198 |
+
"""
|
199 |
+
return h5.root.analysis.songs.cols.audio_md5[songidx]
|
200 |
+
|
201 |
+
def get_danceability(h5,songidx=0):
|
202 |
+
"""
|
203 |
+
Get danceability from a HDF5 song file, by default the first song in it
|
204 |
+
"""
|
205 |
+
return h5.root.analysis.songs.cols.danceability[songidx]
|
206 |
+
|
207 |
+
def get_duration(h5,songidx=0):
|
208 |
+
"""
|
209 |
+
Get duration from a HDF5 song file, by default the first song in it
|
210 |
+
"""
|
211 |
+
return h5.root.analysis.songs.cols.duration[songidx]
|
212 |
+
|
213 |
+
def get_end_of_fade_in(h5,songidx=0):
|
214 |
+
"""
|
215 |
+
Get end of fade in from a HDF5 song file, by default the first song in it
|
216 |
+
"""
|
217 |
+
return h5.root.analysis.songs.cols.end_of_fade_in[songidx]
|
218 |
+
|
219 |
+
def get_energy(h5,songidx=0):
|
220 |
+
"""
|
221 |
+
Get energy from a HDF5 song file, by default the first song in it
|
222 |
+
"""
|
223 |
+
return h5.root.analysis.songs.cols.energy[songidx]
|
224 |
+
|
225 |
+
def get_key(h5,songidx=0):
|
226 |
+
"""
|
227 |
+
Get key from a HDF5 song file, by default the first song in it
|
228 |
+
"""
|
229 |
+
return h5.root.analysis.songs.cols.key[songidx]
|
230 |
+
|
231 |
+
def get_key_confidence(h5,songidx=0):
|
232 |
+
"""
|
233 |
+
Get key confidence from a HDF5 song file, by default the first song in it
|
234 |
+
"""
|
235 |
+
return h5.root.analysis.songs.cols.key_confidence[songidx]
|
236 |
+
|
237 |
+
def get_loudness(h5,songidx=0):
|
238 |
+
"""
|
239 |
+
Get loudness from a HDF5 song file, by default the first song in it
|
240 |
+
"""
|
241 |
+
return h5.root.analysis.songs.cols.loudness[songidx]
|
242 |
+
|
243 |
+
def get_mode(h5,songidx=0):
|
244 |
+
"""
|
245 |
+
Get mode from a HDF5 song file, by default the first song in it
|
246 |
+
"""
|
247 |
+
return h5.root.analysis.songs.cols.mode[songidx]
|
248 |
+
|
249 |
+
def get_mode_confidence(h5,songidx=0):
|
250 |
+
"""
|
251 |
+
Get mode confidence from a HDF5 song file, by default the first song in it
|
252 |
+
"""
|
253 |
+
return h5.root.analysis.songs.cols.mode_confidence[songidx]
|
254 |
+
|
255 |
+
def get_start_of_fade_out(h5,songidx=0):
|
256 |
+
"""
|
257 |
+
Get start of fade out from a HDF5 song file, by default the first song in it
|
258 |
+
"""
|
259 |
+
return h5.root.analysis.songs.cols.start_of_fade_out[songidx]
|
260 |
+
|
261 |
+
def get_tempo(h5,songidx=0):
|
262 |
+
"""
|
263 |
+
Get tempo from a HDF5 song file, by default the first song in it
|
264 |
+
"""
|
265 |
+
return h5.root.analysis.songs.cols.tempo[songidx]
|
266 |
+
|
267 |
+
def get_time_signature(h5,songidx=0):
|
268 |
+
"""
|
269 |
+
Get signature from a HDF5 song file, by default the first song in it
|
270 |
+
"""
|
271 |
+
return h5.root.analysis.songs.cols.time_signature[songidx]
|
272 |
+
|
273 |
+
def get_time_signature_confidence(h5,songidx=0):
|
274 |
+
"""
|
275 |
+
Get signature confidence from a HDF5 song file, by default the first song in it
|
276 |
+
"""
|
277 |
+
return h5.root.analysis.songs.cols.time_signature_confidence[songidx]
|
278 |
+
|
279 |
+
def get_track_id(h5,songidx=0):
|
280 |
+
"""
|
281 |
+
Get track id from a HDF5 song file, by default the first song in it
|
282 |
+
"""
|
283 |
+
return h5.root.analysis.songs.cols.track_id[songidx]
|
284 |
+
|
285 |
+
def get_segments_start(h5,songidx=0):
|
286 |
+
"""
|
287 |
+
Get segments start array. Takes care of the proper indexing if we are in aggregate
|
288 |
+
file. By default, return the array for the first song in the h5 file.
|
289 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
290 |
+
"""
|
291 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
292 |
+
return h5.root.analysis.segments_start[h5.root.analysis.songs.cols.idx_segments_start[songidx]:]
|
293 |
+
return h5.root.analysis.segments_start[h5.root.analysis.songs.cols.idx_segments_start[songidx]:
|
294 |
+
h5.root.analysis.songs.cols.idx_segments_start[songidx+1]]
|
295 |
+
|
296 |
+
def get_segments_confidence(h5,songidx=0):
|
297 |
+
"""
|
298 |
+
Get segments confidence array. Takes care of the proper indexing if we are in aggregate
|
299 |
+
file. By default, return the array for the first song in the h5 file.
|
300 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
301 |
+
"""
|
302 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
303 |
+
return h5.root.analysis.segments_confidence[h5.root.analysis.songs.cols.idx_segments_confidence[songidx]:]
|
304 |
+
return h5.root.analysis.segments_confidence[h5.root.analysis.songs.cols.idx_segments_confidence[songidx]:
|
305 |
+
h5.root.analysis.songs.cols.idx_segments_confidence[songidx+1]]
|
306 |
+
|
307 |
+
def get_segments_pitches(h5,songidx=0):
|
308 |
+
"""
|
309 |
+
Get segments pitches array. Takes care of the proper indexing if we are in aggregate
|
310 |
+
file. By default, return the array for the first song in the h5 file.
|
311 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
312 |
+
"""
|
313 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
314 |
+
return h5.root.analysis.segments_pitches[h5.root.analysis.songs.cols.idx_segments_pitches[songidx]:,:]
|
315 |
+
return h5.root.analysis.segments_pitches[h5.root.analysis.songs.cols.idx_segments_pitches[songidx]:
|
316 |
+
h5.root.analysis.songs.cols.idx_segments_pitches[songidx+1],:]
|
317 |
+
|
318 |
+
def get_segments_timbre(h5,songidx=0):
|
319 |
+
"""
|
320 |
+
Get segments timbre array. Takes care of the proper indexing if we are in aggregate
|
321 |
+
file. By default, return the array for the first song in the h5 file.
|
322 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
323 |
+
"""
|
324 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
325 |
+
return h5.root.analysis.segments_timbre[h5.root.analysis.songs.cols.idx_segments_timbre[songidx]:,:]
|
326 |
+
return h5.root.analysis.segments_timbre[h5.root.analysis.songs.cols.idx_segments_timbre[songidx]:
|
327 |
+
h5.root.analysis.songs.cols.idx_segments_timbre[songidx+1],:]
|
328 |
+
|
329 |
+
def get_segments_loudness_max(h5,songidx=0):
|
330 |
+
"""
|
331 |
+
Get segments loudness max array. Takes care of the proper indexing if we are in aggregate
|
332 |
+
file. By default, return the array for the first song in the h5 file.
|
333 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
334 |
+
"""
|
335 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
336 |
+
return h5.root.analysis.segments_loudness_max[h5.root.analysis.songs.cols.idx_segments_loudness_max[songidx]:]
|
337 |
+
return h5.root.analysis.segments_loudness_max[h5.root.analysis.songs.cols.idx_segments_loudness_max[songidx]:
|
338 |
+
h5.root.analysis.songs.cols.idx_segments_loudness_max[songidx+1]]
|
339 |
+
|
340 |
+
def get_segments_loudness_max_time(h5,songidx=0):
|
341 |
+
"""
|
342 |
+
Get segments loudness max time array. Takes care of the proper indexing if we are in aggregate
|
343 |
+
file. By default, return the array for the first song in the h5 file.
|
344 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
345 |
+
"""
|
346 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
347 |
+
return h5.root.analysis.segments_loudness_max_time[h5.root.analysis.songs.cols.idx_segments_loudness_max_time[songidx]:]
|
348 |
+
return h5.root.analysis.segments_loudness_max_time[h5.root.analysis.songs.cols.idx_segments_loudness_max_time[songidx]:
|
349 |
+
h5.root.analysis.songs.cols.idx_segments_loudness_max_time[songidx+1]]
|
350 |
+
|
351 |
+
def get_segments_loudness_start(h5,songidx=0):
|
352 |
+
"""
|
353 |
+
Get segments loudness start array. Takes care of the proper indexing if we are in aggregate
|
354 |
+
file. By default, return the array for the first song in the h5 file.
|
355 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
356 |
+
"""
|
357 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
358 |
+
return h5.root.analysis.segments_loudness_start[h5.root.analysis.songs.cols.idx_segments_loudness_start[songidx]:]
|
359 |
+
return h5.root.analysis.segments_loudness_start[h5.root.analysis.songs.cols.idx_segments_loudness_start[songidx]:
|
360 |
+
h5.root.analysis.songs.cols.idx_segments_loudness_start[songidx+1]]
|
361 |
+
|
362 |
+
def get_sections_start(h5,songidx=0):
|
363 |
+
"""
|
364 |
+
Get sections start array. Takes care of the proper indexing if we are in aggregate
|
365 |
+
file. By default, return the array for the first song in the h5 file.
|
366 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
367 |
+
"""
|
368 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
369 |
+
return h5.root.analysis.sections_start[h5.root.analysis.songs.cols.idx_sections_start[songidx]:]
|
370 |
+
return h5.root.analysis.sections_start[h5.root.analysis.songs.cols.idx_sections_start[songidx]:
|
371 |
+
h5.root.analysis.songs.cols.idx_sections_start[songidx+1]]
|
372 |
+
|
373 |
+
def get_sections_confidence(h5,songidx=0):
|
374 |
+
"""
|
375 |
+
Get sections confidence array. Takes care of the proper indexing if we are in aggregate
|
376 |
+
file. By default, return the array for the first song in the h5 file.
|
377 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
378 |
+
"""
|
379 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
380 |
+
return h5.root.analysis.sections_confidence[h5.root.analysis.songs.cols.idx_sections_confidence[songidx]:]
|
381 |
+
return h5.root.analysis.sections_confidence[h5.root.analysis.songs.cols.idx_sections_confidence[songidx]:
|
382 |
+
h5.root.analysis.songs.cols.idx_sections_confidence[songidx+1]]
|
383 |
+
|
384 |
+
def get_beats_start(h5,songidx=0):
|
385 |
+
"""
|
386 |
+
Get beats start array. Takes care of the proper indexing if we are in aggregate
|
387 |
+
file. By default, return the array for the first song in the h5 file.
|
388 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
389 |
+
"""
|
390 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
391 |
+
return h5.root.analysis.beats_start[h5.root.analysis.songs.cols.idx_beats_start[songidx]:]
|
392 |
+
return h5.root.analysis.beats_start[h5.root.analysis.songs.cols.idx_beats_start[songidx]:
|
393 |
+
h5.root.analysis.songs.cols.idx_beats_start[songidx+1]]
|
394 |
+
|
395 |
+
def get_beats_confidence(h5,songidx=0):
|
396 |
+
"""
|
397 |
+
Get beats confidence array. Takes care of the proper indexing if we are in aggregate
|
398 |
+
file. By default, return the array for the first song in the h5 file.
|
399 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
400 |
+
"""
|
401 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
402 |
+
return h5.root.analysis.beats_confidence[h5.root.analysis.songs.cols.idx_beats_confidence[songidx]:]
|
403 |
+
return h5.root.analysis.beats_confidence[h5.root.analysis.songs.cols.idx_beats_confidence[songidx]:
|
404 |
+
h5.root.analysis.songs.cols.idx_beats_confidence[songidx+1]]
|
405 |
+
|
406 |
+
def get_bars_start(h5,songidx=0):
|
407 |
+
"""
|
408 |
+
Get bars start array. Takes care of the proper indexing if we are in aggregate
|
409 |
+
file. By default, return the array for the first song in the h5 file.
|
410 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
411 |
+
"""
|
412 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
413 |
+
return h5.root.analysis.bars_start[h5.root.analysis.songs.cols.idx_bars_start[songidx]:]
|
414 |
+
return h5.root.analysis.bars_start[h5.root.analysis.songs.cols.idx_bars_start[songidx]:
|
415 |
+
h5.root.analysis.songs.cols.idx_bars_start[songidx+1]]
|
416 |
+
|
417 |
+
def get_bars_confidence(h5,songidx=0):
|
418 |
+
"""
|
419 |
+
Get bars start array. Takes care of the proper indexing if we are in aggregate
|
420 |
+
file. By default, return the array for the first song in the h5 file.
|
421 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
422 |
+
"""
|
423 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
424 |
+
return h5.root.analysis.bars_confidence[h5.root.analysis.songs.cols.idx_bars_confidence[songidx]:]
|
425 |
+
return h5.root.analysis.bars_confidence[h5.root.analysis.songs.cols.idx_bars_confidence[songidx]:
|
426 |
+
h5.root.analysis.songs.cols.idx_bars_confidence[songidx+1]]
|
427 |
+
|
428 |
+
def get_tatums_start(h5,songidx=0):
|
429 |
+
"""
|
430 |
+
Get tatums start array. Takes care of the proper indexing if we are in aggregate
|
431 |
+
file. By default, return the array for the first song in the h5 file.
|
432 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
433 |
+
"""
|
434 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
435 |
+
return h5.root.analysis.tatums_start[h5.root.analysis.songs.cols.idx_tatums_start[songidx]:]
|
436 |
+
return h5.root.analysis.tatums_start[h5.root.analysis.songs.cols.idx_tatums_start[songidx]:
|
437 |
+
h5.root.analysis.songs.cols.idx_tatums_start[songidx+1]]
|
438 |
+
|
439 |
+
def get_tatums_confidence(h5,songidx=0):
|
440 |
+
"""
|
441 |
+
Get tatums confidence array. Takes care of the proper indexing if we are in aggregate
|
442 |
+
file. By default, return the array for the first song in the h5 file.
|
443 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
444 |
+
"""
|
445 |
+
if h5.root.analysis.songs.nrows == songidx + 1:
|
446 |
+
return h5.root.analysis.tatums_confidence[h5.root.analysis.songs.cols.idx_tatums_confidence[songidx]:]
|
447 |
+
return h5.root.analysis.tatums_confidence[h5.root.analysis.songs.cols.idx_tatums_confidence[songidx]:
|
448 |
+
h5.root.analysis.songs.cols.idx_tatums_confidence[songidx+1]]
|
449 |
+
|
450 |
+
def get_artist_mbtags(h5,songidx=0):
|
451 |
+
"""
|
452 |
+
Get artist musicbrainz tag array. Takes care of the proper indexing if we are in aggregate
|
453 |
+
file. By default, return the array for the first song in the h5 file.
|
454 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
455 |
+
"""
|
456 |
+
if h5.root.musicbrainz.songs.nrows == songidx + 1:
|
457 |
+
return h5.root.musicbrainz.artist_mbtags[h5.root.musicbrainz.songs.cols.idx_artist_mbtags[songidx]:]
|
458 |
+
return h5.root.musicbrainz.artist_mbtags[h5.root.metadata.songs.cols.idx_artist_mbtags[songidx]:
|
459 |
+
h5.root.metadata.songs.cols.idx_artist_mbtags[songidx+1]]
|
460 |
+
|
461 |
+
def get_artist_mbtags_count(h5,songidx=0):
|
462 |
+
"""
|
463 |
+
Get artist musicbrainz tag count array. Takes care of the proper indexing if we are in aggregate
|
464 |
+
file. By default, return the array for the first song in the h5 file.
|
465 |
+
To get a regular numpy ndarray, cast the result to: numpy.array( )
|
466 |
+
"""
|
467 |
+
if h5.root.musicbrainz.songs.nrows == songidx + 1:
|
468 |
+
return h5.root.musicbrainz.artist_mbtags_count[h5.root.musicbrainz.songs.cols.idx_artist_mbtags[songidx]:]
|
469 |
+
return h5.root.musicbrainz.artist_mbtags_count[h5.root.metadata.songs.cols.idx_artist_mbtags[songidx]:
|
470 |
+
h5.root.metadata.songs.cols.idx_artist_mbtags[songidx+1]]
|
471 |
+
|
472 |
+
def get_year(h5,songidx=0):
|
473 |
+
"""
|
474 |
+
Get release year from a HDF5 song file, by default the first song in it
|
475 |
+
"""
|
476 |
+
return h5.root.musicbrainz.songs.cols.year[songidx]
|