pyampact.symbolic.mask

pyampact.symbolic.mask(piece, winms=100, sample_rate=4000, num_harmonics=1, width=0, bpm=60, aFreq=440, base_note=0, tuning_factor=1, obs=24)[source]

Construct a mask from the sampled piano roll using width and harmonics. This builds on the intermediate representations of the pianoRoll and sampled methods. The sampled method already put the x-axis (columns) in regular time intervals. The mask keeps these columns and then alters the y-axis (rows) into frequency bins. The number of bins is determined by the winms and sample_rate values, and is˚ equal to some power of 2 plus 1. The frequency bins serve to “blur” the sampled pitch data that we expect from the score. This allows us to detect real performed sounds in audio recordings that are likely slightly above or below the precise notated pitches. The mask is what allows pyAMPACT to connect symbolic events in a score to observed sounds in an audio recording. Increasing the num_harmonics will also include that many harmonics of a notated score pitch in the mask. Note that the first harmonic is the fundamental frequency which is why the num_harmonics parameter defaults to 1. The width parameter controls how broad or “blurry” the mask is compared to the notated score.

Parameters:
  • winms – Integer, default 100. The window size in milliseconds.

  • sample_rate – Integer, default 2000. The sample rate in Hz.

  • num_harmonics – Integer, default 1. The number of harmonics to use.

  • width – Integer, default 0. The width of the mask.

  • bpm – Integer, default 60. The beats per minute to use for sampling.

  • aFreq – Integer, default 440. The frequency of A4 in Hz.

  • base_note – Integer, default 0. The base MIDI note to use.

  • tuning_factor – Float, default 1. The tuning factor to use.

  • obs – Integer, default 24. The desired observations per second.

Returns:

A DataFrame representing the mask. Each row corresponds to a frequency bin, and each column corresponds to a timepoint in the sampled score. The values are 1 for a note onset and 0 otherwise.