Skip to content
Permalink
Browse files

Switch audio assets to Opus (#167)

* Switch BGMs to Opus

* Switch SFX to Opus; use floating-point mixing

* opus sfx: support resampling via SDL_AudioStream

* bump SDL2 version requirement to 2.0.6

2.0.5 doesn't have the SDL_AudioStream API, and is ancient anyway.
  • Loading branch information...
Akaricchi committed May 11, 2019
1 parent 219aa34 commit b0856ce07d3a7a7b5a44128b59518c9042980a6f
Showing with 243 additions and 43 deletions.
  1. +3 −2 README.rst
  2. +4 −3 meson.build
  3. +1 −1 resources/00-taisei.pkgdir/.nocompress
  4. +1 −1 resources/00-taisei.pkgdir/bgm/bonus0.bgm
  5. BIN resources/00-taisei.pkgdir/bgm/bonus0.ogg
  6. BIN resources/00-taisei.pkgdir/bgm/bonus0.opus
  7. +1 −1 resources/00-taisei.pkgdir/bgm/credits.bgm
  8. BIN resources/00-taisei.pkgdir/bgm/credits.ogg
  9. BIN resources/00-taisei.pkgdir/bgm/credits.opus
  10. +1 −1 resources/00-taisei.pkgdir/bgm/ending.bgm
  11. BIN resources/00-taisei.pkgdir/bgm/ending.ogg
  12. BIN resources/00-taisei.pkgdir/bgm/ending.opus
  13. +1 −1 resources/00-taisei.pkgdir/bgm/menu.bgm
  14. BIN resources/00-taisei.pkgdir/bgm/menu.ogg
  15. BIN resources/00-taisei.pkgdir/bgm/menu.opus
  16. +1 −1 resources/00-taisei.pkgdir/bgm/scuttle.bgm
  17. BIN resources/00-taisei.pkgdir/bgm/scuttle.ogg
  18. BIN resources/00-taisei.pkgdir/bgm/scuttle.opus
  19. +1 −1 resources/00-taisei.pkgdir/bgm/stage1.bgm
  20. BIN resources/00-taisei.pkgdir/bgm/stage1/boss.ogg
  21. BIN resources/00-taisei.pkgdir/bgm/stage1/boss.opus
  22. BIN resources/00-taisei.pkgdir/bgm/stage1/stage.ogg
  23. BIN resources/00-taisei.pkgdir/bgm/stage1/stage.opus
  24. +1 −1 resources/00-taisei.pkgdir/bgm/stage1boss.bgm
  25. +1 −1 resources/00-taisei.pkgdir/bgm/stage2.bgm
  26. BIN resources/00-taisei.pkgdir/bgm/stage2/boss.ogg
  27. BIN resources/00-taisei.pkgdir/bgm/stage2/boss.opus
  28. BIN resources/00-taisei.pkgdir/bgm/stage2/stage.ogg
  29. BIN resources/00-taisei.pkgdir/bgm/stage2/stage.opus
  30. +1 −1 resources/00-taisei.pkgdir/bgm/stage2boss.bgm
  31. +1 −1 resources/00-taisei.pkgdir/bgm/stage3.bgm
  32. BIN resources/00-taisei.pkgdir/bgm/stage3/boss.ogg
  33. BIN resources/00-taisei.pkgdir/bgm/stage3/boss.opus
  34. BIN resources/00-taisei.pkgdir/bgm/stage3/stage.ogg
  35. BIN resources/00-taisei.pkgdir/bgm/stage3/stage.opus
  36. +1 −1 resources/00-taisei.pkgdir/bgm/stage3boss.bgm
  37. +1 −1 resources/00-taisei.pkgdir/bgm/stage4.bgm
  38. BIN resources/00-taisei.pkgdir/bgm/stage4/boss.ogg
  39. BIN resources/00-taisei.pkgdir/bgm/stage4/boss.opus
  40. BIN resources/00-taisei.pkgdir/bgm/stage4/stage.ogg
  41. BIN resources/00-taisei.pkgdir/bgm/stage4/stage.opus
  42. +1 −1 resources/00-taisei.pkgdir/bgm/stage4boss.bgm
  43. +1 −1 resources/00-taisei.pkgdir/bgm/stage5.bgm
  44. BIN resources/00-taisei.pkgdir/bgm/stage5/boss.ogg
  45. BIN resources/00-taisei.pkgdir/bgm/stage5/boss.opus
  46. BIN resources/00-taisei.pkgdir/bgm/stage5/stage.ogg
  47. BIN resources/00-taisei.pkgdir/bgm/stage5/stage.opus
  48. +1 −1 resources/00-taisei.pkgdir/bgm/stage5boss.bgm
  49. +1 −1 resources/00-taisei.pkgdir/bgm/stage6.bgm
  50. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase1.ogg
  51. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase1.opus
  52. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase2.ogg
  53. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase2.opus
  54. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase3.ogg
  55. BIN resources/00-taisei.pkgdir/bgm/stage6/boss_phase3.opus
  56. BIN resources/00-taisei.pkgdir/bgm/stage6/stage.ogg
  57. BIN resources/00-taisei.pkgdir/bgm/stage6/stage.opus
  58. +1 −1 resources/00-taisei.pkgdir/bgm/stage6boss_phase1.bgm
  59. +1 −1 resources/00-taisei.pkgdir/bgm/stage6boss_phase2.bgm
  60. +1 −1 resources/00-taisei.pkgdir/bgm/stage6boss_phase3.bgm
  61. BIN resources/00-taisei.pkgdir/sfx/bomb_marisa_a.ogg
  62. BIN resources/00-taisei.pkgdir/sfx/bomb_marisa_a.opus
  63. BIN resources/00-taisei.pkgdir/sfx/bomb_marisa_b.ogg
  64. BIN resources/00-taisei.pkgdir/sfx/bomb_marisa_b.opus
  65. BIN resources/00-taisei.pkgdir/sfx/bomb_reimu_a.ogg
  66. BIN resources/00-taisei.pkgdir/sfx/bomb_reimu_a.opus
  67. BIN resources/00-taisei.pkgdir/sfx/bomb_youmu_a.ogg
  68. BIN resources/00-taisei.pkgdir/sfx/bomb_youmu_a.opus
  69. BIN resources/00-taisei.pkgdir/sfx/bomb_youmu_b.ogg
  70. BIN resources/00-taisei.pkgdir/sfx/bomb_youmu_b.opus
  71. BIN resources/00-taisei.pkgdir/sfx/boom.ogg
  72. BIN resources/00-taisei.pkgdir/sfx/boom.opus
  73. BIN resources/00-taisei.pkgdir/sfx/boon.ogg
  74. BIN resources/00-taisei.pkgdir/sfx/boon.opus
  75. BIN resources/00-taisei.pkgdir/sfx/bossdeath.ogg
  76. BIN resources/00-taisei.pkgdir/sfx/bossdeath.opus
  77. BIN resources/00-taisei.pkgdir/sfx/charge_extra.ogg
  78. BIN resources/00-taisei.pkgdir/sfx/charge_extra.opus
  79. BIN resources/00-taisei.pkgdir/sfx/charge_generic.ogg
  80. BIN resources/00-taisei.pkgdir/sfx/charge_generic.opus
  81. BIN resources/00-taisei.pkgdir/sfx/death.ogg
  82. BIN resources/00-taisei.pkgdir/sfx/death.opus
  83. BIN resources/00-taisei.pkgdir/sfx/enemydeath.ogg
  84. BIN resources/00-taisei.pkgdir/sfx/enemydeath.opus
  85. BIN resources/00-taisei.pkgdir/sfx/extra_bomb.ogg
  86. BIN resources/00-taisei.pkgdir/sfx/extra_bomb.opus
  87. BIN resources/00-taisei.pkgdir/sfx/extra_life.ogg
  88. BIN resources/00-taisei.pkgdir/sfx/extra_life.opus
  89. BIN resources/00-taisei.pkgdir/sfx/generic_shot.ogg
  90. BIN resources/00-taisei.pkgdir/sfx/generic_shot.opus
  91. BIN resources/00-taisei.pkgdir/sfx/graze.ogg
  92. BIN resources/00-taisei.pkgdir/sfx/graze.opus
  93. BIN resources/00-taisei.pkgdir/sfx/hit.ogg
  94. BIN resources/00-taisei.pkgdir/sfx/hit.opus
  95. BIN resources/00-taisei.pkgdir/sfx/hit0.ogg
  96. BIN resources/00-taisei.pkgdir/sfx/hit0.opus
  97. BIN resources/00-taisei.pkgdir/sfx/hit1.ogg
  98. BIN resources/00-taisei.pkgdir/sfx/hit1.opus
  99. BIN resources/00-taisei.pkgdir/sfx/item_generic.ogg
  100. BIN resources/00-taisei.pkgdir/sfx/item_generic.opus
  101. BIN resources/00-taisei.pkgdir/sfx/laser1.ogg
  102. BIN resources/00-taisei.pkgdir/sfx/laser1.opus
  103. BIN resources/00-taisei.pkgdir/sfx/noise1.ogg
  104. BIN resources/00-taisei.pkgdir/sfx/noise1.opus
  105. BIN resources/00-taisei.pkgdir/sfx/powersurge_end.ogg
  106. BIN resources/00-taisei.pkgdir/sfx/powersurge_end.opus
  107. BIN resources/00-taisei.pkgdir/sfx/powersurge_start.ogg
  108. BIN resources/00-taisei.pkgdir/sfx/powersurge_start.opus
  109. BIN resources/00-taisei.pkgdir/sfx/powerup.ogg
  110. BIN resources/00-taisei.pkgdir/sfx/powerup.opus
  111. BIN resources/00-taisei.pkgdir/sfx/redirect.ogg
  112. BIN resources/00-taisei.pkgdir/sfx/redirect.opus
  113. BIN resources/00-taisei.pkgdir/sfx/shot1.ogg
  114. BIN resources/00-taisei.pkgdir/sfx/shot1.opus
  115. BIN resources/00-taisei.pkgdir/sfx/shot1_loop.ogg
  116. BIN resources/00-taisei.pkgdir/sfx/shot1_loop.opus
  117. BIN resources/00-taisei.pkgdir/sfx/shot2.ogg
  118. BIN resources/00-taisei.pkgdir/sfx/shot2.opus
  119. BIN resources/00-taisei.pkgdir/sfx/shot3.ogg
  120. BIN resources/00-taisei.pkgdir/sfx/shot3.opus
  121. BIN resources/00-taisei.pkgdir/sfx/shot_special1.ogg
  122. BIN resources/00-taisei.pkgdir/sfx/shot_special1.opus
  123. BIN resources/00-taisei.pkgdir/sfx/spellclear.ogg
  124. BIN resources/00-taisei.pkgdir/sfx/spellclear.opus
  125. BIN resources/00-taisei.pkgdir/sfx/spellend.ogg
  126. BIN resources/00-taisei.pkgdir/sfx/spellend.opus
  127. BIN resources/00-taisei.pkgdir/sfx/timeout1.ogg
  128. BIN resources/00-taisei.pkgdir/sfx/timeout1.opus
  129. BIN resources/00-taisei.pkgdir/sfx/timeout2.ogg
  130. BIN resources/00-taisei.pkgdir/sfx/timeout2.opus
  131. BIN resources/00-taisei.pkgdir/sfx/warp.ogg
  132. BIN resources/00-taisei.pkgdir/sfx/warp.opus
  133. +131 −13 src/audio/sdl2mixer/audio_sdl2mixer.c
  134. +4 −3 src/audio/sdl2mixer/meson.build
  135. +2 −2 src/credits.c
  136. +4 −0 src/meson.build
  137. +4 −0 src/util/meson.build
  138. +41 −0 src/util/opuscruft.c
  139. +18 −0 src/util/opuscruft.h
  140. +2 −0 subprojects/.gitignore
  141. +5 −0 subprojects/opus.wrap
  142. +5 −0 subprojects/opusfile.wrap
@@ -16,12 +16,13 @@ Dependencies
^^^^^^^^^^^^

- OpenGL >= 3.3 or OpenGL ES >= 3.0
- SDL2 >= 2.0.5
- SDL2_mixer
- SDL2 >= 2.0.6
- SDL2_mixer >= 2.0.4
- freetype2
- libpng >= 1.5.0
- libwebpdecoder >= 0.5 or libwebp >= 0.5
- libzip >= 1.2
- opusfile
- zlib

Optional:
@@ -114,13 +114,14 @@ endif
static = get_option('static') or (host_machine.system() == 'emscripten')

dep_freetype = dependency('freetype2', required : true, static : static, fallback : ['freetype', 'freetype_dep'])
dep_opusfile = dependency('opusfile', required : false, static : static, fallback : ['opusfile', 'opusfile_dep'])
dep_png = dependency('libpng', version : '>=1.5', required : true, static : static, fallback : ['libpng', 'png_dep'])
dep_sdl2 = dependency('sdl2', version : '>=2.0.5', required : true, static : static, fallback : ['sdl2', 'sdl2_dep'])
dep_sdl2_mixer = dependency('SDL2_mixer', required : false, static : static, fallback : ['sdl2_mixer', 'sdl2_mixer_dep'])
dep_sdl2 = dependency('sdl2', version : '>=2.0.6', required : true, static : static, fallback : ['sdl2', 'sdl2_dep'])
dep_sdl2_mixer = dependency('SDL2_mixer', version : '>=2.0.4', required : false, static : static, fallback : ['sdl2_mixer', 'sdl2_mixer_dep'])
dep_webp = dependency('libwebp', version : '>=0.5', required : false, static : static, fallback : ['libwebp', 'webp_dep'])
dep_webpdecoder = dependency('libwebpdecoder', version : '>=0.5', required : false, static : static, fallback : ['libwebp', 'webpdecoder_dep'])
dep_zlib = dependency('zlib', required : true, static : static, fallback : ['zlib', 'zlib_dep'])
dep_zip = dependency('libzip', version : '>=1.2', required : false, static : static, fallback : ['libzip', 'libzip_dep'])
dep_zlib = dependency('zlib', required : true, static : static, fallback : ['zlib', 'zlib_dep'])
dep_crypto = dependency('libcrypto', required : false, static : static)

dep_m = cc.find_library('m', required : false)
@@ -1 +1 @@
^.*\.(ttf|png|webp|ogg|prog)$
^.*\.(ttf|png|webp|ogg|opus|prog)$
@@ -1,5 +1,5 @@
title = Divine Correction for Outliers
artist = Tuck V
loop = res/bgm/bonus0.ogg
loop = res/bgm/bonus0.opus
loop_point = 2.909093
comment = The decision to arrange a character’s existing theme or to come up with something entirely new is difficult and likely one ZUN himself struggles with.\n\nI know my strengths lie in the latter, which ultimately resulted in the stormy composition usually heard at the top of the tower, but Iku has such an interesting original theme I had to at least accept the challenge.\n\nUltimately, I can’t decide if I did the original justice with this one or not, but I know it holds a special place in my heart.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
title = Existential Field
artist = Tuck V
loop = res/bgm/credits.ogg
loop = res/bgm/credits.opus
comment = The staff roll theme.\n\nA sense of inspiration and the future is maintained from Excitation Field.\n\nOne that’s a lot gentler than a thunderstorm… perhaps a bit more like a rainbow.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
title = Dream Cycle
artist = Tuck V
loop = res/bgm/ending.ogg
loop = res/bgm/ending.opus
comment = The ending’s theme.\n\nIn summation, class, what have we learned today?\n\nKnowledge is the forbidden fruit; from it stem the powers of light and darkness. But it’s about time the protagonists have had a snack.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = Delta Concision
artist = Tuck V
loop = res/bgm/menu.ogg
loop = res/bgm/menu.opus
loop_point = 13.71
comment = An introduction to the occident.\n\nMany paths branch from one. Echoes from across the sea yield a new adventure.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = Logic Bombardier
artist = Tuck V
loop = res/bgm/scuttle.ogg
loop = res/bgm/scuttle.opus
loop_point = 5.64
comment = A secret theme for a most beloved character…\n\nI wanted to play with the concept of Scuttle’s motif as heard in the tunnel of light and try to apply it to a full-length song.\n\nThe results were interesting! Her theme is as much an experiment as her existence.\n\nSupposing she were to appear as a boss, I think it might sound different given a different role in the incident.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = The Fog Invites Unseen Mischief
artist = Tuck V
loop = res/bgm/stage1/stage.ogg
loop = res/bgm/stage1/stage.opus
loop_point = 6.857143
comment = The first stage’s theme.\n\nA relaxing mist illustrated with subdued instruments. Familiar shadows stir trouble just out of view. Ripples of times past dance across Misty Lake.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = An Impish Reflection on the Water
artist = Tuck V
loop = res/bgm/stage1/boss.ogg
loop = res/bgm/stage1/boss.opus
loop_point = 3.200000
comment = Cirno’s theme.\n\nShe’s feeling just as brave this time around, and acting a fair bit stronger.\n\nHowever, she’s really just a minor annoyance, cold and brittle. The protagonists brush off her pranks and move on.
@@ -1,5 +1,5 @@
title = Treasure the Wager, Treasure the Odds
artist = Tuck V
loop = res/bgm/stage2/stage.ogg
loop = res/bgm/stage2/stage.opus
loop_point = 10.124989
comment = The second stage’s theme.\n\nFor such a calm and serene path, there sure are a lot of troublemakers — a deceptively fast-paced theme, to be sure. One excitable example makes a brief appearance. The rhythm of this theme is meant to make you feel lucky.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
title = The Cheerful Presence of a Dark God
artist = Tuck V
loop = res/bgm/stage2/boss.ogg
loop = res/bgm/stage2/boss.opus
comment = Hina Kagiyama’s theme.\n\nThis time, it’s all up to chance.\n\nIt’s a little merciful sometimes, but you still have to do your best, no matter what. Gambling might be a poor stress-reliever…
@@ -1,4 +1,4 @@
title = Fizeau’s Finding ~ Lightray Vector
artist = Tuck V
loop = res/bgm/stage3/stage.ogg
loop = res/bgm/stage3/stage.opus
comment = The third stage’s theme.\n\nIt’s usually tricky to see in the dark. It pulls you in, engulfs you, like a sense-smothering flame. But this time, it might be best to protect your eyes. A fluttering little bug feels most at home in the dead of night, and most alive in a sea of light.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = Lightningbug ~ Lightning Heart
artist = Tuck V
loop = res/bgm/stage3/boss.ogg
loop = res/bgm/stage3/boss.opus
loop_point = 1.500000
comment = Wriggle Nightbug’s theme.\n\nA very motivated bug. She’s at the top of the world! — No, someone else is, she’s in the middle of a tunnel. Regardless, she knows she can do anything if she puts her mind to it, right?\n\nSounds a little “beach”-like in the introduction…
@@ -1,5 +1,5 @@
title = Evidence of Ki Domestication
artist = Tuck V
loop = res/bgm/stage4/stage.ogg
loop = res/bgm/stage4/stage.opus
loop_point = 32.470590
comment = The fourth stage’s theme.\n\nAnother trip back into the orient… like a pendulum swinging back and forth.\n\nThis theme draws inspiration from a particularly elusive musician living on the other side of the sea known for the Chinese influences in his music.\n\nSmells like rust.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = Marginal Red ~ The Red Word
artist = Tuck V
loop = res/bgm/stage4/boss.ogg
loop = res/bgm/stage4/boss.opus
loop_point = 24.000000
comment = Kurumi’s theme.\n\nOld faces and new dreams. She’s taken a new residence, something a little more comfortable than a Lake of Blood, but this confrontation is anything but. A mix of fears make the walls feel like they’re closing in.
@@ -1,4 +1,4 @@
title = Speak Not Falsely ~ Excitation Field
artist = Tuck V
loop = res/bgm/stage5/stage.ogg
loop = res/bgm/stage5/stage.opus
comment = The fifth stage’s theme.\n\nAnd back again… how did that song go? “No reason to get excited…”\n\nBut in honesty, this is a combination of Eastern and Western influences now. If it were like a pendulum up to this point, then this theme is like an oscillating electric current.\n\nThose who climb risk a long fall, so look to the top and don’t make a single dishonest step.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
title = A Prayer Worth Three Hundred Coulombs
artist = Tuck V
loop = res/bgm/stage5/boss.ogg
loop = res/bgm/stage5/boss.opus
loop_point = 12.80
comment = Iku Nagae’s theme.\n\nThis song went through the wringer. Perhaps that’s appropriate for what the protagonists have to do. Imagine climbing a tower in the middle of a vicious thunderstorm and try not to feel exhausted.\n\nIku provides the first tribulation.
@@ -1,5 +1,5 @@
title = Summit of Revelations
artist = Tuck V
loop = res/bgm/stage6/stage.ogg
loop = res/bgm/stage6/stage.opus
loop_point = 13.71
comment = The sixth stage’s theme.\n\nAt the top of the tower, you can see the world, and at what risk?\n\nA grand architectural marvel may take thousands of years to complete… this song was no different! But the end result feels like a great discovery.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
title = Cosmological Battle ~ The Vacuum Catastrophe
artist = Tuck V
loop = res/bgm/stage6/boss_phase1.ogg
loop = res/bgm/stage6/boss_phase1.opus
comment = Elly’s first theme.\n\nAn old friend. I always found myself inspired by the idea of a completely inconsequential character from forgotten times climbing to great heights after fading into obscurity.\n\nShe may have been a lowly gate guard the last time you saw her, but the apple’s fallen on her head. She’s a guard of a different kind of gate now.
@@ -1,5 +1,5 @@
title = Deified Emergent Property ~ Ambivalent Soul
artist = Tuck V
loop = res/bgm/stage6/boss_phase2.ogg
loop = res/bgm/stage6/boss_phase2.opus
loop_point = 1.6
comment = Elly’s second theme.\n\nThe most frightening and wondrous powers of the world remain just out of reach to our mortal minds. But a couple of truly brilliant people just may have found the bridge between our world and theirs…\n\nElly is a new person now, so an arrange wouldn’t speak the truth.
@@ -1,5 +1,5 @@
title = Immutable Truth
artist = Tuck V
loop = res/bgm/stage6/boss_phase3.ogg
loop = res/bgm/stage6/boss_phase3.opus
loop_point = 35.64
comment = Elly’s last spell.\n\nThe most ambitious and impossibly necessary tasks must encapsulate absolutely everything. Many think of science as a body of knowledge, a sealed bubble, within which all “great discoveries” have already been achieved, but the contrary could not be more true. Science is an unending series of dark curtains to pull back, each new finding more magnificent and imperceptible than the last.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,20 +9,32 @@
#include "taisei.h"

#include <SDL_mixer.h>
#include <opusfile.h>

#include "../backend.h"
#include "global.h"
#include "list.h"
#include "util/opuscruft.h"

#define B (_a_backend.funcs)

#define AUDIO_FREQ 44100
#define AUDIO_FORMAT MIX_DEFAULT_FORMAT
#define AUDIO_CHANNELS 100
#define AUDIO_FREQ 48000
#define AUDIO_FORMAT AUDIO_F32SYS
#define AUDIO_CHANNELS 32
#define UI_CHANNELS 4
#define UI_CHANNEL_GROUP 0
#define MAIN_CHANNEL_GROUP 1

#if AUDIO_FORMAT == AUDIO_S16SYS
typedef int16_t sample_t;
#define OPUS_READ_SAMPLES_STEREO op_read_stereo
#elif AUDIO_FORMAT == AUDIO_F32SYS
typedef float sample_t;
#define OPUS_READ_SAMPLES_STEREO op_read_float_stereo
#else
#error Audio format not recognized
#endif

// I needed to add this for supporting loop sounds since Mixer doesn’t remember
// what channel a sound is playing on. - laochailan

@@ -71,7 +83,7 @@ static bool audio_sdl2mixer_init(void) {
return false;
}

if(!(Mix_Init(MIX_INIT_OGG) & MIX_INIT_OGG)) {
if(!(Mix_Init(MIX_INIT_OPUS) & MIX_INIT_OPUS)) {
log_error("Mix_Init() failed: %s", Mix_GetError());
Mix_Quit();
return false;
@@ -346,10 +358,9 @@ static void custom_fadeout_free(int chan, void *udata) {
static void custom_fadeout_proc(int chan, void *stream, int len, void *udata) {
CustomFadeout *e = udata;

assert(AUDIO_FORMAT == AUDIO_S16SYS); // if you wanna change the format, you get to implement it here. This is the hardcoded default format in SDL_Mixer by the way
sample_t *data = stream;
len /= sizeof(sample_t);

int16_t *data = stream;
len /= 2;
for(int i = 0; i < len; i++) {
e->counter++;
data[i]*=1.-min(1,(double)e->counter/(double)e->duration);
@@ -417,7 +428,7 @@ static bool audio_sdl2mixer_sound_stop_all(AudioBackendSoundGroup group) {
}

static const char *const *audio_sdl2mixer_get_supported_exts(uint *numexts) {
static const char *const exts[] = { ".ogg", ".wav" };
static const char *const exts[] = { ".opus", ".ogg", ".wav" };
*numexts = ARRAY_SIZE(exts);
return exts;
}
@@ -433,13 +444,14 @@ static MusicImpl *audio_sdl2mixer_music_load(const char *vfspath) {
Mix_Music *mus = Mix_LoadMUS_RW(rw, true);

if(!mus) {
log_error("Mix_LoadMUS_RW() failed: %s", Mix_GetError());
log_error("Mix_LoadMUS_RW() failed: %s (%s)", Mix_GetError(), vfspath);
return NULL;
}

MusicImpl *imus = calloc(1, sizeof(*imus));
imus->loop = mus;

log_debug("Loaded stream from %s", vfspath);
return imus;
}

@@ -448,6 +460,95 @@ static void audio_sdl2mixer_music_unload(MusicImpl *imus) {
free(imus);
}

static OggOpusFile *try_load_opus(SDL_RWops *rw) {
uint8_t buf[128];
SDL_RWread(rw, buf, 1, sizeof(buf));
int error = op_test(NULL, buf, sizeof(buf));

if(error != 0) {
log_debug("op_test() failed: %i", error);
goto fail;
}

OggOpusFile *opus = op_open_callbacks(rw, &opusutil_rwops_callbacks, buf, sizeof(buf), &error);

if(opus == NULL) {
log_debug("op_open_callbacks() failed: %i", error);
goto fail;
}

return opus;

fail:
SDL_RWseek(rw, 0, RW_SEEK_SET);
return NULL;
}

static Mix_Chunk *read_opus_chunk(OggOpusFile *opus, const char *vfspath) {
int mix_frequency = 0;
int mix_channels;
uint16_t mix_format = 0;
Mix_QuerySpec(&mix_frequency, &mix_format, &mix_channels);

SDL_AudioStream *stream = SDL_NewAudioStream(AUDIO_FORMAT, 2, 48000, mix_format, mix_channels, mix_frequency);

for(;;) {
sample_t read_buf[1920];
int r = OPUS_READ_SAMPLES_STEREO(opus, read_buf, sizeof(read_buf));

if(r == OP_HOLE) {
continue;