News:

SMF for DIYStompboxes.com!

Main Menu

Pitch detection

Started by potul, August 05, 2011, 05:21:48 PM

Previous topic - Next topic

PRR

> If you ever find a "half cycle AMDF" let us know!

Spoiler:

Can't be done for most musical instruments because the waveform is not symmetric.

Play nominal A=440.

One whole-wave is 2.272727mS.

One half-wave computes as 1.136363mS.

If the wave is 45:55 asymmetric, the first half-cycle is 1.022727mS which computes to 489Hz. The next half-cycle is 1.25mS or 400Hz. Or conversely, 400Hz and 489Hz. ~~4 semitones different, or +/-2 semis from the full-wave pitch. Your half-cycle measurement could give either 400 or 489 depending on pluck-direction or pickup polarity.

You may be able to do better by tracking the 2nd and 3rd harmonics. They full-wave sooner. They will in-general (strings or pipes) not be exact harmonics; but may be a heap closer than +/-2 semis. (I guess this is what the FFT does?)
  • SUPPORTER

Ikedude

Does anyone know of a good resource that delves into the harmonic content of a plucked string?

I'm hoping to find out that the relative magnitude of the harmonics are consistent, at least right after plucking. This probably isn't the case but I can't find much helpful information.


Ikedude

Nice, I saw that but it doesn't delve into the numerical relationships between magnitudes. Say, "for a low E string when its plucked open the magnitude of the 2nd harmonic is roughly equal to the first".

It talks about how the harmonic structure of the sound can be changed and how a guitar can then sound like a clarinet but it doesn't say what it is about the guitar signal that makes it a guitar.

I'm guessing the pluck and pickup position affect the nature of the signal too much to get any kind of consistent result. Maybe if you always struck it the same way, ha.

gritz

The CCRMA stuff is great for theory (especially if you're the sort of person that would skip guitar lessons in favour of math class), but it is pretty light on practical application and the kind of creative nuance that music is all about. There, I said it.

You're absolutely right about the pluck and pickup positions being an essential consideration. A string can simultaneously vibrate in many modes and which modes are created and detected depend on the positions of the pluck and pickup respectively. Imagine "pinging" the harmonic at the 12th fret. What you're doing is holding the string still at that point, so it effectively becomes two strings of half the lenght which naturally vibrate one octave up. If there was a pickup at the 12th fret there would be very little output as the string isn't moving at that point - it's what's called a node. If you pluck an open string at the 12th fret you get a very mellow tone because it's mainly fundamental and there's one point of maximum vibration -in the centre of the string. Moving the pluck away from the centre of the string creates more complex vibration modes. There's a lot of complicated maths out there, but it's really just dividing the string into fractions:

http://labspace.open.ac.uk/mod/resource/view.php?id=437040

Knowing this doesn't make a pitch detector any easier to build though. The human ear seems pretty good at guessing the fundamental from the (regular) spaces between the harmonics, but squeezing the Fourier transform into a pedal isn't easy for a hobbyist either...


Gurner

Quote from: Ikedude on February 21, 2012, 02:59:20 PM
It talks about how the harmonic structure of the sound can be changed and how a guitar can then sound like a clarinet but it doesn't say what it is about the guitar signal that makes it a guitar.

Slightly off topic .....from a human perspective (vs a harmonic perspective which is being discussed here) it's mainly the attack portion of an instrument that humans recognise/differentiate instruments by - Roland sussed this many moons ago & used it to great effect when RAM was still mega expensive...basically they sampled the attack 'signature' of all the different instruments (flute chiffs. violin 'bows', guitar chugs, piano hammer/stikes etc)...used that mini sample as a 'header'...and then slapped a synthesized tail on the back end of it....end result very convincing at with very little memory used. (the technique was called LA synthesis by Roland - http://en.wikipedia.org/wiki/Linear_Arithmetic_synthesis)

bilwit

Definitely interested in this. I'm planning on looking into Autocorrelation with my dsPIC33F in the near future.

potul

Quote from: joenoone on February 07, 2012, 09:21:38 AM
Hey Potul - are you still working on this? If so I ran across this a few weeks ago that might help :

    Nearly Optimal Sparse Fourier Transform - http://arxiv.org/abs/1201.2501

I found a reference to it from Slashdot - http://science.slashdot.org/story/12/01/20/037236/faster-than-fast-fourier-transform


Thanks for the information, but I doubt I will be able to use it without a huge investment in ASM programming... :)
The good thing about using FFT in dsPIC is that there are optimized routines in C that can use all the powerhorse of the uC

One example.... I tried to do a "custom" autocorrelation algorithm to stop calculating when a match is found, and it worked, but it took much longer than simply running the built in correlation in C. I'm not saying it can't be done, but it's out of my ASM capabilities.

BTW, just one warning... if you ever try to use the correlation function in dsPIC be aware that there are some wrong pieces of information in the datasheet. It took me some time to troubleshoot.