473,513 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sine wave generation

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

Apr 11 '06 #1
8 12703
mc*****@gmail.com 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
Apr 11 '06 #2
red floyd wrote:
mc*****@gmail.com 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.

Apr 11 '06 #3
mcen...@gmail.com 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

Apr 11 '06 #4

red floyd wrote:
mc*****@gmail.com 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++ :P

Apr 11 '06 #5
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 ***
Apr 11 '06 #6
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

Apr 11 '06 #7
"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.
Apr 11 '06 #8
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" <mc*****@gmail.com> 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


Apr 12 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12688
by: Xanax | last post by:
Hi all, I need to produce a sine wave and use the WaveOut APi to sound it on my sound card. I also need to compute Fast Fourier Transform to modify the Sine wave. Any ideas on where to start or...
11
12005
by: Phil Newman | last post by:
I'm trying to implement a basic sinewave signal using arrays, but I'm having difficulty (I'm a complete beginner!) This is what I have so far: using namespace std; double signal(double...
143
7929
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
10
3077
by: Owkmann | last post by:
Can someone give me a rough idea how a value is obtained for a trigonometric function like Math.Sin? What is the algorithm? I'm finding that putting a large number in this function ( > 8000 )...
5
8801
by: MathNewbie | last post by:
Hi, I'm trying to do get my head around some, probably basic, math calculations. I checked some .net math libs, but the only thing I learn from studying those is humility ;-). Anyway, i have...
0
1723
by: aaronwmail-usenet | last post by:
Announcing SkimpyGimpy Support for PNG image CAPTCHA generation and PNG canvases. You can now use SkimpyGimpy to generate CAPTCHA text representations as PNG image files in addition to...
5
6197
by: RayD | last post by:
I'm looking for a simple program or method to generate sine waves or square waves at a desired frequency. Thanks for your help Ray
4
6815
by: Iain Mackay | last post by:
Python Folks I'm a newbie to Python and am looking for a library / function that can help me fit a 1D data vector to a sine wave. I know the frequency of the wave, so its really only phase and...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.