Re: How to merge .wav files
From: Tassilo v. Parseval (tassilo.von.parseval_at_rwth-aachen.de)
Date: 10/01/04
- Next message: Robert Nilsson: "Re: "su -" in CGI script ?"
- Previous message: Christian Winter: "Re: tr problem"
- Maybe in reply to: Fred Toewe: "Re: How to merge .wav files"
- Next in thread: Sherm Pendley: "Re: How to merge .wav files"
- Reply: Sherm Pendley: "Re: How to merge .wav files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 1 Oct 2004 08:48:01 +0200
Also sprach Jarson:
> I'm building a web-based message alert system in Perl (CGI) using voice TTS.
> Each web client will get a custom voice message that will actually consist
> of selected .wav files merged together to appear as one. My problem, is
> that I don't know how to handle .wav files to merge them properly under
> Perl.
Merging two .wav files is relatively easy. All you have to do is going
sample-wise through both of them in parallel, add the two samples (a
sample is just a signed integer) and write the new value to another
file. You can do the reading with Audio::WAV::Read::read() and writing
with Audio::WAV::Write::write().
Some things to watch for: You have to truncate values when they would go
beyond the maximum or minimum range of the bitrate. For 16 bits the
range is +/- 2**15 - 1. Otherwise they wrap around. Then the two .wav
files should have the same format. If file one is stereo and the second
one mono you always read two samples of the first file and one of the
second and add the second value to the first two values. When they
differ in bitrate you have to convert the samples of the file with the
lower bitrate accordingly (a 8 bit sampling-rate means that you have to
distribute the values in the range (-128 .. 127) to values in the range of
(-2**15 .. 2**15 - 1). Most of the time this distribution happens
evenly. Different sample frequency means that you skip certain samples
in the file with the higher frequency.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
- Next message: Robert Nilsson: "Re: "su -" in CGI script ?"
- Previous message: Christian Winter: "Re: tr problem"
- Maybe in reply to: Fred Toewe: "Re: How to merge .wav files"
- Next in thread: Sherm Pendley: "Re: How to merge .wav files"
- Reply: Sherm Pendley: "Re: How to merge .wav files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|