• Register
  • Help
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Topic: M A T H and the universe...

Share/Bookmark
  1. #1
    Senior Member newmewzikboy's Avatar
    Join Date
    May 2005
    Location
    San Francisco Bay Area
    Posts
    1,700

    M A T H and the universe...

    Anyone want to check out my math?

    Given:

    C = 8.17579892 where i = 0 (MIDI note 0)

    To calculate the frequency Fi of any given MIDI note i :

    Fi = 2^(i/12) * C

    To find the MIDI note number i for a given Frequency of i:

    Round( Log( Fi / C ) / .025083, 0 ) = i

    I think this works?

    Anyone have any code for natural log() function w/o using a library?
    75,000th Post Winner on the Garritan Forum
    "Don't you wish you were me?"

  2. #2
    Senior Member rwayland's Avatar
    Join Date
    Jun 2004
    Location
    California Redwoods
    Posts
    2,938

    Re: M A T H and the universe...

    Quote Originally Posted by newmewzikboy
    Anyone want to check out my math?

    Given:

    C = 8.17579892 where i = 0 (MIDI note 0)

    To calculate the frequency Fi of any given MIDI note i :

    Fi = 2^(i/12) * C

    To find the MIDI note number i for a given Frequency of i:

    Round( Log( Fi / C ) / .025083, 0 ) = i

    I think this works?

    Anyone have any code for natural log() function w/o using a library?
    Well, I have a short program written by me (based on a sloppier version) that will, among other things, provide the frequency of any note. You must specify the frequency standard, such as A=440 or 435 or whatever, and the frequency will be calculated base on that standard. It is a short program, compiled basic. If you are interested, I can email it to you.

    Richard

  3. #3
    Senior Member newmewzikboy's Avatar
    Join Date
    May 2005
    Location
    San Francisco Bay Area
    Posts
    1,700

    Re: M A T H and the universe...

    Thanks for your help. Im really looking for source code to the log function. I think maybe i might be able to swipe a version from java
    75,000th Post Winner on the Garritan Forum
    "Don't you wish you were me?"

  4. #4

    Re: M A T H and the universe...

    Quote Originally Posted by newmewzikboy
    Anyone have any code for natural log() function w/o using a library?
    newmewzikboy,
    you could use a series expansion like this:

    ln (1+x) = x - (x^2)/2 + (x^3)/3 - (x^4)/4 .... +(-1)^(n-1)(x^n)/n

    as long as -1 < x <= 1

    You could check how big the error is if you just use the first tree or four terms.

    If there are more questions I will be glad to help.


    Hannes

  5. #5

    Red face Re: M A T H and the universe...

    Suddenly I don't feel so smart...


  6. #6
    Senior Member Styxx's Avatar
    Join Date
    Mar 2004
    Location
    West Seneca, NY
    Posts
    11,075

    Re: M A T H and the universe...

    "MATH and the universe..." That about covers it. Mind if I run this by some of our Math teachers and IT technical teachers?
    Styxx

  7. #7
    Senior Member Styxx's Avatar
    Join Date
    Mar 2004
    Location
    West Seneca, NY
    Posts
    11,075

    Re: M A T H and the universe...

    Quote Originally Posted by cptexas
    Suddenly I don't feel so smart...

    Oh stop! You can’t measure intelligence by just one extension!
    Styxx

  8. #8
    Senior Member newmewzikboy's Avatar
    Join Date
    May 2005
    Location
    San Francisco Bay Area
    Posts
    1,700

    Re: M A T H and the universe...

    Quote Originally Posted by Hannes_F
    newmewzikboy,
    you could use a series expansion like this:

    ln (1+x) = x - (x^2)/2 + (x^3)/3 - (x^4)/4 .... +(-1)^(n-1)(x^n)/n

    as long as -1 < x <= 1

    You could check how big the error is if you just use the first tree or four terms.

    If there are more questions I will be glad to help.


    Hannes
    Hannes - this is really close, and we could iterate through the sums X^i/i. However, x can sometimes be a large number.

    For example:

    Given:

    Freqency of i = 12543.85396
    Base Freq C = 8.17579892 ( when i = 0 )

    Find the note's index i in relation to C:

    Log( Fi / C ) / .025083 = i

    Log( 12543.85396/ 8.17579892 ) / .025083 = i

    Log( 1534.26644 ) / .025083 = i

    3.185900788 / .025083 = i

    127 = i <== this is correct MIDI note

    Styxx...please submit to your friends. What we are looking for is a way to perform the LOG function without a math library. I am writing a routine in a scripting language that doesnt support math functions or external calls...
    75,000th Post Winner on the Garritan Forum
    "Don't you wish you were me?"

  9. #9
    Senior Member Styxx's Avatar
    Join Date
    Mar 2004
    Location
    West Seneca, NY
    Posts
    11,075

    Re: M A T H and the universe...

    On its way! This is pretty interesting and although I will admit to this being way above my head there is one very intelligent teacher here that may be a great help to even me understanding.
    Pretty cool thread Mr. NMB! Nothing like stimulating intelligence to shake up a rather lackluster morning!
    Styxx

  10. #10

    Re: M A T H and the universe...

    Quote Originally Posted by newmewzikboy

    Log( 1534.26644 ) / .025083 = i

    3.185900788 / .025083 = i

    127 = i <== this is correct MIDI note
    newmewzikboy,

    this is something I cannot do on a computer - need to write it down on paper with a pencil.

    On a quick view I see that you seem to use the logarithm to the base ten (log) but for solving your equation you would need the logarithmus naturalis (ln) or to the base two. That means there should be a ln(2) anywhere in your 0.025083 and I cannot see it right now. Will have a closer look.

    There are other series that may be more convenient. See my next post.

    Hannes

Go Back to forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •