store all data from pfft

    Feb 04 2010 | 8:50 am
    I am really new to Max, so my question may sound a bit dumb ...
    I'm in my second (and last) Master year for Piano. For my end work i am trying to write a program that can analyse the music and determine wich cord(s) are played. Never good luck, but now a friend of me suggested i should use MaxMSP, and as far as I see he is wright.
    I looked into the 'Forbidden Planet'-example and its showing me iits up for the job. He analyses the data with a Fast Fourier Transform module and gives an output from the frequencies set in the filter.
    This is my idea: I need the fft to output everything (frequencie's with there amplitude) so I can filter the notes and determine wich are played (probably i will run into problems to determine upper and lowernotes from notes that are actualy played).
    So: is it possible to make (p)fft~ give a textual output of all the frequencies he found (with there amplitude) to work with?
    Thanks in advance Hans

    • Feb 05 2010 | 3:28 am
      Seconded, this is good advice!
    • Feb 08 2010 | 10:54 am
      I have a windows/linux machine... it seems that most of the externals are for Mac only. I am now trying to work with pitch~. The others won't run on a Windows machine... ro bad, espacially the fiddle~ seems a very good one to me.
      But still I don't get it, a Fourier Transform is analysing the waves, why isn't it possible to just store all the data and work with it? Probably i am asking a very stupid question, but if i can analyse it, why can't i store the data from the (P)FFT?
    • Feb 08 2010 | 11:40 am
      A Fourier Transform might analyze waves, but doesn't do that in order to make a statement about the content of those wave: based on a given set of sine waves, it calculates how to mix them together in order to get the original wave. And that is quite far from analyzing pitches, let alone chords. It is not impossible, but the data from the FFT recipe needs to be reworked. This reworking is the tricky part. The chef working at Melodyne does a good job at realizing what is described as the holy grail of computer music: make an out of tune singer sound in tune.
      In the meantime you could use sfrecord~ to capture the values from a cartopol~ and (after some scaling) have a view of the harmonic content.
      _ johan
    • Feb 08 2010 | 12:06 pm
      The spectrum of a single piano note is already complex, as it has a lot of harmonics, just think about how would you distinguish a played fifth interval from a single note? The fifth just adds to the energy of the harmonics from the fundamental note. Not impossible, but tricky, certainly not a beginners task... But if you simply play on a digital piano, all is easy, Midi is pretty straight forward... There is also an external from Arshia Cont at This external is optimized for analyzing piano. But as for the lack of an own piano I didn't try it...
      Good luck,
    • Feb 10 2010 | 10:58 am
      I know that the spectrum of a single note is complex, that's no problem, as a student at the Lemmens institute we learned what this spectrum is, it determines the colour of the sound (it is determined by the upper (and lower) notes).
      The ultimate purpose of my end work is developing an educational help by digitalizing the sheet music, show it on a touch screen (so the player can make notes). De computer is able to 'follow' the music and show wrongfully played notes and 'turn' the pages.
      It seems like the pitch~ external is doing the job, it can output up to 100 frequencies with there amplitude. So it has to go in a filter that determines (based on the amplitude) which notes are played and which are upper notes. The played notes are going into a midi and are compared with the ones in the sheet music.
      I will start again with the help file of pitch~ as a base.
      I really appreciate your help.
    • Mar 13 2010 | 11:19 am
      I did some work, and I'm really stunned of Max/MSP's possibilities. The patch I worked on is attached, there's only one problem: pitch~ seems to fail in analysing low frequencies... For the upper part of the keyboard everything works just great.
      I was thinking that a FFT needs at least one complete wave to analyse a frequency, is it possible that the samples are to small for low frequencies so there can't be a complete wave in one?
      My patch is attached, in the zip I included the pitch~ external and the fftw3.dll used to analyse (fftw3.dll should be in your max folder)
    • Mar 31 2010 | 7:47 pm
      Hi Artexanis,,briefly, if I understood well, you can use pfft~ and transform your sound in matrices with Jitter, then you can analize the sound on the fly using jit.cellblock and visualize/edit/retrieve any single value stored in a cell: 2 planes > amplitude and phase. From this analysis you can obtain the fundamental frequency of every frame (or a group of frames) and so the harmonics too...or many other infos that you can use to transform the sound or to make a midi score.