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

Discussion in 'C++' started by amitkhemlani@gmail.com, Mar 17, 2005.

  1. Guest

    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
     
    , Mar 17, 2005
    #1
    1. Advertising

  2. <> wrote...
    > 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
     
    Victor Bazarov, Mar 17, 2005
    #2
    1. Advertising

  3. wrote:

    > 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.

    --
    Scott McPhillips [VC++ MVP]
     
    Scott McPhillips [MVP], Mar 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    14,239
    Jonathan Bromley
    Apr 8, 2005
  2. Andrew Chalk

    Playing a WAV file from a Web Page

    Andrew Chalk, Nov 17, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    972
    Andrew Chalk
    Nov 17, 2005
  3. Shandy
    Replies:
    2
    Views:
    2,087
    Leslie
    Sep 11, 2003
  4. 525
    Replies:
    5
    Views:
    2,251
    Andrew Thompson
    Jun 29, 2008
  5. '2+
    Replies:
    2
    Views:
    521
Loading...

Share This Page