Converting Linear Data Stream to Logarithmic

John Kammerer's icon

I've started working with a Microsoft Kinect, and for now I've (arbitrarily) scaled the incoming data streams coming into Max to a 0-127 range. Some of the parameters I want to control are filter frequencies, which don't work well being controlled by the linear data I'm currently receiving.

My question is: how would I go about changing the incoming linear data to a logarithmic scale suitable for use with frequency?

I've tried a few methods so far, all of which either flat-out don't work, or end up being only vague approximations of the curve I need to generate, but I'd like to make this precise. I'm assuming it involves writing an equation with the [expr] object, but my math skills are pretty weak.

Any help is appreciated, thank you!

metamax's icon

Do you have specific equations in mind or just an idea of a curve? You can do all kinds of stuff.

Here's a good starting point.

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

the one thing is scaling. the other thing is interpolation.

John Kammerer's icon

Just the idea of a curve, I think. I like the patch you posted Metamax, great for visualizing this, thanks.

I ended up using a [linedrive] object with a 3rd argument of 1.06. This seems to get me the curve I'm looking for, but I don't understand the math behind it.

Max Patch
Copy patch and select New From Clipboard in Max.

Anyone have any answers as to why 1.06 seems to create the correct curve so that the frequency sweep seems to occur evenly across the range?

Rodrigo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is my go-to curve tester patch. Lots of options and ways to go with it. I just go 0. to 1. and then scale it to the actual range (otherwise the scaling goes funny).

Rodrigo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

There's this part of it too (combined it's too big to copy/paste into forum).

metamax's icon

Here are a few S-curves that are used in motion tweening.

Max Patch
Copy patch and select New From Clipboard in Max.

Rodrigo's icon

Ooh, those are nice. *saved to scaling/remapping/curve patch*

metamax's icon

I recently updated all of my interpolation patches to handle both lists and matrices (in Gen) with some interesting results. The most obvious affect in video is gamma but many variables can be associated with the output.

Here is an example with lists. If someone has a more efficient solution to my use of the pipe object, I would be grateful.

Enjoy!

Max Patch
Copy patch and select New From Clipboard in Max.

metamax's icon

Rodrigo, thanks! I have more than a couple of your patches in my collection.

Rodrigo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Something like this?

metamax's icon

Hmm.. I don't think so. Note the behavior of the sliders when manually adjusting the main slider in my last patch. Each list element is independently delayed. After releasing the slider, the effect doesn't just stop, it levels off. The delay time increases 100ms for each element. I was hoping a single object could do that. Some kind of stream/pipe thingy.

/thread hijack

Rodrigo's icon

Yeah I see.

Maybe some kind of [zl iter] -> [pipe 100] -> [zl group 16], so you don't have to manually increment the pipe that way?

Roman Thilenius's icon

you all know what we would normally use first in place when converting linear to frequency, dont you.

metamax's icon

you all know what we would normally use first in place when converting linear to frequency, dont you.

Some sort of table lookup?

Floating Point's icon

mtof of course

John Kammerer's icon

Rodrigo, these are fantastic, thanks!