GAME: RTC can't interprete compressed WAVE files

Messages are moved here (should anyone ever want to see them again) once they are no longer applicable to the current version (e.g. suggestions that have been implemented or bugs that have been fixed).

Moderator: George Gilbert

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Pedro
Journeyman
Posts: 69
Joined: Sun Nov 14, 2004 11:48 pm
Location: Poland

GAME: RTC can't interprete compressed WAVE files

Post 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
User avatar
George Gilbert
Dungeon Master
Posts: 3022
Joined: Mon Sep 25, 2000 11:04 am
Location: London, England
Contact:

Post 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!
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post 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?
User avatar
linflas
My other avatar is gay
Posts: 2445
Joined: Tue Nov 04, 2003 9:58 pm
Location: Lille, France
Contact:

Post by linflas »

http://fmod.org but i guess many people here have already heard of it
User avatar
Pedro
Journeyman
Posts: 69
Joined: Sun Nov 14, 2004 11:48 pm
Location: Poland

Post 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
User avatar
Pedro
Journeyman
Posts: 69
Joined: Sun Nov 14, 2004 11:48 pm
Location: Poland

Post 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. :)
User avatar
George Gilbert
Dungeon Master
Posts: 3022
Joined: Mon Sep 25, 2000 11:04 am
Location: London, England
Contact:

Post 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!
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post 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.
User avatar
Pedro
Journeyman
Posts: 69
Joined: Sun Nov 14, 2004 11:48 pm
Location: Poland

Post 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.
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Ogg! Ogg! Ogg! ......
User avatar
linflas
My other avatar is gay
Posts: 2445
Joined: Tue Nov 04, 2003 9:58 pm
Location: Lille, France
Contact:

Post by linflas »

Ugh ! :)
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post 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?
User avatar
George Gilbert
Dungeon Master
Posts: 3022
Joined: Mon Sep 25, 2000 11:04 am
Location: London, England
Contact:

Post 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...
User avatar
George Gilbert
Dungeon Master
Posts: 3022
Joined: Mon Sep 25, 2000 11:04 am
Location: London, England
Contact:

Post by George Gilbert »

Fixed for V0.35
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post 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?
User avatar
linflas
My other avatar is gay
Posts: 2445
Joined: Tue Nov 04, 2003 9:58 pm
Location: Lille, France
Contact:

Post by linflas »

68 Mb ! but what kind of massiiiiive world are we going to visit ?
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post 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:
User avatar
George Gilbert
Dungeon Master
Posts: 3022
Joined: Mon Sep 25, 2000 11:04 am
Location: London, England
Contact:

Post 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:
User avatar
Gambit37
Should eat more pies
Posts: 13720
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

George Gilbert wrote:I think you know the answer to that question, don't you :wink:
Um. Er. Yes..... sorry. :D
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post 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. :)
Post Reply