-1

I want to get a single audio file from two user inputs - one for background music and one for audio file. Any Ideas how to do so?

EDIT: Basically, I what I want is the final file be as long as the audio file and having the background music chosen by the user. I do not want to concatenate the file but something like, overlapping of audio files.

Shubham
  • 21,300
  • 18
  • 66
  • 89
  • I don't understand what you're ultimately trying to do. How does a "background" music file play into the current user file? – Jared Farrish Oct 28 '11 at 02:28
  • You need to define "get", for starters. There is nowhere near enough information to answer this question. – Lightness Races in Orbit Oct 28 '11 at 02:29
  • @JaredFarrish: The same thing that we can do in audacity. Like two audio files overlap. – Shubham Oct 28 '11 at 02:31
  • I would think when you "get" the audio files (*by upload I'd assume*) your best bet would be to invoke some API call to a server side application, using the files as arguments. This hypothetical application would be any audio processing program with an API (*none come to mind, then again, I'm just going off the top here*) – Dan Lugg Oct 28 '11 at 02:34
  • @Bracketworks: http://stackoverflow.com/questions/1823480/merge-background-audio-file the same thing I want to do with PHP. Hope I am clear? – Shubham Oct 28 '11 at 02:36

1 Answers1

0

First, read up on the byte structure of the audio format you're using (uncompressed WAV strongly recommended, and the one I used).
Next, go through all the samples and add them together, keeping track of the maximum amplitude.
Finally, normalize the result by using the max amplitude to avoid clipping, then save.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592