22 May '13 - 18:29 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: BASS writes invalid WAV header?  (Read 826 times)
floele
Guest
« on: 24 Apr '11 - 15:17 »
Reply with quoteQuote

Hi,

I am using the WaveWriter class of BASS.NET 2.4.6.4 like this:

BassMisc.WaveWriter waveFile = new BassMisc.WaveWriter("C:\\test.wav", mixerStream, true);
// transfer data from old to new
...
waveFile.Write(data, length);
...
waveFile.Close();

However, the resulting file appears to be invalid (another software component does not like it and they have told me that the length specified in the header is invalid). This is the result: http://cdburnerxp.se/downloads/HeaderIssue.wav

Now I don't know anything about WAV file headers, but I used this project http://www.codeproject.com/KB/audio-video/WaveEdit.aspx to get some details on the file's headers. This program does not like the file as well and crashes apparently because a "fact" header is expected to occur before any data header, though in this case it only seems to be a faulty check for a null reference. That fixed, it analyses the file properly and the file size in the header seems to match the actual file size.

<?xml version="1.0"?>
<WaveFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <maindata>
    <FileName>Track-1.wav</FileName>
    <sGroupID>RIFF</sGroupID>
    <dwFileLength>423406</dwFileLength>
    <sRiffType>WAVE</sRiffType>
  </maindata>
  <format>
    <sChunkID>fmt </sChunkID>
    <dwChunkSize>18</dwChunkSize>
    <wFormatTag>1</wFormatTag>
    <wChannels>2</wChannels>
    <dwSamplesPerSec>44100</dwSamplesPerSec>
    <dwAvgBytesPerSec>176400</dwAvgBytesPerSec>
    <wBlockAlign>4</wBlockAlign>
    <dwBitsPerSample>16</dwBitsPerSample>
  </format>
  <data>
    <sChunkID>data</sChunkID>
    <dwChunkSize>423360</dwChunkSize>
    <lFilePosition>46</lFilePosition>
    <dwMinLength>0</dwMinLength>
    <dSecLength>2.4</dSecLength>
    <dwNumSamples>105840</dwNumSamples>
  </data>
</WaveFile>

So can anyone tell me whether there is a bug in BASS or an incorrect usage of the class on my side? Or is the file not faulty at all?

Best regards,
Florian
Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #1 on: 26 Apr '11 - 16:02 »
Reply with quoteQuote

That WAV file looks perfectly fine, ie. the lengths are correct and a "fact" chunk is not required. So if other software is having trouble with the file, I think it must be a bug in that software.
Logged
radio42
Posts: 4012


« Reply #2 on: 26 Apr '11 - 19:03 »
Reply with quoteQuote

Winamp and WMP and other apps also read/play the file just fine.
Which software is it having trouble with it?
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines