Hello,
In the attachment, there's my wavegenerator. I did not know of the fpwavwriter those days and used my own wav routines.
Near 5 years later, I've found something strange, using your tool :
if I create
2 identical files except for the frequency and with 2 channels and a length of 2 seconds, if I try to concatenate them using
sox like that :
sox file1.wav file2.wav output.wav, I get two times the line :
"WARN wav: premature EOF on wav imput file"So I looked more closely with
sox --i file1.wav :
$ sox --i file1.wav 352 844 octets
Duration : 00:00:16.00 = 705600 samples = 1200 CDDA sectors --> WRONG !
File Size : 353k OK
Bit Rate : 176k --> WRONG !
Same bad result with
file2.wav.
But the output.wav is OK :
$ sox --i output.wav 705 644 octets
Duration : 00:00:04.00 = 176400 samples = 300 CDDA sectors OK
File Size : 706k OK
Bit Rate : 1.41M
For me, the problem is solved using the following changes at the bottom of the procedure
WriteWavStream :
// Complete missing header data
AStream.Position := p - 4;
//AStream.WriteDWord(n * numch * BITS_PER_SAMPLE); // Size of data part
// added "div 8" et no more problem with sox
AStream.WriteDWord(n * numch * BITS_PER_SAMPLE div 8); // Size of data part
AStream.Position := 4;
AStream.WriteDWord(AStream.Size - 8); // File size - RIFF chunk size
// look at http://soundfile.sapp.org/doc/WaveFormat/ : Subchunk2Size (Size of data part) == NumSamples * NumChannels * BitsPerSample/8
Creating a new file with "
div 8" gives the following
good data :
$ sox --i goodfile.wav
Duration : 00:00:02.00 = 88200 samples = 150 CDDA sectors
File Size : 353k
Bit Rate : 1.41M
A last word : the Audacious player
cannot play (don't remember error message) a file created
without "div 8" and
plays it perfectly if created
with "div 8".
Thanks for your work, best regards from South of France,
--
jp