Melodia

Salamon, Justin, and Emilia Gómez. “Melody extraction from polyphonic music signals using pitch contour characteristics.” IEEE Transactions on Audio, Speech, and Language Processing 20.6 (2012): 1759-1770.

@article{salamon2012melody,
  title={Melody extraction from polyphonic music signals using pitch contour characteristics},
  author={Salamon, Justin and G{\'o}mez, Emilia},
  journal={IEEE Transactions on Audio, Speech, and Language Processing},
  volume={20},
  number={6},
  pages={1759--1770},
  year={2012},
  publisher={IEEE}
}
[1]:
import nussl
import matplotlib.pyplot as plt
import time

start_time = time.time()

def visualize_and_embed(estimates):
    plt.figure(figsize=(10, 6))
    plt.subplot(211)
    nussl.utils.visualize_sources_as_masks({
        'Background': estimates[0], 'Foreground': estimates[1]},
        y_axis='mel', db_cutoff=-60, alpha_amount=2.0)

    plt.subplot(212)
    nussl.utils.visualize_sources_as_waveform({
        'Background': estimates[0], 'Foreground': estimates[1]},
        show_legend=False)
    plt.show()
    nussl.play_utils.multitrack(estimates, ['Background', 'Foreground', 'Synth Melody'])

audio_path = nussl.efz_utils.download_audio_file(
    'schoolboy_fascination_excerpt.wav')
audio_signal = nussl.AudioSignal(audio_path)
separator = nussl.separation.primitive.Melodia(
    audio_signal, mask_type='binary')
estimates = separator()
estimates.append(separator.melody_signal * .1)

visualize_and_embed(estimates)
Matching file found at /home/pseetharaman/.nussl/audio/schoolboy_fascination_excerpt.wav, skipping download.
../../_images/examples_primitives_melodia_1_1.png
[2]:
separator = nussl.separation.primitive.Melodia(
    audio_signal, mask_type='soft')
estimates = separator()
estimates.append(separator.melody_signal * .1)
visualize_and_embed(estimates)
../../_images/examples_primitives_melodia_2_0.png
[3]:
separator = nussl.separation.primitive.Melodia(
    audio_signal, apply_vowel_filter=True, mask_type='binary')
estimates = separator()
estimates.append(separator.melody_signal * .1)
visualize_and_embed(estimates)
../../_images/examples_primitives_melodia_3_0.png
[4]:
separator = nussl.separation.primitive.Melodia(
    audio_signal, apply_vowel_filter=True,
    add_lower_octave=True, mask_type='binary')
estimates = separator()
estimates.append(separator.melody_signal * .1)
visualize_and_embed(estimates)
../../_images/examples_primitives_melodia_4_0.png
[5]:
end_time = time.time()
time_taken = end_time - start_time
print(f'Time taken: {time_taken:.4f} seconds')
Time taken: 44.8006 seconds