Results 1 to 4 of 4

Thread: Frequency Generator

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94

    Frequency Generator

    Hey guys

    I want to create a simple program to generate a sound frequency to play through my speakers. I would ideally like to be able to be able to generate a different frequency in each speaker ie 3Khz in right speaker and 3Khz in left speaker. So my question is what is teh easiest and fastest way of doign this.

    Peter
    "Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
    -- Judas Priest

    My email is [email protected]

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    3khz and 3khz are the same, just thought I'd mention that

    First, you need to decide what waveform you're going to use - you can have sine (i.e. use sin() to calculate the amplitude), square (jump between the maximum and minimum values after waiting a certain period, for example 10ms, at each value.

    Then there's sawtooth where you cycle from minimum to maximum then drop, and triangle which is linear up/down (like sine, but sharp at each end and always straight lines).

    Right, that's the waveforms out of the way...

    If you look up the wave* functions in MSDN you'll find how to create and play a sound buffer. From there it's a simple matter of generating the contents (note, once you've created the waveform buffer it's easy because you just keep cycling the same buffer ).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94
    Cheers

    I ment 3Khz and 5khz, something dirrerent to each speaker basically is this possible in teh same way.

    Peter
    "Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
    -- Judas Priest

    My email is [email protected]

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yes. You just need to calculate different values for each channel, but it's still the same functions to play it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

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



Click Here to Expand Forum to Full Width