[Csnd] OT: Math wizard needed (!) - linear to log-log scaling
Date | 2010-08-07 13:49 |
From | Peiman Khosravi |
Subject | [Csnd] OT: Math wizard needed (!) - linear to log-log scaling |
Dear all, I have a math question which is not directly related to Csound. I am using Emmanuel Jourdan's javascript-based function-editor in Max to graphically alter a csound table (for FFTools). I would like to hack the script code to change the graph display from linear to log-log. So I would need the range and domain in the graph (x&y axis) to be scaled logarithmically. I have found the bit in the code where the formula needs to be inserted but my knowledge of math is rather limited. In short this section of the javascript is taking the pixel value (of the inserted points) from the table's GUI and scaling it (linearly) to correspond with the x or y values defined by the size of the range and domain. I would really appreciate if a math wizard could point me in the right direction as to the Math formula to scale the pixel values logarithmically, prior to converting them to x/y values? I know that I'd need to use a combination of Math.pow and probably Math.exp but that's about it!! I don't expect a javascript-specific answer but just in case you are interested here is the relevant bit of the script (for the x axis). Of course your help will be acknowledge. return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) So courbe.PixelDomain is the value that needs to be scaled logarithmically before being scaled to the domain size (x). Or at least that's what I think!! Thanks very very much in advance. Best Peiman PS feel free to contact me directly if you don't want to clutter the list. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-07 15:05 |
From | Peiman Khosravi |
Subject | [Csnd] Re: OT: Math wizard needed (!) - linear to log-log scaling |
To simplify the question: Given a range (say 0-10) how can I scale all the number within that range logarithmically to another range (say 0-100)? Thanks P On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: > Dear all, > > I have a math question which is not directly related to Csound. > > I am using Emmanuel Jourdan's javascript-based function-editor in > Max to graphically alter a csound table (for FFTools). > > I would like to hack the script code to change the graph display > from linear to log-log. So I would need the range and domain in the > graph (x&y axis) to be scaled logarithmically. I have found the bit > in the code where the formula needs to be inserted but my knowledge > of math is rather limited. > > In short this section of the javascript is taking the pixel value > (of the inserted points) from the table's GUI and scaling it > (linearly) to correspond with the x or y values defined by the size > of the range and domain. > > I would really appreciate if a math wizard could point me in the > right direction as to the Math formula to scale the pixel values > logarithmically, prior to converting them to x/y values? I know that > I'd need to use a combination of Math.pow and probably Math.exp but > that's about it!! > > I don't expect a javascript-specific answer but just in case you are > interested here is the relevant bit of the script (for the x axis). > Of course your help will be acknowledge. > > return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) > > So courbe.PixelDomain is the value that needs to be scaled > logarithmically before being scaled to the domain size (x). Or at > least that's what I think!! > > Thanks very very much in advance. > > Best > > Peiman > > PS feel free to contact me directly if you don't want to clutter the > list. > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-07 16:07 |
From | alistair zaldua <26.a.12.4.21.a@googlemail.com> |
Subject | [Csnd] Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
Dear Peiman, Surely you need to know how many steps to scale that range properly? Musical scales are logarithmic as well: The old example is this: Given 440 Hz (chamber music A), you need to have 12 steps to get to the octave above, 880 Hz so: 2 to the power of 1/12 = 1.0594631(this is the factor, so always multiply every further step/frequency by this number) 440 * 1.0594631 = 466.16 (= B flat) 466 * 1.0594631 = 493.8833 (=B natural) 493.88 * 1.0594631 = 523.251 (= C) etc etc until … 830.609 (G#) * 1.0594631 = 880 (A again) I expect that wasn't what you were looking for ? yes? no? Sorry, if I completely misunderstood. :-) Greetings, alistair On Sat, Aug 7, 2010 at 4:05 PM, Peiman Khosravi <peimankhosravi@gmail.com> wrote: To simplify the question: |
Date | 2010-08-07 20:41 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
Maybe what you are looking is something like this (exponential interpolation): y(x) = y1 * (y2/y1)^x where x is your linear range (0 - 1) y1 is your starting point (of your new range) y2 is the end point. so you can start by normalising the original linear range and then you can convert. Mind you, neither y1 or y2 can be zero. Example: 0 - 10 to 1 - 100: (100)^(x/10) Victor On 7 Aug 2010, at 15:05, Peiman Khosravi wrote: > To simplify the question: > > Given a range (say 0-10) how can I scale all the number within that > range logarithmically to another range (say 0-100)? > > Thanks > > P > > On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: > >> Dear all, >> >> I have a math question which is not directly related to Csound. >> >> I am using Emmanuel Jourdan's javascript-based function-editor in >> Max to graphically alter a csound table (for FFTools). >> >> I would like to hack the script code to change the graph display >> from linear to log-log. So I would need the range and domain in the >> graph (x&y axis) to be scaled logarithmically. I have found the bit >> in the code where the formula needs to be inserted but my knowledge >> of math is rather limited. >> >> In short this section of the javascript is taking the pixel value >> (of the inserted points) from the table's GUI and scaling it >> (linearly) to correspond with the x or y values defined by the size >> of the range and domain. >> >> I would really appreciate if a math wizard could point me in the >> right direction as to the Math formula to scale the pixel values >> logarithmically, prior to converting them to x/y values? I know >> that I'd need to use a combination of Math.pow and probably >> Math.exp but that's about it!! >> >> I don't expect a javascript-specific answer but just in case you >> are interested here is the relevant bit of the script (for the x >> axis). Of course your help will be acknowledge. >> >> return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) >> >> So courbe.PixelDomain is the value that needs to be scaled >> logarithmically before being scaled to the domain size (x). Or at >> least that's what I think!! >> >> Thanks very very much in advance. >> >> Best >> >> Peiman >> >> PS feel free to contact me directly if you don't want to clutter >> the list. >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-07 21:00 |
From | Peiman Khosravi |
Subject | [Csnd] Re: Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
Thanks very much Victor. Just one question. How can the starting point of the second range be zero? Since I can't do y2/y1 when y1=0... Best, Peiman On 7 Aug 2010, at 20:41, Victor Lazzarini wrote: > Maybe what you are looking is something like this (exponential > interpolation): > > y(x) = y1 * (y2/y1)^x > > where x is your linear range (0 - 1) > y1 is your starting point (of your new range) > y2 is the end point. > > so you can start by normalising the original linear range and then > you can convert. Mind you, neither y1 or y2 can be zero. > Example: 0 - 10 to 1 - 100: > > (100)^(x/10) > > Victor > > On 7 Aug 2010, at 15:05, Peiman Khosravi wrote: > >> To simplify the question: >> >> Given a range (say 0-10) how can I scale all the number within that >> range logarithmically to another range (say 0-100)? >> >> Thanks >> >> P >> >> On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: >> >>> Dear all, >>> >>> I have a math question which is not directly related to Csound. >>> >>> I am using Emmanuel Jourdan's javascript-based function-editor in >>> Max to graphically alter a csound table (for FFTools). >>> >>> I would like to hack the script code to change the graph display >>> from linear to log-log. So I would need the range and domain in >>> the graph (x&y axis) to be scaled logarithmically. I have found >>> the bit in the code where the formula needs to be inserted but my >>> knowledge of math is rather limited. >>> >>> In short this section of the javascript is taking the pixel value >>> (of the inserted points) from the table's GUI and scaling it >>> (linearly) to correspond with the x or y values defined by the >>> size of the range and domain. >>> >>> I would really appreciate if a math wizard could point me in the >>> right direction as to the Math formula to scale the pixel values >>> logarithmically, prior to converting them to x/y values? I know >>> that I'd need to use a combination of Math.pow and probably >>> Math.exp but that's about it!! >>> >>> I don't expect a javascript-specific answer but just in case you >>> are interested here is the relevant bit of the script (for the x >>> axis). Of course your help will be acknowledge. >>> >>> return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) >>> >>> So courbe.PixelDomain is the value that needs to be scaled >>> logarithmically before being scaled to the domain size (x). Or at >>> least that's what I think!! >>> >>> Thanks very very much in advance. >>> >>> Best >>> >>> Peiman >>> >>> PS feel free to contact me directly if you don't want to clutter >>> the list. >>> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-07 21:09 |
From | Peiman Khosravi |
Subject | [Csnd] Re: Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
ahhh didn't read the last line (well read it but it didn't register!!) Thanks P On 7 Aug 2010, at 20:41, Victor Lazzarini wrote: > Maybe what you are looking is something like this (exponential > interpolation): > > y(x) = y1 * (y2/y1)^x > > where x is your linear range (0 - 1) > y1 is your starting point (of your new range) > y2 is the end point. > > so you can start by normalising the original linear range and then > you can convert. Mind you, neither y1 or y2 can be zero. > Example: 0 - 10 to 1 - 100: > > (100)^(x/10) > > Victor > > On 7 Aug 2010, at 15:05, Peiman Khosravi wrote: > >> To simplify the question: >> >> Given a range (say 0-10) how can I scale all the number within that >> range logarithmically to another range (say 0-100)? >> >> Thanks >> >> P >> >> On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: >> >>> Dear all, >>> >>> I have a math question which is not directly related to Csound. >>> >>> I am using Emmanuel Jourdan's javascript-based function-editor in >>> Max to graphically alter a csound table (for FFTools). >>> >>> I would like to hack the script code to change the graph display >>> from linear to log-log. So I would need the range and domain in >>> the graph (x&y axis) to be scaled logarithmically. I have found >>> the bit in the code where the formula needs to be inserted but my >>> knowledge of math is rather limited. >>> >>> In short this section of the javascript is taking the pixel value >>> (of the inserted points) from the table's GUI and scaling it >>> (linearly) to correspond with the x or y values defined by the >>> size of the range and domain. >>> >>> I would really appreciate if a math wizard could point me in the >>> right direction as to the Math formula to scale the pixel values >>> logarithmically, prior to converting them to x/y values? I know >>> that I'd need to use a combination of Math.pow and probably >>> Math.exp but that's about it!! >>> >>> I don't expect a javascript-specific answer but just in case you >>> are interested here is the relevant bit of the script (for the x >>> axis). Of course your help will be acknowledge. >>> >>> return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) >>> >>> So courbe.PixelDomain is the value that needs to be scaled >>> logarithmically before being scaled to the domain size (x). Or at >>> least that's what I think!! >>> >>> Thanks very very much in advance. >>> >>> Best >>> >>> Peiman >>> >>> PS feel free to contact me directly if you don't want to clutter >>> the list. >>> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-08 00:31 |
From | Peiman Khosravi |
Subject | [Csnd] Re: Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
Just to let you know Victor that your formula does the job and is working perfectly :-) Thanks again. Peiman On 7 Aug 2010, at 20:41, Victor Lazzarini wrote: > Maybe what you are looking is something like this (exponential > interpolation): > > y(x) = y1 * (y2/y1)^x > > where x is your linear range (0 - 1) > y1 is your starting point (of your new range) > y2 is the end point. > > so you can start by normalising the original linear range and then > you can convert. Mind you, neither y1 or y2 can be zero. > Example: 0 - 10 to 1 - 100: > > (100)^(x/10) > > Victor > > On 7 Aug 2010, at 15:05, Peiman Khosravi wrote: > >> To simplify the question: >> >> Given a range (say 0-10) how can I scale all the number within that >> range logarithmically to another range (say 0-100)? >> >> Thanks >> >> P >> >> On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: >> >>> Dear all, >>> >>> I have a math question which is not directly related to Csound. >>> >>> I am using Emmanuel Jourdan's javascript-based function-editor in >>> Max to graphically alter a csound table (for FFTools). >>> >>> I would like to hack the script code to change the graph display >>> from linear to log-log. So I would need the range and domain in >>> the graph (x&y axis) to be scaled logarithmically. I have found >>> the bit in the code where the formula needs to be inserted but my >>> knowledge of math is rather limited. >>> >>> In short this section of the javascript is taking the pixel value >>> (of the inserted points) from the table's GUI and scaling it >>> (linearly) to correspond with the x or y values defined by the >>> size of the range and domain. >>> >>> I would really appreciate if a math wizard could point me in the >>> right direction as to the Math formula to scale the pixel values >>> logarithmically, prior to converting them to x/y values? I know >>> that I'd need to use a combination of Math.pow and probably >>> Math.exp but that's about it!! >>> >>> I don't expect a javascript-specific answer but just in case you >>> are interested here is the relevant bit of the script (for the x >>> axis). Of course your help will be acknowledge. >>> >>> return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) >>> >>> So courbe.PixelDomain is the value that needs to be scaled >>> logarithmically before being scaled to the domain size (x). Or at >>> least that's what I think!! >>> >>> Thanks very very much in advance. >>> >>> Best >>> >>> Peiman >>> >>> PS feel free to contact me directly if you don't want to clutter >>> the list. >>> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-08-08 09:13 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: OT: Math wizard needed (!) - linear to log-log scaling |
Glad to be of assistance. On 8 Aug 2010, at 00:31, Peiman Khosravi wrote: > Just to let you know Victor that your formula does the job and is > working perfectly :-) > > Thanks again. > > Peiman > > On 7 Aug 2010, at 20:41, Victor Lazzarini wrote: > >> Maybe what you are looking is something like this (exponential >> interpolation): >> >> y(x) = y1 * (y2/y1)^x >> >> where x is your linear range (0 - 1) >> y1 is your starting point (of your new range) >> y2 is the end point. >> >> so you can start by normalising the original linear range and then >> you can convert. Mind you, neither y1 or y2 can be zero. >> Example: 0 - 10 to 1 - 100: >> >> (100)^(x/10) >> >> Victor >> >> On 7 Aug 2010, at 15:05, Peiman Khosravi wrote: >> >>> To simplify the question: >>> >>> Given a range (say 0-10) how can I scale all the number within >>> that range logarithmically to another range (say 0-100)? >>> >>> Thanks >>> >>> P >>> >>> On 7 Aug 2010, at 13:49, Peiman Khosravi wrote: >>> >>>> Dear all, >>>> >>>> I have a math question which is not directly related to Csound. >>>> >>>> I am using Emmanuel Jourdan's javascript-based function-editor in >>>> Max to graphically alter a csound table (for FFTools). >>>> >>>> I would like to hack the script code to change the graph display >>>> from linear to log-log. So I would need the range and domain in >>>> the graph (x&y axis) to be scaled logarithmically. I have found >>>> the bit in the code where the formula needs to be inserted but my >>>> knowledge of math is rather limited. >>>> >>>> In short this section of the javascript is taking the pixel value >>>> (of the inserted points) from the table's GUI and scaling it >>>> (linearly) to correspond with the x or y values defined by the >>>> size of the range and domain. >>>> >>>> I would really appreciate if a math wizard could point me in the >>>> right direction as to the Math formula to scale the pixel values >>>> logarithmically, prior to converting them to x/y values? I know >>>> that I'd need to use a combination of Math.pow and probably >>>> Math.exp but that's about it!! >>>> >>>> I don't expect a javascript-specific answer but just in case you >>>> are interested here is the relevant bit of the script (for the x >>>> axis). Of course your help will be acknowledge. >>>> >>>> return ((( x - Bordure)) * courbe.PixelDomain + courbe.ZoomX[0]) >>>> >>>> So courbe.PixelDomain is the value that needs to be scaled >>>> logarithmically before being scaled to the domain size (x). Or at >>>> least that's what I think!! >>>> >>>> Thanks very very much in advance. >>>> >>>> Best >>>> >>>> Peiman >>>> >>>> PS feel free to contact me directly if you don't want to clutter >>>> the list. >>>> >>> >>> >>> >>> Send bugs reports to the Sourceforge bug tracker >>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>> Discussions of bugs and features can be posted here >>> To unsubscribe, send email sympa@lists.bath.ac.uk with body >>> "unsubscribe csound" >>> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |