Commit graph

153 commits

Author SHA1 Message Date
Clownacy
70e431d35d Add missing(?) header 2020-06-24 16:02:28 +01:00
Clownacy
1ff5772843 Fix typo 2020-06-24 12:12:28 +01:00
Clownacy
2ee1bf131e Update miniaudio backend to new mixer 2020-06-24 01:15:21 +01:00
Clownacy
479fff2ccf New mostly-integer-only sound mixer
The mixer itself is integer-only, but the millibel stuff is still
float-based (I don't know if it's worth adding a 10001-value-long
lookup table to replace it).

Anyway, according to a quick test, this new mixer is significantly
faster than the old floating-point one - rarely going above 100
clock() ticks per callback, with the old one almost always running
above that.

For now, only the SDL2 backend supports it - I'll add the others in
upcoming commits.

This will no-doubt cause problems with the enhanced (lite) branch,
where clownaudio always outputs float samples.
2020-06-24 01:11:02 +01:00
Clownacy
22c9987191 Dear me: Test your fixes before committing them
you complete tit-head
2020-04-24 19:49:18 +01:00
Clownacy
cbeeb7a180 Fix WiiU-Software backend buffer being 5ms
5ms is too small: it cannot be updated fast enough, resulting in
crackling coming from the gamepad speakers. Now it's 10ms, as
intended.
2020-04-24 19:42:47 +01:00
Clownacy
20440ff5e0 Missing a line 2020-04-24 17:20:32 +01:00
Clownacy
8e2d8ab962 Add context initialisation to miniaudio backend
This is used for mutexes in the enhanced backend
2020-04-24 17:06:53 +01:00
Clownacy
f55450d141 Rename WiiU.cpp to WiiU-Hardware.cpp 2020-04-21 14:27:15 +01:00
Clownacy
a2b272fdf7 Address a TODO, and do some cleanup 2020-04-21 13:58:20 +01:00
Clownacy
e470b91501 Cleanup and documentation 2020-04-20 02:46:46 +01:00
Clownacy
5c575a0be9 Fix crash
Dammit my build process wasn't actually updating the binary I was
testing.
2020-04-19 20:15:20 +01:00
Clownacy
93cf72e269 Add sanity checks to the Wii U hardware mixer
The other audio backends have these - probably for a good reason,
too.
2020-04-19 19:45:09 +01:00
Clownacy
4f80ff4139 Correct a typo 2020-04-19 19:44:06 +01:00
Clownacy
04faccb259 More cleanup 2020-04-19 19:43:57 +01:00
Clownacy
01a444ff8c More cleanup 2020-04-19 19:37:16 +01:00
Clownacy
5704035b9b Cleanup 2020-04-19 19:31:21 +01:00
Clownacy
9e3b158973 Add stereo support to Wii U software mixer 2020-04-19 19:27:02 +01:00
Clownacy
288c2dccee Wii U - Use a frame callback instead of a thread 2020-04-19 19:05:25 +01:00
Clownacy
07ee648181 Add Wii U software audio mixer
The hardware-accelerated one is suffering from a bizarre-ass bug that
I can't fix for the life of me.
2020-04-19 19:03:00 +01:00
Clownacy
745783a025 Wii U samples are signed 2020-04-19 13:51:45 +01:00
Clownacy
7d95fb8ea3 Wii U audio backend cleanup
Still bugging-out though
2020-04-19 13:46:10 +01:00
Clownacy
11b04fe93b Update other audio backends 2020-04-18 01:38:25 +01:00
Clownacy
011cb94f73 More guards 2020-04-18 01:23:25 +01:00
Clownacy
873566a19e Attempt 100 of trying to fix Wii U audio hangs
There's a new bug I've noticed: sometimes, an instrument will just
'disappear', and refuse to ever play again.

This stuff is practically impossible to debug, so I'm just throwing
things at the wall. This time, I'm going to make more use of the
`AXVoiceBegin` and `AXVoiceEnd` functions. I have no idea what
they're meant to do: code I found online uses it inconstently, and
Decaf doesn't have it implemented at all!

Hopefully, all of my problems have just been race conditions caused
by not using these guard functions (assuming that's what they are).
2020-04-18 01:16:36 +01:00
Clownacy
f78f6b7105 Split Organya callback data
The function pointer only ever needs to be set once, unlike the
timer. This should avoid any scary race-conditions.
2020-04-18 00:54:24 +01:00
Clownacy
1ad6fdf539 Rename mutex 2020-04-17 23:52:00 +01:00
Clownacy
b06e1e1312 Remove old junk 2020-04-17 23:48:40 +01:00
Clownacy
051d12f434 Stop shouldn't rewind the sound
According to the DirectSound docs, stop doesn't rewind.

https://docs.microsoft.com/en-us/previous-versions/ms817375%28v%3dmsdn.10%29
2020-04-17 23:47:45 +01:00
Clownacy
5bcc0ec393 New way to allocate Wii U voices
The previous method wasn't good enough: we were still maxing-out at
96 (did the Decaf devs misread that as hex? Is that why the
emulator's limit is 150 instead?).

Anyway, this new solution is a little brutish, but I can't think of
anything else that would work: right now, I have the Organya thread
constantly polling a linked-list of the currently-loaded sounds, and
checking if their voices have finished playing or not. If they've
finished, they get freed.

When AudioBackend_PlaySound is called, if checks if the sound's voice
has been freed or not, and reallocates it if it has.

There doesn't seem to be a noticable overhead to this, and it keeps
the number of currently-allocated voices *very* low (from 10 to 20 on
average).
2020-04-17 23:43:17 +01:00
Clownacy
b123e3743e Clean-up the weird buggy code
I'mma just assume each sound needs their struct preserving for some
reason.
2020-04-17 21:48:34 +01:00
Clownacy
db14899b3e Try to fix Wii U audio hang part 2
I encountered a hang earlier, so the previous attempt obviously
didn't work.
2020-04-17 18:34:26 +01:00
Clownacy
76e7a6f857 Revert some suspicious code
I'm getting some rare audio hangs. I tried doing some
regression-testing, but it's so random that I'm getting anomalous
results. That said, there were suspicious results around this change
(and also the way `mix_data` is initialised/cleared), so I'm
reverting this for now, and restoring it next time I encounter a
hang.
2020-04-17 16:58:07 +01:00
Clownacy
d025fecf54 Minor cleanup 2020-04-17 15:47:56 +01:00
Clownacy
a177f44b88 Clean up Wii U audio backend 2020-04-17 14:15:23 +01:00
Clownacy
9eacc74ee2 Got music working on Wii U! 2020-04-17 01:47:23 +01:00
Clownacy
edc9299007 Fix the game using too many Wii U voices
Now it just allocates channels on-demand, rather than ahead-of-time.
2020-04-16 22:42:33 +01:00
Clownacy
a7ebdb75e5 Added unfinished Wii U audio backend
Currently doesn't produce sound unless you stop Organya from calling
AudioBackend_CreateSound, because it exhausts the Wii U's 150-sound
pool before the SFX get any of them.
2020-04-16 22:19:00 +01:00
Clownacy
02f570cec7 Add Null audio backend
Literally doesn't do anything
2020-04-13 18:31:39 +01:00
Clownacy
c51a074fad Big disgusting backend rework
We need to avoid `WindowsWrapper.h` in the backends whenever we can,
to avoid name collisions (the Wii U homebrew library) defines its own
BOOL/TRUE/FALSE, which really doesn't work with CSE2.
2020-04-13 18:19:39 +01:00
Clownacy
cdd97cb733 Some cleanup 2020-04-13 13:34:55 +01:00
Clownacy
4f7cc9582d Revert "Backends: Added init/de-init messages for backends"
This reverts commit 9be8b9a493.
2020-04-13 13:28:57 +01:00
Gabriel Ravier
9be8b9a493 Backends: Added init/de-init messages for backends
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 02:26:51 +02:00
Gabriel Ravier
92d565692a Backends: Use "SDL" instead of "SDL2" to match documentation vocabulary
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 01:16:45 +02:00
Gabriel Ravier
27eb7d1788 Backend/Audio/SDL2: Replace puts call with Backend_PrintInfo
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:49:22 +02:00
Gabriel Ravier
dcd4bcf1b2 Backends: Fix some of the error handling and replaced some printf calls
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:42:24 +02:00
Gabriel Ravier
16441ee87b Backends: Improved miniaudio and GLFW3 error handling
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-11 16:57:04 +02:00
Gabriel Ravier
7f7c3d8434 Backends: Started adding a bunch of error handling stuff (error checking only done in SDL2 for now)
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-10 22:32:29 +02:00
Clownacy
6456649e11 Pre-process audio in the software mixer
This should improve performance slightly
2020-04-06 19:52:53 +01:00
Clownacy
5daea02ac6 Change the audio backend API
Removes locking and unlocking: instead, samples are passed to Create.
2020-04-06 19:44:45 +01:00