User talk:Titmouse

From WiiBrew
Jump to: navigation, search

Hi. I saw a post you made last year on the forum ( http://forum.wiibrew.org/read.php?11,65351,65408#msg-65408 ) where you said you were able to get gcmodplay to work with asndlib instead of aesndlib.

Well, I've hit a similar annoying problem as the one you experienced.... I can't use MOD files and MP3 or OGG files in the same game, because gcmodplay was changed to use aesnd but everything else uses asnd (why in the world did they do that?). At least I was able to use chris's example code to get sound effects working with aesnd, but it sucks that any music file not in MOD format has to be converted to RAW to be used with aesndlib!

How hard is it to get gcmodplay to use asndlib again? I really don't know about rebuilding anything.... I don't suppose it's as easy as replacing certain files with the rebuilt ones? --Mr. Reaper 05:44, 24 July 2012 (CEST)


Hi Reaper, Just spotted your post

However I stopped using that mod player some time back as I found a new one called GRRMOD (its playback is far better) here's my code that uses it https://code.google.com/p/wii-bolt-thrower/ , it includes the GRRMOD lib I’ve tweaked. This new Lib is under “Extra_libs_needed.Source”

I posted this about it… http://forum.wiibrew.org/read.php?11,69350,69350#msg-69350 Note: My project's a Mercurial repository; source tab says what to do to get code (TortoiseHg works well for me)

If you still need to use gcmodplay drop me another line and I’ll post up a working example or something. —Preceding unsigned comment added by Titmouse (talkcontribs) 10:41, 28 July 2012 (CEST)


GRRMOD looks good... I could use the ability to play MOD, MP3, and XM files, but I really am lost as far as knowing how to implement it.... I got Devkitpro and GRRlib installed of course -- I can use them, but I don't really understand how it all works, heh. Is it difficult to install your modified GRRMOD (and modified aesnd) on top of that (if it's not too much trouble)?
Would it be easier to get gcmodplay to co-exist with the ability to play MP3 files? --Mr. Reaper 21:48, 28 July 2012 (CEST)


Probably easier to use GRRMOD - I’ve compile the grrmod lib without MP3 support as the MP3 stuff was said not to be completed by the chaps developing it. For mp3 type technology I use Ogg vorbis, take a look at tremor for playing oggs. I tend to stay away from mp3 as things like oggs are far better quality while taking up less disk space. Have a look at tremor for the wii (example oggplayer.cpp/h in my Bolt Thrower code) *** But leave this to last, get grrmod working first **

GRRMOD comes with a working demo, I’ve changed a bit, now just plays music with a blank screen as it had dependences on graphics stuff I did not want to use, see: \Extra_libs_needed.Source\Source\GRRMOD\Source\main.c, in my bolt thrower google code To install GRRMOD just copy the files, grrmod.h & libgrrmod.a (from GRRMOD dir, make sure to use my updated grrmod lib from Google code, not the official one!!!) to C:\devkitPro\libogc\include\grrmod.h C:\devkitPro\libogc\lib\wii\libgrrmod.a (example is default path)

Use the main.c demo as starting point (I’ve just upload a fix to this demo as this did not compile, download a fresh version if need be)

your makefile should look something like this ...

LIBS := -lfat -lvorbisidec -lpng -lz -lgrrmod -lwiiuse -lbte -laesnd -logc -lm

Let me know how you get on :) --Titmouse 17:04, 29 July 2012 (CEST)


Thanks for the instructions. I downloaded the two files and put them in place, and got the main.c, then set up the makefile as above, but it won't compile. I get:

c:/projects/grrmod/source/main.c:19:23: fatal error: music_mp3.h: No such file or directory

I must still be missing something.

I found I didn't have the lvorbisidec you said should be in the makefile, so I went ahead and got that from Extra_libs_needed.libs/libogc/lib/wii/libvorbisidec.a and copied to my lib/wii folder too.



EDIT: Oh! I realised that the error I'm getting is because I need to have some song files (mp3/mod/xm/etc.) in a data directory to be converted to header files for inclusion in the compiled DOL.

So to compile this GRRMOD test, you also need the files in a "data" directory:

music.mp3 music.xm music.mod music.s3m music.it

Or comment out both lines in main.c (one will be the #include, the other is in the PLAYLIST) that refer to each file format you don't need (like mp3), and then you only need the above files in the formats you want.



Also, did you update something in aesnd? Do I need to update that too?


Ok, I got the example main.c compiling and working correctly. Thanks! Unfortunately for me, it won't play the XM file that I wanted to use! It just freezes up and makes a loud noise.... It works with a different XM file though... so there must be some issues with certain files.

I will have to convert that XM to an OGG I guess (massive increase in file size, but still better than having to convert it to RAW as I'm currently doing!)... so my next question is... How do I implement the OGG playback? I'll try to look at the Tremor thing in your google code, but if you have any more helpful tips and easy instructions, you could post them here for the benefit of anyone else who wants to use these things. Thanks! --Mr. Reaper 01:27, 30 July 2012 (CEST)


Hi Reaper, take a look in the devkitpro examples.

devkitPro\examples\wii\audio\oggplayer + working demo as template.c (I rewrote that oggplayer.c since the code was on the fudged side, it works just fine as it is - I just rewrote it so I could understand how the whole thing worked)

As for aesndlib you probably don't need my changes to aesndlib.c, see http://forum.wiibrew.org/read.php?11,68659,68659. I find AESND_AllocateNextFreeVoice(...) very useful in my games, since it will give you a free voice something the old sound lib use to provide, I prefer to dynamical pop off my sounds as it simplifies everything no end.

BTW what was the name of the XM file it could not play, I'll give it a go here to see if anything can be done.


The problem is that the OGG player that comes with Devkitpro still uses asnd, and of course asnd won't work in the same game along with aesnd (which is used by either gcmodplay or grrmod). I haven't looked at it in detail, other than noticing that it's using -lasnd and asndlib.h ... Is there a way to get it to work with aesnd?
Or... do I need to install Tremor ?
Hm, in my game I am just using some statically assigned sound channels, as sometimes I want to interrupt a long sound with another sound... although sometimes it glitches out, and the long sound refises to stop playing when I tell it to..... I've found a similar problem with MOD files using either gcmodplay or grrmod.... Like in the grrmod example, it has buttons 1 and 2 for "start" and "stop" playing the sound. If you keep pressing 1,2... 1,2... 1,2.... eventually the sound will glitch out when you press "stop" and repeat a note over and over, and will refuse to stop playing (whether by Stop or Pause) until you start it over or start a new song.... I know you don't usually start and stop a sound 50 times in a game, but after playing my game many times, I'd randomly get that sound glitch. The way I work around it now it to never actually "stop" a MOD file from playing until I am ready to start up a new one, and instead I turn the volume of the music down to 0 and let it keep playing! That avoids having the sound glitch out anyway... But I'm getting off topic :)
Here is the XM file that glitches out grrmod (haunted.xm): http://modarchive.org/index.php?request=view_by_moduleid&query=153821
I'm using it as the intro music for my game. Looks like I'll probably have to convert it to OGG (once I get that working too), but if you can figure out why it doesnt work, that would be even better (I don't have high hopes though -- probbly just grrmod can't handle something weird about the file).... --Mr. Reaper 01:14, 31 July 2012 (CEST)


Ahh yes that was probably another reason why a rewrote oggplayer.c, my version of oggplayer.cpp uses aesndlib, so it’s in c++ and it does need tremor for it to work. Do you need it in plain c?

I suspect the sound issues are a result of calling something like AESND_AllocateVoice, you will run out of voices if you never free them. For example Tower Defense has this type of bug when picking tunes as it just allocates and never free the voices playing the music.

For the xm - Not sure but maybe you could try loading the XM into a music editor or something and save it out again, might have something like a 'make it very compatible' option in the save, but I’m guessing such a thing exists. --Titmouse 21:23, 31 July 2012 (CEST)

...extra note, thats why I added AESNDPB* AESND_AllocateNextFreeVoice(AESNDVoiceCallback cb) to the offical aesndlib lib so I did not need to free voices. —Preceding unsigned comment added by Titmouse (talkcontribs) 21:29, 31 July 2012 (CEST)


Ok, so, I guess I should download and install Termor from its wiibrew page, and then what do I need to do to intsall your rewritten ogg player? If you could point me to what files I need to get and where I need to copy them to, it would help me out. --Mr. Reaper 02:10, 1 August 2012 (CEST)


Take a peek under BoltThrower\source\oggplayer, copy all that and add the oggplayer directory to your makefile. I do something like this to the makefile listing the directories containing source code (this is just an example from my makefie)
MODULES  := source \
source/LWOSource \
source/libpng \
source/libpng/pngu \
source/TinyXML \
source/CullFrustum \
source/oggplayer
SOURCES := $(MODULES) <---- then sources references the above modules

Not forgetting that my oggplayer using aesndlib rewrite is in C++ --Titmouse 23:04, 1 August 2012 (CEST)


I'm afraid I'm a little lost. Here's what I did so far:
I downloaded the precompiled Tremor files from the link on that wiibrew page and extracted them as shown to my devkitPPC folder.
Then I got oggplayer.h and oggplayer.cpp from your boltthrower/source/oggplayer/ and copied those to a test project -- I'm using the modplayer example from devkit pro as a start so: modplayer\source\oggplayer\
Then in the makefile I added this:
SOURCES := source source/oggplayer
And I assumed I needed to add this as well:
LIBS := -lwiiuse -lbte -lmodplay -libvorbisidec -laesnd -logc -lm
I tried to compile to see if everything was in place, but I got an error:
c:/projects/modplay/source/oggplayer/oggplayer.cpp:5:21: fatal error: ../Util.h: No such file or directory
So I looked in oggplayer.cpp and saw that there are several other of your files that I may need?
  1. include "../Util.h"
  2. include <tremor/ivorbiscodec.h>
  3. include <tremor/ivorbisfile.h>
  4. include "oggplayer.h"
  5. include "../Singleton.h"
  6. include "../Wiimanager.h"
  7. include "../DEBUG.h"
Well, I'm not sure if I need all those for ogg playback, or if some are just things you are using for your project....
Anyway, I also tried commenting out the Util.h line to see if the rest would compile, but then I got:

c:/projects/modplay/source/oggplayer/oggplayer.cpp:6:33: fatal error: tremor/ivorbiscodec.h: No such file or directory

So... now I'm wondering if I have tremor installed correctly, or if I need to do something else... or maybe give the path to it in the makefile or something....
Sorry to be such a bother! I just need a way to play an OGG file (or mp3 or something) in the same game as a MOD file (compatability with aesnd basically).... And... I'm afraid I don't really know why it makes a difference that you used c++ for your oggplayer rewrite...? I just need some functions that will allow me to start and stop ogg files, that will work with devkit pro/aesndlib.... --Mr. Reaper 03:45, 2 August 2012 (CEST)
EDIT: Maybe it would be helpful if you could e-mail me just a basic working example ogg player project? —Preceding unsigned comment added by Mr. Reaper (talkcontribs) 04:01, 2 August 2012 (CEST)


Looks like any issue includes can just be deleted, think just one is needed for debugging, and you can just delete the exitprintf from the code to get rid of that one. Here's some example code to play an ogg, [1]http://code.google.com/p/wii-bolt-thrower/downloads/list It’s a rewritten version the \devkitPro\examples\wii\audio\oggplayer (very basic) demo. It makes use of these libs -lvorbisidec –laesnd

This code is basically the guts of my oggplayer system ripped from my bolt thrower code, luckily there were no dependences so it was simple thing to separate it from the game. To test this ogg player code I’ve reused the original devkitpro example code with minor calling tweaks.--Titmouse 19:55, 2 August 2012 (CEST)


Oh, it's so close to working now! Ok, I tested your compiled example and of course that works, then I tried compiling it after cleaning all the build files. I was still getting the Tremor error I mentioned above.... Well, I moved the location of the Tremor files from the default devkitPPC folders into the libogc folders like everything else, and that got rid of the tremor error. So aparently the default locations mentioned in the Tremor page are not right? I moved the files to these locations isntead:
libogc\
+- include\
+-- tremor\
+--- config_types.h
+--- ivorbiscodec.h
+--- ivorbisfile.h
+--- ogg.h
+--- os_types.h
+- lib\
+-- wii\
+--- libvorbisidec.a
Ok, now I'm getting this error:

c:/projects/oggplayer_aesnd/source/oggplayer.cpp: In member function 'void OggPlayer::Init()':

c:/projects/oggplayer_aesnd/source/oggplayer.cpp:211:77: error: 'AESND_AllocateFixedVoice' was not declared in this scope

That's some of your custom aesnd code, right?
Ah! I checked the oggplayer.cpp file and I see that you'd commented out the standard(?) AESND_AllocateVoice line and replaced it with the FixedVoice one, so I changed which one was commented out, and now it compiles and runs!
Ok.... now I'll see if I can integrate this into my own game and make everything work nicely together.... If I manage to get it working, I'll definatly have to mention you in my game's credits screen ;) --Mr. Reaper 03:27, 3 August 2012 (CEST)


No problem, happy to help (I'm unavailable next week) Well done getting this far – it’s all part of the learning curve --Titmouse 19:22, 3 August 2012 (CEST)

I've got it working nicely in my game now. I noticed one issue though. If I understand correctly, the OGG player grabs a single voice from aesnd to use for oggs. That's all fine -- I use static voice channels for sound effects, so that if I play a new sound effect on the same channel, it overrides and stops the old sound that is still playing on that channel. The OGG player does the same thing, BUT if I do that 3 or 4 times, it crashes the program.... Should that happen? Maybe it's a result of me not using your aesnd updates. Of course, the easy workaround is to be sure and issue the Stop command before starting a new OGG file.... (to reproduce it, just use your example OGG player proect and have button 1 start an ogg file, and button 2 stop it. Pressing 1,2,1,2,1,2 is fine, but if you press 1,1,1,1 it'll crash... Do the same thing with a MOD file using the mod player and it won't crash). --Mr. Reaper 04:10, 4 August 2012 (CEST)


Yes both OggPlayer & GrrMod store a voice at init time. So that’s two voices taken at startup. So you should be able to call both players with new things as often as you like. Yes you need to call Stop before playing the next (I also call GRRMOD_Unload before each new play) --Titmouse 11:36, 4 August 2012 (CEST)


One more question: would it be easy to integrate this into Devkitpro so that I don't have to include the separate files along with my source code for each individual project? I assume I could put oggplayer.h into "\libogc\include\" along with all the other .h files, but then what would I do with oggplayer.cpp? I guess there's no way to integrate all the code into the .h file? --Mr. Reaper 20:44, 5 August 2012 (CEST)


What you’re suggesting is not a good idea, maybe best to compile as a separate lib. This is not something I’ve ever done myself so can’t help with that bit. But once you’ve created a standalone library, then you will only need to add an #include “example.h” line in your code, not forgetting to add the new lib to your makefile. If you do use a lib, it’s kept in something like ‘devkitPro\libogc\lib\wii\example.a’, and devkitPro\libogc\include for the header file with the interface. All your projects can share it without the need to compile that code.

Yeah, I don't know how to compile a lib either.... It would be nice to have everything neatly integrated with the libraries, but it's not a big deal -- I'll just keep copying the source files separately then.
Anyway, I had something really weird happen to my Wii the other day, having to do with playing MOD files and possibly something about the OGG player.... I was working on my game (which is now using your OGG player, but still using gcmodplay for MOD files), and I just left the game running while I did something else for a few hours. I THINK I left it on a screean that was playing a looping OGG... I guess it's possible that I left it on a screen that was playing a MOD file, but my title screen uses an OGG, and I thought that's where I left it (I didn't pay that much attention). Well, when I started playing it again, the MOD files sounded weird. I realized that one of the tracks of the MOD files wasn't playing.... So I exited to HBC and restarted the game, and got the same result.... Then I exited to the Wii menu, and noticed that the system menu "startup sound" sounded different... like higher pitched or something... the tones just weren't right. So I turned the Wii completely off for a while, then back on, but it didn't change. Then I even unplugged it for like 20 minutes but when I turned it back on, I had the same issues.... I tried playing different homebrew games that use MOD files (like the MOD player example, and the Homebrew Browser, and my game) and got the same result -- one of the channels of any MOD file (in any homebrew game) was not playing.... I also tried the GRRMOD example, and it seemed to play all the channels of the file, but it sounded maybe a little muffled.... (By the way, all other sounds seemed fine, such as playing OGG files or standard games). Well, I turned off the Wii, unplugged it, and left it that way overnight. When I turned it back on the next day, I could tell right away that the system menu startup sound was back to normal, and all the MOD files in my homebrew were working correctly again..... Isn't that weird? Maybe... a certain area of the wii memory is used to play like "Track 3" of a MOD file (I think it was Track 3, after looking at the MOD files in a tracker program)), and somehow that area of memory got... locked or something? I really have no clue (and I'm not doing anything weird in my code that I know of -- just following the standard examples of how to play sound files). Anyway, the problem went away and everything seems to be working fine now.... --Mr. Reaper 20:21, 12 August 2012 (CEST)


Very odd behavior; can’t see how that would happen, most of the music player’s available mix to a single voice in real time. Might be a good idea to see if you reproduce it - “if it’s happened once, it will happen again”, but next time it may show itself in another way as a hard to find bug! It might be hardware getting too hot, but I doubt it. Then again how would something survive a 20 minute hard reset! I’ve tested my code over long periods and not come across this, since I don’t use gcmodplay that could be your issue. Are you using aesndlib for gcmodplay?

Yes, aesndlib with gcmodplay. I did feel around the Wii when it happened to see if there was a lot of heat, but it didn't seem like there was. And you'd think a heat issue would start causing random graphics glitches.... I kind of don't want to try to reproduce it.... It freaked me out a bit the first time it happened! I was worried that something had gone permanently wrong with my Wii after the 20 minute unplug didn't cure the issue.... Even if I could reproduce it, I wouldn't have a clue as to what was causing it or how to fix it.... It's weird that it only seemed to affect MOD files played with gcmodplay (I bet that's what Homebrew Browser uses too) and the startup tones on the system menu (maybe the low notes weren't playing, so I was only hearing the higher-pitched ones, but it definately sounded different... I wonder if those tones use a MOD-like format?). --Mr. Reaper 06:37, 13 August 2012 (CEST)


Hey, brand new question! I am working on a side project, and I have the need to allocate a lot of sound voices.... Of course, the default AESND_AllocateVoice quickly runs out of voices, so I wanted to try out your modified code with AESND_AllocateNextFreeVoice, so I grabbed libaesnd.a and aesndlib.h from your google code page and copied them to the right places (backed up my originals first). Well, when I use your sound libraries, it seems to chop off the first part of a sound (the standard aesnd libs don't do that for me).... Even if I change nothing else in my code (still use a static voice channel), if I compile with your libs the sound gets chopped, but with the standard libs it plays fine.... That's a problem for me, because I'm using some very small sound samples of like 1/10th of a second in length, so I'm losing like half of the sound or so.... Other than that, I can tell that AESND_AllocateNextFreeVoice is working just how I need it to.... Maybe your modified libs are based on an older version of aesnd or something? Any way to fix this? --Mr. Reaper 02:48, 14 August 2012 (CEST)


Take a look at SoundManager.cpp - SoundManager::LoadSound(...), this uses the StoreSoundFromWav and StoreSoundFromOgg this is how I load sound files from disk. Not sure why but maybe the sample is seen as 8 bit instead of 16 bit so only half is played (or mono when stereo). Well I’m kind of guessing as I've not had this issue. As a quick test now will the code as it is, try seeing what happens if you play a test sample that’s ½ minute play time, how long does it play for?