amads.algorithms.slice.salami#

Salami slice algorithm for segmenting musical scores.

This module implements the salami slice algorithm, which segments a musical score into vertical slices at each note onset and offset. Each slice contains all notes that are sounding at that point in time.

Notes

The algorithm is named after the way a salami sausage is sliced into thin, vertical segments.

Author#

Peter Harrison

class amads.algorithms.slice.salami.Timepoint(time, note_ons=<factory>, note_offs=<factory>, sounding_notes=<factory>) None[source]#

A point in time with associated note events.

Parameters:
  • time (float) – The time in seconds

  • note_ons (list[Note]) – Notes that start at this timepoint

  • note_offs (list[Note]) – Notes that end at this timepoint

  • sounding_notes (set[Note]) – All notes that are sounding at this timepoint

classmethod from_notes(notes, time_n_digits=None) List[Timepoint][source]#

Create a sequence of timepoints from a list of notes.

Parameters:
  • notes (List[Note]) – The notes to process

  • time_n_digits (int, optional) – Number of decimal places to round times to

Returns:

Sequence of timepoints with associated note events

Return type:

List[Timepoint]

property last_note_end#

Get the end time of the last note sounding at this timepoint.

Returns:

The end time

Return type:

float

amads.algorithms.slice.salami.salami_slice(passage, remove_duplicated_pitches=True, include_empty_slices=False, include_note_end_slices=True, min_slice_duration=0.01) List[Slice][source]#

Segment a musical passage into vertical slices at note onsets and offsets (‘salami slices’).

Parameters:
  • passage (Score or Iterable[Note]) – The musical passage to slice

  • remove_duplicated_pitches (bool, default=True) – Whether to remove duplicate pitches within each slice

  • include_empty_slices (bool, default=False) – Whether to include slices with no sounding notes

  • include_note_end_slices (bool, default=True) – Whether to create slices at note ends

  • min_slice_duration (float, default=0.01) – Minimum duration for a slice to be included

Returns:

The sequence of vertical slices

Return type:

List[Slice]