Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > sine wave generation

Reply
Thread Tools

sine wave generation

 
 
mcenley@gmail.com
Guest
Posts: n/a
 
      04-11-2006
can any one please help me in creatind a sine wave in C++ please
i also need to play it as a .wav file any random sound within sudible
frequency will do

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      04-11-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> can any one please help me in creatind a sine wave in C++ please
> i also need to play it as a .wav file any random sound within sudible
> frequency will do
>


cat /dev/urandom > /dev/dsp
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      04-11-2006
red floyd wrote:
> (E-Mail Removed) wrote:
>> can any one please help me in creatind a sine wave in C++ please
>> i also need to play it as a .wav file any random sound within sudible
>> frequency will do
>>

>
> cat /dev/urandom > /dev/dsp


Or in other words, you're off-topic.

WAV files and sound playing is OT.

Creating a sine wave: define your format. look in <cmath> for the
definition of std::sin.

 
Reply With Quote
 
mlimber
Guest
Posts: n/a
 
      04-11-2006
(E-Mail Removed) wrote:
> can any one please help me in creatind a sine wave in C++ please


You can use std::sin(), which is presented in the <cmath> header. If
you need more help, be more specific.

> i also need to play it as a .wav file any random sound within sudible
> frequency will do


This is off-topic here since it is not about the C++ language proper
(arbitrary applications that happen to be written in C++ don't count).

Cheers! --M

 
Reply With Quote
 
Noah Roberts
Guest
Posts: n/a
 
      04-11-2006

red floyd wrote:
> (E-Mail Removed) wrote:
> > can any one please help me in creatind a sine wave in C++ please
> > i also need to play it as a .wav file any random sound within sudible
> > frequency will do
> >

>
> cat /dev/urandom > /dev/dsp


Platform dependant and not C++

 
Reply With Quote
 
Fraser Ross
Guest
Posts: n/a
 
      04-11-2006
You will need to convert the amplitude from the range 0 - 1, to 0 to 127
or -1 to -128 for a negative amplitude. You would probably want to
round the floating point value by adding 0.5 before assigning to signed
char. This is assuming you want a 8 bit signed values WAV file. That
can't actually be done but 8 bit unsigned is allowed. There is a lot of
quirks with WAV files which you would find from trying to use them.

Fraser.


*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
 
Reply With Quote
 
decorr
Guest
Posts: n/a
 
      04-11-2006
hey friends thanks for the information
i am a newbie when it comes to programming and i am trying off a few
codes but the codes which i used didnt give me the results
As i am working on TurboC v3.0 compiler on windows platform i directly
include<math.h> and i cant directly generate a sine wave
if possible i can change the compiler can you please give me the
required link to change my compiler so that i may download it
more over i have to physically generate a sine wave and play it in any
audible frequency

 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      04-11-2006
"decorr" writes:

> hey friends thanks for the information
> i am a newbie when it comes to programming and i am trying off a few
> codes but the codes which i used didnt give me the results
> As i am working on TurboC v3.0 compiler on windows platform i directly
> include<math.h> and i cant directly generate a sine wave
> if possible i can change the compiler can you please give me the
> required link to change my compiler so that i may download it
> more over i have to physically generate a sine wave and play it in any
> audible frequency


Your post has a fog index of about 43. A fog index of 12 or so is
considered difficult. If you can't be bothered to write English, post
someplace where your style is considered cute.

Besides that, you were told this is off topic. Try sending e-mail to the
people who gave you useful responses. Or else post to another group. But
please, no more posts in pidgin English to this group.


 
Reply With Quote
 
john chung
Guest
Posts: n/a
 
      04-12-2006
You may want to look at the electronic hobbist in generating sine
waves. They have a good coverage for you to start with. Sinwave for
a beginner is not such a good exercise.

www.epemag.com


http://www.codeproject.com/audio/SoundGenerator.asp

is another example for VC++

john


PS: when I was a beginner i did not start with sinwaves, it is more
important to understand how to use the language in the beginning.


On 11 Apr 2006 11:27:18 -0700, "decorr" <(E-Mail Removed)> wrote:

>hey friends thanks for the information
>i am a newbie when it comes to programming and i am trying off a few
>codes but the codes which i used didnt give me the results
>As i am working on TurboC v3.0 compiler on windows platform i directly
>include<math.h> and i cant directly generate a sine wave
>if possible i can change the compiler can you please give me the
>required link to change my compiler so that i may download it
>more over i have to physically generate a sine wave and play it in any
>audible frequency


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
superposition of a square wave over a sine wave Shiva VHDL 2 02-02-2009 02:49 PM
superposition of a square wave over a sine wave rara10 VHDL 0 01-30-2009 08:21 PM
sine and cosine wave generation FPGA VHDL 8 01-14-2008 09:11 PM
square wave / sine wave generator red floyd C++ 5 06-21-2007 09:30 PM
Best way to generate a sine wave? dhbrewer@gmail.com VHDL 1 11-28-2005 04:51 PM



Advertisments