Welcome! Log In Create A New Profile

Advanced

Audio library.

Posted by Daid 
Audio library.
November 30, 2009 02:25PM
I'm teaching some people C by letting them program stuff for the Wii (which is more interesting then the math assignments they get)

GRRLIB is great for 2D graphics, it has an easy API which is powerful enough (And less complex then SDL).

Now I'm looking for something that does the same for audio. Just load a few sound files and play them on command. Nothing fancy, a bit like SDL_Mixer. But I cannot use SDL as I already use GRRLIB for GFX.
Re: Audio library.
November 30, 2009 03:05PM
Well, tough luck. There simply isn't one. There is a mixing library, ports of different decoders, ports of said decoders that have been hacked to use previously mentioned mixing library and code to run the decoders alone. But nothing that is just one library. It is something that has bugged me for years (no kidding). If you make a library, do tell me. It isn't that hard to work with audio.
Re: Audio library.
November 30, 2009 03:43PM
Guess I know what I have to do.

I had to do my own audio mixing for GuitarsOnFire, so I guess I'll build that into a simple library.

I envision a simple API like this:

//SimpleAudioLibrary
int SAL_Init();
SAL_SAMPLE SAL_LoadFile(const char* filename);
SAL_SAMPLE SAL_LoadBuffer(const void* buffer, const int bufferSize. const char* type);
int SAL_Play(SAL_SAMPLE sample, int volume);
int SAL_PlayLoop(SAL_SAMPLE sample, int volume);
void SAL_Stop(int id);
void SAL_DeleteSample(SAL_SAMPLE sample);
int SAL_Destroy();

And the LoadFile/LoadBuffer should handle the basic file types like MP3, OGG and WAV.
Re: Audio library.
December 01, 2009 11:14AM
I do not like the idea of decoding all the audio before playback, you should reachecture the code to do on demand decoding, to keep the ram usage low, after all, the ram is limited and audio can be quite the memory user, especially decompressed. You will just not fit more than a few tracks in the Wii ram, and that has to compete with things like graphics (that consumes even more memory) and the general application storage.

Or maybe I am just assuming wrong?



Edited 1 time(s). Last edit at 12/01/2009 11:14AM by henke37.
Re: Audio library.
December 01, 2009 12:22PM
I started working on this library. First results are good. I could load a few 44100hz OGG samples and play them.

Still need to add support for large OGG files (AKA Music), MP3 files and WAV files, insert a bit more error checking, and do sample rate conversions.
Re: Audio library.
December 06, 2009 01:52PM
What about MOD files like MOD or XM? They can sound nicely and don't each much memory, on Nintendo DS it's great solution I must say and Wii for sure can technically play that files...
Re: Audio library.
December 07, 2009 12:40PM
Good idea. Any pointers to example audio files for mod/xm?

I've added support for large OGG files that stream from SD.
Also made basic support for WAV files, but supporting every single variant might be tough (in theory you can make WAV files that contain MP3 data) so I'll just leave it at basic uncompressed WAV files for now.
Adding mp3 should be trival, as I already have code for that. But mp3 will put the whole thing in GPL license. So I'll make that optional.
Started to work on the resampler (to change from any sample frequency to 48kHz) nothing fancy as it has to do it's work in realtime.

I'm have an issue with music right now. Same issue I had with GuitarsOnFire, but I don't feel like using the same solution. Problem is that I have slow SD cards and it makes the audio skip. On GoF I just loaded the whole file from disk before starting playback, but for a general library that's not desirable.
Re: Audio library.
December 07, 2009 09:08PM
Quote
Daid
GRRLIB is great for 2D graphics, it has an easy API which is powerful enough (And less complex then SDL).
SDL maybe more complex but its sure as easy as hell to make a game engine out of SDL on the PC and port it to wii in under 5 minutes, atleast i feel like that about SDL, and along with its vast array of extensions it unlikely that you will need anything else
Re: Audio library.
December 08, 2009 02:35AM
Ah yes MP3 format is war one...somewhere it is free somewhere pay-to-use...it drives everybody sick :P
MOD/XM files are in network for free there is tons of them, search for some mod library or something, I don't have any good files near so that's why I'm pointing on network, sorry :(
You will need tracker program to play them like MilkyTracker
I mean play on PC to check out what's what
Re: Audio library.
December 08, 2009 02:47AM
There's only a license issue when encoding mp3's.

Also why can't you use SDL_Mixer? Just don't init the video subsystem.
Re: Audio library.
December 08, 2009 10:30AM
I'm not going to start a discussion about SDL. SDL is a great library that does it job wonderfully. But in my case it does not fit the job. No single tool fits all jobs.

And the MP3 issue is no license issue, it's a code issue. The only mp3 decoder libraries that I know of are mpg123 and libmad. And those are GPL/LGPL. And we cannot do dynamic linking on the Wii (well, in theory we could, but nobody has done it yet) means we have to GPL sources that use it.
Re: Audio library.
December 08, 2009 06:46PM
I don't think GPL/LGPL licensing mean you have to provide all the source if you use one lib, just the lib source. In fact the same rule would apply for using libogc or any other homebrew library as it's BSD/GPL/LGPL so in theory you can't develop any homebrew without releasing the source.

Not releasing source for homebrew is somewhat shitty anyway.
Re: Audio library.
December 08, 2009 10:00PM
Quote
scanff
I don't think GPL/LGPL licensing mean you have to provide all the source if you use one lib, just the lib source. In fact the same rule would apply for using libogc or any other homebrew library as it's BSD/GPL/LGPL so in theory you can't develop any homebrew without releasing the source.

Not releasing source for homebrew is somewhat shitty anyway.
what if your app can be exploited? i remember that the gecko os source was used by many "dark" brewers to create the many backup loaders and wad installers that we have today.

Personally, it should be down to choice of the developer, if he/she feels their work could be misused then closed it should be, i am working on a zelda clone and i want it kept closed because i feel that IF it is popular than it is likely to be open to abuse by nublets from gbafail who may change the game algorithms so link runs at a billion pixels per second or someone who wants to rip of my work by changing the title and rereleasing it
Re: Audio library.
December 08, 2009 11:48PM
Quote
scanff
I don't think GPL/LGPL licensing mean you have to provide all the source if you use one lib, just the lib source. In fact the same rule would apply for using libogc or any other homebrew library as it's BSD/GPL/LGPL so in theory you can't develop any homebrew without releasing the source.

Not releasing source for homebrew is somewhat shitty anyway.
You misunderstand GPL then. libogc is not GPL on it's own, but there are some optional GPL libraries you can use delivered with devkitpro. (libmad being one of them)

But as soon as you use LGPL code in your program you should supply the means to replace the LGPL part of your program with a different version. In case of dynamic linking you can link do an DLL/.SO and supply the code for that DLL/SO. But on the Wii that's hard. I think you could get around it by supplying the code for the library you use, and the object files so someone can link in a different/modified version of the library.

In case of GPL is 'worse', then you have to supply the code to everything that links with the library. As libmad is GPL it means that every piece of homebrew that uses libmad from devkitpro should release it's sourcecode. But, wait a sec... libwiiuse is GPL-3. Ok, license wise homebrew is a mess, basicly you could sue just about every piece of homebrew that doesn't release the sourcecode, good chance you could sue tweezers for not release the homebrew channel source (if you can prove they used libwiiuse, and didn't optain libwiiuse from the owner under a different license)

But GPL is simple, if you release a binary using ANY GPL code then you must also release the readable+compilable source code for that binary. (Releasing the source can be done in multiple ways, see the license for details) The right to modify and expand is what GPL protects.
Re: Audio library.
December 09, 2009 12:37AM
Quote
Daid
But, wait a sec... libwiiuse is GPL-3.
If fact on the Web site it says:
Quote
www.wiiuse.net
Licensed under GNU GPLv3 and GNU LGPLv3 (non-commercial).
Most homebrew are non-commercial, so they could be licensed under GNU LGPLv3 ;)



Edited 4 time(s). Last edit at 12/09/2009 12:40AM by Crayon.
Re: Audio library.
December 09, 2009 01:24AM
Still means you should be able to replace libwiiuse if it is used in a homebrew app ;-) But people are less picky on LGPL 'violations' like that, and I'm not even sure LGPL fully works like that. Pretty sure you should release the sources if you modify the library. (Very sure about how GPL works, just a bit unclear about LGPL). But then we're mostly fine I guess.

(I got the GPL-3 from the comments in the source files, which doesn't say LGPL).
Sorry, only registered users may post in this forum.

Click here to login