mat.ffttrig~

AudioMatt's icon

This is some code for finding the centroid of a transient. A click in the right inlet will trigger the analysis. Playing around with it has convinced me it's super useful however I'm not super confident in my C coding so I won't be publishing this as part of any packages. I'm really nervous about memory leaks etc. If someone wants to look it over and possibly alter it, go for it.

It computes an FFT, finds a bark(ish) scale and then gives the centroid of that scale. It's probably great at analyzing table drumming.

Luigi Castelli's icon

Hi Matt,

I gave a quick glance at your code and it has has some issues.
It is not a good idea to make outlet calls from the perform routine.
Read the chapter "Anatomy of a MSP Object" from the Max/MSP SDK.
You want to create and use a clock to schedule outlet calls from the high priority thread.
Since a clock_delay() function will be called from the perform routine, you also need to pay attention not to clog the scheduler by calling the function too often, especially at small vector sizes.
Going from the audio thread to the scheduler thread is not trivial in complex scenarios.
Your scenario is not very complex but you need to take care of a few important things.
I am sorry for being so general, but I don't have time to go into specifics right now...
Maybe someone else may be able to go more in depth...

Hope this helps somehow.
Take care

- Luigi

AudioMatt's icon

Don't be sorry. This is why I didn't distribute it as opposed to just posting the code.
It's good to know this stuff. Guess I have more to learn. Hope I can figure it all out!

It also sounds like it may be smarter to send a click out with my centroid value.

-Matt

AudioMatt's icon

Also if anyone has any further advice here, I'm sort of lost as to what to read. Anatomy of an MSP object is actually *more* general than Luigi.