Thread: pow() function

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    4

    pow() function

    Hi,

    This is my first post to this forum so please be careful with me.

    As part of my HNC in electronics I have to write a program in C that works out the frequencies of the other notes using the note of A-4 (440Hz) as my reference point. We have been told that we have to use the function of pow() to complete this task.

    What I need to know if anyone can help with what the formula is that I need to use to complete this task using the above function.

    I am not asking for someone to give me the code to do this, but merely need some pointers in the right direction to complete this.

    IE do I need to combine this function with another math function to create the correct forumla (and don't forget a clue to the right formula to use would help as well)!!!

    Hope some you out there can help me and I look forward to your replies.

    Cheers,

    Ian

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do you know what the formulae is already? If so, write it out in words, then turn it into code. When you run into a problem with said code, take a gander at the forum rules and then post your problem accordingly.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    4
    Hi,

    That is part of my problem if I knew what the formula was then there is a good chance that I maybe able to work it out for myself!

    I was hoping that someone on this forum had been given a similar problem in the past and would know the correct formula to use the pow() function.

    But thanks for your post anyway.

    Ian

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I've no idea where pow() comes into it - I always thought octaves were based on doubling frequencies, not raising them to some power.
    So the next A up from 440 is 440*2, ie 880Hz, which is going to be considerably smaller than say pow(440,2)

    Unless there is some relationship like
    B = pow(A, 1.0001 ); // some small fractional power just greater than 1
    But that would require a complete octave's worth of frequencies and some thinking about....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005

    Re: pow() function

    >What I need to know if anyone can help with what the formula is that I need to use to complete this task using the above function.

    Perhaps this?

    [EDIT]More info.
    Last edited by Dave_Sinkula; 10-17-2003 at 10:58 AM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    4
    From what I can tell what you have just said allows you to go from the note A-4 to A-5, and misses out all the notes in between this. What I am trying to do is calculate all the frequencies of an octave using A-4 as the starting point.

    ie
    A-4 440.00
    A#4 466.16
    B-4 493.88
    C-5 523.25
    C#5 554.37
    D-5 587.33
    D#5 622.25
    E-5 659.26
    F-5 698.46
    F#5 739.99
    G-5 783.99
    G#5 830.61
    A-5 880.00

    What I need is the formula to calculate something like the above, but also being able to calculate the frequncies below 440Hz as well!

    Hope this makes things a little clearer!

    Ian

  7. #7
    Registered User
    Join Date
    Oct 2003
    Posts
    4
    Just looked at the link in Dave's post.

    Thank you. I think what is posted there is just about what I am looking for.

    And good luck, with the event to come (Compile and run the code at the bottom of Dave's post to find out more).

    Ian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM