madmom.features.notes

This module contains note transcription related functionality.

madmom.features.notes.load_notes(*args, **kwargs)[source]

Load the notes from a file.

Parameters:

filename : str or file handle

Input file to load the notes from.

Returns:

numpy array

Notes.

Notes

The file format must be (duration and velocity being optional):

‘note_time’ ‘MIDI_note’ [‘duration’ [‘MIDI_velocity’]]

with one note per line and individual fields separated by whitespace.

madmom.features.notes.expand_notes(notes, duration=0.6, velocity=100)[source]

Expand the notes to include all columns.

Parameters:

notes : numpy array, shape (num_notes, 2)

Notes, one per row (column definition see notes).

duration : float, optional

Note duration if not defined by notes.

velocity : int, optional

Note velocity if not defined by notes.

Returns:

numpy array

Notes (including note duration and velocity).

Notes

The note columns format must be (duration and velocity being optional):

‘note_time’ ‘MIDI_note’ [‘duration’ [‘MIDI_velocity’]]

madmom.features.notes.write_notes(notes, filename, sep='\t', fmt=None, header='')[source]

Write the notes to a file (as many columns as given).

Parameters:

notes : numpy array, shape (num_notes, 2)

Notes, one per row (column definition see notes).

filename : str or file handle

Output filename or handle.

sep : str, optional

Separator for the fields.

fmt : list, optional

Format of the fields (i.e. columns, see notes)

header : str, optional

Header to be written (as a comment).

Returns:

numpy array

Notes.

Notes

The note columns format must be (duration and velocity being optional):

‘note_time’ ‘MIDI_note’ [‘duration’ [‘MIDI_velocity’]]

madmom.features.notes.write_midi(notes, filename, duration=0.6, velocity=100)[source]

Write the notes to a MIDI file.

Parameters:

notes : numpy array, shape (num_notes, 2)

Notes, one per row (column definition see notes).

filename : str

Output MIDI file.

duration : float, optional

Note duration if not defined by notes.

velocity : int, optional

Note velocity if not defined by notes.

Returns:

numpy array

Notes (including note length and velocity).

Notes

The note columns format must be (duration and velocity being optional):

‘note_time’ ‘MIDI_note’ [‘duration’ [‘MIDI_velocity’]]

madmom.features.notes.write_mirex_format(notes, filename, duration=0.6)[source]

Write the frequencies of the notes to file (in MIREX format).

Parameters:

notes : numpy array, shape (num_notes, 2)

Notes, one per row (column definition see notes).

filename : str or file handle

Output filename or handle.

duration : float, optional

Note duration if not defined by notes.

Returns:

numpy array

Notes in MIREX format.

Notes

The note columns format must be (duration and velocity being optional):

‘note_time’ ‘MIDI_note’ [‘duration’ [‘MIDI_velocity’]]

The output format required by MIREX is:

‘onset_time’ ‘offset_time’ ‘note_frequency’

madmom.features.notes.note_reshaper(notes)[source]

Reshapes the activations produced by a RNN to have the right shape.

Parameters:

notes : numpy array

Note activations.

Returns:

numpy array

Reshaped array to represent the 88 MIDI notes.