How to use the mirdata.utils.EventData function in mirdata

To help you get started, we’ve selected a few mirdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
'lyrics_1',
        ),
        [
            utils.LyricData(
                np.array([0.0, 0.232]),
                np.array([0.227, 0.742]),
                np.array(['is', 'cool']),
                np.array([None, None]),
            ),
            'lyrics_2',
        ],
    ]
    lyrics_data_6 = [(None, None)]
    lyrics_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(lyrics_data=lyrics_data_1)
    jam_2 = jams_utils.jams_converter(lyrics_data=lyrics_data_2)
    jam_3 = jams_utils.jams_converter(lyrics_data=lyrics_data_3)
    jam_6 = jams_utils.jams_converter(lyrics_data=lyrics_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'lyrics', 0)
    assert time == [0.027, 0.232]
    assert duration == [0.2, 0.51]
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
key_data_3 = [
        (utils.KeyData(np.array([0.0]), np.array([100.0]), np.array(['A'])), 'keys_1'),
        (utils.KeyData(np.array([0.0]), np.array([50.0]), np.array(['B'])), 'keys_2'),
    ]
    key_data_4 = (
        utils.KeyData(np.array([0.0]), np.array([100.0]), np.array(['A'])),
        'keys_1',
    )
    key_data_5 = [
        [utils.KeyData(np.array([0.0]), np.array([100.0]), np.array(['A'])), 'keys_1'],
        (utils.KeyData(np.array([0.0]), np.array([50.0]), np.array(['B'])), 'keys_2'),
    ]
    key_data_6 = [(None, None)]
    key_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(key_data=key_data_1)
    jam_2 = jams_utils.jams_converter(key_data=key_data_2)
    jam_3 = jams_utils.jams_converter(key_data=key_data_3)
    jam_6 = jams_utils.jams_converter(key_data=key_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'key', 0)
    assert time == [0.0]
    assert duration == [100.0]
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            'I am a description',
        )
    ]
    event_data2 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]), np.array([0.4, 0.5]), np.array([2, 'event B'])
            ),
            'events 1',
        ),
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array([{'a': 1, 2: 'b'}, 'a great label']),
            ),
            'events 2',
        ),
    ]
    event_data3 = [
        (
            utils.EventData(
                np.array([20, 30]),  # invalid because > duration
                np.array([0.3, 0.4]),
                np.array([{'a': 1, 2: 'b'}, 'a great label']),
            ),
            'asdf',
        )
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
def test_events():
    event_data1 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            'I am a description',
        )
    ]
    event_data2 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]), np.array([0.4, 0.5]), np.array([2, 'event B'])
            ),
            'events 1',
        ),
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array([{'a': 1, 2: 'b'}, 'a great label']),
            ),
            'events 2',
        ),
    ]
    event_data3 = [
        (
            utils.EventData(
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
),
            None,
        ],
        (
            utils.NoteData(
                np.array([[0.0, 0.8, 1.0], [0.5, 1.0, 1.5]]).T,
                np.array([1108.731, 1108.731, 1108.731]),
                np.array([1, 1, 1]),
            ),
            'notes_2',
        ),
    ]
    note_data_6 = [(None, None)]
    note_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(note_data=note_data_1)
    jam_2 = jams_utils.jams_converter(note_data=note_data_2)
    jam_3 = jams_utils.jams_converter(note_data=note_data_3)
    jam_6 = jams_utils.jams_converter(note_data=note_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'note_hz', 0)
    assert time == [0.0, 0.5, 1.0]
    assert duration == [0.5, 0.5, 0.5]
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
np.array(['verse A', 'verse B', 'verse A']),
            ),
            None,
        ],
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            'sections_2',
        ),
    ]
    section_data_6 = [(None, None)]
    section_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(section_data=section_data_1)
    jam_2 = jams_utils.jams_converter(section_data=section_data_2)
    jam_3 = jams_utils.jams_converter(section_data=section_data_3)
    jam_6 = jams_utils.jams_converter(section_data=section_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'segment', 0)
    assert time == [0.0, 10.0, 20.0]
    assert duration == [10.0, 10.0, 5.0]
github mir-dataset-loaders / mirdata / tests / test_jams_utils.py View on Github external
def test_beats():
    beat_data_1 = [(utils.BeatData(np.array([0.2, 0.3]), np.array([1, 2])), None)]
    beat_data_2 = [(utils.BeatData(np.array([0.5, 0.7]), np.array([2, 3])), 'beats_2')]
    beat_data_3 = [
        (utils.BeatData(np.array([0.0, 0.3]), np.array([1, 2])), 'beats_1'),
        (utils.BeatData(np.array([0.5, 0.13]), np.array([4, 3])), 'beats_2'),
    ]
    beat_data_4 = (utils.BeatData(np.array([0.0, 0.3]), np.array([1, 2])), 'beats_1')
    beat_data_5 = [
        (utils.BeatData(np.array([0.0, 0.3]), np.array([1, 2])), 'beats_1'),
        [utils.BeatData(np.array([0.5, 0.13]), np.array([4, 3])), 'beats_2'],
    ]
    beat_data_6 = [(None, None)]
    beat_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(beat_data=beat_data_1)
    jam_2 = jams_utils.jams_converter(beat_data=beat_data_2)
    jam_3 = jams_utils.jams_converter(beat_data=beat_data_3)
    jam_6 = jams_utils.jams_converter(beat_data=beat_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'beat', 0)
    assert time == [0.2, 0.3]
    assert duration == [0.0, 0.0]
github mir-dataset-loaders / mirdata / mirdata / groove_midi.py View on Github external
def drum_events(self):
        """EventData: annotated drum kit events"""
        start_times = []
        end_times = []
        events = []
        for note in self.midi.instruments[0].notes:
            start_times.append(note.start)
            end_times.append(note.end)
            events.append(DRUM_MAPPING[note.pitch])
        return utils.EventData(
            np.array(start_times), np.array(end_times), np.array(events)
        )
github mir-dataset-loaders / mirdata / mirdata / rwc_popular.py View on Github external
with open(voca_inst_path, 'r') as fhandle:
        reader = csv.reader(fhandle, delimiter='\t')
        raw_data = []
        for line in reader:
            if line[0] != 'Piece No.':
                raw_data.append(line)

    for i in range(len(raw_data)):
        # Parsing vocal-instrument activity as intervals (beg, end, event)
        if raw_data[i] != raw_data[-1]:
            begs.append(float(raw_data[i][0]))
            ends.append(float(raw_data[i + 1][0]))
            events.append(raw_data[i][1])

    return utils.EventData(np.array(begs), np.array(ends), np.array(events))