Page 1 of 1

GAME: RTC can't interprete compressed WAVE files

Posted: Tue Apr 26, 2005 1:07 am
by Pedro
As standard WAVEs take a lot of diskspace and RTC files are growing very quickly, I tried to add to the project some compressed ones but I got an error as below:

*** CRITICAL ERROR (line 24): Could not interpret sound file for SOUND_OTHER_GROWL3. Expecting a WAVE or RIFF encoded file.

I can play the same file under editor so I think it's some problem concerning implementation of DirectX functions in RTC engine ?


Pedro

Posted: Tue Apr 26, 2005 1:40 pm
by George Gilbert
Interesting - as you say, it's down to the DirectX layer as RTC just passes the byte stream into the DX APIs and "hopes" it works. RTC itself doesn't actually *do* anything with the data.

It it works in the RTC editor though, that's interesting - i implies that the call I make to the DirectX API is slightly different, so it something that could be fixed.

Can you send me the file you're using and I'll have an experiment to see whats going on!

Posted: Tue Apr 26, 2005 2:29 pm
by Gambit37
If you take an uncompressed PCM WAVE file and save it in a .RTC file, it's automatically compressed by around a factor of 4 (George's RTC format is compressed, like a ZIP file).

If your compressed WAVE file is in 4-bit ADPCM formt, you'll be making around about the same savings.

To make truly noticeable gains in file-size reduction you need a more efficient lossy format such as MP3 or OGG. Would it be hard to add that George?

Posted: Tue Apr 26, 2005 3:57 pm
by linflas
http://fmod.org but i guess many people here have already heard of it

Posted: Tue Apr 26, 2005 4:02 pm
by Pedro
Gambit37 wrote:If you take an uncompressed PCM WAVE file and save it in a .RTC file, it's automatically compressed by around a factor of 4 (George's RTC format is compressed, like a ZIP file).

If your compressed WAVE file is in 4-bit ADPCM formt, you'll be making around about the same savings.
WAVE files are generally difficult to compress. One of the most efficient WAVE loseless compressor is APE format. It gains about 40-60% (~about 1/2) of original size. To check my words I made a quick test:

decompressed WAVE = 73812 bytes
decompressed WAVE compressed by ZIP = 62189
compressed WAVE (lossy) = 16710 bytes
compressed WAVE (lossy) compressed by ZIP = 16250

Results:
compressed WAVE gains ~77.4%
decompressed WAVE compressed by ZIP gains only ~15.7%
compressed WAVE ≈ compressed WAVE compressed by ZIP

The results show that compressed lossy WAVES save a lot of space.

@George: I sent an example WAVE to your account at ragingmole.com

Pedro

Posted: Tue Apr 26, 2005 5:48 pm
by Pedro
George Gilbert wrote:Interesting - as you say, it's down to the DirectX layer as RTC just passes the byte stream into the DX APIs and "hopes" it works. RTC itself doesn't actually *do* anything with the data.
It just came into my mind that DX has probably nothing to do. The error occurs when the project is compiled and I suppose this is concerned with including of resource file into data. Compressed WAVE has probably a slightly diffrent header which is not recognised as WAVE file by your code. I think that problem can disappear if you include it as binary file and not as WAVE file.

Of course this is only my theory. :)

Posted: Tue Apr 26, 2005 7:24 pm
by George Gilbert
Sadly the theory is wrong. RTC saves whatever you put as the filename as a binary stream without looking at it at all. It then passes the stream directly to the DirectX APIs. When the file is compiled etc it makes no difference whatsoever; it's just a string of bytes that RTC knows nothing about; it relies on DirectX to parse the headers etc and return any errors it sees fit.

Gambit raises an interesting point; the RTC format is indeed compressed. It's not particularly optimised for sound files but it will probably do a reasonable job. I wonder what the difference is between the size of an RTC file with a compressed WAV and one with an uncompressed one would be...

As for accepting other formats (MP3 etc), again that comes to what is available across the DirectX interface. At the risk of labouring the point, there's no code in RTC to read, let alone play sound files and I don't particularly fancy adding that in as it's probably quite a large amount of work!

Posted: Wed Apr 27, 2005 12:33 am
by Gambit37
There's tons of players and freely available code on the net for playing back MP3 and OGG -- I don't understand how it could possibly be a lot of work. Make use of GPL software -- you don't have to do all this stuff yourself! ;-)

I just checked www.vorbis.com for more info but it's currently down.

Posted: Wed Apr 27, 2005 12:46 am
by Pedro
George Gilbert wrote:Sadly the theory is wrong. RTC saves whatever you put as the filename as a binary stream without looking at it at all. It then passes the stream directly to the DirectX APIs. When the file is compiled etc it makes no difference whatsoever; it's just a string of bytes that RTC knows nothing about; it relies on DirectX to parse the headers etc and return any errors it sees fit.
I cannot say much without source code but I'm wondering why the error occures while project is compiled if you don't use any DX API at this stage.
George Gilbert wrote: I wonder what the difference is between the size of an RTC file with a compressed WAV and one with an uncompressed one would be...
So lets look here:
WAVE uncompressed = 73812 bytes
WAVE compressed = 16710 bytes
RTC after compilation and compression enlarged 61760 bytes so the gain is ~16.3% - much less than for compressed lossy WAVE.

To tell the truth, I don't need this possibility (compressed WAVEs) to be a happy RTC user. But I'm not sure if other people will be happy too when they will have to download, for example, 10MB dungeon.

Posted: Wed Apr 27, 2005 12:57 am
by Gambit37
Ogg! Ogg! Ogg! ......

Posted: Wed Apr 27, 2005 9:51 am
by linflas
Ugh ! :)

Posted: Wed Apr 27, 2005 11:06 am
by beowuuf
Isn't it just an unwritten rule that no matter how insignificant-seeming the change, anything you alter will probably generate annoying bugs and require massive de-bugging?

Posted: Wed Apr 27, 2005 6:21 pm
by George Gilbert
I'm sure it's written, and probably in stone in fifty foot high letters too!

Another good rule of thumb is that it takes about 5% of the total time to get something working. The other 95% is taken getting it to work all the time...

Posted: Mon May 16, 2005 10:39 am
by George Gilbert
Fixed for V0.35

Posted: Sat Nov 19, 2005 12:22 pm
by Gambit37
Which bit was fixed? The playing of compressed wavs, or the addition of MP3? ;)

I've been messing with background music and trying full CD quality wavs -- two of my files bloat the RTC file to 68MB and cause memory problems (slow gameplay and texture droput). If these were compressed wavs, they'd be about 17MB. On the other hand, MP3 equivalents are around 6MB.

For large downloads, if you're going to add the BGM support, MP3 really is a must. It's available to most windows PCs across DirectX. Do you think you will be adding this support?

Posted: Sat Nov 19, 2005 1:26 pm
by linflas
68 Mb ! but what kind of massiiiiive world are we going to visit ?

Posted: Sat Nov 19, 2005 1:47 pm
by Gambit37
That is just 2 background tracks of approx 3 minutes each at full CD quality (16-bit, 2 channel 44.1Khz). No extra data at all -- I'm testing these in the plain vanilla DM dungeon.

This is why need MP3 support....! :wink:

Posted: Sat Nov 19, 2005 2:39 pm
by George Gilbert
Gambit37 wrote:Which bit was fixed? The playing of compressed wavs, or the addition of MP3?
I think you know the answer to that question, don't you :wink:

I'll have another look at how easy adding MP3 is though. :roll:

Posted: Sat Nov 19, 2005 2:41 pm
by Gambit37
George Gilbert wrote:I think you know the answer to that question, don't you :wink:
Um. Er. Yes..... sorry. :D

Posted: Sat Nov 19, 2005 7:56 pm
by Sophia
For what it's worth, Ogg/Vorbis has a nice toolkit for decompressing and playing sound files, too. I managed to get it working in a program I was writing very quickly-- of course, it was already internally suited for playing background music. It seems like the audio code for RTC is suited more for one-shot sounds.

Just another thought, though. :)