Results 1 to 3 of 3

Thread: Oscilating a variable

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Is there a way to oscilate the value of a variable from -x to +x at x cycles-per-second? Looking to form a symetrical sine wave if possible.

    In case you're curious, this is for outputting to the soundcard. It seems that the data sent to the soundcard is used to manually vibrate the speaker. I'm interested on synthysizing a high-piched sine wave over through my soundcard.

    BTW, I'm writing this for VB and QB. (Both display the sine wave, but only QB plays it on the soundcard) so no external dlls or ocxs please.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    maybe this is the formula you want:

    amplitude = Sin(6.283*X*t)*X

    sinus reads radians in vb so therefore you see 2*pi is 6.283 and you multiply it with X to perform x cycles per second. t is specified in seconds as amplitude is a function of t. The curve will oscillate from -x to x due to the the *X outside sin since sin returns values between -1 and 1.

    Hope this helped
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    thanks. I'll see if this helps

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