Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Taristin on June 11, 2004, 11:50:04 am

Title: OGG Support damnit!
Post by: Taristin on June 11, 2004, 11:50:04 am
Pretty Please?
Title: OGG Support damnit!
Post by: DaBrain on June 11, 2004, 12:01:50 pm
Yeah, I'd like to see that in a future build.

Ogg is the best way for any mod that has custom music.
(at equal filesize,  better quality :) )
Title: OGG Support damnit!
Post by: Unidan on June 11, 2004, 12:06:36 pm
Screw Ogg, vqf all the way. >XD
Title: OGG Support damnit!
Post by: Fineus on June 11, 2004, 12:16:46 pm
Dammit! WAV! What's wrong with you, act like men! ;)

(honestly, OGG would be nice).
Title: OGG Support damnit!
Post by: Taristin on June 11, 2004, 12:26:36 pm
:wtf: is vqf?  No. I refuse to search for it.
Title: OGG Support damnit!
Post by: Flaser on June 11, 2004, 12:31:01 pm
If you have to search for a file/media format, then it's either too experimental/not widespread enough for SCP or you're a L4M3R who badly needs a fresh set of digital diapers.

I guess we all know under which category vqf falls.
Title: OGG Support damnit!
Post by: kasperl on June 11, 2004, 12:55:26 pm
RTFM, damnit.

http://dynamic4.gamespy.com/~freespace/fsdoc/index.php/New%20File%20Formats

This thread is really bloody annoying to see, I do expect you guys to at lleast try and get some brains, and not barge in here demanding features.
Title: OGG Support damnit!
Post by: Taristin on June 11, 2004, 01:00:12 pm
1. Calm down. Breathe. Think. Then post.

2. It's not a feature that has lisencing problems. It's free, is it not? And if it's a viable alternative to Wav, with better quality for equal the file size, how is it different than offering TGA or JPG support? Which use more resources?

3. If a thread annoys you. Leave it. Problem solved.
Title: OGG Support damnit!
Post by: kasperl on June 11, 2004, 01:03:49 pm
Cursing when requesting a feature is hardly polite, now is it?

There are other issues. Effort is one, performance might be another. This is something to ask nicely, not to curse about when you want it.
Title: OGG Support damnit!
Post by: Taristin on June 11, 2004, 01:05:48 pm
The title was more for humor than anything else. And I'll wait for an actual programmer to tell me no, than listen to you saying why it shouldn't be so. If we all listened to those who complained, we'd have nothing here, because TopAce doesn't think the effort is worth the gain.
Title: OGG Support damnit!
Post by: Unidan on June 11, 2004, 01:07:50 pm
Yeah.. vqf is one of the digital audio formats that competed against mp3 and Ogg. It's liscensed by Yamaha I do believe, so it never got off the ground. I do have a small selection of Chinese pop recorded in vqf though. ^^;
Title: OGG Support damnit!
Post by: kasperl on June 11, 2004, 01:07:51 pm
OK, but the cursing just hit me. Asking politely is generally a lot better.
Title: OGG Support damnit!
Post by: Taristin on June 11, 2004, 01:10:29 pm
Appears I forgot the winky smily...
Title: OGG Support damnit!
Post by: Fineus on June 11, 2004, 01:29:05 pm
It should've been obvious. Can you keep this on topic?
Title: OGG Support damnit!
Post by: Viper1000 on June 11, 2004, 05:58:43 pm
We want MIDI's! :D
Title: OGG Support damnit!
Post by: Moonsword on June 11, 2004, 06:23:26 pm
*head hits table*

Calm down, people.

I'm pretty sure the threat title was a joke.
Title: OGG Support damnit!
Post by: WMCoolmon on June 11, 2004, 06:24:16 pm
Funny thing is, there's actually files for MIDIs that I think were with the original source from :V:. They're absolutely empty. :D

There are two issues with adding OGG. Well, make that three.
1) Processing time. This would be a problem if you decoded them on-the-fly rather than extracting them on mission start.

2) Memory requirements. In FS2 right now, it's setup to use files loaded into memory that are in PCM format. A 2 minute file will take up roughly 22 MB at 48000hz/16-bit/stereo (CD Quality). In a 128kbps OGG, it would be 1.64 MB. This means a soundtrack would take up 50 MB or more when loaded into memory, if you were using higher-quality OGGs.

3) Coding overhead. At the very least, you'd have to write a conversion function for loading OGGs. If you wanted to minimize memory use to the same size as the loaded OGG, you'd have to write load/play/stop/ff/rewind/etc functions and more for OGGs (This would take somewhat more processing power).


I think the big hold-up right now is lack of anyone with sound experience..
Title: OGG Support damnit!
Post by: Bri_Dog on June 11, 2004, 07:28:51 pm
Real Audio all the way!!!!!!
Title: OGG Support damnit!
Post by: Flaser on June 11, 2004, 07:30:30 pm
Just a minor note: OGG is not a substitute for WAV (which is a container format like AVI IIRC) but ADPCM (WMCoolmon, could you explain the difference between ADPCM and PCM, AFAIK the first is a MS format, while the later is not...but that's all I know about it).

However I don't understand why OGG would take more memory - it was supposed to be more efficient at compressing than PCM.

BTW if OGG support gets implemented VBR decoding should be a prime target, since anything VBR can be tons better than a CBR encoded file both quality and size wise, unless you set the bitrate (and quality) to ridiculously low levels.

About the processing part: IMHO you're right, but compared to other tasks (especially since the GPU handles nowadays quite a big portion of the load) it could be neligable.

Supporting the format would be beneficial for campaign distributions since the Voice Over could be a lot smaller, and the music higher quality.
Title: OGG Support damnit!
Post by: WMCoolmon on June 11, 2004, 08:22:02 pm
ADPCM is basically compressed PCM. From what I've seen it's not as good as OGG or MP3 at all, it was used in Inferno and as a result the music was noticeably distorted.

OGG would only take up less memory than a wav if it was decoded at play-time (Which would take up more processing power). It'd be harder to code though because you'd have to re-do all the wav playing functions.
However, if play-time OGG were implemented it would be easy to add an OGG player into the FS2, possibly even add a HUD gauge for it.

Load-time OGG would be far more likely, which would extract the files when a mission was loaded and put them into memory as WAV files. I'm not sure exactly how FS2 handles music, but if it loads it into memory when it needs to be played, you'd have to change the sound system to load music when the mission starts rather than on load.

If either OGG method was used, I think mission and campaign designers would started using higher quality sounds, which would take up more space. This is why I think OGG would take up more memory than wav files if it was implemented.
Title: OGG Support damnit!
Post by: Bobboau on June 11, 2004, 09:20:21 pm
anyone know about Open AL?
Title: OGG Support damnit!
Post by: mrduckman on June 11, 2004, 09:50:06 pm
OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.


www.openal.org
Title: OGG Support damnit!
Post by: Inquisitor on June 11, 2004, 10:02:42 pm
We used OpenAL and Ogg decoders in Lore. It's not a trivial implementation, but, it wasn't impossible either.

If anyone wants to take a crack at it, I think the audio system could use the love...

Isn't the linux port using openAL?
Title: OGG Support damnit!
Post by: taylor on June 14, 2004, 04:59:15 pm
We would probably do better to just use OGG to play music and voices (streaming both of them) which would give better quality and shouldn't use too much memory or CPU time.  The CPU usage is a lot lower on the newer decoders now than it used to be.  The game needs fast computers anyway and we'll have the benefit of the various SSE extensions to assist.  I can't really see the benefit of having regular effects be OGG but I'm not against the idea.

Yes, the Linux and OSX ports use OpenAL.  The OpenAL code is not yet complete and is missing streaming (I'm working on it, sort of) and 3D sound.  The 3D code is there but is b0rked and I don't know enough of the sound physics to figure out exactly what I did wrong.  Both Mac and Linux versions of OpenAL have extensions to decode/play OGG files but I'm not sure about the Windows version.

Oh and Inquisitor, I don't suppose there is a Linux version of Lore around somewhere is there?  All I've seen is Mac and Windows versions and it looks like a cool game but my money only gets spent on Linux stuff these days.
Title: OGG Support damnit!
Post by: Flipside on June 15, 2004, 09:05:25 am
Is there a limit to the resolution of the WAV files in-game, I've always kept them at the quality used by :v: but if you can use higher res sounds then I'm inclined to agree with Taylor.
Title: OGG Support damnit!
Post by: Inquisitor on June 15, 2004, 06:12:42 pm
taylor: email me, I'll hook you up with a copy of the Linux build.
Title: OGG Support damnit!
Post by: Darkhill on June 17, 2004, 08:09:30 pm
You are making it to hard on yourselves.  Look up something called FMOD, it reduces playing a ogg file down to a couple of lines of code.  It handles all of the decoding and playback of audio files.  It can stream them from disk so there is should be very little overhead to it.  I've implemented a mp3 jukebox in Imperial Alliance using FMOD and I haven't noticed any kind of slowdown.  The only thing that you need to distrubute is like a 150k dll.  And since this project is freeware then there is no charge for usage.
Title: OGG Support damnit!
Post by: WMCoolmon on June 21, 2004, 04:59:22 pm
To implement support for a sound format, functions are needed to:


I'd prefer not to use something that requires a DLL, and is portable.

If I have those three functions for a given filetype it *should* be possible to add support for it.


A couple examples from the FS2 code's ACM converter code...note that all are run after the file to convert has been loaded into memory.

Music

These three functions are used to convert ADPCM music files. stream_open opens a stream, getting everything ready to convert the file.

convert converts part of the data into PCM format.

stream_close closes the stream, cleaning everything up.

Code: [Select]

//Get ready to convert
int ACM_stream_open(WAVEFORMATEX *pwfxSrc, WAVEFORMATEX *pwfxDest, void **stream, int dest_bps)

//While we have music playing, convert part of it...boy, if only this did OGG too.
int ACM_convert(void *stream, ubyte *src, int src_len, ubyte *dest, int max_dest_bytes, unsigned int *dest_len, unsigned int *src_bytes_used)

//We're done!
int ACM_stream_close(void *stream)


Sound FX and maybe voice

This function converts an entire ADPCM file into PCM format, which is later loaded into a DirectSound buffer.

Code: [Select]
// =============================================================================
// ACM_convert_ADPCM_to_PCM()
//
// Convert an ADPCM wave file to a PCM wave file using the Audio Compression Manager
//
// parameters:    *pwfxSrc   => address of WAVEFORMATEX structure describing the source wave
//                *src       => pointer to raw source wave data
//                src_len    => num bytes of source wave data
//                **dest     => pointer to pointer to dest buffer for wave data
//                              (mem is allocated in this function if *dest is NULL)
// max_dest_bytes => Maximum memory allocated to dest
//                *dest_len => returns num bytes of wave data in converted form (OUTPUT PARAMETER)
// *src_bytes_used => returns num bytes of src actually used in the conversion
// dest_bps => bits per sample that data should be uncompressed to
//
// returns:       0 => success
//               -1 => could not convert wav file
//
//
// NOTES:
// 1. Storage for the decompressed audio will be allocated in this function if *dest in NULL.
//    The caller is responsible for freeing this memory later.
//
int ACM_convert_ADPCM_to_PCM(WAVEFORMATEX *pwfxSrc, ubyte *src, int src_len, ubyte **dest, int max_dest_bytes, int *dest_len, unsigned int *src_bytes_used, unsigned short dest_bps)
Title: OGG Support damnit!
Post by: Flipside on June 21, 2004, 06:16:28 pm
http://www.vorbis.com/download_win_1.0.1.psp

I'm not sure if it's any help, but thats the main SDK download from the Ogg Vorbis site, I've no idea whether that is what you're looking for as I have a suspicion is uses dlls :(
Title: OGG Support damnit!
Post by: taylor on June 21, 2004, 06:35:51 pm
FMOD would work but it's not open source.  It's available on most platforms but it's up to the developers to add new support or fix problems.  In my case, for instance, they don't have a 64-bit Linux version available so I can't use it.  FMOD is just like DevIL but for audio and it was pretty easy to add DevIL support.  It does support WAV (PCM & ADPCM) as well as OGG but other formats can be platform specific.

We can just integrate the Vorbis code in to do the decoding.  It's free and under a BSD-like license so all we have to add is a copyright notice in the docs, no external DLLs.  If it's done correctly then it will end up looking like the ADPCM stuff (function wise) and will be cross platform and can be tuned to suit our needs.  Icculus already donated his ADPCM decoder which is cross platform, but currently only used with Linux, so FMOD would only give us OGG.  Reworking everything to support FMOD looks like a lot of work simply from a code cleanup point of view and it's not even something I can think about working on until it's 64-bit ready for Linux.

From an implementation standpoint I think that FMOD would work out pretty well but with the drawbacks (not OSS, platform support possibly sketchy, formats not truely compatible cross-platform) it could end up being a dead end at some point down the road.  I'm not against it at this point in time but I'm certainly not for it either.  Adding a few new files for OGG decoding with 3 or so external functions to convert with sounds like a better bet to me.
Title: OGG Support damnit!
Post by: Darkhill on June 21, 2004, 08:30:28 pm
I have an advantage as I'm not/don't care about porting Imperial Alliance to other platforms.  And I'm trying to get it done in the least amount of time.  I.E. its pretty senseless for me to take the time to code in a decoder when I can just use FMOD.  Also I'm not reworking everything to use FMOD.  FMOD is only for the background music all the other sound effects are still done with the original FS2 code.  The user has the option to use the original event driven audio with sound effects or disable the event audio and use mp3(ogg) with sound effects.
Title: OGG Support damnit!
Post by: Kosh on June 21, 2004, 11:02:10 pm
Not to burst anyone's bubble, but shouldn't we figure out what is causing that memory usage issue and fix it before adding more features?



But, it's not really any of my business anyway.
Title: OGG Support damnit!
Post by: WMCoolmon on June 22, 2004, 01:15:56 am
Oops.

Incidentally, does anyone see anything wrong with these calculations?

      si->n_channels = si->ogg_info.vi->channels;
      si->sample_rate = si->ogg_info.vi->rate;
      si->bits = 16;                        //OGGs always decoded at 16 bits here
      si->n_block_align = si->n_channels * 2;
      si->avg_bytes_per_sec = si->sample_rate * si->n_block_align;
      si->size = ov_pcm_total(&si->ogg_info, -1) * si->n_block_align;
      snd->duration = fl2i(1000.0f * (si->size / (si->bits/8.0f)) / si->sample_rate);
Title: OGG Support damnit!
Post by: taylor on June 22, 2004, 01:50:54 am
Kosh: Assuming that you are using D3D, can you try running in OpenGL mode and see if you still have the same memory problems.  I don't see this issue but since I don't really use D3D I'm not sure if that's the reason or not.  And this happens with official 3.6 right?  Let me know what build (if not 3.6) and VPs (if other than MediaVP stuff) you have and I'll run through this tomorrow.

Quote
Originally posted by WMCoolmon
Incidentally, does anyone see anything wrong with these calculations?
ov_pcm_total() returns a 64-bit value so it's not going to fit in si->size without truncating.  You can cast it (hope not though) or have it calculated already and ensure it's less than UINT_MAX before doing math on it and assigning it to si->size.  Other than that I don't see anything obvious.
Title: OGG Support damnit!
Post by: WMCoolmon on June 22, 2004, 06:17:23 pm
Okay, I commited my work on this to the CVS repository. Could someone see what I did wrong?

There's also a big section of code in the load_buffer() function that I was trying to use for debugging, didn't work, but I left it in in case someone else had use for it and could get it to work. You'll probably wanna delete it when OGG is all fixed.
Title: OGG Support damnit!
Post by: Kosh on June 22, 2004, 10:32:09 pm
Taylor, I PM'd you the answer. Enough off topic for me.
Title: OGG Support damnit!
Post by: taylor on June 23, 2004, 12:01:51 am
Quote
Originally posted by Kosh
Taylor, I PM'd you the answer. Enough off topic for me.

Yeah, I haven't answered yet but you probably know that already.  I'm working on something and will get you a new build to test if you want.  I haven't had as much time to work on this today as I had thought but I'll PM you when I've got something. Building as I write this and if it works4me I'll let you know.