Jul 31 2008 | 3:00 pm

- Jul 31 2008 | 3:15 pmi'm not sure i understand what ur after, but this patch might help if u want to be able to control the curve (log factor):j
- Jul 31 2008 | 3:26 pmYes, this is helpful. So what you have done here is take (x/127) to the y power and multiply by 100.So,((x/(xn-1))^ywould be a useful equation to use, in general?
- Jul 31 2008 | 3:28 pmI'm also interested in applying this to cycle~, so that cycle~ could output waves logarithmically. How would one go about this?
- Jul 31 2008 | 3:37 pmnevermind
- Jul 31 2008 | 3:40 pmQuote: laotze wrote on Thu, 31 July 2008 16:28----------------------------------------------------> I'm also interested in applying this to cycle~, so that cycle~ could output waves logarithmically. How would one go about this?----------------------------------------------------i'm sorry i dont understand what u mean by outputting waves logarithmically? what would be the purpose, or try to describe what ur trying to achieve?j
- Aug 01 2008 | 6:16 pmJay Bodley schrieb:> I am wondering how Max computes on a logarithmic scale.There are a lot of ways to do that, the most universal is expr, but formusical purposes, there are mtof, ftom, atodb and dbtoa which transformcommon human perception curves (loudness/amplitude and pitch/frequency)Stefan--Stefan Tiedje------------x---------_____-----------|----------------(_|_ ----|-----|-----()--------- _|_)----|-----()------------------------()--------www.ccmix.com
- Aug 02 2008 | 12:29 amUsing [expr] you can use natural log and log base 10.However you can use maths laws to translate these to work in any base you want. For example this is helpful if you want to play microtonal music using something other than 12 equal divisions of the octave (12 EDO or 12 TET).Here are some two [expr]s which show how MIDI pitch number and frequency are related logarithmically. Basically they are equivalent to [mtof] and [ftom] but you can see (and hopefully understand) all the maths going on inside.There is also a mathematical expression I have worked out that transforms 0-127 linear range into the [filtergraph~] logarithmic range of 20-20000. You might find this helpful for any filter GUIs as you will find that using a standard [num] or [float] box you move through low frequencies quickly and high frequencies really slowly!I hope this helps in some way.lhmax v2;
- Aug 04 2008 | 10:45 amthanks for your examples! for the sake of deeper understanding - wouldyou mind telling us what the two values 119.589417 and 15.48682 standfor in your equation?p> There is also a mathematical expression I have worked out that transforms 0-127 linear range into the [filtergraph~] logarithmic range of 20-20000. You might find this helpful for any filter GUIs as you will find that using a standard [num] or [float] box you move through low frequencies quickly and high frequencies really slowly!>> I hope this helps in some way.>> lh>>>--http://pure.test.athttp://www.myspace.com/pvre
- Aug 04 2008 | 11:31 amOf course! Sorry for not explaining it in the original post.Those numbers are simply there to scale the output of the [mtof] equation to fit the boundaries 20-20000Hz. If you run the MIDI range 0-127 straight into [mtof] then the range is something like 8.2-12553Hz which isn't ideal. You could simply use a [scale] object mapping the values you get straight to the audible audio frequency range. Perhaps try:[scale 8.1758 12543.85 20. 20000.].However I decided to do it using maths. To get these numbers I sent 20 and 20000 to my [ftom] equation. In this case using the [ftom] object doesn't work because it only returns integers. The results were:20Hz = 15.4868220000Hz = 135.076233difference = 119.589417Now to use these in the [mtof] equation we need to take the original input ($i1) and replace it with a new equation. First we scale the 0-127 range to 0-1. Then we multiply this by the difference between our desired range. Finally we add on the minimum value.$i1/127.*119.589417+15.48682Substituting this equation in to the original [mtof] gives us the final result. I hope this has helped you understand, I have tried to explain it as clearly as possible. If you'd like to see the equations for [atodb] and [dbtoa] then let me know. They were much simpler to work out.lh
- Aug 04 2008 | 4:10 pm=)))ok, i thought its some magic numbers like pi or 1/sqrt(2) or something.so you simply stretched mtof to 20-20000?thanks for the demystification!pLuke wrote:> Of course! Sorry for not explaining it in the original post.>> Those numbers are simply there to scale the output of the [mtof] equation to fit the boundaries 20-20000Hz. If you run the MIDI range 0-127 straight into [mtof] then the range is something like 8.2-12553Hz which isn't ideal. You could simply use a [scale] object mapping the values you get straight to the audible audio frequency range. Perhaps try:>> [scale 8.1758 12543.85 20. 20000.].>> However I decided to do it using maths. To get these numbers I sent 20 and 20000 to my [ftom] equation. In this case using the [ftom] object doesn't work because it only returns integers. The results were:>> 20Hz = 15.48682> 20000Hz = 135.076233> difference = 119.589417>> Now to use these in the [mtof] equation we need to take the original input ($i1) and replace it with a new equation. First we scale the 0-127 range to 0-1. Then we multiply this by the difference between our desired range. Finally we add on the minimum value.>> $i1/127.*119.589417+15.48682>> Substituting this equation in to the original [mtof] gives us the final result. I hope this has helped you understand, I have tried to explain it as clearly as possible. If you'd like to see the equations for [atodb] and [dbtoa] then let me know. They were much simpler to work out.>> lh>>>--http://pure.test.athttp://www.myspace.com/pvre
- Aug 06 2008 | 1:43 pmLuke schrieb:> In this case using the [ftom] object doesn't work because it only> returns integers. The results were:give ftom a float argument and it will spit out floats...Stefan--Stefan Tiedje------------x---------_____-----------|----------------(_|_ ----|-----|-----()--------- _|_)----|-----()------------------------()--------www.ccmix.com
- Aug 09 2008 | 6:47 amLuke (thereishopeforus, for some reason I think your name is luke, am I correct?)Any chance you could explain your ftom equation? I need to make it work to output numbers from 1-256.I need to have a logathmic slider, like the one in your example, but the user needs to be able to type in frequency values in the numeric box and have it update the slider position correctly, by using a [float] object and some set $1 messages.It would be greatly appreciated!
- Aug 09 2008 | 11:16 pmSure.The log() bit switches from a linear to logarithmic scale, to be specific using the twelfth root of two which is the equation used to work out frequencies in 12 tone equal temperament (equal divisions of the octave).The $f1/440 and +69 bits on there are to work this out relative to concert A = 440Hz. This would give you midi note values.The -15/119*127 bit then scales the midi note value output between 0 and 127 for the pitches 20-20000Hz. I've explained how I got these numbers in a previous post on this topic. Assuming you want to still use this frequency range then all you need to do to get the output value 0-255 is replace the final "127" with "255".lh (the l is for luke)max v2;
- Apr 09 2016 | 10:01 pmHi Luke.I just came across you post.I need to scale 20-20000 to 0-127, so the other way around.How would the formula look this way around?I'd appreciate your help a lot.Thanks, Josef
- Apr 10 2016 | 6:03 pmyou probably want to convert Hz to note numbers, this is what [ftom] does.otherwise you´d scale ranges by- normalise the input range to base 0- divide thu input range width- multiply by output range width- add output range offsetand do it in floating point, and then round.- 20/ 189980* 127+ 0.5intthat would be about what [scale] or [zmap] are doing , too...