I am successfully loading and playing a .wav sound file, yet I get a "division by zero" error when I call SoundLength().
What's going on?
SoundLength Error
Re: SoundLength Error
What PB Version are you using?
A small runnable example would be nice.
A small runnable example would be nice.
Re: SoundLength Error
Version 5.73 LTS x64
Code: Select all
InitSound()
soundOpen = LoadSound(1, "D:\My Music\Beautiful Music\A Summer Place.wav")
If soundOpen <> 0: Debug "Sound opened OK": EndIf
Debug SoundLength(1)
FreeSound(1)
Re: SoundLength Error
Sounds like a bug in the SoundLength() function.
It would be useful to share the problematic WAV, if possible. Or even just the WAV header, as viewed in hex editor etc.
Probably whatever program wrote the WAV wrote invalid or incomplete header data, OR it's a variant of the WAV format which PureBasic doesn't support.
Either way: The PB function should fail gracefully (return 0 or -1?) not a hard crash attempting to divide by zero.
It would be useful to share the problematic WAV, if possible. Or even just the WAV header, as viewed in hex editor etc.
Probably whatever program wrote the WAV wrote invalid or incomplete header data, OR it's a variant of the WAV format which PureBasic doesn't support.
Either way: The PB function should fail gracefully (return 0 or -1?) not a hard crash attempting to divide by zero.
Re: SoundLength Error
That's pretty much it.Probably whatever program wrote the WAV wrote invalid or incomplete header data, OR it's a variant of the WAV format which PureBasic doesn't support.
There are two types of WAVE FORMAT. Either one can be present in a .wav file. They are both 100% supported by Microsoft, not proprietary.
WAVEFORMATEX is the old, legacy format.
WAVEFORMATEXTENSIBLE is the new format which accommodates more than 2 channels and bit depths greater than 16 bits.
I had created my wav files using the new wave format at 24 bits, causing PB SoundLength() to fail.
I re-made the files as old-style, 16-bit files and the SoundLength() function worked OK.