Forums > MaxMSP

Scale exponential mode. Reversible?

Mar 14 2009 | 8:08 pm

I’m pretty new to max.
I’m working with the scale object. I have it set to the exact "flow" that I want now. However, I need to be able to take what is coming out of my scale object and convert it back to the original input. Since I’m using an exponent, this is proving to be incredibly difficult to figure out. I’ve attached a patch to better describe what the situation is. I’m not yet hip to the majority of the max lingo.

Mar 14 2009 | 11:47 pm

The [scale] object fifth argument is probably not the way you want to go. I would recommend not using it at all. Ever. Instead you could write your own expression with [expr] or [pow] or you could use Zachary Seldess’ [z.scale] abstraction or one of Peter Castine’s [lp.scampi] or [lp.scampf] externals. Here’s an example using [z.scale] which you can find on the thread linked below. Set your desired last argument and then to flip it back use the inverse as I have done.


— Pasted Max Patch, click to expand. —
Mar 15 2009 | 7:34 am

Thanks so much for your help. I only have time right now to quickly glance at the information you’ve given me so I’m not fully making sense of it all right now. It looks like I’m really going to have to spend some time with this to understand it a little better. Like I said, I’m really new to max and programming in general. I’ve always been on the front end of stuff until recently.
Based on the research I already did (searching the forum), I assumed I was going to get a response telling me not to use the 5th [scale] argument. Which is what sucks because like I said, I really like how I had it set up using [scale] and it was working perfectly for me up til now. Here is some more detail of what I’m trying to accomplish. Hopefully someone will read this and respond with "hey idiot, you’re trying to hard, all you need to do is…"

I’m using an external controller (my iPhone) to control a filtergraph. It’s a 4 band EQ.
I’m using the third page of the "simple" setup of the app Touch OSC on my iPhone to do this (if that helps).
I have it set up to set the frequency and gain of the selected filter with the "xy thing" and then there are 4 toggles that I am using to select which filter (or "band") I am adjusting. I’m currently using the [scale] before the frequency input of the filtergraph with a 5th argument of 1.06 and it’s giving me a really good response for adjusting the frequency of the filtergraph (which I have set as linear as opposed to logarithmic in the inspector). The reason I’m using this 5th argument is because of how frequencygraphs work (and audio in general). When EQing, there is a much bigger difference between 20Hz and 30Hz than there is between 20000Hz and 20020Hz…
When I switch to a different filter (or band) I need to have the location of the "xy thing" on my phone reset to the xy location of that specific filter that I just selected. This is where I need to take the output of the X location and "unscale" it to get something that I can send back to my iPhone.
My phone is sending a value between 0 and 1 that I need to then convert to the frequencies that I will be using (between 10 and 20000).
Hopefully that made some sense to someone. I will follow this up as soon as possible with an example patch.
Thanks again thereishope.

Mar 15 2009 | 10:38 am

I guessed you might be dealing with frequency from your first post. For this task I would recommend using [mtof] and [ftom] which use the correct exponential scaling to convert between midi notes and frequency. You can then use [scale] to map it to the range you want. This is done in the first example.

It is possible to do all this with one [expr] object as illustrated in the second example but you do need to delve into the maths behind it all fairly deeply. If you want me to explain what’s going on in this equation then just ask and I’ll give it a shot.

On a more general note; as a beginner if you get stuck you should open the help files of the objects you are using and have a look at the examples they provide. There will also be a link to the reference page which will explain in detail what the object can do. Another good idea is to look at the help files for all the related objects that appear in the drop down menu. And finally you should definitely work your way through the max and msp tutorials as they are pretty much the best way to learn the basics of the programming language.


— Pasted Max Patch, click to expand. —
Mar 15 2009 | 4:20 pm

Got it! Thanks so much for your help. I just used the z.scale and it fixed the problem perfectly. The z.scale apparently works exactly the way that I thought the [scale] should be working. I was getting into so much ridiculous math trying to convert that back. I was starting to get scared that the only way to get what I wanted was to spend days trying to figure something out like that second example you sent me. I didn’t pay enough attention in math class to be able to bust that out though.
As far as help files and tutorials go, since I picked this up about 2 months ago I’ve been spending every free second I have studying up on them. They are incredibly helpful.
Thanks again!

Mar 15 2009 | 7:08 pm

Hi guys,

Related to this, I just updated z.scale and z.zmap so that they now have an exponential AND a logarithmic mode. In logarithmic mode (which behaves in much the same way as the actual 5th arg of scale) the 5th arg controls the exponential base value of the curve. In exponential mode, the 5th arg controls the exponenent of the curve. Both modes are potentially useful, depending on what you’re scaling for.

The new abstractions are attached, or you can get them here:


Viewing 6 posts - 1 through 6 (of 6 total)

Forums > MaxMSP