pyampact.alignment.run_alignment

pyampact.alignment.run_alignment(audio_file, score_file, width=3, target_sr=4000, nharm=3, win_ms=100, hop=32)[source]
Parameters:
  • audio_file (string) – Path to audio file

  • score_file (string) – Path to score/symbolic file

  • width (float) – Width parameter for the DTW alignment.

  • target_sr (int) – Target sample rate for resampling the audio (if needed).

  • nharm (int) – Number of harmonics to include in the analysis.

  • win_ms (float) – Window size in milliseconds for the analysis.

  • hop (int) – Number of samples between successive frames.

Returns:

  • spec (ndarray) – Spectrogram of the audio file.

  • piece (Music21 Object) – All labels in Music21 format

  • newNmat (DataFrame) – Updated DataFrame containing the note matrix (nmat) data after alignment.

  • y (ndarray) – Audio data of audio_file

  • original_sr (int) – Sample rate returned by audio_file

Notes

This function leverages DTW to align MIDI note information with the time series audio signal. It computes onset and offset times and updates the alignment using a similarity matrix. Optionally, it can display the audio spectrogram for visual analysis.