Merging waveform data
I am using the mci commands to play an audio stream from a video
and i was wondering if anyone knew how to take 2 audio sources
(ex. an avi stream and a .wav file) and merge them into one audio stream.
An .avi stream is something immensely more complex than a simple wave sound stream - it is a complicated format that involves encoded audio and video streams utilizing several complex compression and decimation algorithms. There is no simple 1-on-1 way to mix these two.
For n unencoded audio (wav) streams, it's fairly simple, though:
Beware, though if you're using 16-bit stream data, and more than 1 stream that you want to mix,
If this is too complicated or unclear, I'll explain further - just let me know. Unless, of course, I misunderstood your question...
edit: forgot something...
[edited by - crispy on April 9, 2003 7:19:12 PM]
For n unencoded audio (wav) streams, it's fairly simple, though:
for(i = 0; i < bufsize; i++)' { output[i] = 0; for(n = 0; n < numstreams; n++) { output->data[i] += stream[n]->data[i]; } //need to to normalize result output->data[i] /= numstreams; }
Beware, though if you're using 16-bit stream data, and more than 1 stream that you want to mix,
output->data
must bew at least 32-bit or you'll end up with an overflow!If this is too complicated or unclear, I'll explain further - just let me know. Unless, of course, I misunderstood your question...
edit: forgot something...
[edited by - crispy on April 9, 2003 7:19:12 PM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement