 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dave Atkin Guest
|
Posted: Wed Feb 07, 2007 9:12 am Post subject: How to mixdown an interleaved stereo wavefile to mono? |
|
|
Hi All,
Can anyone give me an example of how to mix down an interleaved stereo wave
file to a mono wave file?
Also how to avoid clipping when summing the channels?
Finally how to convert two split stereo files (left.wav & right.wav) into an
interleaved file?
I welcome any suggestions, but I would prefer code that doesn't rely on any
third party libraries.
I'm using D7 and WinXP.
Many thanks,
Dave Atkin |
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Wed Feb 07, 2007 11:22 pm Post subject: Re: How to mixdown an interleaved stereo wavefile to mono? |
|
|
| Quote: | Can anyone give me an example of how to mix down an interleaved stereo wave
file to a mono wave file?
|
I'd simply calculate the average...
| Quote: | Also how to avoid clipping when summing the channels?
|
....which can't be higher than the maximum.
var
SourceP: ^SmallInt; // assuming 16 bit
DestP: ^SmallInt;
V: Integer;
begin
// init pointers (set them to begin of data blocks)
while not finished do begin
V := SourceP^; // left channel
Inc(SourceP);
Inc(V, SourceP^); // right channel
Inc(SourceP);
DestP^ := V div 2;
Inc(DestP);
end;
end;
| Quote: | Finally how to convert two split stereo files (left.wav & right.wav) into an
interleaved file?
|
var
SourceP1, SourceP2: ^SmallInt; // assuming 16 bit
DestP: ^SmallInt;
V: Integer;
begin
// init pointers (set them to begin of data blocks)
while not finished do begin
V := SourceP1^; // left channel
Inc(SourceP1);
Inc(V, SourceP2^); // right channel
Inc(SourceP2);
DestP^ := V div 2;
Inc(DestP);
end;
end;
:-)
Some say that the quality is better if dithering is used. I think the
trick is to calculate the error you get when dividing (the rest of the
division) and try to minimize it over time (round down in case you did
round up before and the other way round). On the other hand it might
generate unwanted noise, try it.
--
Jens Gruschel
http://www.pegtop.net |
|
| Back to top |
|
 |
Atmapuri Guest
|
Posted: Wed Feb 21, 2007 8:24 pm Post subject: Re: How to mixdown an interleaved stereo wavefile to mono? |
|
|
Hi!
| Quote: | Can anyone give me an example of how to mix down an interleaved stereo
wave
file to a mono wave file?
|
Sum together the channels and then optionally scale it by a few % down.
When you are listening to two channels with two speakers, both channels
are also summed up as the waves in the air before they reach your ear.
Regards!
Atmapuri
| Quote: | Also how to avoid clipping when summing the channels?
Finally how to convert two split stereo files (left.wav & right.wav) into
an
interleaved file?
I welcome any suggestions, but I would prefer code that doesn't rely on
any
third party libraries.
I'm using D7 and WinXP.
Many thanks,
Dave Atkin
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|