carat.annotations.load_downbeats

carat.annotations.load_downbeats(labels_file, delimiter=', ', times_col=0, labels_col=1, downbeat_label='.1')[source]

Load annotated downbeats from text (csv) file.

Parameters:
labels_file : str

name (including path) of the input file

delimiter : str

string used as delimiter in the input file

times_col : int

column index of the time data

labels_col : int

column index of the label data

downbeat_label : str

string to look for in the label data to select downbeats

Returns:
downbeat_times : np.ndarray

time instants of the downbeats

downbeat_labels : list

abels at the downbeats

Notes

It is assumed that the annotations are provided as a text file (csv). Apart from the time data (mandatory) a label can be given for each downbeat (optional). The time data is assumed to be given in seconds.

If a single file contains both beats and downbeats then the downbeat_label is used to select downbeats. The downbeats are those beats whose label has the given downbeat_label string. For instance the beat labels can be numbers, e.g. ‘1’, ‘2’. Then, the downbeat_label is just ‘1’. This is the case for the BRID samba dataset. In the case of the candombe dataset, the beat labels indicate bar number and beat number. For instance, ‘1.1’, ‘1.2’, ‘1.3’ and ‘1.4’ are the four beats of the first bar. Hence, the string needed to indetify the downbeats is ‘.1’.

Examples

Load an included example file from the candombe dataset. http://www.eumus.edu.uy/candombe/datasets/ISMIR2015/

>>> annotations_file = carat.util.example_beats_file(num_file=1)
>>> downbeats, downbeat_labs = carat.annotations.load_downbeats(annotations_file)
>>> downbeats[:3]
array([0.54857143, 2.33265306, 4.11530612])
>>> downbeat_labs[:3]
['1.1', '2.1', '3.1']

Load an included example file from the samba dataset. http://www.smt.ufrj.br/~starel/datasets/brid.html

>>> annotations_file = carat.util.example_beats_file(num_file=2)
>>> downbeats, downbeat_labs = annotations.load_downbeats(annotations_file,
                                                          delimiter=' ', downbeat_label='1')
>>> downbeats
array([ 2.088,  3.012,  3.933,  4.867,  5.771,  6.69 ,  7.633,  8.545,
        9.48 , 10.404, 11.322, 12.251, 13.167, 14.094, 15.014, 15.931,
       16.865, 17.788, 18.706, 19.643, 20.557, 21.494, 22.408,  23.31,
       24.235, 25.151, 26.063])
>>> downbeat_labs
['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
 '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']