madmom.features.notes

This module contains note transcription related functionality.

Notes are stored as numpy arrays with the following column definition:

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

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, fmt=None, delimiter='\t', 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.

fmt : list, optional

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

delimiter : str, optional

String or character separating the columns.

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’

class madmom.features.notes.RNNPianoNoteProcessor(**kwargs)[source]

Processor to get a (piano) note activation function from a RNN.

Examples

Create a RNNPianoNoteProcessor and pass a file through the processor to obtain a note onset activation function (sampled with 100 frames per second).

>>> proc = RNNPianoNoteProcessor()
>>> proc  
<madmom.features.notes.RNNPianoNoteProcessor object at 0x...>
>>> act = proc('tests/data/audio/sample.wav')
>>> act.shape
(281, 88)
>>> act  
array([[-0.00014,  0.0002 , ..., -0.     ,  0.     ],
       [ 0.00008,  0.0001 , ...,  0.00006, -0.00001],
       ...,
       [-0.00005, -0.00011, ...,  0.00005, -0.00001],
       [-0.00017,  0.00002, ...,  0.00009, -0.00009]], dtype=float32)