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