1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Audio wave file mixing

Discussion in 'C' started by crouchy8, Apr 1, 2008.

  1. crouchy8

    crouchy8 New Member

    Joined:
    Mar 24, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello peeps,

    This may sound a bit of a strange request but I am an electronic engineer who's not very good with programming.
    I am, if anyone can help, looking to write an ANSI C program which will mix two audio wav files together. The program should operate in a DOS console and simply request both the input files, the percentage mix and the output filename.

    I'm really into my audio and have just never been able to work out how to do it, if anyone knows of any code I could use or knows of where I could start looking it would be much apopreciated.

    Kind regards........:)
     
  2. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    The hard part of this is going to be figuring out how to read and write wave files. If you have some kind of library that'll make it easier, otherwise you'll need to research the file structure and work out how to write code to read and write files in the appropriate structure.

    After that it's easy, if the files represent the same data rate. The output amplitude at a given time is just the sum of the amplitude values of the input files at that same time. Watch out for overflows, and decide what to do if the files are not the same length. Work in higher precision than the input files, for example if they're 16 or 24-bit audio, use 32-bit integers. Convert the percentage mix into integer (e.g. 75 for 75%) then multiply values by 100 and divide by the value; the headroom you have will easily accommodate this even if you're mixing several files together.

    When checking for overflows, use something like if (MAXVALUE-a)<b rather than trying to figure out if a+b overflows. This keeps the calculations within the same precision. (i.e. if a and b are 16 bit, you can't check in 16 bits if a+B>65535, you would have to upconvert to 32 bits. But you can check if 65535-a<b within 16 bits).
     
  3. crestiksa

    crestiksa New Member

    Joined:
    Oct 18, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi

    Im trying to create a composition consisting of four sounds and am trying to find some simple music mixing software that will allow me to do such a thing, but I have NO idea what to use. Can any one suggest any thing???

    Regards
    Dave
     
  4. suhas j. tilekar

    suhas j. tilekar New Member

    Joined:
    Dec 9, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    1st Tell me mixing of wave files means to appends the files to each other or anather thing. ?
     

Share This Page