How to convert to WAV file with a specific requirement....

A

amitkhemlani

Hello All,

I have data in the form of characters Ex: "Amit". I convert the data
from its character representation to its ascii values so "Amit" gets
converted to "97 109 105 116". I then convert the ASCII values to its
bit representation. In the bit stream if i get a 1 I want to sound a
beep for 1ms(milliseconds) with frequency 1350 Hz and if I get a 0 I
want to sound a beep for 2ms at 2025 Hz.

Knowing this information how to I convert my data to WAV file. Is it
possible to do so? If it is can anyone tell me how do I got about doing
it. Thanks for the help.

Hope to hearing from anyone soon.

Best Regards,
Amit
 
V

Victor Bazarov

I have data in the form of characters Ex: "Amit". I convert the data
from its character representation to its ascii values so "Amit" gets
converted to "97 109 105 116". I then convert the ASCII values to its
bit representation. In the bit stream if i get a 1 I want to sound a
beep for 1ms(milliseconds) with frequency 1350 Hz and if I get a 0 I
want to sound a beep for 2ms at 2025 Hz.

Knowing this information how to I convert my data to WAV file. Is it
possible to do so? If it is can anyone tell me how do I got about doing
it. Thanks for the help.

It is possible to do. However, what does it have to do with C++? WAV
file format is not part of the language specification. If you know how
data are laid out in a WAV file, open a file using any way C++ has
(FILE*, ofstream) and write it using the appropriate means (fwrite, fputs,
write, operator<<). If you don't know the format of a WAV file, then
this is not the right place to ask.

V
 
S

Scott McPhillips [MVP]

Hello All,

I have data in the form of characters Ex: "Amit". I convert the data
from its character representation to its ascii values so "Amit" gets
converted to "97 109 105 116". I then convert the ASCII values to its
bit representation. In the bit stream if i get a 1 I want to sound a
beep for 1ms(milliseconds) with frequency 1350 Hz and if I get a 0 I
want to sound a beep for 2ms at 2025 Hz.

Knowing this information how to I convert my data to WAV file. Is it
possible to do so? If it is can anyone tell me how do I got about doing
it. Thanks for the help.

Hope to hearing from anyone soon.

Best Regards,
Amit

Let's assume that you are asking how to use the C++ language to compute
a brief segment of a sine wave. Call the C++ library trigonometric sine
function (sin) repeatedly to compute points on a sine wave. This will
compute each point needed to create a beep (pure tone).

pt[x] = sin( w * t );

w is the desired frequency in radians, t is time. The number of
points you need is computed from the desired sample rate and beep
duration. The time t increment is 1/sample_rate. Convert each sample
result to a C++ short. pt[x] is an array of shorts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top