Commit graph

153 commits

Author SHA1 Message Date
Clownacy
9fd95e720c Whoops, remove a leftover std:: 2020-04-06 13:49:57 +01:00
Clownacy
ba9ccec945 Change double to float
A quick test with godbolt shows this produces smaller (and presumably
faster) code.
2020-04-06 13:48:44 +01:00
Clownacy
545948584a Different optimisation for software-mixer
`trunc` can resolve to a library call, while a cast-to-int doesn't
appear to. Since the mixer already does a cast-to-int when retrieving
samples, I can kill two birds with one stone.
2020-04-06 13:40:39 +01:00
Clownacy
1016411fa4 Cleanup 2020-04-06 13:37:53 +01:00
Gabriel Ravier
81e3259535 Backends/Audio/SoftwareMixer: Optimized fmod(x, 1.0) to x - trunc(x)
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-05 23:04:59 +02:00
Gabriel Ravier
1cf4200051 Merge branch 'portable' into improvePerformance2 2020-04-05 19:33:13 +02:00
Clownacy
bcd883e767 Fix weird buzzing in the software mixer
Not really sure why this causes it, but apparently it does.
2020-04-05 18:17:38 +01:00
Gabriel Ravier
1d9048c8a6 Merge branch 'portable' into improvePerformance2
# Conflicts:
#	src/Backends/Rendering/Software.cpp
2020-04-05 01:16:09 +02:00
Clownacy
7c729af36f Add a comment 2020-04-04 20:58:12 +01:00
Clownacy
6ea58290f4 Set SDL2 audio backend to 48000Hz 2020-04-04 20:57:34 +01:00
Clownacy
b3e40b0475 Fix SDL2 audio backend 2020-04-04 20:52:24 +01:00
Gabriel Ravier
afd3abecc4 Correctly used Attributes.h instead of a definition directly in SoftwareMixer.cpp
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-03 00:43:34 +02:00
Gabriel Ravier
f68984bd58 Merge branch 'portable' into improvePerformance2
# Conflicts:
#	src/Backends/Audio/SDL2.cpp
2020-04-03 00:36:44 +02:00
Clownacy
373c0e658a Use PlatformBackend_ShowMessageBox somewhere 2020-04-02 21:32:50 +01:00
Clownacy
b57ccd7ed5 Shut up errors on Windows 2020-03-31 20:22:54 +01:00
Clownacy
d0b20316de Don't do -Iexternal
It pollutes the #include space.
2020-03-31 14:26:24 +01:00
Clownacy
d91c1e9bdc Update the SDL2 audio backend
Now uses the shared software mixer
2020-03-31 12:19:44 +01:00
Clownacy
732d3bbc5c Split software audio mixer to its own file
This will be shared between the SDL2 and miniaudio backends,
eliminating all that digusting duplicate code.
2020-03-31 12:14:20 +01:00
Clownacy
4e58457e1d Make miniaudio backend use native sample rate
This avoids the need for miniaudio to resample the mixer's output.
2020-03-31 10:20:20 +01:00
Clownacy
dd04977f29 Update miniaudio to v0.10.1
This newer version supports marking all of its declarations as
static, avoiding the conflict between the miniaudio audio backend,
and the copy of miniaudio embedded in clownaudio in the enhanced
branch.
2020-03-17 13:25:41 +00:00
Clownacy
9af25f7c67 Hopefully fixed miniaudio backend on Windows
Stupid BOOL type
2020-03-04 21:02:17 +00:00
Clownacy
af24d010a5 Clean-up miniaudio backend a little
Really need to figure out the best way to abstract-away the software
mixer...
2020-02-29 18:19:06 +00:00
Clownacy
8ec8a8d990 Added unfinished miniaudio audio backend
Currently only works with CMake
2020-02-29 18:18:59 +00:00
Gabriel Ravier
b238bcee03 Remove random lines mistakenly added by merge 2020-02-14 08:27:07 +01:00
Gabriel Ravier
65db12baaa Started trying to optimize MakePixelWaveData 2020-02-13 19:55:39 +01:00
Clownacy
f82a53d336 Prevent errors encountered by MSVC 2020-02-09 18:47:50 +00:00
Clownacy
2e5e1994c2 Enable debug console prints in non-debug builds 2020-02-03 16:44:52 +00:00
Clownacy
e3db7749ba Add verbose error-reporting to backends
Should fix #98
2020-02-01 12:22:44 +00:00
Clownacy
788697dc5d Fix a possible hang in the audio mixer
It was likely a race condition between the game thread writing to
'organya_timer', and the audio thread reading it.

...I really need to rethink the API for this Organya-synchronisation
thing.
2020-01-29 23:21:27 +00:00
Clownacy
e4394aea1f Whoops, forgot to remove this #include 2020-01-29 22:16:21 +00:00
Clownacy
d0defa4a7b This cast shouldn't be necessary 2020-01-29 22:15:53 +00:00
Clownacy
638e96be11 Move and rename attrHot
Like the MIN and MAX macros, I'd rather keep this in the source file
than a common header.
2020-01-29 22:14:35 +00:00
Gabriel Ravier
5e6658847c Re-add missing "(double)"
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-01-29 23:04:17 +01:00
Gabriel Ravier
88a8362f23 Reverted fmodf stuff and tried to make it so C++ compilers would go for the float version in appropriate circumstances (fmodf directly is unavailable due to not being in C89)
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-01-29 23:01:31 +01:00
Gabriel Ravier
1442299924 Made MixSounds be marked as hot
Signed-off-by: Gabriel Ravier <gabrielravier@gabrielAncientIBMv2>
2020-01-29 23:01:31 +01:00
Gabriel Ravier
c15ecbf728 Used fmodf instead of fmod for a 0.5% performance increase in MixSounds
Signed-off-by: Gabriel Ravier <gabrielravier@gabrielAncientIBMv2>
2020-01-29 23:01:31 +01:00
Clownacy
79886f5ae4 Add debug prints for listing SDL2 drivers
These list what video/render/audio backends are available, and which
are currently being used.

SDL2 allows you to choose a specific video/audio driver with the
SDL_VIDEODRIVER and SDL_AUDIODRIVER environment variables,
respectively, but there's no such option for the render driver.
2020-01-20 15:27:05 +00:00
Clownacy
449a09b09e Fix an occational invalid memory read
Stupid floating-point rounding errors. Had to undo a fancy
optimisation to avoid it.
2020-01-09 09:10:24 +00:00
Clownacy
bbf77f9cfd Capitalise a macro 2020-01-04 20:57:36 +00:00
Clownacy
01c5fb3a37 Shut up another warning 2019-10-29 12:25:03 +00:00
Clownacy
b6f8bf68ec Minor audio backend cleanup 2019-09-16 23:08:05 +00:00
Clownacy
949bfd129b Allow SDL2 to change the audio frequency
The mixer can handle arbitrary frequencies, so there's no point in
forcing SDL2 to use 44100Hz.
2019-09-10 22:11:31 +00:00
Clownacy
aede7b6069 Restore the FREQUENCY constant
Cave Story at 2000Hz is fun
2019-09-10 14:04:06 +00:00
Clownacy
657b586cd1 Add missing #include to audio backend
Another GabrielRavier fix.
2019-09-10 12:36:55 +00:00
Clownacy
355b303635 Shut up some warnings 2019-09-10 01:53:19 +01:00
Clownacy
3eb346ce10 Synchronise the audio callback with Organya
This is the 'perfect' Organya playback I mentioned in the commit
message for 5ea356a3bd
2019-09-09 21:43:33 +00:00
Clownacy
a076274864 Make a clamp macro safer 2019-09-09 20:24:09 +00:00
Clownacy
a220732aac Shut up some warnings 2019-09-06 20:03:35 +01:00
Clownacy
0dc9bb6b1b Change the audio backend API again 2019-09-06 14:46:31 +00:00
Clownacy
ce055c12cb Remove a now-unused function 2019-09-05 03:17:20 +00:00