Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Ogg and other file format support?

Recommended Posts

Hey guys!


Was working on some sounds and music for Hostile. Exported some footstep sounds in .ogg format, and tried playing them ingame by modifying the script. Unfortunaly, it's not possible to play those sounds, because .ogg isn't supported in LE? sad.png


I can easily convert them to .wav, that's no problem. And, for small sound files like footsteps or screams or whatever, wav would be acceptable...but, not really for music.


A 3 minute music file in .wav format is around 30 MB. So, if you have like 10 music files in .wav, you'll need a lot of disk space for them. If you then add all the other sounds, and other media (art, textures, models, etc...), you'll end up with a game that uses a lot of disk space. wacko.png


The same 3 minute song is like 10 times smaller in .ogg format, while still keeping a pretty good sound quality. The same for .mp3 format, but from what i've read, .mp3 isn't allowed commercially?


Anyways, i think it would be a good idea to have support for .ogg and other formats that can save disk space without loss of quality. smile.png

  • Upvote 7
Link to post
Share on other sites

Here's some decoding code:

// oggdecoder.c

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

#include <vorbis/vorbisfile.h>

static int quiet = 0;
static int bits = 16;
#if __APPLE__ && __BIG_ENDIAN__
static int endian = 1;
static int endian = 0;
static int raw = 0;
static int sign = 1;

typedef struct oggio oggio;

struct oggio
   OggVorbis_File	vf;
ov_callbacks	cb;

void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off)

void *Decode_Ogg(void *stream,void *oread,void *oseek,void *oclose,void *otell,int *samples,int *channels,int *freq)
oggio		*ogg;
int			res;
ogg_int64_t	samples64;



if (res<0) {free(ogg);return 0;}



return ogg;

int Read_Ogg(oggio *ogg,char *buf,int bytes)	// null buffer to close
int		res,bs;

if (buf==0) return ov_clear(&ogg->vf);

while (bytes>0)
	if (res<0)
		if (bs) return -1;	// Only one logical bitstream currently supported
		return -2;			// Warning: hole in data
return 0;

  • Upvote 4
Link to post
Share on other sites
  • 1 month later...

If you have some C++ knowledge you can add support for the BASS audio library (supports MP3, OGG and more). It's free of charge for non-commercial use.


What you need:

- http://www.un4seen.com/ (library)

- https://github.com/brachyonic/LuaBASS (Lua bind for BASS)

- A wrapper to mimic/replace the common Sound Lua functions. I'm working on this, might release it when I'm done and people want it.

  • Upvote 1
Link to post
Share on other sites

Are your sounds that important? I mean.. I can understand you want to protect your Lua code and such, but many commercial games store their sounds in normal files.


Or is it due to licensing?


I just finished my wrapper which overwrites the normal Sound & Source, which works perfectly. I also made some updates to the LuaBASS bind. If anyone wants more info just send me a PM. :)

Link to post
Share on other sites

This is a powerful addition to the engine! However, as ZIP is horrible at compressing WAV, the file size issue will remain.


Edit: Just did a quick test at home on a 5 minute song.


WAV (16 bit PCM, 2 channels, 44,100 Hz): 50.4MB


ZIPped WAV: 44.5MB


OGG (7 quality, around 190kbps, 44kHz): 7.28MB


From my understanding these are typical results and all projects with music and sound (and how many don't have them eventually?) would benefit from this implementation.

  • Upvote 2
Link to post
Share on other sites
  • 3 weeks later...

As a sound designer I completely agree. OGG is a must. It will not only reduce the size of your games but also improve loading times since there's a lot less data to be parsed.


Additionally we could use WAV/OGG asset playback straight from the editor. Its very annoying to Alt-Tab between your audio editing package and LE just to audition the sounds you want to use.

  • Upvote 5
Link to post
Share on other sites
  • 3 weeks later...
  • 4 weeks later...
  • 3 weeks later...

Yesterday during the Leadwerks hangout Josh said its not a priority. "who has that much music to benefit from compression" were his words. Unfortunately.




An average WAV music file can weight around 40 to 60 MB. An equivalent OGG file would be about 5-10 MB depending on quality. The argument that encrypted ZIP files help in this case is not appropriate. ZIP compression is horrible at reducing audio file size and besides the file it self is never reduced it still needs to be decompressed in RAM which can be used for other [more useful] purposes. OGG uses psychoacoustic compression which strips parts of audio that we as humans would never hear anyway. Thus reducing the file bandwidth. I guess for now its up to us to implement some kind of audio compression.

Link to post
Share on other sites

If foliage and some other features comes faster, than it's ok to leave Ogg for now.

And perhaps someone will write a plugin and Lua binding for all LE3 users ? smile.png


He promised a slew of new features that we all are waiting for. So OGG can wait indeed, especially if no one is stopping you from writing your own parser.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...