Shop OBEX P1 Docs P2 Docs Learn Events
The golden ratio- Basic stamp question — Parallax Forums

The golden ratio- Basic stamp question

ArchiverArchiver Posts: 46,084
edited 2004-06-26 17:39 in General Discussion
I am trying to figure out how to program the basic stamp to use the
number phi (1.61803398874989484820...) or (5 + 1)/2.
What I am doing is creating a complex sine wave with an infinately
complex series of tones created by using the number phi as a
constant. I have heard it said that this number is what we percieve
as beauty. I am not sure exactly what this means, but I want to
check it out. I am using the freqout function with two piezo
buzzers. I want to make them give off a tone of a number times
phi. I am having trouble programming in complex equations into the
stamp. Any suggestions?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-06-25 15:42
    The BASIC Stamp uses integer math, but there is a trick you can do to
    multiply by fractional values -- though nothing to the resolution of
    your golden number. You can multiply by units of 1/65536 (0.000015259)
    by using the ** operator. To multiply by your number you would do this:

    myNewValue = myOldValue + (myOldValue ** 40503)

    If you work backwards, this is the same as

    myNewValue = myOldValue x 1.618026733

    and is about as close as you're going to get. That said, you're going
    to end up with a whole number ... so this may not work out for you in
    the end.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: wilcowannabe [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=PJD_P9M1xdbOjLk0n8BoapzTAvHNMdB0G-PoKSoMoDjFYZ1JpaGmfp1PKw3BaWpzVZCuyd50C7kkC8sX]wilcowannabe@y...[/url
    Sent: Friday, June 25, 2004 5:09 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] The golden ratio- Basic stamp question


    I am trying to figure out how to program the basic stamp to use the
    number phi (1.61803398874989484820...) or (5 + 1)/2.
    What I am doing is creating a complex sine wave with an infinately
    complex series of tones created by using the number phi as a
    constant. I have heard it said that this number is what we percieve
    as beauty. I am not sure exactly what this means, but I want to
    check it out. I am using the freqout function with two piezo
    buzzers. I want to make them give off a tone of a number times
    phi. I am having trouble programming in complex equations into the
    stamp. Any suggestions?
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-26 17:39
    Hi Wilcowannabe,

    Here is a similar notion and a tutorial about
    using the ** operator to create fractions at this
    URL:
    <http://www.emesystems.com/BS2math1.htm#musical>

    That shows how to use the ratio,
    1.059463
    to create an even-tempered ascending major
    musical scale using the Stamp and a speaker. And
    the ratio,
    0.943874
    to generate a descending minor scale.

    (By the way, nothing played on piezo buzzer or
    speaker is ever going to meet a standard of
    beauty, for anyone, anywhere, anytime. Well,
    granted, there has to be an exception!)

    There is an accumulation of integer round-off
    errors as a program applies the multiplier again
    and again. If you really want to experiment with
    higher precision and want to dig deeper into the
    math, try this
    http://www.emesystems.com/BS2math6.htm#multiplication
    That shows how to carry the same logic out to 24
    or 32 bits. There is an example with
    multiplication by a constant 3.7305512 to 8
    decimal places precision.

    -- Tracy



    >I am trying to figure out how to program the basic stamp to use the
    >number phi (1.61803398874989484820...) or (5 + 1)/2.
    >What I am doing is creating a complex sine wave with an infinately
    >complex series of tones created by using the number phi as a
    >constant. I have heard it said that this number is what we percieve
    >as beauty. I am not sure exactly what this means, but I want to
    >check it out. I am using the freqout function with two piezo
    >buzzers. I want to make them give off a tone of a number times
    >phi. I am having trouble programming in complex equations into the
    >stamp. Any suggestions?
Sign In or Register to comment.