Homebrew Official Homebrew Launcher for WiiU

  • Thread starter Cyan
  • Start date
  • Views 804,283
  • Replies 1,173
  • Likes 98

brienj

Trying to avoid getting cancer
Member
Joined
Jan 3, 2016
Messages
1,232
Trophies
0
Website
twitter.com
XP
2,142
Country
United States
So as said before I will point you to the functions that you have to call consecutively to get sounds to work.

The first thing to call of course is the intialisation of AX:
https://github.com/dimok789/loadiin...htly-8f0f7a8/src/sounds/SoundHandler.cpp#L225

Use init with parameters as the other function is old and should not be used anymore with sound lib 2.

After that you have to register a callback function in the AX frame cycle.
https://github.com/dimok789/loadiin...htly-8f0f7a8/src/sounds/SoundHandler.cpp#L242

Just some C function that will be called every 3ms. In this C callback you have to handle your voices. Which you still have to create (you can of course create the voices before registering for the AX frame callback).

Here is my frame callback:
https://github.com/dimok789/loadiin...htly-8f0f7a8/src/sounds/SoundHandler.cpp#L279

(Don't worry about it being C++ its a static function in a class which works very alike to a C function but just with a namespace before it)

So as you see you will have to make a state machine handling all your voices in that function. You must check their current status and process them accordingly. Don't forget to protect the voice with a mutex if you access them from another thread. The AX callback is its own thread.

Ok now to the point on how to aqcuire a voice.
https://github.com/dimok789/loadiine_gx2/blob/Loadiine-nightly-8f0f7a8/src/sounds/Voice.h#L47

This is just a struct with a few internal states. I treat it as a void* because I dont care about its internal variables (which isnt very "clean"). The priority of the voices go from 1 to 31 where 1 is the highest priority.

Once you have acquired a voice you have to define the type of voice. It's either a streaming voice or a normal voice. I always use normal voices as I can do streaming with them as well.

Once you define the type of the voice you can set its volume (AXSetVoiceVe) and mix (AXSetVoiceDeviceMix). The volume is set by the upper 16 bit of the uint you see in that code and max is 0x8000. As for mixing you can do some crazy mixing of up to 6 channels in it. I juse use the two channels of the stereo output in one voice at full volume. It is the simplest form of mixing. That also means that both channel play exactly the same samples here and therefore its only "mono" in my code. To do real stereo you would need to acquire two voices and play the different samples of a channel accordingly. Also I setup the same mixing for TV (device = 0) and DRC (device = 1). So actually one voice does the work for 4 channels. You can of course assign each channel its own voice and play different sounds on them.

Thats all you will actually need to setup the voices.

Now to start playing the voice with your samples. The first step is to set the buffer you want to play. This is set by the AXSetVoiceOffsets function in my code.
https://github.com/dimok789/loadiine_gx2/blob/Loadiine-nightly-8f0f7a8/src/sounds/Voice.h#L79

It takes a struct as an argument that defines the sample buffer, format of it and the offset in the buffer to play and if it should be looped or not. Here is the struct:
https://github.com/dimok789/loadiine_gx2/blob/Loadiine-nightly-8f0f7a8/src/sounds/Voice.h#L155

The sample format should be ADPCM (big endian s8 or s16 samples). The format can either be 8 bit = 0x0A or 16 bit 0x19. If you just want the samples to be played once then define the loop parameter as 0 otherwise 1. Then you define the current position and end position in samples count (so either in 8 bit or 16 bit steps, I use always 16 bit samples so 2 byte per sample). You can also define a loop offset where it should continue to play once it is reached the end sample. The offset is an offset from the start in samples count. It can be any location in memory and does not have to be directly behind the first buffer. With this you can make a 2nd buffer, fill it up with samples and make the voic jump to the start of the 2nd buffer as soon as the end sample of the first buffer is reached. Once it switches to the 2nd buffer you change the end sample variable to the end value of the 2nd buffer and the loop offset back to the start of the 1st buffer. While the 2nd buffer is playing you re-fill the samples of the first buffer. When the 2nd buffer is finished playing and the end sample of the 2nd buffer is reached it will jump back to 1st buffer start. This can go on as long as you want and you can make an endless flawless playing of a stream with it. And that is exactly what I do there. I check in each AX frame callback the loop counter of the voice with AXGetVoiceLoopCount(voice) and if it is changed then I know it switched to a knew buffer. In that case I change the end sample of the voice with AXSetVoiceEndOffset() and then change the loop offset with AXSetVoiceLoopOffset().

So this was a little detour to how to make a stream. Now back to how to start the voice playing. The first initial buffer is set with the function AXSetVoiceOffsets() which takes a pointer to the struct i described before as an argument together with the voice that is used.
After you set the initial sample buffer what is left to do is to define the pitch of the voice by calling AXSetVoiceSrc. It takes another struct that defines a fixed point converted pitch value. See here for the calculation:
https://github.com/dimok789/loadiine_gx2/blob/Loadiine-nightly-8f0f7a8/src/sounds/Voice.h#L91

I dont remember what the last 3 unsigned int values were but they seemed to be always 0. The next function sets the voice interpolation type with AXSetVoiceSrcType which defines what kind of converter should be used. I chose 1 as it is linear interpolation which is ok in most use cases.

The last thing to do is to actually start the voice by calling AXSetVoiceState() with the voice and 1 as parameter (or 0 to stop).

Well that is all to it. I hope I didnt leave anything out. To stop playing you just call AXSetVoiceState() with 0 and then free the voice with AXFreeVoice().

If you still have troubles with getting this to work then let me know. I will write up a simple example application on how to use it which will probably take less time for me than writing this huge post (sorry about it :P).
This is great, thanks for taking the time to write it up. This will greatly reduce the time for me to get it working properly. I've had the samples ready to go for a while now, and I am pretty sure they are the right format, but I'll be sure to double check before I start.
 

dimok

Well-Known Member
Member
Joined
Jan 11, 2009
Messages
728
Trophies
3
XP
2,635
Country
United States
This is great, thanks for taking the time to write it up. This will greatly reduce the time for me to get it working properly. I've had the samples ready to go for a while now, and I am pretty sure they are the right format, but I'll be sure to double check before I start.
Actually I just saw you asked for a wrapper for the C++ stuff. This actually would be the easiest way to go about it as you can re-use all my stuff. I can help you with creating that wrapper for C. What I need to know from you is the information on how you want to start playing the sounds? Meaning: do you want to pass raw samples to the sound and just call something like "play()" or "stop()" and maybe a "setVolume()"? Or do you need something more advanced with an MP3 to raw samples converter to which you pass a complete MP3 as file buffer?
 
  • Like
Reactions: brienj and pwsincd

brienj

Trying to avoid getting cancer
Member
Joined
Jan 3, 2016
Messages
1,232
Trophies
0
Website
twitter.com
XP
2,142
Country
United States
Actually I just saw you asked for a wrapper for the C++ stuff. This actually would be the easiest way to go about it as you can re-use all my stuff. I can help you with creating that wrapper for C. What I need to know from you is the information on how you want to start playing the sounds? Meaning: do you want to pass raw samples to the sound and just call something like "play()" or "stop()" and maybe a "setVolume()"? Or do you need something more advanced with an MP3 to raw samples converter to which you pass a complete MP3 as file buffer?
I have some wav file samples that are the same ones used in MAME for the actual Asteroids game. I don't know if you are familiar with those, but the bagkground thumping sound is actually two different samples, one hi, one lo, and I will be timing them to play one after the other, unless just combining them together and playing in a loop is easiest, although I planned on speeding the timing up like in the real game. The thruster sample just plays over and over for however long you apply thrust. And the laser fire only sounds each time you shoot, along with the exploding sounds, which only play when the asteroids are hit. I wouldn't mind using your code and wrapping it, but that's the problem, I am not sure if that would actually be harder than just writing my own functions or not, but since you already have them, I thought it might be easier.
 

thanyou

New Member
Newbie
Joined
Jan 19, 2016
Messages
3
Trophies
0
Age
30
XP
54
Country
United States
I've been on the most recent wiiu version, waiting for the kernal exploit and here it is finally. So the first thing I do is try and get homebrew working so I can do most elf stuff, but I can't seem to get the hbl to load off of the browser exploit. The Kernel loads fine enough, hosted through xampp and then I use mongoose to host www and I direct my wiiu browser to http://192.168.1.9:8080/ but I get a message saying simply "CGI failure"

The release version I used was version 1.1, and I'll try 1.2 RC3 and then update this post. If anyone can give me some guidance I'm really new to wiiu modding. I'm well versed in wii stuff, so I have an idea of what I need to be doing, its just not cooperating haha.

EDIT: Yup just tried the RC3 version and same issue. Should I try using xampp and loading the payload.php?

EDIT: Yay I got it! What I had to do was launch it through xampp instead, and use this url: http://192.168.1.64/www/payload.php?sysver=550
 
Last edited by thanyou,

dimok

Well-Known Member
Member
Joined
Jan 11, 2009
Messages
728
Trophies
3
XP
2,635
Country
United States
@dimok, random question - how does one use your debug logger? As in, what do I need on my PC? It looks like a very neat system and will definitely be better than OSScreen (what I've been using)
Indeed, it is very usefull.

OK here is what you need to do:
comment in that define so it is defined to 1
https://github.com/dimok789/hello_world/blob/master/src/utils/logger.h#L8

initialise like this:
https://github.com/dimok789/hello_world/blob/master/src/main.c#L28
https://github.com/dimok789/hello_world/blob/master/src/main.c#L30

I didnt figure out why but it seems sometimes it failes the intial intialisation. (I didnt actually check why still on TODO). So what you might need to do in that case is something like this (I know its ugly but makes it work for now):
https://github.com/dimok789/ddd/blob/master/src/main.c#L46
It was a quick fix so I could continue my work on other stuff but I will have to eventually look at it.

That's all you need on WiiU. Just call log_printf to print formatted text after that.

On your host you need this application:
https://github.com/dimok789/loadiine_gx2/tree/master/udp_debug_reader
There is a windows and linux compiled binary included on that git path.
 

thanyou

New Member
Newbie
Joined
Jan 19, 2016
Messages
3
Trophies
0
Age
30
XP
54
Country
United States
New problem... After having it work flawlessly a few times consecutively, I get a black screen that just says "FSGetMountSource failed." Anything I can do but just keep trying?

EDIT: Ugh just a fluke I guess. Maybe I need a new SD card. Just took another try and it worked perfectly fine again :l
 
Last edited by thanyou,

GR-DRACULA

Well-Known Member
Member
Joined
Sep 14, 2015
Messages
281
Trophies
0
Age
24
Location
crete
XP
521
Country
Greece
could you please tell me the name of the music of homebrew launcher? or send the file plz a friend of mine wants to know X'D @Cyan could you help us?
 

Pokepicker

Well-Known Member
Member
Joined
Nov 2, 2015
Messages
270
Trophies
0
Age
35
XP
1,737
Country
Norway
I have a question.
When I launch HBL (1.2RC3) from the browser it starts up just fine. But. I see three apps in the list (inside HBL). A FTP client, loadiineGX2 and HBL.
I figured it was reduntent to have HBL listed inside HBL, so I removed HBL from the SD card. Now I get an error since the HBL folder is missing. So I put the HBL folder back on the SD card.

This is not a big problem, but it looks strange and might be tempting to click. Maybe HBL could filter itself out of the list?
This "issue" was also around in RC2. I can not speak for earlier versions.
 

dimok

Well-Known Member
Member
Joined
Jan 11, 2009
Messages
728
Trophies
3
XP
2,635
Country
United States
I have a question.
When I launch HBL (1.2RC3) from the browser it starts up just fine. But. I see three apps in the list (inside HBL). A FTP client, loadiineGX2 and HBL.
I figured it was reduntent to have HBL listed inside HBL, so I removed HBL from the SD card. Now I get an error since the HBL folder is missing. So I put the HBL folder back on the SD card.

This is not a big problem, but it looks strange and might be tempting to click. Maybe HBL could filter itself out of the list?
This "issue" was also around in RC2. I can not speak for earlier versions.
That is not necessarily an issue. I display it on purpose as currently it is the only way to re-launch HBL within it self (and SendElf option of course). You might be right though and I should filter it as usually you don't want to re-launch it.
 

Pokepicker

Well-Known Member
Member
Joined
Nov 2, 2015
Messages
270
Trophies
0
Age
35
XP
1,737
Country
Norway
I'm guessing this is a silly question: why might one want to run the HBL while already inside HBL?
I'm looking at this as a users stand point. Launching the app doesn't seem to do much else then display the same image I was already on. Do you devs use this option for something?

I'm just currious :)
 

SkittleDash

Head Nurse
Member
Joined
Oct 21, 2015
Messages
1,863
Trophies
2
Age
28
Location
Storm Border
XP
1,071
Country
Japan
I keep getting "Could not find SD/wii/apps/Homebrew_launcher/Homebrew_launcher.elf" I'm very sure it is. I'm using 1.2 RC3 since it's compatible with 5.5.1 and using wiibru to launch it. Any ideas?
 
Joined
Apr 19, 2015
Messages
1,023
Trophies
1
Location
Stuck in the PowerPC
Website
heyquark.com
XP
3,909
Country
Australia
More questions for @dimok! Yay!

So I've been trying to use some of your code but I'm having trouble compiling most of it - mainly because I'm missing libgd. It's not in the devKitPro portlibs and I couldn't convince it to compile itself (it refused to detect zlib. All the other portlibs were fine, but zlib? Nah). So how did you get it working? Did libgd compile for you?
 

looseless

Well-Known Member
Newcomer
Joined
Apr 27, 2014
Messages
68
Trophies
0
Age
59
XP
160
Country
France
More questions for @dimok! Yay!

So I've been trying to use some of your code but I'm having trouble compiling most of it - mainly because I'm missing libgd. It's not in the devKitPro portlibs and I couldn't convince it to compile itself (it refused to detect zlib. All the other portlibs were fine, but zlib? Nah). So how did you get it working? Did libgd compile for you?
Download portlibs and libogc from this page :
https://github.com/dimok789/loadiine_gx2/releases/tag/open_beta
 
Joined
Apr 19, 2015
Messages
1,023
Trophies
1
Location
Stuck in the PowerPC
Website
heyquark.com
XP
3,909
Country
Australia
Alright, I'm close. The libraries all seem to be working fine, but now GLM is telling me that the C++ standard libraries don't exist ;D

Stuff like std::acosh and std::round are throwing "has not been defined" errors. All the issues seem to be in the GLM files and the only erroring functions are std:: maths stuff (although there are a few cryptic errors relating to float pointers that will probably fix themselves).

All the other standard stuff seems to be working okay, it's just maths in GLM.
 

dimok

Well-Known Member
Member
Joined
Jan 11, 2009
Messages
728
Trophies
3
XP
2,635
Country
United States
Alright, I'm close. The libraries all seem to be working fine, but now GLM is telling me that the C++ standard libraries don't exist ;D

Stuff like std::acosh and std::round are throwing "has not been defined" errors. All the issues seem to be in the GLM files and the only erroring functions are std:: maths stuff (although there are a few cryptic errors relating to float pointers that will probably fix themselves).

All the other standard stuff seems to be working okay, it's just maths in GLM.
The problem is that those functions are C++11 implementations. The devkitPro C++11 implementation is incomplete. No one is really updating it anymore. I had to modify GLM to use the C implemantion of these functions instead of the C++11 one.

I would suggest you to remove your own copy of GLM and use the one I included in the portlibs package. Just put the "portlibs" and "libogc" folder from the above link from @looseless into your devkitPro folder and it should be working. Of course you can also just do the same change yourself and use a newer version of GLM than I have included there (if there is a newer one, I didnt check but its still the version from november 2015 in there).
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    I @ idonthave: :)