pitch analysis to parameter.

Questions and discussion about building and using Max for Live devices
Post Reply
keefbaker
Posts: 95
Joined: Fri Nov 06, 2009 12:06 pm

pitch analysis to parameter.

Post by keefbaker » Wed Nov 23, 2011 3:47 pm

I may make myself look dim here but what i was after trying to create was a device that examines the incoming pitch of an input, say a wav file, and then outputs that pitch, scaled to a live parameter output.

Does this device already exist and therefore can I be saved the heartache of attempting and failing to make it?

Is pitch analysis of external files possible in max?

What will happen in the next exciting episode of Dangermouse?

galaxiesmerge
Posts: 3
Joined: Tue Feb 24, 2009 10:26 pm
Location: USA
Contact:

Re: pitch analysis to parameter.

Post by galaxiesmerge » Wed Nov 23, 2011 3:58 pm

Pitch analysis can be achieved in the following way for monophonic parameter control:

1) You need to setup a table of the fundamental frequencies, *and* at least a couple of related harmonics in a lookup table
2) Then, you need to perform a Fourier analysis on a waveform buffer to extract the spectrum
3) You need to order that spectrum in a histogram of frequency versus power
4) For each set of the the two or three highest power harmonics, check to see which one is a nearest match to the ones in your lookup table (i.e. you need a fuzzy match) to get your pitch
5) For the average energy around the harmonic, compute a normalized number - this can be your "velocity"
6) Send the velocity and pitch through MIDI to any parameter

You should note that this requires a certain level of expertise in MAX programming but, the tools to do this are all there.

Now, if you want to do *polyphonic pitch*, you need high resolution Fourier and several algorithms to recognize pitches in relation to each other (because sometimes the spectra can confuse algorithms and the wrong notes can be chosen only because of power and not that they are roots, for example, of chords). So polyphony requires relative and musical pitch analysis so you will need to build a table of chords and other information.

I hope this helps.
Don't play what's there, play what's not there.
-Miles Davis

keefbaker
Posts: 95
Joined: Fri Nov 06, 2009 12:06 pm

Re: pitch analysis to parameter.

Post by keefbaker » Wed Nov 23, 2011 4:17 pm

Wow! Ok, thanks. It was monophonic thankfully. I'll look into this and see what I can figure out.

pid
Posts: 354
Joined: Thu Nov 05, 2009 9:51 am

Re: pitch analysis to parameter.

Post by pid » Wed Nov 23, 2011 5:40 pm

that is a fantastic and very funny response from 'galaxiesmerge'.

whilst it is mainly true, i suspect there is a wry grin there somewhere behind his/her post, as the OP's question is so so common, they should really have searched the ableton and cycling 74 forums first to get a more pragmatic answer.

i must be in a weird mood today, here goes:

1. there are 'third party externals' for Max, and thus many many many patches, knocking around, which do all this for you. or at least 'help you along the way'. as with any hugely general question like the op's, it usually demonstrates that the asker has very little clue of the intricacies which go into achieving such a goal. i.e., "it is not as simple as that".
2. in case you do not realise, 'third party externals' are a bit like 'plugins' for max that 'other people' make (as opposed to coming with the standard distro). the ones you need are:
pitch~ for windows and osx
analyzer~ osx only
sigmund~ osx only (there is a windows port, but not by the author, so do not trust it)
if you search www.maxobjects.com or google, you will find them.
many many people will tell you to use the third party "fiddle~" external - do not. ignore them. it is rubbish and old now and does not really work properly. the author of it wrote 'sigmund~' instead, and 'pitch~' is almost identical to 'fiddle~' but slightly better.
3. study these objects, try using them, work out what you need to do, listen to the advice of galaxiesmerge above?
4. you will find that there is a hell of a lot of 'tweaking' and 'customisation' involved depending on your need.

also, do not forget the avg~, average~, peakamp~, etc objects that come with the standard Max distribution - they can be very helpful in these matters.

while galaxiesmerge was mainly correct, there are other ways to do all this. for example the 'wavelet transform'.

in max6 (so soon M4L too we hope) there is a new standard object in the distro which does pitch tracking etc using 'wavelet transform' method called "fzero~". it works very well monophonic, although not so well on piano / some types of bass. the handy thing about wavelet method is that it has less latency (usually) than the fft method.

this issue comes up on the forums all the time. please send people here for a verbose and likely inaccurate answer in the future.
3dot... wrote: in short.. we live in disappointing times..

keefbaker
Posts: 95
Joined: Fri Nov 06, 2009 12:06 pm

Re: pitch analysis to parameter.

Post by keefbaker » Thu Nov 24, 2011 4:15 pm

Ok, fair I should have searched more. But thanks for your help. :D

oddstep
Posts: 1732
Joined: Tue Feb 12, 2008 9:47 pm
Location: Plymouth the great

Re: pitch analysis to parameter.

Post by oddstep » Sun Nov 27, 2011 1:04 pm

I agree with pid. Pitch~ good, fiddle~ didn't work for me.

zlatko
Posts: 116
Joined: Mon Apr 27, 2009 3:34 pm

Re: pitch analysis to parameter.

Post by zlatko » Fri Dec 09, 2011 10:29 pm

you can buid a pitch-follower with auto-correlation and adaptive filters too... however I would love to see Griesinger's 'plus-minus' pitch follower implemented - it seems the most wonderful design with no repercussion in the trade, just caught a glimpse of it in one of his slide shows....
Who else has been sick of 4/4 for the last 10 years ??

www.zlatko.hu

masterblasterofdisaster
Posts: 137
Joined: Sun Nov 13, 2011 3:43 am
Location: Vancouver BC

Re: pitch analysis to parameter.

Post by masterblasterofdisaster » Fri Dec 09, 2011 11:29 pm

zlatko wrote:you can buid a pitch-follower with auto-correlation and adaptive filters too... however I would love to see Griesinger's 'plus-minus' pitch follower implemented - it seems the most wonderful design with no repercussion in the trade, just caught a glimpse of it in one of his slide shows....
That plus/minus pitch detector does look interesting, but I can only find a single slide describing it. Not much to go on. I'd love to find the paper... will keep looking in the meanwhile. I found another pretty fast one that I had begun to implement in C++ that is based on a Haar wavelet transform. Maybe I should finish it...

zlatko
Posts: 116
Joined: Mon Apr 27, 2009 3:34 pm

Re: pitch analysis to parameter.

Post by zlatko » Fri Dec 09, 2011 11:44 pm

yeah, not sure if there is a paper, maybe he figured it doesn't work in the end... :)
it's too good to be true, finding a pitch even if the fundamental is filtered out... hell yeah...

you have wavelet transform running? anything you would share?
Who else has been sick of 4/4 for the last 10 years ??

www.zlatko.hu

masterblasterofdisaster
Posts: 137
Joined: Sun Nov 13, 2011 3:43 am
Location: Vancouver BC

Re: pitch analysis to parameter.

Post by masterblasterofdisaster » Sat Dec 10, 2011 12:02 am

zlatko wrote:yeah, not sure if there is a paper, maybe he figured it doesn't work in the end... :)
it's too good to be true, finding a pitch even if the fundamental is filtered out... hell yeah...

you have wavelet transform running? anything you would share?
I have bits together, but not the whole thing yet. If I ever finish it, I suppose I should look at the max api in the meanwhile (I was originally using the plogue bidule api).

Here's the paper in the meanwhile - matlab code is included at the end.

http://online.physics.uiuc.edu/courses/ ... velets.pdf

ned rush
Posts: 402
Joined: Wed Sep 23, 2009 1:45 pm
Contact:

Re: pitch analysis to parameter.

Post by ned rush » Sun Dec 11, 2011 7:02 pm

I use fiddle~ quite a lot and never had any trouble with it if I scale it's output. I should check out those others at some point.

Post Reply