Jump to content

Ogg and other file format support?


ChrisV
 Share

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

 

ZBrush 4R7 64-bit - 3DCoat 4.5 BETA 12 - Fl Studio 12 64Bit - LE 3.2 Indie version - Truespace 7 - Blender 2.71 - iClone 5.51 Pro - iClone 3DXChange 5.51 pipeline - Kontakt 5 - Bryce 7 - UU3D Pro - Substance Designer/Painter - Shadermap 3 - PaintShop Photo Pro X7 - Hexagon - Audacity - Gimp 2.8 - Vue 2015 - Reaktor 5 - Guitar Rig 5 - Bitmap2Material 3

Link to comment
Share on other sites

I agree there should be support for .ogg in LE3.

Threadripper 2920X Gen2 CPU(AMD 12-core 24 thread) | 32Gigs DDR4 RAM | MSI Nvidia GeForce RTX 2070 Stock OCed | ASRock X399 Professional Gaming Motherboard | Triple M.2 500Gig SSD's in Raid0

Windows 10 Pro | Blender | Paint.NetWorld Machine | Shader Map 4 | Substance Designer | Substance Painter | Inkscape | Universal Sound FX | ProBuilder | 3D World Studio | Spacescape | OpenSky | CubeMapGen | Ecrett Music | Godot Engine | Krita | Kumoworks | GDScript | Lua | Python | C# | Leadworks Engine | Unity Engine

 

Link to comment
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;
#else
static int endian = 0;
#endif
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;

*samples=-1;

ogg=(oggio*)malloc(sizeof(oggio));
ogg->cb.read_func=oread;
ogg->cb.seek_func=oseek;
ogg->cb.close_func=oclose;
ogg->cb.tell_func=otell;

res=ov_open_callbacks(stream,&ogg->vf,0,0,ogg->cb);
if (res<0) {free(ogg);return 0;}

samples64=ov_pcm_total(&ogg->vf,0);
*samples=(int)samples64;

*channels=ov_info(&ogg->vf,-1)->channels;
*freq=ov_info(&ogg->vf,-1)->rate;

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)
{
	res=ov_read(&ogg->vf,buf,bytes,endian,bits/8,sign,&bs);
	if (res<0)
	{
		if (bs) return -1;	// Only one logical bitstream currently supported
		return -2;			// Warning: hole in data
	}
	buf+=res;
	bytes-=res;
}
return 0;
}

  • Upvote 4

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
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 comment
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 comment
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 comment
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

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
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.

 

[Edit]

 

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.

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
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.

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
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.

Guest
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.

 Share

×
×
  • Create New...