# Note segmentation from pitch values

My goal is to extract a melodic respresentation for monophonic signal like voice.

I have used YIN algorithm to find the pitch of the signal. Now I want to detect notes from the pitch values (like they will change when a note change and become stable when it does not change). So my goal is to segment pitch values into notes so basically I have to:

• split the different sung notes within voiced segments.
• assign a constant pitch value to each estimated note.

So what should be my approach after the pitch estimation ?

(As i have very few DSP experience so I would like a detailed answer. Thank you)

• Thank you. I will definitely check them. But for monophonic signals isn't YIN enough ? Sep 24, 2017 at 13:59
• i just am not impressed with YIN even for monophonic musical signals. i really don't think what YIN offers new (essentially Eqs. (8) and (10) ) is all that useful for anything. take a look at how that second referenced answer shows a form of autocorrelation from just the difference function. and this autocorrelation does not suffer the tapering effect in Eq. (3) of the same reference. you have a direct measure of the periodicity, a caution regarding inaudible subharmonics and how that causes an octave problem, and a means to deal with that. Sep 25, 2017 at 2:42
• I am trying AMDF and see if i can get a better result. How about Two way mismatch algorithm ? Sep 26, 2017 at 16:49
• dunno what "Two way mismatch algorithm" is. never heard that term. once you get a result with AMDF, then try ASDF (square the term rather than $|\cdot|$). they try subtracting $\tfrac12$ ASDF from the energy to get autocorrelation. Consider the method described in this answer. Sep 26, 2017 at 17:49

okay, so 9 hours ago i posted in a comment links to other questions/answers regarding this topic for you to maybe pre-digest.

this is the issue of audio-to-MIDI conversion, which has been discussed, particularly among the Music Information Retrieval(MIR) people. it's not a perfectly solved problem, especially for anything polyphonic. even picking apart a duet is hard.

for monophonic, it's not so hard to get a decent pitch contour plot (that is the detected pitch vs. time) along with a plot for amplitude vs. time and a plot for pitch confidence or tone harmonicity (or the degree of periodicity of the note waveform) vs. time. there are other measures that one can do, such as a few different timbre parameters (like brightness, even/odd harmonic energy ratio).

what would be interesting maybe for you to do is, with your favorite monophonic test file (people often use Tom's Diner from Suzanne Vega) and see what pitch contour you get from YIN. and compare that to the pitch contour you get from using the ASDF (turned into autocorrelation) and peak picking from my other answers:

Fast pitch recognition

How to deal with low fundamental when using AMDF for pitch extraction?

What is an AMDF?

What is the difference between pitch detection and Onset detection?

so first make sure you get a decent pitch contour for your monophonic voice and see if the "octave errors" get patched up before looking for note onsets.

for many notes, the onset is clear by looking at sharp transitions in the amplitude contour curve and in the "harmonicity" curve. but if you're humming and not having any impulsive or sharp beginnings to notes, these curves make it hard to detect note onsets. sometimes then you need to look at somewhat sharper pitch transitions and also when the pitch crosses semi-tone boundaries. but somehow you don't want vibrato to trigger new notes if the vibrato happens to bring your note a little closer to another pitch in the 12 notes per octave scale.

finally, once you do effectively segment your notes, then you need to look at the pitch contour and decide, closer to the note onset, which of the equally-tempered, $\frac1{12}$ octave pitches you are closest to. but that can have a pitch offset if the whole song is a little sharp or a little flat (but the notes are well tuned to each other).

• So from the answer : 1-:I need to get a good pitch curve, 2-: After the pitch curve i have to detect onsets from that(Should i make a running average of pitch and try to find if any pitch value gets higher than the average and detect that an onset ?), 3-: So for each onset change i should get a new note ? 4-:I have to convert the pitch values associated with each note to note values ?........clear me in this things. Thanks Sep 24, 2017 at 13:57
• Also i would appreciate if you know of any publications that convert pitches to notes. Sep 24, 2017 at 13:58
• do you know the MIDI pitch scale with A440 = MIDI Note 69? and do you know that pitch is the logarithm of the fundamental frequency? (and the fundamental frequency is the reciprocal of the period that you get from AMDF or ASDF or autocorrelation or YIN?) MIDI pitch is: $$p = 69 + 12 \cdot \log_2 \left( \frac{f_0}{440 \mathrm{Hz}} \right)$$ where $f_0 = \frac1P$ is the fundamental frequency and $P$ is the period. Sep 25, 2017 at 2:50
• first thing, Nazmus is to get a good pitch contour and do something to patch the octave errors or similar blips in what should be a smooth curve. then you will need to detect note onsets (and *"off"*sets to get the MIDI Note Off message defined). then, for the possibly varying pitch between the onset and offset, you need to make a commitment for what note was intended. usually you emphasize the pitch soon after the onset and model any drifting or glissando as a MIDI Pitch Bend. on the pitch contour (after patching errors), you might want to low-pass filter out the vibrato. Sep 25, 2017 at 19:24