ruby2d 0.12.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (620) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +7 -0
  3. data/README.md +141 -0
  4. data/USAGE.md +2435 -0
  5. data/assets/Rakefile +637 -0
  6. data/assets/build_support/CMakeLists.txt +94 -0
  7. data/assets/build_support/mruby/build_config.rb +34 -0
  8. data/assets/build_support/mruby/build_config_wasm.rb +30 -0
  9. data/assets/build_support/sdl_test.c +174 -0
  10. data/assets/deps.yaml +16 -0
  11. data/assets/platform/include/SDL3/SDL.h +91 -0
  12. data/assets/platform/include/SDL3/SDL_assert.h +705 -0
  13. data/assets/platform/include/SDL3/SDL_asyncio.h +550 -0
  14. data/assets/platform/include/SDL3/SDL_atomic.h +692 -0
  15. data/assets/platform/include/SDL3/SDL_audio.h +2370 -0
  16. data/assets/platform/include/SDL3/SDL_begin_code.h +553 -0
  17. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_bits.h +47 -27
  18. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_blendmode.h +59 -55
  19. data/assets/platform/include/SDL3/SDL_camera.h +535 -0
  20. data/assets/platform/include/SDL3/SDL_clipboard.h +331 -0
  21. data/assets/{include/SDL2/close_code.h → platform/include/SDL3/SDL_close_code.h} +9 -8
  22. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_copying.h +3 -1
  23. data/assets/platform/include/SDL3/SDL_cpuinfo.h +374 -0
  24. data/assets/platform/include/SDL3/SDL_dialog.h +343 -0
  25. data/assets/platform/include/SDL3/SDL_dlopennote.h +234 -0
  26. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_egl.h +11 -8
  27. data/assets/platform/include/SDL3/SDL_endian.h +645 -0
  28. data/assets/platform/include/SDL3/SDL_error.h +226 -0
  29. data/assets/platform/include/SDL3/SDL_events.h +1645 -0
  30. data/assets/platform/include/SDL3/SDL_filesystem.h +537 -0
  31. data/assets/platform/include/SDL3/SDL_gamepad.h +1656 -0
  32. data/assets/platform/include/SDL3/SDL_gpu.h +4608 -0
  33. data/assets/platform/include/SDL3/SDL_guid.h +106 -0
  34. data/assets/platform/include/SDL3/SDL_haptic.h +1461 -0
  35. data/assets/platform/include/SDL3/SDL_hidapi.h +571 -0
  36. data/assets/platform/include/SDL3/SDL_hints.h +5001 -0
  37. data/assets/platform/include/SDL3/SDL_init.h +507 -0
  38. data/assets/platform/include/SDL3/SDL_intrin.h +410 -0
  39. data/assets/platform/include/SDL3/SDL_iostream.h +1379 -0
  40. data/assets/platform/include/SDL3/SDL_joystick.h +1385 -0
  41. data/assets/platform/include/SDL3/SDL_keyboard.h +608 -0
  42. data/assets/platform/include/SDL3/SDL_keycode.h +347 -0
  43. data/assets/platform/include/SDL3/SDL_loadso.h +145 -0
  44. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_locale.h +40 -24
  45. data/assets/platform/include/SDL3/SDL_log.h +541 -0
  46. data/assets/platform/include/SDL3/SDL_main.h +704 -0
  47. data/assets/platform/include/SDL3/SDL_main_impl.h +151 -0
  48. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_messagebox.h +85 -48
  49. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_metal.h +29 -29
  50. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_misc.h +13 -12
  51. data/assets/platform/include/SDL3/SDL_mouse.h +813 -0
  52. data/assets/platform/include/SDL3/SDL_mutex.h +1117 -0
  53. data/assets/platform/include/SDL3/SDL_oldnames.h +1339 -0
  54. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl.h +1247 -278
  55. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengl_glext.h +5 -1
  56. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles.h +6 -7
  57. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2.h +10 -11
  58. data/assets/platform/include/SDL3/SDL_pen.h +198 -0
  59. data/assets/platform/include/SDL3/SDL_pixels.h +1441 -0
  60. data/assets/{include/SDL2/SDL_test_log.h → platform/include/SDL3/SDL_platform.h} +25 -26
  61. data/assets/platform/include/SDL3/SDL_platform_defines.h +497 -0
  62. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_power.h +40 -20
  63. data/assets/platform/include/SDL3/SDL_process.h +441 -0
  64. data/assets/platform/include/SDL3/SDL_properties.h +572 -0
  65. data/assets/platform/include/SDL3/SDL_rect.h +528 -0
  66. data/assets/platform/include/SDL3/SDL_render.h +3028 -0
  67. data/assets/platform/include/SDL3/SDL_revision.h +59 -0
  68. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_scancode.h +59 -68
  69. data/assets/platform/include/SDL3/SDL_sensor.h +321 -0
  70. data/assets/platform/include/SDL3/SDL_stdinc.h +6186 -0
  71. data/assets/platform/include/SDL3/SDL_storage.h +686 -0
  72. data/assets/platform/include/SDL3/SDL_surface.h +1769 -0
  73. data/assets/platform/include/SDL3/SDL_system.h +840 -0
  74. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test.h +16 -22
  75. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_assert.h +27 -34
  76. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_common.h +109 -52
  77. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_compare.h +22 -14
  78. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_crc32.h +27 -30
  79. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_font.h +50 -49
  80. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_fuzzer.h +64 -79
  81. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_harness.h +47 -30
  82. data/assets/platform/include/SDL3/SDL_test_log.h +83 -0
  83. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_md5.h +21 -28
  84. data/assets/{include/SDL2 → platform/include/SDL3}/SDL_test_memory.h +19 -16
  85. data/assets/platform/include/SDL3/SDL_thread.h +602 -0
  86. data/assets/platform/include/SDL3/SDL_time.h +249 -0
  87. data/assets/platform/include/SDL3/SDL_timer.h +454 -0
  88. data/assets/platform/include/SDL3/SDL_touch.h +184 -0
  89. data/assets/platform/include/SDL3/SDL_tray.h +544 -0
  90. data/assets/platform/include/SDL3/SDL_version.h +198 -0
  91. data/assets/platform/include/SDL3/SDL_video.h +3497 -0
  92. data/assets/platform/include/SDL3/SDL_vulkan.h +287 -0
  93. data/assets/platform/include/SDL3_image/SDL_image.h +3328 -0
  94. data/assets/platform/include/SDL3_mixer/SDL_mixer.h +3369 -0
  95. data/assets/platform/include/SDL3_ttf/SDL_textengine.h +181 -0
  96. data/assets/platform/include/SDL3_ttf/SDL_ttf.h +2833 -0
  97. data/assets/{include → platform/include}/mrbconf.h +42 -31
  98. data/assets/{include → platform/include}/mruby/array.h +3 -4
  99. data/assets/{include → platform/include}/mruby/boxing_nan.h +10 -0
  100. data/assets/platform/include/mruby/boxing_no.h +59 -0
  101. data/assets/{include → platform/include}/mruby/boxing_word.h +72 -26
  102. data/assets/platform/include/mruby/class.h +157 -0
  103. data/assets/{include → platform/include}/mruby/common.h +30 -1
  104. data/assets/{include → platform/include}/mruby/compile.h +52 -74
  105. data/assets/{include → platform/include}/mruby/data.h +2 -2
  106. data/assets/{include → platform/include}/mruby/debug.h +12 -5
  107. data/assets/{include → platform/include}/mruby/dump.h +7 -9
  108. data/assets/{include → platform/include}/mruby/endian.h +1 -1
  109. data/assets/platform/include/mruby/error.h +173 -0
  110. data/assets/platform/include/mruby/gc.h +79 -0
  111. data/assets/{include → platform/include}/mruby/hash.h +1 -7
  112. data/assets/platform/include/mruby/internal.h +282 -0
  113. data/assets/platform/include/mruby/irep.h +143 -0
  114. data/assets/{include → platform/include}/mruby/istruct.h +1 -1
  115. data/assets/platform/include/mruby/khash.h +455 -0
  116. data/assets/platform/include/mruby/mempool.h +19 -0
  117. data/assets/{include → platform/include}/mruby/numeric.h +7 -10
  118. data/assets/platform/include/mruby/object.h +51 -0
  119. data/assets/{include → platform/include}/mruby/opcode.h +5 -5
  120. data/assets/{include → platform/include}/mruby/ops.h +19 -6
  121. data/assets/platform/include/mruby/presym/id.h +1447 -0
  122. data/assets/{include → platform/include}/mruby/presym/scanning.h +10 -7
  123. data/assets/platform/include/mruby/presym/table.h +2893 -0
  124. data/assets/platform/include/mruby/presym.h +65 -0
  125. data/assets/platform/include/mruby/proc.h +184 -0
  126. data/assets/{include → platform/include}/mruby/range.h +0 -2
  127. data/assets/{include → platform/include}/mruby/string.h +33 -53
  128. data/assets/platform/include/mruby/throw.h +81 -0
  129. data/assets/{include → platform/include}/mruby/value.h +64 -29
  130. data/assets/{include → platform/include}/mruby/variable.h +6 -23
  131. data/assets/{include → platform/include}/mruby/version.h +7 -7
  132. data/assets/{include → platform/include}/mruby.h +238 -116
  133. data/assets/platform/macos-arm64/bin/mrbc +0 -0
  134. data/assets/platform/macos-arm64/lib/libSDL3.a +0 -0
  135. data/assets/platform/macos-arm64/lib/libSDL3_image.a +0 -0
  136. data/assets/platform/macos-arm64/lib/libSDL3_mixer.a +0 -0
  137. data/assets/platform/macos-arm64/lib/libSDL3_ttf.a +0 -0
  138. data/assets/platform/macos-arm64/lib/libmruby.a +0 -0
  139. data/assets/platform/wasm/lib/libFLAC.a +0 -0
  140. data/assets/platform/wasm/lib/libSDL3.a +0 -0
  141. data/assets/platform/wasm/lib/libSDL3_image.a +0 -0
  142. data/assets/platform/wasm/lib/libSDL3_mixer.a +0 -0
  143. data/assets/platform/wasm/lib/libSDL3_ttf.a +0 -0
  144. data/assets/platform/wasm/lib/libfreetype.a +0 -0
  145. data/assets/platform/wasm/lib/libharfbuzz.a +0 -0
  146. data/assets/platform/wasm/lib/libmruby.a +0 -0
  147. data/assets/platform/wasm/lib/libogg.a +0 -0
  148. data/assets/platform/wasm/lib/libplutosvg.a +0 -0
  149. data/assets/platform/wasm/lib/libplutovg.a +0 -0
  150. data/assets/platform/wasm/lib/libpng.a +0 -0
  151. data/assets/platform/wasm/lib/libpng16.a +0 -0
  152. data/assets/platform/wasm/lib/libvorbis.a +0 -0
  153. data/assets/platform/wasm/lib/libvorbisfile.a +0 -0
  154. data/assets/platform/wasm/lib/libzlibstatic.a +0 -0
  155. data/assets/platform/windows-arm64-mingw-ucrt/bin/mrbc.exe +0 -0
  156. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3.a +0 -0
  157. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_image.a +0 -0
  158. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
  159. data/assets/platform/windows-arm64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
  160. data/assets/platform/windows-arm64-mingw-ucrt/lib/libmruby.a +0 -0
  161. data/assets/platform/windows-x86_64-mingw-ucrt/bin/mrbc.exe +0 -0
  162. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3.a +0 -0
  163. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_image.a +0 -0
  164. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_mixer.a +0 -0
  165. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libSDL3_ttf.a +0 -0
  166. data/assets/platform/windows-x86_64-mingw-ucrt/lib/libmruby.a +0 -0
  167. data/assets/resources/fonts/outfit/OFL.txt +93 -0
  168. data/assets/resources/fonts/outfit/outfit.ttf +0 -0
  169. data/assets/resources/fonts/roboto_mono/OFL.txt +91 -0
  170. data/assets/resources/fonts/roboto_mono/roboto_mono.ttf +0 -0
  171. data/assets/resources/icons/icon.icns +0 -0
  172. data/assets/resources/icons/icon.png +0 -0
  173. data/assets/resources/spritesheets/License.txt +28 -0
  174. data/assets/resources/spritesheets/spritesheet-backgrounds.png +0 -0
  175. data/assets/resources/spritesheets/spritesheet-backgrounds.xml +16 -0
  176. data/assets/resources/spritesheets/spritesheet-characters.png +0 -0
  177. data/assets/resources/spritesheets/spritesheet-characters.xml +47 -0
  178. data/assets/resources/spritesheets/spritesheet-enemies.png +0 -0
  179. data/assets/resources/spritesheets/spritesheet-enemies.xml +62 -0
  180. data/assets/resources/spritesheets/spritesheet-tiles.png +0 -0
  181. data/assets/resources/spritesheets/spritesheet-tiles.xml +316 -0
  182. data/assets/{wasm → resources/web}/template.html +1 -1
  183. data/assets/target.rb +131 -0
  184. data/bin/ruby2d +281 -82
  185. data/examples/astar.rb +269 -0
  186. data/examples/asteroids.rb +403 -0
  187. data/examples/bezier_editor.rb +96 -0
  188. data/examples/boids.rb +191 -0
  189. data/examples/bouncing_balls.rb +119 -0
  190. data/examples/breakout.rb +186 -0
  191. data/examples/constellations.rb +100 -0
  192. data/examples/dashboard.rb +133 -0
  193. data/examples/double_pendulum.rb +254 -0
  194. data/examples/falling_sand.rb +291 -0
  195. data/examples/fireworks.rb +110 -0
  196. data/examples/fluid_dynamics.rb +340 -0
  197. data/examples/fourier_epicycles.rb +142 -0
  198. data/examples/fractal_tree.rb +326 -0
  199. data/examples/game_of_life.rb +148 -0
  200. data/examples/gamepads.rb +333 -0
  201. data/examples/hill_driver.rb +613 -0
  202. data/examples/logo_animation.rb +251 -0
  203. data/examples/lorenz_attractor.rb +115 -0
  204. data/examples/mandelbrot.rb +207 -0
  205. data/examples/marching_squares.rb +200 -0
  206. data/examples/maze.rb +323 -0
  207. data/examples/nbody.rb +338 -0
  208. data/examples/outrun.rb +391 -0
  209. data/examples/pixel_paint.rb +313 -0
  210. data/examples/platformer.rb +335 -0
  211. data/examples/ray_casting_maze.rb +175 -0
  212. data/examples/shadow_casting.rb +151 -0
  213. data/examples/shape_recognizer.rb +908 -0
  214. data/examples/snake.rb +144 -0
  215. data/examples/sprite_sheets.rb +246 -0
  216. data/examples/swarm.rb +206 -0
  217. data/examples/tsp_annealing.rb +104 -0
  218. data/examples/ui_controls.rb +163 -0
  219. data/examples/wireframe_3d.rb +139 -0
  220. data/ext/ruby2d/audio.c +324 -0
  221. data/ext/ruby2d/canvas.c +1715 -494
  222. data/ext/ruby2d/ext.c +541 -0
  223. data/ext/ruby2d/extconf.rb +122 -145
  224. data/ext/ruby2d/font.c +566 -20
  225. data/ext/ruby2d/fps.c +92 -0
  226. data/ext/ruby2d/image.c +466 -41
  227. data/ext/ruby2d/ruby2d.c +374 -1890
  228. data/ext/ruby2d/ruby2d.h +840 -460
  229. data/ext/ruby2d/shapes.c +931 -101
  230. data/ext/ruby2d/text.c +586 -21
  231. data/ext/ruby2d/window.c +1693 -283
  232. data/lib/ruby2d/atlas_parser.rb +194 -0
  233. data/lib/ruby2d/audio.rb +73 -0
  234. data/lib/ruby2d/benchmark.rb +259 -0
  235. data/lib/ruby2d/bitmap_text.rb +155 -0
  236. data/lib/ruby2d/button.rb +402 -0
  237. data/lib/ruby2d/canvas.rb +703 -279
  238. data/lib/ruby2d/circle.rb +206 -29
  239. data/lib/ruby2d/cli/browser.rb +314 -0
  240. data/lib/ruby2d/cli/build.rb +471 -257
  241. data/lib/ruby2d/cli/colorize.rb +7 -5
  242. data/lib/ruby2d/cli/examples.rb +127 -0
  243. data/lib/ruby2d/cli/launch.rb +24 -39
  244. data/lib/ruby2d/cli/lib_files.rb +48 -0
  245. data/lib/ruby2d/cli/messages.rb +40 -0
  246. data/lib/ruby2d/cli/setup.rb +273 -0
  247. data/lib/ruby2d/cli/static_server.rb +160 -0
  248. data/lib/ruby2d/cli/usage.rb +255 -0
  249. data/lib/ruby2d/color.rb +191 -69
  250. data/lib/ruby2d/core.rb +37 -19
  251. data/lib/ruby2d/deps_help.rb +89 -0
  252. data/lib/ruby2d/dsl.rb +51 -12
  253. data/lib/ruby2d/ellipse.rb +228 -0
  254. data/lib/ruby2d/exceptions.rb +0 -2
  255. data/lib/ruby2d/font.rb +34 -74
  256. data/lib/ruby2d/gamepad.rb +323 -0
  257. data/lib/ruby2d/gem_paths.rb +19 -0
  258. data/lib/ruby2d/image.rb +155 -52
  259. data/lib/ruby2d/interactive.rb +103 -0
  260. data/lib/ruby2d/json_parser.rb +268 -0
  261. data/lib/ruby2d/line.rb +194 -85
  262. data/lib/ruby2d/mruby_compat.rb +12 -0
  263. data/lib/ruby2d/polygon.rb +297 -0
  264. data/lib/ruby2d/polyline.rb +368 -0
  265. data/lib/ruby2d/quad.rb +358 -94
  266. data/lib/ruby2d/rectangle.rb +77 -19
  267. data/lib/ruby2d/renderable.rb +411 -11
  268. data/lib/ruby2d/sprite.rb +471 -180
  269. data/lib/ruby2d/sprite_sheet.rb +64 -0
  270. data/lib/ruby2d/square.rb +29 -17
  271. data/lib/ruby2d/text.rb +196 -65
  272. data/lib/ruby2d/tileset.rb +139 -81
  273. data/lib/ruby2d/triangle.rb +324 -89
  274. data/lib/ruby2d/version.rb +1 -3
  275. data/lib/ruby2d/vertices.rb +62 -85
  276. data/lib/ruby2d/warnings.rb +29 -0
  277. data/lib/ruby2d/window/class_methods.rb +218 -0
  278. data/lib/ruby2d/window/gamepad_events.rb +141 -0
  279. data/lib/ruby2d/window/key_events.rb +74 -0
  280. data/lib/ruby2d/window/mouse_events.rb +171 -0
  281. data/lib/ruby2d/window/object_events.rb +168 -0
  282. data/lib/ruby2d/window.rb +632 -585
  283. data/lib/ruby2d.rb +14 -19
  284. metadata +275 -443
  285. data/assets/app.icns +0 -0
  286. data/assets/include/GL/glew.h +0 -26427
  287. data/assets/include/GLES2/gl2.h +0 -656
  288. data/assets/include/GLES2/gl2ext.h +0 -3949
  289. data/assets/include/GLES2/gl2ext_angle.h +0 -701
  290. data/assets/include/GLES2/gl2platform.h +0 -27
  291. data/assets/include/GLES3/gl3.h +0 -1192
  292. data/assets/include/GLES3/gl31.h +0 -1507
  293. data/assets/include/GLES3/gl32.h +0 -1808
  294. data/assets/include/GLES3/gl3platform.h +0 -27
  295. data/assets/include/KHR/khrplatform.h +0 -290
  296. data/assets/include/SDL2/SDL.h +0 -233
  297. data/assets/include/SDL2/SDL_assert.h +0 -326
  298. data/assets/include/SDL2/SDL_atomic.h +0 -415
  299. data/assets/include/SDL2/SDL_audio.h +0 -1500
  300. data/assets/include/SDL2/SDL_clipboard.h +0 -141
  301. data/assets/include/SDL2/SDL_config.h +0 -61
  302. data/assets/include/SDL2/SDL_config_android.h +0 -194
  303. data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
  304. data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
  305. data/assets/include/SDL2/SDL_config_macosx.h +0 -277
  306. data/assets/include/SDL2/SDL_config_minimal.h +0 -95
  307. data/assets/include/SDL2/SDL_config_ngage.h +0 -89
  308. data/assets/include/SDL2/SDL_config_os2.h +0 -207
  309. data/assets/include/SDL2/SDL_config_pandora.h +0 -141
  310. data/assets/include/SDL2/SDL_config_windows.h +0 -331
  311. data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
  312. data/assets/include/SDL2/SDL_config_winrt.h +0 -220
  313. data/assets/include/SDL2/SDL_config_xbox.h +0 -235
  314. data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
  315. data/assets/include/SDL2/SDL_endian.h +0 -348
  316. data/assets/include/SDL2/SDL_error.h +0 -163
  317. data/assets/include/SDL2/SDL_events.h +0 -1166
  318. data/assets/include/SDL2/SDL_filesystem.h +0 -149
  319. data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
  320. data/assets/include/SDL2/SDL_gesture.h +0 -117
  321. data/assets/include/SDL2/SDL_guid.h +0 -100
  322. data/assets/include/SDL2/SDL_haptic.h +0 -1341
  323. data/assets/include/SDL2/SDL_hidapi.h +0 -451
  324. data/assets/include/SDL2/SDL_hints.h +0 -2569
  325. data/assets/include/SDL2/SDL_image.h +0 -2173
  326. data/assets/include/SDL2/SDL_joystick.h +0 -1066
  327. data/assets/include/SDL2/SDL_keyboard.h +0 -353
  328. data/assets/include/SDL2/SDL_keycode.h +0 -358
  329. data/assets/include/SDL2/SDL_loadso.h +0 -115
  330. data/assets/include/SDL2/SDL_log.h +0 -404
  331. data/assets/include/SDL2/SDL_main.h +0 -275
  332. data/assets/include/SDL2/SDL_mixer.h +0 -2784
  333. data/assets/include/SDL2/SDL_mouse.h +0 -465
  334. data/assets/include/SDL2/SDL_mutex.h +0 -471
  335. data/assets/include/SDL2/SDL_name.h +0 -33
  336. data/assets/include/SDL2/SDL_pixels.h +0 -644
  337. data/assets/include/SDL2/SDL_platform.h +0 -261
  338. data/assets/include/SDL2/SDL_quit.h +0 -58
  339. data/assets/include/SDL2/SDL_rect.h +0 -376
  340. data/assets/include/SDL2/SDL_render.h +0 -1919
  341. data/assets/include/SDL2/SDL_revision.h +0 -6
  342. data/assets/include/SDL2/SDL_rwops.h +0 -841
  343. data/assets/include/SDL2/SDL_sensor.h +0 -322
  344. data/assets/include/SDL2/SDL_shape.h +0 -155
  345. data/assets/include/SDL2/SDL_stdinc.h +0 -830
  346. data/assets/include/SDL2/SDL_surface.h +0 -997
  347. data/assets/include/SDL2/SDL_system.h +0 -623
  348. data/assets/include/SDL2/SDL_syswm.h +0 -386
  349. data/assets/include/SDL2/SDL_test_images.h +0 -78
  350. data/assets/include/SDL2/SDL_test_random.h +0 -115
  351. data/assets/include/SDL2/SDL_thread.h +0 -464
  352. data/assets/include/SDL2/SDL_timer.h +0 -222
  353. data/assets/include/SDL2/SDL_touch.h +0 -150
  354. data/assets/include/SDL2/SDL_ttf.h +0 -2316
  355. data/assets/include/SDL2/SDL_types.h +0 -29
  356. data/assets/include/SDL2/SDL_version.h +0 -204
  357. data/assets/include/SDL2/SDL_video.h +0 -2150
  358. data/assets/include/SDL2/SDL_vulkan.h +0 -215
  359. data/assets/include/SDL2/begin_code.h +0 -187
  360. data/assets/include/mruby/boxing_no.h +0 -58
  361. data/assets/include/mruby/class.h +0 -108
  362. data/assets/include/mruby/error.h +0 -147
  363. data/assets/include/mruby/gc.h +0 -94
  364. data/assets/include/mruby/irep.h +0 -147
  365. data/assets/include/mruby/khash.h +0 -284
  366. data/assets/include/mruby/object.h +0 -43
  367. data/assets/include/mruby/presym/disable.h +0 -70
  368. data/assets/include/mruby/presym/enable.h +0 -37
  369. data/assets/include/mruby/presym.h +0 -40
  370. data/assets/include/mruby/proc.h +0 -211
  371. data/assets/include/mruby/throw.h +0 -66
  372. data/assets/macos/universal/bin/mrbc +0 -0
  373. data/assets/macos/universal/lib/libFLAC.a +0 -0
  374. data/assets/macos/universal/lib/libSDL2.a +0 -0
  375. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  376. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  377. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  378. data/assets/macos/universal/lib/libavif.a +0 -0
  379. data/assets/macos/universal/lib/libbrotlicommon-static.a +0 -0
  380. data/assets/macos/universal/lib/libbrotlidec-static.a +0 -0
  381. data/assets/macos/universal/lib/libfreetype.a +0 -0
  382. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  383. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  384. data/assets/macos/universal/lib/libhwy.a +0 -0
  385. data/assets/macos/universal/lib/libjpeg.a +0 -0
  386. data/assets/macos/universal/lib/libjxl.a +0 -0
  387. data/assets/macos/universal/lib/libmodplug.a +0 -0
  388. data/assets/macos/universal/lib/libmpg123.a +0 -0
  389. data/assets/macos/universal/lib/libmruby.a +0 -0
  390. data/assets/macos/universal/lib/libogg.a +0 -0
  391. data/assets/macos/universal/lib/libpng.a +0 -0
  392. data/assets/macos/universal/lib/libtiff.a +0 -0
  393. data/assets/macos/universal/lib/libvorbis.a +0 -0
  394. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  395. data/assets/macos/universal/lib/libwebp.a +0 -0
  396. data/assets/macos/universal/lib/libzstd.a +0 -0
  397. data/assets/test_media/README.md +0 -3
  398. data/assets/test_media/bitstream_vera/COPYRIGHT.txt +0 -124
  399. data/assets/test_media/bitstream_vera/vera.ttf +0 -0
  400. data/assets/test_media/boom.png +0 -0
  401. data/assets/test_media/coin.png +0 -0
  402. data/assets/test_media/colors.png +0 -0
  403. data/assets/test_media/controller.png +0 -0
  404. data/assets/test_media/dial.wav +0 -0
  405. data/assets/test_media/hero.png +0 -0
  406. data/assets/test_media/image.bmp +0 -0
  407. data/assets/test_media/image.jpg +0 -0
  408. data/assets/test_media/image.png +0 -0
  409. data/assets/test_media/music.flac +0 -0
  410. data/assets/test_media/music.mp3 +0 -0
  411. data/assets/test_media/music.ogg +0 -0
  412. data/assets/test_media/music.wav +0 -0
  413. data/assets/test_media/originals/boom.pxm +0 -0
  414. data/assets/test_media/originals/coin.pxm +0 -0
  415. data/assets/test_media/originals/controller.sketch +0 -0
  416. data/assets/test_media/originals/hero.pxm +0 -0
  417. data/assets/test_media/originals/image.pxm +0 -0
  418. data/assets/test_media/originals/music.caf +0 -0
  419. data/assets/test_media/originals/texture_atlas.pxm +0 -0
  420. data/assets/test_media/rondo_alla_turka.ogg +0 -0
  421. data/assets/test_media/sound.flac +0 -0
  422. data/assets/test_media/sound.mp3 +0 -0
  423. data/assets/test_media/sound.ogg +0 -0
  424. data/assets/test_media/sound.wav +0 -0
  425. data/assets/test_media/sprite_sheet.png +0 -0
  426. data/assets/test_media/texture_atlas.png +0 -0
  427. data/assets/wasm/libmruby.a +0 -0
  428. data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
  429. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  430. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
  431. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  432. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
  433. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  434. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
  435. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
  436. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
  437. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
  438. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
  439. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
  440. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  441. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
  442. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
  443. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libhwy.a +0 -0
  444. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
  445. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
  446. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjxl.a +0 -0
  447. data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
  448. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  449. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  450. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
  451. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  452. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  453. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  454. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng.a +0 -0
  455. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  456. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -1
  457. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  458. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
  459. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  460. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  461. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
  462. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  463. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  464. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  465. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  466. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  467. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  468. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  469. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  470. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  471. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  472. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  473. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  474. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  475. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  476. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  477. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  478. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  479. data/assets/windows/mingw-w64-x86_64/lib/libhwy.a +0 -0
  480. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  481. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  482. data/assets/windows/mingw-w64-x86_64/lib/libjxl.a +0 -0
  483. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  484. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  485. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  486. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  487. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  488. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  489. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  490. data/assets/windows/mingw-w64-x86_64/lib/libpng.a +0 -0
  491. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  492. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -1
  493. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  494. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  495. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  496. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  497. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  498. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  499. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  500. data/assets/xcode/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
  501. data/assets/xcode/ios/Assets.xcassets/Contents.json +0 -6
  502. data/assets/xcode/ios/Base.lproj/LaunchScreen.storyboard +0 -27
  503. data/assets/xcode/ios/Info.plist +0 -43
  504. data/assets/xcode/ios/MRuby.framework/Headers/mrbconf.h +0 -143
  505. data/assets/xcode/ios/MRuby.framework/Headers/mruby/array.h +0 -280
  506. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
  507. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
  508. data/assets/xcode/ios/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
  509. data/assets/xcode/ios/MRuby.framework/Headers/mruby/class.h +0 -97
  510. data/assets/xcode/ios/MRuby.framework/Headers/mruby/common.h +0 -77
  511. data/assets/xcode/ios/MRuby.framework/Headers/mruby/compile.h +0 -195
  512. data/assets/xcode/ios/MRuby.framework/Headers/mruby/data.h +0 -75
  513. data/assets/xcode/ios/MRuby.framework/Headers/mruby/debug.h +0 -67
  514. data/assets/xcode/ios/MRuby.framework/Headers/mruby/dump.h +0 -196
  515. data/assets/xcode/ios/MRuby.framework/Headers/mruby/error.h +0 -75
  516. data/assets/xcode/ios/MRuby.framework/Headers/mruby/gc.h +0 -91
  517. data/assets/xcode/ios/MRuby.framework/Headers/mruby/hash.h +0 -215
  518. data/assets/xcode/ios/MRuby.framework/Headers/mruby/irep.h +0 -75
  519. data/assets/xcode/ios/MRuby.framework/Headers/mruby/istruct.h +0 -47
  520. data/assets/xcode/ios/MRuby.framework/Headers/mruby/khash.h +0 -274
  521. data/assets/xcode/ios/MRuby.framework/Headers/mruby/numeric.h +0 -161
  522. data/assets/xcode/ios/MRuby.framework/Headers/mruby/object.h +0 -44
  523. data/assets/xcode/ios/MRuby.framework/Headers/mruby/opcode.h +0 -69
  524. data/assets/xcode/ios/MRuby.framework/Headers/mruby/ops.h +0 -117
  525. data/assets/xcode/ios/MRuby.framework/Headers/mruby/proc.h +0 -131
  526. data/assets/xcode/ios/MRuby.framework/Headers/mruby/range.h +0 -49
  527. data/assets/xcode/ios/MRuby.framework/Headers/mruby/re.h +0 -16
  528. data/assets/xcode/ios/MRuby.framework/Headers/mruby/string.h +0 -444
  529. data/assets/xcode/ios/MRuby.framework/Headers/mruby/throw.h +0 -55
  530. data/assets/xcode/ios/MRuby.framework/Headers/mruby/value.h +0 -309
  531. data/assets/xcode/ios/MRuby.framework/Headers/mruby/variable.h +0 -136
  532. data/assets/xcode/ios/MRuby.framework/Headers/mruby/version.h +0 -110
  533. data/assets/xcode/ios/MRuby.framework/Headers/mruby.h +0 -1282
  534. data/assets/xcode/ios/MRuby.framework/Info.plist +0 -20
  535. data/assets/xcode/ios/MRuby.framework/MRuby +0 -0
  536. data/assets/xcode/ios/MyApp.xcodeproj/project.pbxproj +0 -368
  537. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  538. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  539. data/assets/xcode/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
  540. data/assets/xcode/ios/main.c +0 -1
  541. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
  542. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -6
  543. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -17
  544. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
  545. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -6
  546. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
  547. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -6
  548. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -16
  549. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -6
  550. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -17
  551. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -16
  552. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -6
  553. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -16
  554. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -6
  555. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -32
  556. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -16
  557. data/assets/xcode/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -16
  558. data/assets/xcode/tvos/Assets.xcassets/Contents.json +0 -6
  559. data/assets/xcode/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -22
  560. data/assets/xcode/tvos/Info.plist +0 -30
  561. data/assets/xcode/tvos/MRuby.framework/Headers/mrbconf.h +0 -143
  562. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/array.h +0 -280
  563. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +0 -102
  564. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_no.h +0 -56
  565. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/boxing_word.h +0 -144
  566. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/class.h +0 -97
  567. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/common.h +0 -77
  568. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/compile.h +0 -195
  569. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/data.h +0 -75
  570. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/debug.h +0 -67
  571. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/dump.h +0 -196
  572. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/error.h +0 -75
  573. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/gc.h +0 -91
  574. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/hash.h +0 -215
  575. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/irep.h +0 -75
  576. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/istruct.h +0 -47
  577. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/khash.h +0 -274
  578. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/numeric.h +0 -161
  579. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/object.h +0 -44
  580. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/opcode.h +0 -69
  581. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/ops.h +0 -117
  582. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/proc.h +0 -131
  583. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/range.h +0 -49
  584. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/re.h +0 -16
  585. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/string.h +0 -444
  586. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/throw.h +0 -55
  587. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/value.h +0 -309
  588. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/variable.h +0 -136
  589. data/assets/xcode/tvos/MRuby.framework/Headers/mruby/version.h +0 -110
  590. data/assets/xcode/tvos/MRuby.framework/Headers/mruby.h +0 -1282
  591. data/assets/xcode/tvos/MRuby.framework/Info.plist +0 -20
  592. data/assets/xcode/tvos/MRuby.framework/MRuby +0 -0
  593. data/assets/xcode/tvos/MyApp.xcodeproj/project.pbxproj +0 -350
  594. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  595. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  596. data/assets/xcode/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -30
  597. data/assets/xcode/tvos/main.c +0 -1
  598. data/ext/ruby2d/common.c +0 -185
  599. data/ext/ruby2d/controllers.c +0 -110
  600. data/ext/ruby2d/gl.c +0 -398
  601. data/ext/ruby2d/gl2.c +0 -86
  602. data/ext/ruby2d/gl3.c +0 -304
  603. data/ext/ruby2d/gles.c +0 -302
  604. data/ext/ruby2d/input.c +0 -48
  605. data/ext/ruby2d/music.c +0 -127
  606. data/ext/ruby2d/sound.c +0 -132
  607. data/lib/ruby2d/cli/console.rb +0 -65
  608. data/lib/ruby2d/cli/enable_console.rb +0 -7
  609. data/lib/ruby2d/cli/platform.rb +0 -17
  610. data/lib/ruby2d/music.rb +0 -77
  611. data/lib/ruby2d/pixel.rb +0 -18
  612. data/lib/ruby2d/pixmap.rb +0 -39
  613. data/lib/ruby2d/pixmap_atlas.rb +0 -56
  614. data/lib/ruby2d/sound.rb +0 -61
  615. data/lib/ruby2d/texture.rb +0 -38
  616. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2.h +0 -0
  617. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2ext.h +0 -0
  618. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_gl2platform.h +0 -0
  619. /data/assets/{include/SDL2 → platform/include/SDL3}/SDL_opengles2_khrplatform.h +0 -0
  620. /data/assets/{include → platform/include}/mruby/re.h +0 -0
@@ -0,0 +1,3369 @@
1
+ /*
2
+ SDL_mixer: An audio mixer library based on the SDL library
3
+ Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /* WIKI CATEGORY: SDLMixer */
23
+
24
+ /**
25
+ * # CategorySDLMixer
26
+ *
27
+ * SDL_mixer is a library to make complicated audio processing tasks easier.
28
+ *
29
+ * It offers audio file decoding, mixing multiple sounds together, basic 3D
30
+ * positional audio, and various audio effects.
31
+ *
32
+ * It can mix sound to multiple audio devices in real time, or generate mixed
33
+ * audio data to a memory buffer for any other use. It can do both at the same
34
+ * time!
35
+ *
36
+ * To use the library, first call MIX_Init(). Then create a mixer with
37
+ * MIX_CreateMixerDevice() (or MIX_CreateMixer() to render to memory).
38
+ *
39
+ * Once you have a mixer, you can load sound data with MIX_LoadAudio(),
40
+ * MIX_LoadAudio_IO(), or MIX_LoadAudioWithProperties(). Data gets loaded once
41
+ * and can be played over and over.
42
+ *
43
+ * When loading audio, SDL_mixer can parse out several metadata tag formats,
44
+ * such as ID3 and APE tags, and exposes this information through the
45
+ * MIX_GetAudioProperties() function.
46
+ *
47
+ * To play audio, you create a track with MIX_CreateTrack(). You need one
48
+ * track for each sound that will be played simultaneously; think of tracks as
49
+ * individual sliders on a mixer board. You might have loaded hundreds of
50
+ * audio files, but you probably only have a handful of tracks that you assign
51
+ * those loaded files to when they are ready to play, and reuse those tracks
52
+ * with different audio later. Tracks take their input from a MIX_Audio
53
+ * (static data to be played multiple times) or an SDL_AudioStream (streaming
54
+ * PCM audio the app supplies, possibly as needed). A third option is to
55
+ * supply an SDL_IOStream, to load and decode on the fly, which might be more
56
+ * efficient for background music that is only used once, etc.
57
+ *
58
+ * Assign input to a MIX_Track with MIX_SetTrackAudio(),
59
+ * MIX_SetTrackAudioStream(), or MIX_SetTrackIOStream().
60
+ *
61
+ * Once a track has an input, start it playing with MIX_PlayTrack(). There are
62
+ * many options to this function to dictate mixing features: looping, fades,
63
+ * etc.
64
+ *
65
+ * Tracks can be tagged with arbitrary strings, like "music" or "ingame" or
66
+ * "ui". These tags can be used to start, stop, and pause a selection of
67
+ * tracks at the same moment.
68
+ *
69
+ * All significant portions of the mixing pipeline have callbacks, so that an
70
+ * app can hook in to the appropriate locations to examine or modify audio
71
+ * data as it passes through the mixer: a "raw" callback for raw PCM data
72
+ * decoded from an audio file without any modifications, a "cooked" callback
73
+ * for that same data after all transformations (fade, positioning, etc) have
74
+ * been processed, a "stopped" callback for when the track finishes mixing, a
75
+ * "postmix" callback for the final mixed audio about to be sent to the audio
76
+ * hardware to play. Additionally, you can use MIX_Group objects to mix a
77
+ * subset of playing tracks and access the data before it is mixed in with
78
+ * other tracks. All of this is optional, but allows for powerful access and
79
+ * control of the mixing process.
80
+ *
81
+ * SDL_mixer can also be used for decoding audio files without actually
82
+ * rendering a mix. This is done with MIX_AudioDecoder. Even though SDL_mixer
83
+ * handles decoding transparently when used as the audio engine for an app,
84
+ * and probably won't need this interface in that normal scenario, this can be
85
+ * useful when using a different audio library to access many file formats.
86
+ *
87
+ * This library offers several features on top of mixing sounds together: a
88
+ * track can have its own gain, to adjust its volume, in addition to a master
89
+ * gain applied as well. One can set the "frequency ratio" of a track or the
90
+ * final mixed output, to speed it up or slow it down, which also adjusts its
91
+ * pitch. A channel map can also be applied per-track, to change what speaker
92
+ * a given channel of audio is output to.
93
+ *
94
+ * Almost all timing in SDL_mixer is in _sample frames_. Stereo PCM audio data
95
+ * in Sint16 format takes 4 bytes per sample frame (2 bytes per sample times 2
96
+ * channels), for example. This allows everything in SDL_mixer to run at
97
+ * sample-perfect accuracy, and it lets it run without concern for wall clock
98
+ * time--you can produce audio faster than real-time, if desired. The problem,
99
+ * though, is different pieces of audio at different _sample rates_ will
100
+ * produce a different number of sample frames for the same length of time. To
101
+ * deal with this, conversion routines are offered: MIX_TrackMSToFrames(),
102
+ * MIX_TrackFramesToMS(), etc. Functions that operate on multiple tracks at
103
+ * once will deal with time in milliseconds, so it can do these conversions
104
+ * internally; be sure to read the documentation for these small quirks!
105
+ *
106
+ * SDL_mixer offers basic positional audio: a simple 3D positioning API
107
+ * through MIX_SetTrack3DPosition() and MIX_SetTrackStereo(). The former will
108
+ * do simple distance attenuation and spatialization--on a stereo setup, you
109
+ * will hear sounds move from left to right--and on a surround-sound
110
+ * configuration, individual tracks can move around the user. The latter,
111
+ * MIX_SetTrackStereo(), will force a sound to the Front Left and Front Right
112
+ * speakers and let the app pan it left and right as desired. Either effect
113
+ * can be useful for different situations. SDL_mixer is not meant to be a full
114
+ * 3D audio engine, but rather Good Enough for many purposes; if something
115
+ * more powerful in terms of 3D audio is needed, consider a proper 3D library
116
+ * like OpenAL.
117
+ */
118
+
119
+ #ifndef SDL_MIXER_H_
120
+ #define SDL_MIXER_H_
121
+
122
+ #include <SDL3/SDL.h>
123
+ #include <SDL3/SDL_begin_code.h>
124
+
125
+ /* Set up for C function definitions, even when using C++ */
126
+ #ifdef __cplusplus
127
+ extern "C" {
128
+ #endif
129
+
130
+
131
+ /**
132
+ * An opaque object that represents a mixer.
133
+ *
134
+ * The MIX_Mixer is the toplevel object for this library. To use SDL_mixer,
135
+ * you must have at least one, but are allowed to have several. Each mixer is
136
+ * responsible for generating a single output stream of mixed audio, usually
137
+ * to an audio device for realtime playback.
138
+ *
139
+ * Mixers are either created to feed an audio device (through
140
+ * MIX_CreateMixerDevice()), or to generate audio to a buffer in memory, where
141
+ * it can be used for anything (through MIX_CreateMixer()).
142
+ *
143
+ * \since This datatype is available since SDL_mixer 3.0.0.
144
+ */
145
+ typedef struct MIX_Mixer MIX_Mixer;
146
+
147
+ /**
148
+ * An opaque object that represents audio data.
149
+ *
150
+ * Generally you load audio data (in whatever file format) into SDL_mixer with
151
+ * MIX_LoadAudio() or one of its several variants, producing a MIX_Audio
152
+ * object.
153
+ *
154
+ * A MIX_Audio represents static audio data; it could be background music, or
155
+ * maybe a laser gun sound effect. It is loaded into RAM and can be played
156
+ * multiple times, possibly on different tracks at the same time.
157
+ *
158
+ * Unlike most other objects, MIX_Audio objects can be shared between mixers.
159
+ *
160
+ * \since This datatype is available since SDL_mixer 3.0.0.
161
+ */
162
+ typedef struct MIX_Audio MIX_Audio;
163
+
164
+ /**
165
+ * An opaque object that represents a source of sound output to be mixed.
166
+ *
167
+ * A MIX_Mixer has an arbitrary number of tracks, and each track manages its
168
+ * own unique audio to be mixed together.
169
+ *
170
+ * Tracks also have other properties: gain, loop points, fading, 3D position,
171
+ * and other attributes that alter the produced sound; many can be altered
172
+ * during playback.
173
+ *
174
+ * \since This datatype is available since SDL_mixer 3.0.0.
175
+ */
176
+ typedef struct MIX_Track MIX_Track;
177
+
178
+ /**
179
+ * An opaque object that represents a grouping of tracks.
180
+ *
181
+ * SDL_mixer offers callbacks at various stages of the mixing pipeline to
182
+ * allow apps to view and manipulate data as it is transformed. Sometimes it
183
+ * is useful to hook in at a point where several tracks--but not all tracks--
184
+ * have been mixed. For example, when a game is in some options menu, perhaps
185
+ * adjusting game audio but not UI sounds could be useful.
186
+ *
187
+ * SDL_mixer allows you to assign several tracks to a group, and receive a
188
+ * callback when that group has finished mixing, with a buffer of just that
189
+ * group's mixed audio, before it mixes into the final output.
190
+ *
191
+ * \since This datatype is available since SDL_mixer 3.0.0.
192
+ */
193
+ typedef struct MIX_Group MIX_Group;
194
+
195
+ /**
196
+ * The current major version of SDL_mixer headers.
197
+ *
198
+ * If this were SDL_mixer version 3.2.1, this value would be 3.
199
+ *
200
+ * \since This macro is available since SDL_mixer 3.0.0.
201
+ */
202
+ #define SDL_MIXER_MAJOR_VERSION 3
203
+
204
+ /**
205
+ * The current minor version of the SDL_mixer headers.
206
+ *
207
+ * If this were SDL_mixer version 3.2.1, this value would be 2.
208
+ *
209
+ * \since This macro is available since SDL_mixer 3.0.0.
210
+ */
211
+ #define SDL_MIXER_MINOR_VERSION 2
212
+
213
+ /**
214
+ * The current micro (or patchlevel) version of the SDL_mixer headers.
215
+ *
216
+ * If this were SDL_mixer version 3.2.1, this value would be 1.
217
+ *
218
+ * \since This macro is available since SDL_mixer 3.0.0.
219
+ */
220
+ #define SDL_MIXER_MICRO_VERSION 4
221
+
222
+ /**
223
+ * This is the current version number macro of the SDL_mixer headers.
224
+ *
225
+ * \since This macro is available since SDL_mixer 3.0.0.
226
+ *
227
+ * \sa MIX_Version
228
+ */
229
+ #define SDL_MIXER_VERSION SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_MICRO_VERSION)
230
+
231
+ /**
232
+ * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
233
+ *
234
+ * \since This macro is available since SDL_mixer 3.0.0.
235
+ */
236
+ #define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
237
+ ((SDL_MIXER_MAJOR_VERSION >= X) && \
238
+ (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION >= Y) && \
239
+ (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION > Y || SDL_MIXER_MICRO_VERSION >= Z))
240
+
241
+ /**
242
+ * Get the version of SDL_mixer that is linked against your program.
243
+ *
244
+ * If you are linking to SDL_mixer dynamically, then it is possible that the
245
+ * current version will be different than the version you compiled against.
246
+ * This function returns the current version, while SDL_MIXER_VERSION is the
247
+ * version you compiled with.
248
+ *
249
+ * This function may be called safely at any time, even before MIX_Init().
250
+ *
251
+ * \returns the version of the linked library.
252
+ *
253
+ * \since This function is available since SDL_mixer 3.0.0.
254
+ *
255
+ * \sa SDL_MIXER_VERSION
256
+ */
257
+ extern SDL_DECLSPEC int SDLCALL MIX_Version(void);
258
+
259
+ /**
260
+ * Initialize the SDL_mixer library.
261
+ *
262
+ * This must be successfully called once before (almost) any other SDL_mixer
263
+ * function can be used.
264
+ *
265
+ * It is safe to call this multiple times; the library will only initialize
266
+ * once, and won't deinitialize until MIX_Quit() has been called a matching
267
+ * number of times. Extra attempts to init report success.
268
+ *
269
+ * \returns true on success, false on error; call SDL_GetError() for details.
270
+ *
271
+ * \threadsafety This function is not thread safe.
272
+ *
273
+ * \since This function is available since SDL_mixer 3.0.0.
274
+ *
275
+ * \sa MIX_Quit
276
+ */
277
+ extern SDL_DECLSPEC bool SDLCALL MIX_Init(void);
278
+
279
+ /**
280
+ * Deinitialize the SDL_mixer library.
281
+ *
282
+ * This must be called when done with the library, probably at the end of your
283
+ * program.
284
+ *
285
+ * It is safe to call this multiple times; the library will only deinitialize
286
+ * once, when this function is called the same number of times as MIX_Init was
287
+ * successfully called.
288
+ *
289
+ * Once you have successfully deinitialized the library, it is safe to call
290
+ * MIX_Init to reinitialize it for further use.
291
+ *
292
+ * On successful deinitialization, SDL_mixer will destroy almost all created
293
+ * objects, including objects of type:
294
+ *
295
+ * - MIX_Mixer
296
+ * - MIX_Track
297
+ * - MIX_Audio
298
+ * - MIX_Group
299
+ * - MIX_AudioDecoder
300
+ *
301
+ * ...which is to say: it's possible a single call to this function will clean
302
+ * up anything it allocated, stop all audio output, close audio devices, etc.
303
+ * Don't attempt to destroy objects after this call. The app is still
304
+ * encouraged to manage their resources carefully and clean up first, treating
305
+ * this function as a safety net against memory leaks.
306
+ *
307
+ * \threadsafety This function is not thread safe.
308
+ *
309
+ * \since This function is available since SDL_mixer 3.0.0.
310
+ *
311
+ * \sa MIX_Init
312
+ */
313
+ extern SDL_DECLSPEC void SDLCALL MIX_Quit(void);
314
+
315
+ /**
316
+ * Report the number of audio decoders available for use.
317
+ *
318
+ * An audio decoder is what turns specific audio file formats into usable PCM
319
+ * data. For example, there might be an MP3 decoder, or a WAV decoder, etc.
320
+ * SDL_mixer probably has several decoders built in.
321
+ *
322
+ * The return value can be used to call MIX_GetAudioDecoder() in a loop.
323
+ *
324
+ * The number of decoders available is decided during MIX_Init() and does not
325
+ * change until the library is deinitialized.
326
+ *
327
+ * \returns the number of decoders available.
328
+ *
329
+ * \threadsafety It is safe to call this function from any thread.
330
+ *
331
+ * \since This function is available since SDL_mixer 3.0.0.
332
+ *
333
+ * \sa MIX_GetAudioDecoder
334
+ */
335
+ extern SDL_DECLSPEC int SDLCALL MIX_GetNumAudioDecoders(void);
336
+
337
+ /**
338
+ * Report the name of a specific audio decoders.
339
+ *
340
+ * An audio decoder is what turns specific audio file formats into usable PCM
341
+ * data. For example, there might be an MP3 decoder, or a WAV decoder, etc.
342
+ * SDL_mixer probably has several decoders built in.
343
+ *
344
+ * The names are capital English letters and numbers, low-ASCII. They don't
345
+ * necessarily map to a specific file format; Some decoders, like "XMP"
346
+ * operate on multiple file types, and more than one decoder might handle the
347
+ * same file type, like "DRMP3" vs "MPG123". Note that in that last example,
348
+ * neither decoder is called "MP3".
349
+ *
350
+ * The index of a specific decoder is decided during MIX_Init() and does not
351
+ * change until the library is deinitialized. Valid indices are between zero
352
+ * and the return value of MIX_GetNumAudioDecoders().
353
+ *
354
+ * The returned pointer is const memory owned by SDL_mixer; do not free it.
355
+ *
356
+ * \param index the index of the decoder to query.
357
+ * \returns a UTF-8 (really, ASCII) string of the decoder's name, or NULL if
358
+ * `index` is invalid.
359
+ *
360
+ * \threadsafety It is safe to call this function from any thread.
361
+ *
362
+ * \since This function is available since SDL_mixer 3.0.0.
363
+ *
364
+ * \sa MIX_GetNumAudioDecoders
365
+ */
366
+ extern SDL_DECLSPEC const char * SDLCALL MIX_GetAudioDecoder(int index);
367
+
368
+ /**
369
+ * Create a mixer that plays sound directly to an audio device.
370
+ *
371
+ * This is usually the function you want, vs MIX_CreateMixer().
372
+ *
373
+ * You can choose a specific device ID to open, following SDL's usual rules,
374
+ * but often the correct choice is to specify
375
+ * SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK and let SDL figure out what device to use
376
+ * (and seamlessly transition you to new hardware if the default changes).
377
+ *
378
+ * Only playback devices make sense here. Attempting to open a recording
379
+ * device will fail.
380
+ *
381
+ * This will call SDL_Init(SDL_INIT_AUDIO) internally; it's safe to call
382
+ * SDL_Init() before this call, too, if you intend to enumerate audio devices
383
+ * to choose one to open here.
384
+ *
385
+ * An audio format can be requested, and the system will try to set the
386
+ * hardware to those specifications, or as close as possible, but this is just
387
+ * a hint. SDL_mixer will handle all data conversion behind the scenes in any
388
+ * case, and specifying a NULL spec is a reasonable choice. The best reason to
389
+ * specify a format is because you know all your data is in that format and it
390
+ * might save some unnecessary CPU time on conversion.
391
+ *
392
+ * The actual device format chosen is available through MIX_GetMixerFormat().
393
+ *
394
+ * Once a mixer is created, next steps are usually to load audio (through
395
+ * MIX_LoadAudio() and friends), create a track (MIX_CreateTrack()), and play
396
+ * that audio through that track.
397
+ *
398
+ * When done with the mixer, it can be destroyed with MIX_DestroyMixer().
399
+ *
400
+ * \param devid the device to open for playback, or
401
+ * SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK for the default.
402
+ * \param spec the audio format to request from the device. May be NULL.
403
+ * \returns a mixer that can be used to play audio, or NULL on failure; call
404
+ * SDL_GetError() for more information.
405
+ *
406
+ * \threadsafety This function should only be called on the main thread.
407
+ *
408
+ * \since This function is available since SDL_mixer 3.0.0.
409
+ *
410
+ * \sa MIX_CreateMixer
411
+ * \sa MIX_DestroyMixer
412
+ */
413
+ extern SDL_DECLSPEC MIX_Mixer * SDLCALL MIX_CreateMixerDevice(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec);
414
+
415
+ /**
416
+ * Create a mixer that generates audio to a memory buffer.
417
+ *
418
+ * Usually you want MIX_CreateMixerDevice() instead of this function. The
419
+ * mixer created here can be used with MIX_Generate() to produce more data on
420
+ * demand, as fast as desired.
421
+ *
422
+ * An audio format must be specified. This is the format it will output in.
423
+ * This cannot be NULL.
424
+ *
425
+ * Once a mixer is created, next steps are usually to load audio (through
426
+ * MIX_LoadAudio() and friends), create a track (MIX_CreateTrack()), and play
427
+ * that audio through that track.
428
+ *
429
+ * When done with the mixer, it can be destroyed with MIX_DestroyMixer().
430
+ *
431
+ * \param spec the audio format that mixer will generate.
432
+ * \returns a mixer that can be used to generate audio, or NULL on failure;
433
+ * call SDL_GetError() for more information.
434
+ *
435
+ * \threadsafety It is safe to call this function from any thread.
436
+ *
437
+ * \since This function is available since SDL_mixer 3.0.0.
438
+ *
439
+ * \sa MIX_CreateMixerDevice
440
+ * \sa MIX_DestroyMixer
441
+ */
442
+ extern SDL_DECLSPEC MIX_Mixer * SDLCALL MIX_CreateMixer(const SDL_AudioSpec *spec);
443
+
444
+ /**
445
+ * Free a mixer.
446
+ *
447
+ * If this mixer was created with MIX_CreateMixerDevice(), this function will
448
+ * also close the audio device and call SDL_QuitSubSystem(SDL_INIT_AUDIO).
449
+ *
450
+ * Any MIX_Group or MIX_Track created for this mixer will also be destroyed.
451
+ * Do not access them again or attempt to destroy them after the device is
452
+ * destroyed. MIX_Audio objects will not be destroyed, since they can be
453
+ * shared between mixers (but those will all be destroyed during MIX_Quit()).
454
+ *
455
+ * \param mixer the mixer to destroy.
456
+ *
457
+ * \threadsafety If this is used with a MIX_Mixer from MIX_CreateMixerDevice,
458
+ * then this function should only be called on the main thread.
459
+ * If this is used with a MIX_Mixer from MIX_CreateMixer, then
460
+ * it is safe to call this function from any thread.
461
+ *
462
+ * \since This function is available since SDL_mixer 3.0.0.
463
+ *
464
+ * \sa MIX_CreateMixerDevice
465
+ * \sa MIX_CreateMixer
466
+ */
467
+ extern SDL_DECLSPEC void SDLCALL MIX_DestroyMixer(MIX_Mixer *mixer);
468
+
469
+
470
+ /**
471
+ * Get the properties associated with a mixer.
472
+ *
473
+ * The following read-only properties are provided by SDL_mixer:
474
+ *
475
+ * - `MIX_PROP_MIXER_DEVICE_NUMBER`: the SDL_AudioDeviceID that this mixer has
476
+ * opened for playback. This will be zero (no device) if the mixer was
477
+ * created with Mix_CreateMixer() instead of Mix_CreateMixerDevice().
478
+ *
479
+ * \param mixer the mixer to query.
480
+ * \returns a valid property ID on success or 0 on failure; call
481
+ * SDL_GetError() for more information.
482
+ *
483
+ * \threadsafety It is safe to call this function from any thread.
484
+ *
485
+ * \since This function is available since SDL_mixer 3.0.0.
486
+ */
487
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL MIX_GetMixerProperties(MIX_Mixer *mixer);
488
+
489
+ #define MIX_PROP_MIXER_DEVICE_NUMBER "SDL_mixer.mixer.device"
490
+
491
+
492
+ /**
493
+ * Get the audio format a mixer is generating.
494
+ *
495
+ * Generally you don't need this information, as SDL_mixer will convert data
496
+ * as necessary between inputs you provide and its output format, but it might
497
+ * be useful if trying to match your inputs to reduce conversion and
498
+ * resampling costs.
499
+ *
500
+ * For mixers created with MIX_CreateMixerDevice(), this is the format of the
501
+ * audio device (and may change later if the device itself changes; SDL_mixer
502
+ * will seamlessly handle this change internally, though).
503
+ *
504
+ * For mixers created with MIX_CreateMixer(), this is the format that
505
+ * MIX_Generate() will produce, as requested at create time, and does not
506
+ * change.
507
+ *
508
+ * Note that internally, SDL_mixer will work in SDL_AUDIO_F32 format before
509
+ * outputting the format specified here, so it would be more efficient to
510
+ * match input data to that, not the final output format.
511
+ *
512
+ * \param mixer the mixer to query.
513
+ * \param spec where to store the mixer audio format.
514
+ * \returns true on success or false on failure; call SDL_GetError() for more
515
+ * information.
516
+ *
517
+ * \threadsafety It is safe to call this function from any thread.
518
+ *
519
+ * \since This function is available since SDL_mixer 3.0.0.
520
+ */
521
+ extern SDL_DECLSPEC bool SDLCALL MIX_GetMixerFormat(MIX_Mixer *mixer, SDL_AudioSpec *spec);
522
+
523
+ /**
524
+ * Lock a mixer by obtaining its internal mutex.
525
+ *
526
+ * While locked, the mixer will not be able to mix more audio or change its
527
+ * internal state in another thread. Those other threads will block until the
528
+ * mixer is unlocked again.
529
+ *
530
+ * Under the hood, this function calls SDL_LockMutex(), so all the same rules
531
+ * apply: the lock can be recursive, it must be unlocked the same number of
532
+ * times from the same thread that locked it, etc.
533
+ *
534
+ * Just about every SDL_mixer API _also_ locks the mixer while doing its work,
535
+ * as does the SDL audio device thread while actual mixing is in progress, so
536
+ * basic use of this library never requires the app to explicitly lock the
537
+ * device to be thread safe. There are two scenarios where this can be useful,
538
+ * however:
539
+ *
540
+ * - The app has a provided a callback that the mixing thread might call, and
541
+ * there is some app state that needs to be protected against race
542
+ * conditions as changes are made and mixing progresses simultaneously. Any
543
+ * lock can be used for this, but this is a conveniently-available lock.
544
+ * - The app wants to make multiple, atomic changes to the mix. For example,
545
+ * to start several tracks at the exact same moment, one would lock the
546
+ * mixer, call MIX_PlayTrack multiple times, and then unlock again; all the
547
+ * tracks will start mixing on the same sample frame.
548
+ *
549
+ * Each call to this function must be paired with a call to MIX_UnlockMixer
550
+ * from the same thread. It is safe to lock a mixer multiple times; it remains
551
+ * locked until the final matching unlock call.
552
+ *
553
+ * Do not lock the mixer for significant amounts of time, or it can cause
554
+ * audio dropouts. Just do simple things quickly and unlock again.
555
+ *
556
+ * Locking a NULL mixer is a safe no-op.
557
+ *
558
+ * \param mixer the mixer to lock. May be NULL.
559
+ *
560
+ * \threadsafety It is safe to call this function from any thread.
561
+ *
562
+ * \since This function is available since SDL_mixer 3.0.0.
563
+ *
564
+ * \sa MIX_UnlockMixer
565
+ */
566
+ extern SDL_DECLSPEC void SDLCALL MIX_LockMixer(MIX_Mixer *mixer);
567
+
568
+ /**
569
+ * Unlock a mixer previously locked by a call to MIX_LockMixer().
570
+ *
571
+ * While locked, the mixer will not be able to mix more audio or change its
572
+ * internal state another thread. Those other threads will block until the
573
+ * mixer is unlocked again.
574
+ *
575
+ * Under the hood, this function calls SDL_LockMutex(), so all the same rules
576
+ * apply: the lock can be recursive, it must be unlocked the same number of
577
+ * times from the same thread that locked it, etc.
578
+ *
579
+ * Unlocking a NULL mixer is a safe no-op.
580
+ *
581
+ * \param mixer the mixer to unlock. May be NULL.
582
+ *
583
+ * \threadsafety This call must be paired with a previous MIX_LockMixer call
584
+ * on the same thread.
585
+ *
586
+ * \since This function is available since SDL_mixer 3.0.0.
587
+ *
588
+ * \sa MIX_LockMixer
589
+ */
590
+ extern SDL_DECLSPEC void SDLCALL MIX_UnlockMixer(MIX_Mixer *mixer);
591
+
592
+ /**
593
+ * Load audio for playback from an SDL_IOStream.
594
+ *
595
+ * In normal usage, apps should load audio once, maybe at startup, then play
596
+ * it multiple times.
597
+ *
598
+ * When loading audio, it will be cached fully in RAM in its original data
599
+ * format. Each time it plays, the data will be decoded. For example, an MP3
600
+ * will be stored in memory in MP3 format and be decompressed on the fly
601
+ * during playback. This is a tradeoff between i/o overhead and memory usage.
602
+ *
603
+ * If `predecode` is true, the data will be decompressed during load and
604
+ * stored as raw PCM data. This might dramatically increase loading time and
605
+ * memory usage, but there will be no need to decompress data during playback.
606
+ *
607
+ * (One could also use MIX_SetTrackIOStream() to bypass loading the data into
608
+ * RAM upfront at all, but this offers still different tradeoffs. The correct
609
+ * approach depends on the app's needs and employing different approaches in
610
+ * different situations can make sense.)
611
+ *
612
+ * MIX_Audio objects can be shared between mixers. This function takes a
613
+ * MIX_Mixer, to imply this is the most likely place it will be used and
614
+ * loading should try to match its audio format, but the resulting audio can
615
+ * be used elsewhere. If `mixer` is NULL, SDL_mixer will set reasonable
616
+ * defaults.
617
+ *
618
+ * Once a MIX_Audio is created, it can be assigned to a MIX_Track with
619
+ * MIX_SetTrackAudio(), or played without any management with MIX_PlayAudio().
620
+ *
621
+ * When done with a MIX_Audio, it can be freed with MIX_DestroyAudio().
622
+ *
623
+ * This function loads data from an SDL_IOStream. There is also a version that
624
+ * loads from a path on the filesystem (MIX_LoadAudio()), and one that accepts
625
+ * properties for ultimate control (MIX_LoadAudioWithProperties()).
626
+ *
627
+ * The SDL_IOStream provided must be able to seek, or loading will fail. If
628
+ * the stream can't seek (data is coming from an HTTP connection, etc),
629
+ * consider caching the data to memory or disk first and creating a new stream
630
+ * to read from there.
631
+ *
632
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
633
+ * \param io the SDL_IOStream to load data from.
634
+ * \param predecode if true, data will be fully uncompressed before returning.
635
+ * \param closeio true if SDL_mixer should close `io` before returning
636
+ * (success or failure).
637
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
638
+ * on failure; call SDL_GetError() for more information.
639
+ *
640
+ * \threadsafety It is safe to call this function from any thread.
641
+ *
642
+ * \since This function is available since SDL_mixer 3.0.0.
643
+ *
644
+ * \sa MIX_DestroyAudio
645
+ * \sa MIX_SetTrackAudio
646
+ * \sa MIX_LoadAudio
647
+ * \sa MIX_LoadAudioWithProperties
648
+ */
649
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadAudio_IO(MIX_Mixer *mixer, SDL_IOStream *io, bool predecode, bool closeio);
650
+
651
+ /**
652
+ * Load audio for playback from a file.
653
+ *
654
+ * This is equivalent to calling:
655
+ *
656
+ * ```c
657
+ * MIX_LoadAudio_IO(mixer, SDL_IOFromFile(path, "rb"), predecode, true);
658
+ * ```
659
+ *
660
+ * This function loads data from a path on the filesystem. There is also a
661
+ * version that loads from an SDL_IOStream (MIX_LoadAudio_IO()), and one that
662
+ * accepts properties for ultimate control (MIX_LoadAudioWithProperties()).
663
+ *
664
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
665
+ * \param path the path on the filesystem to load data from.
666
+ * \param predecode if true, data will be fully uncompressed before returning.
667
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
668
+ * on failure; call SDL_GetError() for more information.
669
+ *
670
+ * \threadsafety It is safe to call this function from any thread.
671
+ *
672
+ * \since This function is available since SDL_mixer 3.0.0.
673
+ *
674
+ * \sa MIX_DestroyAudio
675
+ * \sa MIX_SetTrackAudio
676
+ * \sa MIX_LoadAudio_IO
677
+ * \sa MIX_LoadAudioWithProperties
678
+ */
679
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadAudio(MIX_Mixer *mixer, const char *path, bool predecode);
680
+
681
+ /**
682
+ * Load audio for playback from a memory buffer without making a copy.
683
+ *
684
+ * When loading audio through most other LoadAudio functions, the data will be
685
+ * cached fully in RAM in its original data format, for decoding on-demand.
686
+ * This function does most of the same work as those functions, but instead
687
+ * uses a buffer of memory provided by the app that it does not make a copy
688
+ * of.
689
+ *
690
+ * This buffer must live for the entire time the returned MIX_Audio lives, as
691
+ * the mixer will access the buffer whenever it needs to mix more data.
692
+ *
693
+ * This function is meant to maximize efficiency: if the data is already in
694
+ * memory and can remain there, don't copy it. This data can be in any
695
+ * supported audio file format (WAV, MP3, etc); it will be decoded on the fly
696
+ * while mixing. Unlike MIX_LoadAudio(), there is no `predecode` option
697
+ * offered here, as this is meant to optimize for data that's already in
698
+ * memory and intends to exist there for significant time; since predecoding
699
+ * would only need the file format data once, upfront, one could simply wrap
700
+ * it in SDL_CreateIOFromConstMem() and pass that to MIX_LoadAudio_IO().
701
+ *
702
+ * MIX_Audio objects can be shared between multiple mixers. The `mixer`
703
+ * parameter just suggests the most likely mixer to use this audio, in case
704
+ * some optimization might be applied, but this is not required, and a NULL
705
+ * mixer may be specified.
706
+ *
707
+ * If `free_when_done` is true, SDL_mixer will call `SDL_free(data)` when the
708
+ * returned MIX_Audio is eventually destroyed. This can be useful when the
709
+ * data is not static, but rather loaded elsewhere for this specific MIX_Audio
710
+ * and simply wants to avoid the extra copy.
711
+ *
712
+ * As audio format information is obtained from the file format metadata, this
713
+ * isn't useful for raw PCM data; in that case, use MIX_LoadRawAudioNoCopy()
714
+ * instead, which offers an SDL_AudioSpec.
715
+ *
716
+ * Once a MIX_Audio is created, it can be assigned to a MIX_Track with
717
+ * MIX_SetTrackAudio(), or played without any management with MIX_PlayAudio().
718
+ *
719
+ * When done with a MIX_Audio, it can be freed with MIX_DestroyAudio().
720
+ *
721
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
722
+ * \param data the buffer where the audio data lives.
723
+ * \param datalen the size, in bytes, of the buffer.
724
+ * \param free_when_done if true, `data` will be given to SDL_free() when the
725
+ * MIX_Audio is destroyed.
726
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
727
+ * on failure; call SDL_GetError() for more information.
728
+ *
729
+ * \threadsafety It is safe to call this function from any thread.
730
+ *
731
+ * \since This function is available since SDL_mixer 3.0.0.
732
+ *
733
+ * \sa MIX_DestroyAudio
734
+ * \sa MIX_SetTrackAudio
735
+ * \sa MIX_LoadRawAudioNoCopy
736
+ * \sa MIX_LoadAudio_IO
737
+ */
738
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadAudioNoCopy(MIX_Mixer *mixer, const void *data, size_t datalen, bool free_when_done);
739
+
740
+ /**
741
+ * Load audio for playback through a collection of properties.
742
+ *
743
+ * Please see MIX_LoadAudio_IO() for a description of what the various
744
+ * LoadAudio functions do. This function uses properties to dictate how it
745
+ * operates, and exposes functionality the other functions don't provide.
746
+ *
747
+ * SDL_PropertiesID are discussed in
748
+ * [SDL's documentation](https://wiki.libsdl.org/SDL3/CategoryProperties)
749
+ * .
750
+ * These are the supported properties:
751
+ *
752
+ * - `MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER`: a pointer to an SDL_IOStream to
753
+ * be used to load audio data. Required. This stream must be able to seek!
754
+ * - `MIX_PROP_AUDIO_LOAD_CLOSEIO_BOOLEAN`: true if SDL_mixer should close the
755
+ * SDL_IOStream before returning (success or failure).
756
+ * - `MIX_PROP_AUDIO_LOAD_PREDECODE_BOOLEAN`: true if SDL_mixer should fully
757
+ * decode and decompress the data before returning. Otherwise it will be
758
+ * stored in its original state and decompressed on demand.
759
+ * - `MIX_PROP_AUDIO_LOAD_PREFERRED_MIXER_POINTER`: a pointer to a MIX_Mixer,
760
+ * in case steps can be made to match its format when decoding. Optional.
761
+ * - `MIX_PROP_AUDIO_LOAD_SKIP_METADATA_TAGS_BOOLEAN`: true to skip parsing
762
+ * metadata tags, like ID3 and APE tags. This can be used to speed up
763
+ * loading _if the data definitely doesn't have these tags_. Some decoders
764
+ * will fail if these tags are present when this property is true.
765
+ * - `MIX_PROP_AUDIO_LOAD_IGNORE_LOOPS_BOOLEAN`: true to ignore metadata in
766
+ * the audio data specifying loop points. This will make a file decode from
767
+ * start to finish without looping, even if the file specified it should
768
+ * have. This audio can still be looped at playback time via MIX_Track loop
769
+ * settings, regardless of this setting. Default false.
770
+ * - `MIX_PROP_AUDIO_DECODER_STRING`: the name of the decoder to use for this
771
+ * data. Optional. If not specified, SDL_mixer will examine the data and
772
+ * choose the best decoder. These names are the same returned from
773
+ * MIX_GetAudioDecoder().
774
+ *
775
+ * Specific decoders might accept additional custom properties, such as where
776
+ * to find soundfonts for MIDI playback, etc.
777
+ *
778
+ * \param props a set of properties on how to load audio.
779
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
780
+ * on failure; call SDL_GetError() for more information.
781
+ *
782
+ * \threadsafety It is safe to call this function from any thread.
783
+ *
784
+ * \since This function is available since SDL_mixer 3.0.0.
785
+ *
786
+ * \sa MIX_DestroyAudio
787
+ * \sa MIX_SetTrackAudio
788
+ * \sa MIX_LoadAudio
789
+ * \sa MIX_LoadAudio_IO
790
+ */
791
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadAudioWithProperties(SDL_PropertiesID props);
792
+
793
+ #define MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER "SDL_mixer.audio.load.iostream"
794
+ #define MIX_PROP_AUDIO_LOAD_CLOSEIO_BOOLEAN "SDL_mixer.audio.load.closeio"
795
+ #define MIX_PROP_AUDIO_LOAD_PREDECODE_BOOLEAN "SDL_mixer.audio.load.predecode"
796
+ #define MIX_PROP_AUDIO_LOAD_PREFERRED_MIXER_POINTER "SDL_mixer.audio.load.preferred_mixer"
797
+ #define MIX_PROP_AUDIO_LOAD_SKIP_METADATA_TAGS_BOOLEAN "SDL_mixer.audio.load.skip_metadata_tags"
798
+ #define MIX_PROP_AUDIO_LOAD_IGNORE_LOOPS_BOOLEAN "SDL_mixer.audio.load.ignore_loops"
799
+ #define MIX_PROP_AUDIO_DECODER_STRING "SDL_mixer.audio.decoder"
800
+
801
+ /**
802
+ * Load raw PCM data from an SDL_IOStream.
803
+ *
804
+ * There are other options for _streaming_ raw PCM: an SDL_AudioStream can be
805
+ * connected to a track, as can an SDL_IOStream, and will read from those
806
+ * sources on-demand when it is time to mix the audio. This function is useful
807
+ * for loading static audio data that is meant to be played multiple times.
808
+ *
809
+ * This function will load the raw data in its entirety and cache it in RAM.
810
+ *
811
+ * MIX_Audio objects can be shared between multiple mixers. The `mixer`
812
+ * parameter just suggests the most likely mixer to use this audio, in case
813
+ * some optimization might be applied, but this is not required, and a NULL
814
+ * mixer may be specified.
815
+ *
816
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
817
+ * \param io the SDL_IOStream to load data from.
818
+ * \param spec what format the raw data is in.
819
+ * \param closeio true if SDL_mixer should close `io` before returning
820
+ * (success or failure).
821
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
822
+ * on failure; call SDL_GetError() for more information.
823
+ *
824
+ * \threadsafety It is safe to call this function from any thread.
825
+ *
826
+ * \since This function is available since SDL_mixer 3.0.0.
827
+ *
828
+ * \sa MIX_DestroyAudio
829
+ * \sa MIX_SetTrackAudio
830
+ * \sa MIX_LoadRawAudio
831
+ * \sa MIX_LoadRawAudioNoCopy
832
+ * \sa MIX_LoadAudio_IO
833
+ */
834
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadRawAudio_IO(MIX_Mixer *mixer, SDL_IOStream *io, const SDL_AudioSpec *spec, bool closeio);
835
+
836
+ /**
837
+ * Load raw PCM data from a memory buffer.
838
+ *
839
+ * There are other options for _streaming_ raw PCM: an SDL_AudioStream can be
840
+ * connected to a track, as can an SDL_IOStream, and will read from those
841
+ * sources on-demand when it is time to mix the audio. This function is useful
842
+ * for loading static audio data that is meant to be played multiple times.
843
+ *
844
+ * This function will load the raw data in its entirety and cache it in RAM,
845
+ * allocating a copy. If the original data will outlive the created MIX_Audio,
846
+ * you can use MIX_LoadRawAudioNoCopy() to avoid extra allocations and copies.
847
+ *
848
+ * MIX_Audio objects can be shared between multiple mixers. The `mixer`
849
+ * parameter just suggests the most likely mixer to use this audio, in case
850
+ * some optimization might be applied, but this is not required, and a NULL
851
+ * mixer may be specified.
852
+ *
853
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
854
+ * \param data the raw PCM data to load.
855
+ * \param datalen the size, in bytes, of the raw PCM data.
856
+ * \param spec what format the raw data is in.
857
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
858
+ * on failure; call SDL_GetError() for more information.
859
+ *
860
+ * \threadsafety It is safe to call this function from any thread.
861
+ *
862
+ * \since This function is available since SDL_mixer 3.0.0.
863
+ *
864
+ * \sa MIX_DestroyAudio
865
+ * \sa MIX_SetTrackAudio
866
+ * \sa MIX_LoadRawAudio_IO
867
+ * \sa MIX_LoadRawAudioNoCopy
868
+ * \sa MIX_LoadAudio_IO
869
+ */
870
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadRawAudio(MIX_Mixer *mixer, const void *data, size_t datalen, const SDL_AudioSpec *spec);
871
+
872
+ /**
873
+ * Load raw PCM data from a memory buffer without making a copy.
874
+ *
875
+ * This buffer must live for the entire time the returned MIX_Audio lives, as
876
+ * the mixer will access the buffer whenever it needs to mix more data.
877
+ *
878
+ * This function is meant to maximize efficiency: if the data is already in
879
+ * memory and can remain there, don't copy it. But it can also lead to some
880
+ * interesting tricks, like changing the buffer's contents to alter multiple
881
+ * playing tracks at once. (But, of course, be careful when being too clever.)
882
+ *
883
+ * MIX_Audio objects can be shared between multiple mixers. The `mixer`
884
+ * parameter just suggests the most likely mixer to use this audio, in case
885
+ * some optimization might be applied, but this is not required, and a NULL
886
+ * mixer may be specified.
887
+ *
888
+ * If `free_when_done` is true, SDL_mixer will call `SDL_free(data)` when the
889
+ * returned MIX_Audio is eventually destroyed. This can be useful when the
890
+ * data is not static, but rather composed dynamically for this specific
891
+ * MIX_Audio and simply wants to avoid the extra copy.
892
+ *
893
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
894
+ * \param data the buffer where the raw PCM data lives.
895
+ * \param datalen the size, in bytes, of the buffer.
896
+ * \param spec what format the raw data is in.
897
+ * \param free_when_done if true, `data` will be given to SDL_free() when the
898
+ * MIX_Audio is destroyed.
899
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
900
+ * on failure; call SDL_GetError() for more information.
901
+ *
902
+ * \threadsafety It is safe to call this function from any thread.
903
+ *
904
+ * \since This function is available since SDL_mixer 3.0.0.
905
+ *
906
+ * \sa MIX_DestroyAudio
907
+ * \sa MIX_SetTrackAudio
908
+ * \sa MIX_LoadRawAudio
909
+ * \sa MIX_LoadRawAudio_IO
910
+ * \sa MIX_LoadAudio_IO
911
+ */
912
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_LoadRawAudioNoCopy(MIX_Mixer *mixer, const void *data, size_t datalen, const SDL_AudioSpec *spec, bool free_when_done);
913
+
914
+ /**
915
+ * Create a MIX_Audio that generates a sinewave.
916
+ *
917
+ * This is useful just to have _something_ to play, perhaps for testing or
918
+ * debugging purposes.
919
+ *
920
+ * You specify its frequency in Hz (determines the pitch of the sinewave's
921
+ * audio) and amplitude (determines the volume of the sinewave: 1.0f is very
922
+ * loud, 0.0f is silent).
923
+ *
924
+ * A number of milliseconds of audio to generate can be specified. Specifying
925
+ * a value less than zero will generate infinite audio (when assigned to a
926
+ * MIX_Track, the sinewave will play forever).
927
+ *
928
+ * MIX_Audio objects can be shared between multiple mixers. The `mixer`
929
+ * parameter just suggests the most likely mixer to use this audio, in case
930
+ * some optimization might be applied, but this is not required, and a NULL
931
+ * mixer may be specified.
932
+ *
933
+ * \param mixer a mixer this audio is intended to be used with. May be NULL.
934
+ * \param hz the sinewave's frequency in Hz.
935
+ * \param amplitude the sinewave's amplitude from 0.0f to 1.0f.
936
+ * \param ms the maximum number of milliseconds of audio to generate, or less
937
+ * than zero to generate infinite audio.
938
+ * \returns an audio object that can be used to make sound on a mixer, or NULL
939
+ * on failure; call SDL_GetError() for more information.
940
+ *
941
+ * \threadsafety It is safe to call this function from any thread.
942
+ *
943
+ * \since This function is available since SDL_mixer 3.0.0.
944
+ *
945
+ * \sa MIX_DestroyAudio
946
+ * \sa MIX_SetTrackAudio
947
+ * \sa MIX_LoadAudio_IO
948
+ */
949
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_CreateSineWaveAudio(MIX_Mixer *mixer, int hz, float amplitude, Sint64 ms);
950
+
951
+
952
+ /**
953
+ * Get the properties associated with a MIX_Audio.
954
+ *
955
+ * SDL_mixer offers some properties of its own, but this can also be a
956
+ * convenient place to store app-specific data.
957
+ *
958
+ * A SDL_PropertiesID is created the first time this function is called for a
959
+ * given MIX_Audio, if necessary.
960
+ *
961
+ * The following read-only properties are provided by SDL_mixer:
962
+ *
963
+ * - `MIX_PROP_METADATA_TITLE_STRING`: the audio's title ("Smells Like Teen
964
+ * Spirit").
965
+ * - `MIX_PROP_METADATA_ARTIST_STRING`: the audio's artist name ("Nirvana").
966
+ * - `MIX_PROP_METADATA_ALBUM_STRING`: the audio's album name ("Nevermind").
967
+ * - `MIX_PROP_METADATA_COPYRIGHT_STRING`: the audio's copyright info
968
+ * ("Copyright (c) 1991")
969
+ * - `MIX_PROP_METADATA_TRACK_NUMBER`: the audio's track number on the album
970
+ * (1)
971
+ * - `MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER`: the total tracks on the album
972
+ * (13)
973
+ * - `MIX_PROP_METADATA_YEAR_NUMBER`: the year the audio was released (1991)
974
+ * - `MIX_PROP_METADATA_DURATION_FRAMES_NUMBER`: The sample frames worth of
975
+ * PCM data that comprise this audio. It might be off by a little if the
976
+ * decoder only knows the duration as a unit of time.
977
+ * - `MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN`: if true, audio never runs
978
+ * out of sound to generate. This isn't necessarily always known to
979
+ * SDL_mixer, though.
980
+ *
981
+ * Other properties, documented with MIX_LoadAudioWithProperties(), may also
982
+ * be present.
983
+ *
984
+ * Note that the metadata properties are whatever SDL_mixer finds in things
985
+ * like ID3 tags, and they often have very little standardized formatting, may
986
+ * be missing, and can be completely wrong if the original data is
987
+ * untrustworthy (like an MP3 from a P2P file sharing service).
988
+ *
989
+ * \param audio the audio to query.
990
+ * \returns a valid property ID on success or 0 on failure; call
991
+ * SDL_GetError() for more information.
992
+ *
993
+ * \threadsafety It is safe to call this function from any thread.
994
+ *
995
+ * \since This function is available since SDL_mixer 3.0.0.
996
+ */
997
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL MIX_GetAudioProperties(MIX_Audio *audio);
998
+
999
+ #define MIX_PROP_METADATA_TITLE_STRING "SDL_mixer.metadata.title"
1000
+ #define MIX_PROP_METADATA_ARTIST_STRING "SDL_mixer.metadata.artist"
1001
+ #define MIX_PROP_METADATA_ALBUM_STRING "SDL_mixer.metadata.album"
1002
+ #define MIX_PROP_METADATA_COPYRIGHT_STRING "SDL_mixer.metadata.copyright"
1003
+ #define MIX_PROP_METADATA_TRACK_NUMBER "SDL_mixer.metadata.track"
1004
+ #define MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER "SDL_mixer.metadata.total_tracks"
1005
+ #define MIX_PROP_METADATA_YEAR_NUMBER "SDL_mixer.metadata.year"
1006
+ #define MIX_PROP_METADATA_DURATION_FRAMES_NUMBER "SDL_mixer.metadata.duration_frames"
1007
+ #define MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN "SDL_mixer.metadata.duration_infinite"
1008
+
1009
+
1010
+ /**
1011
+ * Get the length of a MIX_Audio's playback in sample frames.
1012
+ *
1013
+ * This information is also available via the
1014
+ * MIX_PROP_METADATA_DURATION_FRAMES_NUMBER property, but it's common enough
1015
+ * to provide a simple accessor function.
1016
+ *
1017
+ * This reports the length of the data in _sample frames_, so sample-perfect
1018
+ * mixing can be possible. Sample frames are only meaningful as a measure of
1019
+ * time if the sample rate (frequency) is also known. To convert from sample
1020
+ * frames to milliseconds, use MIX_AudioFramesToMS().
1021
+ *
1022
+ * Not all audio file formats can report the complete length of the data they
1023
+ * will produce through decoding: some can't calculate it, some might produce
1024
+ * infinite audio.
1025
+ *
1026
+ * Also, some file formats can only report duration as a unit of time, which
1027
+ * means SDL_mixer might have to estimate sample frames from that information.
1028
+ * With less precision, the reported duration might be off by a few sample
1029
+ * frames in either direction.
1030
+ *
1031
+ * This will return a value >= 0 if a duration is known. It might also return
1032
+ * MIX_DURATION_UNKNOWN or MIX_DURATION_INFINITE.
1033
+ *
1034
+ * \param audio the audio to query.
1035
+ * \returns the length of the audio in sample frames, or MIX_DURATION_UNKNOWN
1036
+ * or MIX_DURATION_INFINITE.
1037
+ *
1038
+ * \threadsafety It is safe to call this function from any thread.
1039
+ *
1040
+ * \since This function is available since SDL_mixer 3.0.0.
1041
+ */
1042
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_GetAudioDuration(MIX_Audio *audio);
1043
+
1044
+ #define MIX_DURATION_UNKNOWN -1
1045
+ #define MIX_DURATION_INFINITE -2
1046
+
1047
+
1048
+ /**
1049
+ * Query the initial audio format of a MIX_Audio.
1050
+ *
1051
+ * Note that some audio files can change format in the middle; some explicitly
1052
+ * support this, but a more common example is two MP3 files concatenated
1053
+ * together. In many cases, SDL_mixer will correctly handle these sort of
1054
+ * files, but this function will only report the initial format a file uses.
1055
+ *
1056
+ * \param audio the audio to query.
1057
+ * \param spec on success, audio format details will be stored here.
1058
+ * \returns true on success or false on failure; call SDL_GetError() for more
1059
+ * information.
1060
+ *
1061
+ * \threadsafety It is safe to call this function from any thread.
1062
+ *
1063
+ * \since This function is available since SDL_mixer 3.0.0.
1064
+ */
1065
+ extern SDL_DECLSPEC bool SDLCALL MIX_GetAudioFormat(MIX_Audio *audio, SDL_AudioSpec *spec);
1066
+
1067
+ /**
1068
+ * Destroy the specified audio.
1069
+ *
1070
+ * MIX_Audio is reference-counted internally, so this function only unrefs it.
1071
+ * If doing so causes the reference count to drop to zero, the MIX_Audio will
1072
+ * be deallocated. This allows the system to safely operate if the audio is
1073
+ * still assigned to a MIX_Track at the time of destruction. The actual
1074
+ * destroying will happen when the track stops using it.
1075
+ *
1076
+ * But from the caller's perspective, once this function is called, it should
1077
+ * assume the `audio` pointer has become invalid.
1078
+ *
1079
+ * Destroying a NULL MIX_Audio is a legal no-op.
1080
+ *
1081
+ * \param audio the audio to destroy.
1082
+ *
1083
+ * \threadsafety It is safe to call this function from any thread.
1084
+ *
1085
+ * \since This function is available since SDL_mixer 3.0.0.
1086
+ */
1087
+ extern SDL_DECLSPEC void SDLCALL MIX_DestroyAudio(MIX_Audio *audio);
1088
+
1089
+ /**
1090
+ * Create a new track on a mixer.
1091
+ *
1092
+ * A track provides a single source of audio. All currently-playing tracks
1093
+ * will be processed and mixed together to form the final output from the
1094
+ * mixer.
1095
+ *
1096
+ * There are no limits to the number of tracks one may create, beyond running
1097
+ * out of memory, but in normal practice there are a small number of tracks
1098
+ * that are reused between all loaded audio as appropriate.
1099
+ *
1100
+ * Tracks are unique to a specific MIX_Mixer and can't be transferred between
1101
+ * them.
1102
+ *
1103
+ * \param mixer the mixer on which to create this track.
1104
+ * \returns a new MIX_Track on success, NULL on error; call SDL_GetError() for
1105
+ * more informations.
1106
+ *
1107
+ * \threadsafety It is safe to call this function from any thread.
1108
+ *
1109
+ * \since This function is available since SDL_mixer 3.0.0.
1110
+ *
1111
+ * \sa MIX_DestroyTrack
1112
+ */
1113
+ extern SDL_DECLSPEC MIX_Track * SDLCALL MIX_CreateTrack(MIX_Mixer *mixer);
1114
+
1115
+ /**
1116
+ * Destroy the specified track.
1117
+ *
1118
+ * If the track is currently playing, it will be stopped immediately, without
1119
+ * any fadeout. If there is a callback set through
1120
+ * MIX_SetTrackStoppedCallback(), it will _not_ be called.
1121
+ *
1122
+ * If the mixer is currently mixing in another thread, this will block until
1123
+ * it finishes. Destroying a track from the mixer thread itself (during a
1124
+ * callback) will cause it to be destroyed as soon as this iteration of the
1125
+ * mixer thread is not using it; in this scenario, destroying a track and then
1126
+ * making futher changes to it is considered undefined behavior.
1127
+ *
1128
+ * Destroying a NULL MIX_Track is a legal no-op.
1129
+ *
1130
+ * \param track the track to destroy.
1131
+ *
1132
+ * \threadsafety It is safe to call this function from any thread.
1133
+ *
1134
+ * \since This function is available since SDL_mixer 3.0.0.
1135
+ */
1136
+ extern SDL_DECLSPEC void SDLCALL MIX_DestroyTrack(MIX_Track *track);
1137
+
1138
+ /**
1139
+ * Get the properties associated with a track.
1140
+ *
1141
+ * Currently SDL_mixer assigns no properties of its own to a track, but this
1142
+ * can be a convenient place to store app-specific data.
1143
+ *
1144
+ * A SDL_PropertiesID is created the first time this function is called for a
1145
+ * given track.
1146
+ *
1147
+ * \param track the track to query.
1148
+ * \returns a valid property ID on success or 0 on failure; call
1149
+ * SDL_GetError() for more information.
1150
+ *
1151
+ * \threadsafety It is safe to call this function from any thread.
1152
+ *
1153
+ * \since This function is available since SDL_mixer 3.0.0.
1154
+ */
1155
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL MIX_GetTrackProperties(MIX_Track *track);
1156
+
1157
+ /**
1158
+ * Get the MIX_Mixer that owns a MIX_Track.
1159
+ *
1160
+ * This is the mixer pointer that was passed to MIX_CreateTrack().
1161
+ *
1162
+ * \param track the track to query.
1163
+ * \returns the mixer associated with the track, or NULL on error; call
1164
+ * SDL_GetError() for more information.
1165
+ *
1166
+ * \threadsafety It is safe to call this function from any thread.
1167
+ *
1168
+ * \since This function is available since SDL_mixer 3.0.0.
1169
+ */
1170
+ extern SDL_DECLSPEC MIX_Mixer * SDLCALL MIX_GetTrackMixer(MIX_Track *track);
1171
+
1172
+ /**
1173
+ * Set a MIX_Track's input to a MIX_Audio.
1174
+ *
1175
+ * A MIX_Audio is audio data stored in RAM (possibly still in a compressed
1176
+ * form). One MIX_Audio can be assigned to multiple tracks at once.
1177
+ *
1178
+ * Once a track has a valid input, it can start mixing sound by calling
1179
+ * MIX_PlayTrack(), or possibly MIX_PlayTag().
1180
+ *
1181
+ * Calling this function with a NULL audio input is legal, and removes any
1182
+ * input from the track. If the track was currently playing, the next time the
1183
+ * mixer runs, it'll notice this and mark the track as stopped, calling any
1184
+ * assigned MIX_TrackStoppedCallback.
1185
+ *
1186
+ * It is legal to change the input of a track while it's playing, however some
1187
+ * states, like loop points, may cease to make sense with the new audio. In
1188
+ * such a case, one can call MIX_PlayTrack again to adjust parameters.
1189
+ *
1190
+ * The track will hold a reference to the provided MIX_Audio, so it is safe to
1191
+ * call MIX_DestroyAudio() on it while the track is still using it. The track
1192
+ * will drop its reference (and possibly free the resources) once it is no
1193
+ * longer using the MIX_Audio.
1194
+ *
1195
+ * \param track the track on which to set a new audio input.
1196
+ * \param audio the new audio input to set. May be NULL.
1197
+ * \returns true on success, false on error; call SDL_GetError() for details.
1198
+ *
1199
+ * \threadsafety It is safe to call this function from any thread.
1200
+ *
1201
+ * \since This function is available since SDL_mixer 3.0.0.
1202
+ */
1203
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackAudio(MIX_Track *track, MIX_Audio *audio);
1204
+
1205
+ /**
1206
+ * Set a MIX_Track's input to an SDL_AudioStream.
1207
+ *
1208
+ * Using an audio stream allows the application to generate any type of audio,
1209
+ * in any format, possibly procedurally or on-demand, and mix in with all
1210
+ * other tracks.
1211
+ *
1212
+ * When a track uses an audio stream, it will call SDL_GetAudioStreamData as
1213
+ * it needs more audio to mix. The app can either buffer data to the stream
1214
+ * ahead of time, or set a callback on the stream to provide data as needed.
1215
+ * Please refer to SDL's documentation for details.
1216
+ *
1217
+ * A given audio stream may only be assigned to a single track at a time;
1218
+ * duplicate assignments won't return an error, but assigning a stream to
1219
+ * multiple tracks will cause each track to read from the stream arbitrarily,
1220
+ * causing confusion and incorrect mixing.
1221
+ *
1222
+ * Once a track has a valid input, it can start mixing sound by calling
1223
+ * MIX_PlayTrack(), or possibly MIX_PlayTag().
1224
+ *
1225
+ * Calling this function with a NULL audio stream is legal, and removes any
1226
+ * input from the track. If the track was currently playing, the next time the
1227
+ * mixer runs, it'll notice this and mark the track as stopped, calling any
1228
+ * assigned MIX_TrackStoppedCallback.
1229
+ *
1230
+ * It is legal to change the input of a track while it's playing, however some
1231
+ * states, like loop points, may cease to make sense with the new audio. In
1232
+ * such a case, one can call MIX_PlayTrack again to adjust parameters.
1233
+ *
1234
+ * The provided audio stream must remain valid until the track no longer needs
1235
+ * it (either by changing the track's input or destroying the track).
1236
+ *
1237
+ * \param track the track on which to set a new audio input.
1238
+ * \param stream the audio stream to use as the track's input.
1239
+ * \returns true on success, false on error; call SDL_GetError() for details.
1240
+ *
1241
+ * \threadsafety It is safe to call this function from any thread.
1242
+ *
1243
+ * \since This function is available since SDL_mixer 3.0.0.
1244
+ */
1245
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackAudioStream(MIX_Track *track, SDL_AudioStream *stream);
1246
+
1247
+ /**
1248
+ * Set a MIX_Track's input to an SDL_IOStream.
1249
+ *
1250
+ * This is not the recommended way to set a track's input, but this can be
1251
+ * useful for a very specific scenario: a large file, to be played once, that
1252
+ * must be read from disk in small chunks as needed. In most cases, however,
1253
+ * it is preferable to create a MIX_Audio ahead of time and use
1254
+ * MIX_SetTrackAudio() instead.
1255
+ *
1256
+ * The stream supplied here should provide an audio file in a supported
1257
+ * format. SDL_mixer will parse it during this call to make sure it's valid,
1258
+ * and then will read file data from the stream as it needs to decode more
1259
+ * during mixing.
1260
+ *
1261
+ * The stream must be able to seek through the complete set of data, or this
1262
+ * function will fail.
1263
+ *
1264
+ * A given IOStream may only be assigned to a single track at a time;
1265
+ * duplicate assignments won't return an error, but assigning a stream to
1266
+ * multiple tracks will cause each track to read from the stream arbitrarily,
1267
+ * causing confusion, incorrect mixing, or failure to decode.
1268
+ *
1269
+ * Once a track has a valid input, it can start mixing sound by calling
1270
+ * MIX_PlayTrack(), or possibly MIX_PlayTag().
1271
+ *
1272
+ * Calling this function with a NULL stream is legal, and removes any input
1273
+ * from the track. If the track was currently playing, the next time the mixer
1274
+ * runs, it'll notice this and mark the track as stopped, calling any assigned
1275
+ * MIX_TrackStoppedCallback.
1276
+ *
1277
+ * It is legal to change the input of a track while it's playing, however some
1278
+ * states, like loop points, may cease to make sense with the new audio. In
1279
+ * such a case, one can call MIX_PlayTrack again to adjust parameters.
1280
+ *
1281
+ * The provided stream must remain valid until the track no longer needs it
1282
+ * (either by changing the track's input or destroying the track).
1283
+ *
1284
+ * \param track the track on which to set a new audio input.
1285
+ * \param io the new i/o stream to use as the track's input.
1286
+ * \param closeio if true, close the stream when done with it.
1287
+ * \returns true on success, false on error; call SDL_GetError() for details.
1288
+ *
1289
+ * \threadsafety It is safe to call this function from any thread.
1290
+ *
1291
+ * \since This function is available since SDL_mixer 3.0.0.
1292
+ *
1293
+ * \sa MIX_SetTrackRawIOStream
1294
+ */
1295
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackIOStream(MIX_Track *track, SDL_IOStream *io, bool closeio);
1296
+
1297
+ /**
1298
+ * Set a MIX_Track's input to an SDL_IOStream providing raw PCM data.
1299
+ *
1300
+ * This is not the recommended way to set a track's input, but this can be
1301
+ * useful for a very specific scenario: a large file, to be played once, that
1302
+ * must be read from disk in small chunks as needed. In most cases, however,
1303
+ * it is preferable to create a MIX_Audio ahead of time and use
1304
+ * MIX_SetTrackAudio() instead.
1305
+ *
1306
+ * Also, an MIX_SetTrackAudioStream() can _also_ provide raw PCM audio to a
1307
+ * track, via an SDL_AudioStream, which might be preferable unless the data is
1308
+ * already coming directly from an SDL_IOStream.
1309
+ *
1310
+ * The stream supplied here should provide an audio in raw PCM format.
1311
+ *
1312
+ * A given IOStream may only be assigned to a single track at a time;
1313
+ * duplicate assignments won't return an error, but assigning a stream to
1314
+ * multiple tracks will cause each track to read from the stream arbitrarily,
1315
+ * causing confusion and incorrect mixing.
1316
+ *
1317
+ * Once a track has a valid input, it can start mixing sound by calling
1318
+ * MIX_PlayTrack(), or possibly MIX_PlayTag().
1319
+ *
1320
+ * Calling this function with a NULL stream is legal, and removes any input
1321
+ * from the track. If the track was currently playing, the next time the mixer
1322
+ * runs, it'll notice this and mark the track as stopped, calling any assigned
1323
+ * MIX_TrackStoppedCallback.
1324
+ *
1325
+ * It is legal to change the input of a track while it's playing, however some
1326
+ * states, like loop points, may cease to make sense with the new audio. In
1327
+ * such a case, one can call MIX_PlayTrack again to adjust parameters.
1328
+ *
1329
+ * The provided stream must remain valid until the track no longer needs it
1330
+ * (either by changing the track's input or destroying the track).
1331
+ *
1332
+ * \param track the track on which to set a new audio input.
1333
+ * \param io the new i/o stream to use as the track's input.
1334
+ * \param spec the format of the PCM data that the SDL_IOStream will provide.
1335
+ * \param closeio if true, close the stream when done with it.
1336
+ * \returns true on success, false on error; call SDL_GetError() for details.
1337
+ *
1338
+ * \threadsafety It is safe to call this function from any thread.
1339
+ *
1340
+ * \since This function is available since SDL_mixer 3.0.0.
1341
+ *
1342
+ * \sa MIX_SetTrackAudioStream
1343
+ * \sa MIX_SetTrackIOStream
1344
+ */
1345
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackRawIOStream(MIX_Track *track, SDL_IOStream *io, const SDL_AudioSpec *spec, bool closeio);
1346
+
1347
+
1348
+ /**
1349
+ * Assign an arbitrary tag to a track.
1350
+ *
1351
+ * A tag can be any valid C string in UTF-8 encoding. It can be useful to
1352
+ * group tracks in various ways. For example, everything in-game might be
1353
+ * marked as "game", so when the user brings up the settings menu, the app can
1354
+ * pause all tracks involved in gameplay at once, but keep background music
1355
+ * and menu sound effects running.
1356
+ *
1357
+ * A track can have as many tags as desired, until the machine runs out of
1358
+ * memory.
1359
+ *
1360
+ * It's legal to add the same tag to a track more than once; the extra
1361
+ * attempts will report success but not change anything.
1362
+ *
1363
+ * Tags can later be removed with MIX_UntagTrack().
1364
+ *
1365
+ * \param track the track to add a tag to.
1366
+ * \param tag the tag to add.
1367
+ * \returns true on success, false on error; call SDL_GetError() for details.
1368
+ *
1369
+ * \threadsafety It is safe to call this function from any thread.
1370
+ *
1371
+ * \since This function is available since SDL_mixer 3.0.0.
1372
+ *
1373
+ * \sa MIX_UntagTrack
1374
+ */
1375
+ extern SDL_DECLSPEC bool SDLCALL MIX_TagTrack(MIX_Track *track, const char *tag);
1376
+
1377
+ /**
1378
+ * Remove an arbitrary tag from a track.
1379
+ *
1380
+ * A tag can be any valid C string in UTF-8 encoding. It can be useful to
1381
+ * group tracks in various ways. For example, everything in-game might be
1382
+ * marked as "game", so when the user brings up the settings menu, the app can
1383
+ * pause all tracks involved in gameplay at once, but keep background music
1384
+ * and menu sound effects running.
1385
+ *
1386
+ * It's legal to remove a tag that the track doesn't have; this function
1387
+ * doesn't report errors, so this simply does nothing.
1388
+ *
1389
+ * Specifying a NULL tag will remove all tags on a track.
1390
+ *
1391
+ * \param track the track from which to remove a tag.
1392
+ * \param tag the tag to remove, or NULL to remove all current tags.
1393
+ *
1394
+ * \threadsafety It is safe to call this function from any thread.
1395
+ *
1396
+ * \since This function is available since SDL_mixer 3.0.0.
1397
+ *
1398
+ * \sa MIX_TagTrack
1399
+ */
1400
+ extern SDL_DECLSPEC void SDLCALL MIX_UntagTrack(MIX_Track *track, const char *tag);
1401
+
1402
+ /**
1403
+ * Get the tags currently associated with a track.
1404
+ *
1405
+ * Tags are not provided in any guaranteed order.
1406
+ *
1407
+ * \param track the track to query.
1408
+ * \param count a pointer filled in with the number of tags returned, can be
1409
+ * NULL.
1410
+ * \returns an array of the tags, NULL-terminated, or NULL on failure; call
1411
+ * SDL_GetError() for more information. This is a single allocation
1412
+ * that should be freed with SDL_free() when it is no longer needed.
1413
+ *
1414
+ * \threadsafety It is safe to call this function from any thread.
1415
+ *
1416
+ * \since This function is available since SDL_mixer 3.0.0.
1417
+ */
1418
+ extern SDL_DECLSPEC char ** SDLCALL MIX_GetTrackTags(MIX_Track *track, int *count);
1419
+
1420
+ /**
1421
+ * Get all tracks with a specific tag.
1422
+ *
1423
+ * Tracks are not provided in any guaranteed order.
1424
+ *
1425
+ * \param mixer the mixer to query.
1426
+ * \param tag the tag to search.
1427
+ * \param count a pointer filled in with the number of tracks returned, can be
1428
+ * NULL.
1429
+ * \returns an array of the tracks, NULL-terminated, or NULL on failure; call
1430
+ * SDL_GetError() for more information. The returned pointer should
1431
+ * be freed with SDL_free() when it is no longer needed.
1432
+ *
1433
+ * \threadsafety It is safe to call this function from any thread.
1434
+ *
1435
+ * \since This function is available since SDL_mixer 3.0.0.
1436
+ */
1437
+ extern SDL_DECLSPEC MIX_Track ** SDLCALL MIX_GetTaggedTracks(MIX_Mixer *mixer, const char *tag, int *count);
1438
+
1439
+ /**
1440
+ * Seek a playing track to a new position in its input.
1441
+ *
1442
+ * (Not to be confused with MIX_SetTrack3DPosition(), which is positioning of
1443
+ * the track in 3D space, not the playback position of its audio data.)
1444
+ *
1445
+ * On a playing track, the next time the mixer runs, it will start mixing from
1446
+ * the new position.
1447
+ *
1448
+ * Position is defined in _sample frames_ of decoded audio, not units of time,
1449
+ * so that sample-perfect mixing can be achieved. To instead operate in units
1450
+ * of time, use MIX_TrackMSToFrames() to get the approximate sample frames for
1451
+ * a given tick.
1452
+ *
1453
+ * This function requires an input that can seek (so it can not be used if the
1454
+ * input was set with MIX_SetTrackAudioStream()), and a audio file format that
1455
+ * allows seeking. SDL_mixer's decoders for some file formats do not offer
1456
+ * seeking, or can only seek to times, not exact sample frames, in which case
1457
+ * the final position may be off by some amount of sample frames. Please check
1458
+ * your audio data and file bug reports if appropriate.
1459
+ *
1460
+ * It's legal to call this function on a track that is stopped, but a future
1461
+ * call to MIX_PlayTrack() will reset the start position anyhow. Paused tracks
1462
+ * will resume at the new input position.
1463
+ *
1464
+ * \param track the track to change.
1465
+ * \param frames the sample frame position to seek to.
1466
+ * \returns true on success, false on error; call SDL_GetError() for details.
1467
+ *
1468
+ * \threadsafety It is safe to call this function from any thread.
1469
+ *
1470
+ * \since This function is available since SDL_mixer 3.0.0.
1471
+ *
1472
+ * \sa MIX_GetTrackPlaybackPosition
1473
+ */
1474
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackPlaybackPosition(MIX_Track *track, Sint64 frames);
1475
+
1476
+ /**
1477
+ * Get the current input position of a playing track.
1478
+ *
1479
+ * (Not to be confused with MIX_GetTrack3DPosition(), which is positioning of
1480
+ * the track in 3D space, not the playback position of its audio data.)
1481
+ *
1482
+ * Position is defined in _sample frames_ of decoded audio, not units of time,
1483
+ * so that sample-perfect mixing can be achieved. To instead operate in units
1484
+ * of time, use MIX_TrackFramesToMS() to convert the return value to
1485
+ * milliseconds.
1486
+ *
1487
+ * Stopped and paused tracks will report the position when they halted.
1488
+ * Playing tracks will report the current position, which will change over
1489
+ * time.
1490
+ *
1491
+ * \param track the track to change.
1492
+ * \returns the track's current sample frame position, or -1 on error; call
1493
+ * SDL_GetError() for details.
1494
+ *
1495
+ * \threadsafety It is safe to call this function from any thread.
1496
+ *
1497
+ * \since This function is available since SDL_mixer 3.0.0.
1498
+ *
1499
+ * \sa MIX_SetTrackPlaybackPosition
1500
+ */
1501
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_GetTrackPlaybackPosition(MIX_Track *track);
1502
+
1503
+ /**
1504
+ * Query whether a given track is fading.
1505
+ *
1506
+ * This specifically checks if the track is _not stopped_ (paused or playing),
1507
+ * and it is fading in or out, and returns the number of frames remaining in
1508
+ * the fade.
1509
+ *
1510
+ * If fading out, the returned value will be negative. When fading in, the
1511
+ * returned value will be positive. If not fading, this function returns zero.
1512
+ *
1513
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1514
+ * returns 0, but there is no mechanism to distinguish errors from tracks that
1515
+ * aren't fading.
1516
+ *
1517
+ * \param track the track to query.
1518
+ * \returns less than 0 if the track is fading out, greater than 0 if fading
1519
+ * in, zero otherwise.
1520
+ *
1521
+ * \threadsafety It is safe to call this function from any thread.
1522
+ *
1523
+ * \since This function is available since SDL_mixer 3.0.0.
1524
+ */
1525
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_GetTrackFadeFrames(MIX_Track *track);
1526
+
1527
+ /**
1528
+ * Query how many loops remain for a given track.
1529
+ *
1530
+ * This returns the number of loops still pending; if a track will eventually
1531
+ * complete and loop to play again one more time, this will return 1. If a
1532
+ * track _was_ looping but is on its final iteration of the loop (will stop
1533
+ * when this iteration completes), this will return zero.
1534
+ *
1535
+ * A track that is looping infinitely will return -1. This value does not
1536
+ * report an error in this case.
1537
+ *
1538
+ * A track that is stopped (not playing and not paused) will have zero loops
1539
+ * remaining.
1540
+ *
1541
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1542
+ * returns zero, but there is no mechanism to distinguish errors from
1543
+ * non-looping tracks.
1544
+ *
1545
+ * \param track the track to query.
1546
+ * \returns the number of pending loops, zero if not looping, and -1 if
1547
+ * looping infinitely.
1548
+ *
1549
+ * \threadsafety It is safe to call this function from any thread.
1550
+ *
1551
+ * \since This function is available since SDL_mixer 3.0.0.
1552
+ */
1553
+ extern SDL_DECLSPEC int SDLCALL MIX_GetTrackLoops(MIX_Track *track);
1554
+
1555
+ /**
1556
+ * Change the number of times a currently-playing track will loop.
1557
+ *
1558
+ * This replaces any previously-set remaining loops. A value of 1 will loop to
1559
+ * the start of playback one time. Zero will not loop at all. A value of -1
1560
+ * requests infinite loops. If the input is not seekable and `num_loops` isn't
1561
+ * zero, this function will report success but the track will stop at the
1562
+ * point it should loop.
1563
+ *
1564
+ * The new loop count replaces any previous state, even if the track has
1565
+ * already looped.
1566
+ *
1567
+ * This has no effect on a track that is stopped, or rather, starting a
1568
+ * stopped track later will set a new loop count, replacing this value.
1569
+ * Stopped tracks can specify a loop count while starting via
1570
+ * MIX_PROP_PLAY_LOOPS_NUMBER. This function is intended to alter that count
1571
+ * in the middle of playback.
1572
+ *
1573
+ * \param track the track to configure.
1574
+ * \param num_loops new number of times to loop. Zero to disable looping, -1
1575
+ * to loop infinitely.
1576
+ * \returns true on success, false on error; call SDL_GetError() for details.
1577
+ *
1578
+ * \threadsafety It is safe to call this function from any thread.
1579
+ *
1580
+ * \since This function is available since SDL_mixer 3.0.0.
1581
+ *
1582
+ * \sa MIX_GetTrackLoops
1583
+ */
1584
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackLoops(MIX_Track *track, int num_loops);
1585
+
1586
+ /**
1587
+ * Query the MIX_Audio assigned to a track.
1588
+ *
1589
+ * This returns the MIX_Audio object currently assigned to `track` through a
1590
+ * call to MIX_SetTrackAudio(). If there is none assigned, or the track has an
1591
+ * input that isn't a MIX_Audio (such as an SDL_AudioStream or SDL_IOStream),
1592
+ * this will return NULL.
1593
+ *
1594
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1595
+ * returns NULL, but there is no mechanism to distinguish errors from tracks
1596
+ * without a valid input.
1597
+ *
1598
+ * \param track the track to query.
1599
+ * \returns a MIX_Audio if available, NULL if not.
1600
+ *
1601
+ * \threadsafety It is safe to call this function from any thread.
1602
+ *
1603
+ * \since This function is available since SDL_mixer 3.0.0.
1604
+ *
1605
+ * \sa MIX_GetTrackAudioStream
1606
+ */
1607
+ extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_GetTrackAudio(MIX_Track *track);
1608
+
1609
+ /**
1610
+ * Query the SDL_AudioStream assigned to a track.
1611
+ *
1612
+ * This returns the SDL_AudioStream object currently assigned to `track`
1613
+ * through a call to MIX_SetTrackAudioStream(). If there is none assigned, or
1614
+ * the track has an input that isn't an SDL_AudioStream (such as a MIX_Audio
1615
+ * or SDL_IOStream), this will return NULL.
1616
+ *
1617
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1618
+ * returns NULL, but there is no mechanism to distinguish errors from tracks
1619
+ * without a valid input.
1620
+ *
1621
+ * \param track the track to query.
1622
+ * \returns an SDL_AudioStream if available, NULL if not.
1623
+ *
1624
+ * \threadsafety It is safe to call this function from any thread.
1625
+ *
1626
+ * \since This function is available since SDL_mixer 3.0.0.
1627
+ *
1628
+ * \sa MIX_GetTrackAudio
1629
+ */
1630
+ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL MIX_GetTrackAudioStream(MIX_Track *track);
1631
+
1632
+ /**
1633
+ * Return the number of sample frames remaining to be mixed in a track.
1634
+ *
1635
+ * If the track is playing or paused, and its total duration is known, this
1636
+ * will report how much audio is left to mix. If the track is playing, future
1637
+ * calls to this function will report different values.
1638
+ *
1639
+ * Remaining audio is defined in _sample frames_ of decoded audio, not units
1640
+ * of time, so that sample-perfect mixing can be achieved. To instead operate
1641
+ * in units of time, use MIX_TrackFramesToMS() to convert the return value to
1642
+ * milliseconds.
1643
+ *
1644
+ * This function does not take into account fade-outs or looping, just the
1645
+ * current mixing position vs the duration of the track.
1646
+ *
1647
+ * If the duration of the track isn't known, or `track` is NULL, this function
1648
+ * returns -1. A stopped track reports 0.
1649
+ *
1650
+ * \param track the track to query.
1651
+ * \returns the total sample frames still to be mixed, or -1 if unknown.
1652
+ *
1653
+ * \threadsafety It is safe to call this function from any thread.
1654
+ *
1655
+ * \since This function is available since SDL_mixer 3.0.0.
1656
+ */
1657
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_GetTrackRemaining(MIX_Track *track);
1658
+
1659
+ /**
1660
+ * Convert milliseconds to sample frames for a track's current format.
1661
+ *
1662
+ * This calculates time based on the track's current input format, which can
1663
+ * change when its input does, and also if that input changes formats
1664
+ * mid-stream (for example, if decoding a file that is two MP3s concatenated
1665
+ * together).
1666
+ *
1667
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1668
+ * returns -1. If the track has no input, this returns -1. If `ms` is < 0,
1669
+ * this returns -1.
1670
+ *
1671
+ * \param track the track to query.
1672
+ * \param ms the milliseconds to convert to track-specific sample frames.
1673
+ * \returns Converted number of sample frames, or -1 for errors/no input; call
1674
+ * SDL_GetError() for details.
1675
+ *
1676
+ * \threadsafety It is safe to call this function from any thread.
1677
+ *
1678
+ * \since This function is available since SDL_mixer 3.0.0.
1679
+ *
1680
+ * \sa MIX_TrackFramesToMS
1681
+ */
1682
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_TrackMSToFrames(MIX_Track *track, Sint64 ms);
1683
+
1684
+ /**
1685
+ * Convert sample frames for a track's current format to milliseconds.
1686
+ *
1687
+ * This calculates time based on the track's current input format, which can
1688
+ * change when its input does, and also if that input changes formats
1689
+ * mid-stream (for example, if decoding a file that is two MP3s concatenated
1690
+ * together).
1691
+ *
1692
+ * Sample frames are more precise than milliseconds, so out of necessity, this
1693
+ * function will approximate by rounding down to the closest full millisecond.
1694
+ *
1695
+ * On various errors (MIX_Init() was not called, the track is NULL), this
1696
+ * returns -1. If the track has no input, this returns -1. If `frames` is < 0,
1697
+ * this returns -1.
1698
+ *
1699
+ * \param track the track to query.
1700
+ * \param frames the track-specific sample frames to convert to milliseconds.
1701
+ * \returns Converted number of milliseconds, or -1 for errors/no input; call
1702
+ * SDL_GetError() for details.
1703
+ *
1704
+ * \threadsafety It is safe to call this function from any thread.
1705
+ *
1706
+ * \since This function is available since SDL_mixer 3.0.0.
1707
+ *
1708
+ * \sa MIX_TrackMSToFrames
1709
+ */
1710
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_TrackFramesToMS(MIX_Track *track, Sint64 frames);
1711
+
1712
+ /**
1713
+ * Convert milliseconds to sample frames for a MIX_Audio's format.
1714
+ *
1715
+ * This calculates time based on the audio's initial format, even if the
1716
+ * format would change mid-stream.
1717
+ *
1718
+ * If `ms` is < 0, this returns -1.
1719
+ *
1720
+ * \param audio the audio to query.
1721
+ * \param ms the milliseconds to convert to audio-specific sample frames.
1722
+ * \returns Converted number of sample frames, or -1 for errors/no input; call
1723
+ * SDL_GetError() for details.
1724
+ *
1725
+ * \threadsafety It is safe to call this function from any thread.
1726
+ *
1727
+ * \since This function is available since SDL_mixer 3.0.0.
1728
+ *
1729
+ * \sa MIX_AudioFramesToMS
1730
+ */
1731
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_AudioMSToFrames(MIX_Audio *audio, Sint64 ms);
1732
+
1733
+ /**
1734
+ * Convert sample frames for a MIX_Audio's format to milliseconds.
1735
+ *
1736
+ * This calculates time based on the audio's initial format, even if the
1737
+ * format would change mid-stream.
1738
+ *
1739
+ * Sample frames are more precise than milliseconds, so out of necessity, this
1740
+ * function will approximate by rounding down to the closest full millisecond.
1741
+ *
1742
+ * If `frames` is < 0, this returns -1.
1743
+ *
1744
+ * \param audio the audio to query.
1745
+ * \param frames the audio-specific sample frames to convert to milliseconds.
1746
+ * \returns Converted number of milliseconds, or -1 for errors/no input; call
1747
+ * SDL_GetError() for details.
1748
+ *
1749
+ * \threadsafety It is safe to call this function from any thread.
1750
+ *
1751
+ * \since This function is available since SDL_mixer 3.0.0.
1752
+ *
1753
+ * \sa MIX_AudioMSToFrames
1754
+ */
1755
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_AudioFramesToMS(MIX_Audio *audio, Sint64 frames);
1756
+
1757
+ /**
1758
+ * Convert milliseconds to sample frames at a specific sample rate.
1759
+ *
1760
+ * If `sample_rate` is <= 0, this returns -1. If `ms` is < 0, this returns -1.
1761
+ *
1762
+ * \param sample_rate the sample rate to use for conversion.
1763
+ * \param ms the milliseconds to convert to rate-specific sample frames.
1764
+ * \returns Converted number of sample frames, or -1 for errors; call
1765
+ * SDL_GetError() for details.
1766
+ *
1767
+ * \threadsafety It is safe to call this function from any thread.
1768
+ *
1769
+ * \since This function is available since SDL_mixer 3.0.0.
1770
+ *
1771
+ * \sa MIX_FramesToMS
1772
+ */
1773
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_MSToFrames(int sample_rate, Sint64 ms);
1774
+
1775
+ /**
1776
+ * Convert sample frames, at a specific sample rate, to milliseconds.
1777
+ *
1778
+ * Sample frames are more precise than milliseconds, so out of necessity, this
1779
+ * function will approximate by rounding down to the closest full millisecond.
1780
+ *
1781
+ * If `sample_rate` is <= 0, this returns -1. If `frames` is < 0, this returns
1782
+ * -1.
1783
+ *
1784
+ * \param sample_rate the sample rate to use for conversion.
1785
+ * \param frames the rate-specific sample frames to convert to milliseconds.
1786
+ * \returns Converted number of milliseconds, or -1 for errors; call
1787
+ * SDL_GetError() for details.
1788
+ *
1789
+ * \threadsafety It is safe to call this function from any thread.
1790
+ *
1791
+ * \since This function is available since SDL_mixer 3.0.0.
1792
+ *
1793
+ * \sa MIX_MSToFrames
1794
+ */
1795
+ extern SDL_DECLSPEC Sint64 SDLCALL MIX_FramesToMS(int sample_rate, Sint64 frames);
1796
+
1797
+
1798
+ /* operations that deal with actual mixing/playback... */
1799
+
1800
+ /**
1801
+ * Start (or restart) mixing a track for playback.
1802
+ *
1803
+ * The track will use whatever input was last assigned to it when playing; an
1804
+ * input must be assigned to this track or this function will fail. Inputs are
1805
+ * assigned with calls to MIX_SetTrackAudio(), MIX_SetTrackAudioStream(), or
1806
+ * MIX_SetTrackIOStream().
1807
+ *
1808
+ * If the track is already playing, or paused, this will restart the track
1809
+ * with the newly-specified parameters.
1810
+ *
1811
+ * As there are several parameters, and more may be added in the future, they
1812
+ * are specified with an SDL_PropertiesID. The parameters have reasonable
1813
+ * defaults, and specifying a 0 for `options` will choose defaults for
1814
+ * everything.
1815
+ *
1816
+ * SDL_PropertiesID are discussed in
1817
+ * [SDL's documentation](https://wiki.libsdl.org/SDL3/CategoryProperties)
1818
+ * .
1819
+ *
1820
+ * These are the supported properties:
1821
+ *
1822
+ * - `MIX_PROP_PLAY_LOOPS_NUMBER`: The number of times to loop the track when
1823
+ * it reaches the end. A value of 1 will loop to the start one time. Zero
1824
+ * will not loop at all. A value of -1 requests infinite loops. If the input
1825
+ * is not seekable and this value isn't zero, this function will report
1826
+ * success but the track will stop at the point it should loop. Default 0.
1827
+ * - `MIX_PROP_PLAY_MAX_FRAME_NUMBER`: Mix at most to this sample frame
1828
+ * position in the track. This will be treated as if the input reach EOF at
1829
+ * this point in the audio file. If -1, mix all available audio without a
1830
+ * limit. Default -1.
1831
+ * - `MIX_PROP_PLAY_MAX_MILLISECONDS_NUMBER`: The same as using the
1832
+ * MIX_PROP_PLAY_MAX_FRAME_NUMBER property, but the value is specified in
1833
+ * milliseconds instead of sample frames. If both properties are specified,
1834
+ * the sample frames value is favored. Default -1.
1835
+ * - `MIX_PROP_PLAY_START_FRAME_NUMBER`: Start mixing from this sample frame
1836
+ * position in the track's input. A value <= 0 will begin from the start of
1837
+ * the track's input. If the input is not seekable and this value is > 0,
1838
+ * this function will report failure. Default 0.
1839
+ * - `MIX_PROP_PLAY_START_MILLISECOND_NUMBER`: The same as using the
1840
+ * MIX_PROP_PLAY_START_FRAME_NUMBER property, but the value is specified in
1841
+ * milliseconds instead of sample frames. If both properties are specified,
1842
+ * the sample frames value is favored. Default 0.
1843
+ * - `MIX_PROP_PLAY_LOOP_START_FRAME_NUMBER`: If the track is looping, this is
1844
+ * the sample frame position that the track will loop back to; this lets one
1845
+ * play an intro at the start of a track on the first iteration, but have a
1846
+ * loop point somewhere in the middle thereafter. A value <= 0 will begin
1847
+ * the loop from the start of the track's input. Default 0.
1848
+ * - `MIX_PROP_PLAY_LOOP_START_MILLISECOND_NUMBER`: The same as using the
1849
+ * MIX_PROP_PLAY_LOOP_START_FRAME_NUMBER property, but the value is
1850
+ * specified in milliseconds instead of sample frames. If both properties
1851
+ * are specified, the sample frames value is favored. Default 0.
1852
+ * - `MIX_PROP_PLAY_FADE_IN_FRAMES_NUMBER`: The number of sample frames over
1853
+ * which to fade in the newly-started track. The track will begin mixing
1854
+ * silence and reach full volume smoothly over this many sample frames. If
1855
+ * the track loops before the fade-in is complete, it will continue to fade
1856
+ * correctly from the loop point. A value <= 0 will disable fade-in, so the
1857
+ * track starts mixing at full volume. Default 0.
1858
+ * - `MIX_PROP_PLAY_FADE_IN_MILLISECONDS_NUMBER`: The same as using the
1859
+ * MIX_PROP_PLAY_FADE_IN_FRAMES_NUMBER property, but the value is specified
1860
+ * in milliseconds instead of sample frames. If both properties are
1861
+ * specified, the sample frames value is favored. Default 0.
1862
+ * - `MIX_PROP_PLAY_FADE_IN_START_GAIN_FLOAT`: If fading in, start fading from
1863
+ * this volume level. 0.0f is silence and 1.0f is full volume, every in
1864
+ * between is a linear change in gain. The specified value will be clamped
1865
+ * between 0.0f and 1.0f. Default 0.0f.
1866
+ * - `MIX_PROP_PLAY_APPEND_SILENCE_FRAMES_NUMBER`: At the end of mixing this
1867
+ * track, after all loops are complete, append this many sample frames of
1868
+ * silence as if it were part of the audio file. This allows for apps to
1869
+ * implement effects in callbacks, like reverb, that need to generate
1870
+ * samples past the end of the stream's audio, or perhaps introduce a delay
1871
+ * before starting a new sound on the track without having to manage it
1872
+ * directly. A value <= 0 generates no silence before stopping the track.
1873
+ * Default 0.
1874
+ * - `MIX_PROP_PLAY_APPEND_SILENCE_MILLISECONDS_NUMBER`: The same as using the
1875
+ * MIX_PROP_PLAY_APPEND_SILENCE_FRAMES_NUMBER property, but the value is
1876
+ * specified in milliseconds instead of sample frames. If both properties
1877
+ * are specified, the sample frames value is favored. Default 0.
1878
+ * - `MIX_PROP_PLAY_HALT_WHEN_EXHAUSTED_BOOLEAN`: If true, when input is
1879
+ * completely consumed for the track, the mixer will mark the track as
1880
+ * stopped (and call any appropriate MIX_TrackStoppedCallback, etc); to play
1881
+ * more, the track will need to be restarted. If false, the track will just
1882
+ * not contribute to the mix, but it will not be marked as stopped. There
1883
+ * may be clever logic tricks this exposes generally, but this property is
1884
+ * specifically useful when the track's input is an SDL_AudioStream assigned
1885
+ * via MIX_SetTrackAudioStream(). Setting this property to true can be
1886
+ * useful when pushing a complete piece of audio to the stream that has a
1887
+ * definite ending, as the track will operate like any other audio was
1888
+ * applied. Setting to false means as new data is added to the stream, the
1889
+ * mixer will start using it as soon as possible, which is useful when audio
1890
+ * should play immediately as it drips in: new VoIP packets, etc. Note that
1891
+ * in this situation, if the audio runs out when needed, there _will_ be
1892
+ * gaps in the mixed output, so try to buffer enough data to avoid this when
1893
+ * possible. Note that a track is not consider exhausted until all its loops
1894
+ * and appended silence have been mixed (and also, that loops don't mean
1895
+ * anything when the input is an AudioStream). Default true.
1896
+ * - `MIX_PROP_PLAY_START_ORDER_NUMBER`: This is a special-case property that
1897
+ * most apps can ignore. For mod file formats, start mixing from a specific
1898
+ * "order" index instead of the start of the file. A value < 0 will cause
1899
+ * this property to be ignored. If the decoder doesn't support this
1900
+ * property, it will also be ignored. If this property is _not_ ignored, the
1901
+ * MIX_PROP_PLAY_START_FRAME_NUMBER and
1902
+ * MIX_PROP_PLAY_START_MILLISECOND_NUMBER properties will be ignored
1903
+ * instead. Default -1. Since SDL_mixer 3.2.2.
1904
+ *
1905
+ * If this function fails, mixing of this track will not start (or restart, if
1906
+ * it was already started).
1907
+ *
1908
+ * \param track the track to start (or restart) mixing.
1909
+ * \param options a set of properties that control playback. May be zero.
1910
+ * \returns true on success, false on error; call SDL_GetError() for details.
1911
+ *
1912
+ * \threadsafety It is safe to call this function from any thread.
1913
+ *
1914
+ * \since This function is available since SDL_mixer 3.0.0.
1915
+ *
1916
+ * \sa MIX_PlayTag
1917
+ * \sa MIX_PlayAudio
1918
+ * \sa MIX_StopTrack
1919
+ * \sa MIX_PauseTrack
1920
+ * \sa MIX_TrackPlaying
1921
+ */
1922
+ extern SDL_DECLSPEC bool SDLCALL MIX_PlayTrack(MIX_Track *track, SDL_PropertiesID options);
1923
+
1924
+ #define MIX_PROP_PLAY_LOOPS_NUMBER "SDL_mixer.play.loops"
1925
+ #define MIX_PROP_PLAY_MAX_FRAME_NUMBER "SDL_mixer.play.max_frame"
1926
+ #define MIX_PROP_PLAY_MAX_MILLISECONDS_NUMBER "SDL_mixer.play.max_milliseconds"
1927
+ #define MIX_PROP_PLAY_START_FRAME_NUMBER "SDL_mixer.play.start_frame"
1928
+ #define MIX_PROP_PLAY_START_MILLISECOND_NUMBER "SDL_mixer.play.start_millisecond"
1929
+ #define MIX_PROP_PLAY_START_ORDER_NUMBER "SDL_mixer.play.start_order"
1930
+ #define MIX_PROP_PLAY_LOOP_START_FRAME_NUMBER "SDL_mixer.play.loop_start_frame"
1931
+ #define MIX_PROP_PLAY_LOOP_START_MILLISECOND_NUMBER "SDL_mixer.play.loop_start_millisecond"
1932
+ #define MIX_PROP_PLAY_FADE_IN_FRAMES_NUMBER "SDL_mixer.play.fade_in_frames"
1933
+ #define MIX_PROP_PLAY_FADE_IN_MILLISECONDS_NUMBER "SDL_mixer.play.fade_in_milliseconds"
1934
+ #define MIX_PROP_PLAY_FADE_IN_START_GAIN_FLOAT "SDL_mixer.play.fade_in_start_gain"
1935
+ #define MIX_PROP_PLAY_APPEND_SILENCE_FRAMES_NUMBER "SDL_mixer.play.append_silence_frames"
1936
+ #define MIX_PROP_PLAY_APPEND_SILENCE_MILLISECONDS_NUMBER "SDL_mixer.play.append_silence_milliseconds"
1937
+ #define MIX_PROP_PLAY_HALT_WHEN_EXHAUSTED_BOOLEAN "SDL_mixer.play.halt_when_exhausted"
1938
+
1939
+ /**
1940
+ * Start (or restart) mixing all tracks with a specific tag for playback.
1941
+ *
1942
+ * This function follows all the same rules as MIX_PlayTrack(); please refer
1943
+ * to its documentation for the details. Unlike that function, MIX_PlayTag()
1944
+ * operates on multiple tracks at once that have the specified tag applied,
1945
+ * via MIX_TagTrack().
1946
+ *
1947
+ * If all of your tagged tracks have different sample rates, it would make
1948
+ * sense to use the `*_MILLISECONDS_NUMBER` properties in your `options`,
1949
+ * instead of `*_FRAMES_NUMBER`, and let SDL_mixer figure out how to apply it
1950
+ * to each track.
1951
+ *
1952
+ * This function returns true if all tagged tracks are started (or restarted).
1953
+ * If any track fails, this function returns false, but all tracks that could
1954
+ * start will still be started even when this function reports failure.
1955
+ *
1956
+ * From the point of view of the mixing process, all tracks that successfully
1957
+ * (re)start will do so at the exact same moment.
1958
+ *
1959
+ * \param mixer the mixer on which to look for tagged tracks.
1960
+ * \param tag the tag to use when searching for tracks.
1961
+ * \param options the set of options that will be applied to each track.
1962
+ * \returns true on success, false on error; call SDL_GetError() for details.
1963
+ *
1964
+ * \threadsafety It is safe to call this function from any thread.
1965
+ *
1966
+ * \since This function is available since SDL_mixer 3.0.0.
1967
+ *
1968
+ * \sa MIX_PlayTrack
1969
+ * \sa MIX_TagTrack
1970
+ * \sa MIX_StopTrack
1971
+ * \sa MIX_PauseTrack
1972
+ * \sa MIX_TrackPlaying
1973
+ */
1974
+ extern SDL_DECLSPEC bool SDLCALL MIX_PlayTag(MIX_Mixer *mixer, const char *tag, SDL_PropertiesID options);
1975
+
1976
+ /**
1977
+ * Play a MIX_Audio from start to finish without any management.
1978
+ *
1979
+ * This is what we term a "fire-and-forget" sound. Internally, SDL_mixer will
1980
+ * manage a temporary track to mix the specified MIX_Audio, cleaning it up
1981
+ * when complete. No options can be provided for how to do the mixing, like
1982
+ * MIX_PlayTrack() offers, and since the track is not available to the caller,
1983
+ * no adjustments can be made to mixing over time.
1984
+ *
1985
+ * This is not the function to build an entire game of any complexity around,
1986
+ * but it can be convenient to play simple, one-off sounds that can't be
1987
+ * stopped early. An example would be a voice saying "GAME OVER" during an
1988
+ * unpausable endgame sequence.
1989
+ *
1990
+ * There are no limits to the number of fire-and-forget sounds that can mix at
1991
+ * once (short of running out of memory), and SDL_mixer keeps an internal pool
1992
+ * of temporary tracks it creates as needed and reuses when available.
1993
+ *
1994
+ * \param mixer the mixer on which to play this audio.
1995
+ * \param audio the audio input to play.
1996
+ * \returns true if the track has begun mixing, false on error; call
1997
+ * SDL_GetError() for details.
1998
+ *
1999
+ * \threadsafety It is safe to call this function from any thread.
2000
+ *
2001
+ * \since This function is available since SDL_mixer 3.0.0.
2002
+ *
2003
+ * \sa MIX_PlayTrack
2004
+ * \sa MIX_LoadAudio
2005
+ */
2006
+ extern SDL_DECLSPEC bool SDLCALL MIX_PlayAudio(MIX_Mixer *mixer, MIX_Audio *audio);
2007
+
2008
+ /**
2009
+ * Halt a currently-playing track, possibly fading out over time.
2010
+ *
2011
+ * If `fade_out_frames` is > 0, the track does not stop mixing immediately,
2012
+ * but rather fades to silence over that many sample frames before stopping.
2013
+ * Sample frames are specific to the input assigned to the track, to allow for
2014
+ * sample-perfect mixing. MIX_TrackMSToFrames() can be used to convert
2015
+ * milliseconds to an appropriate value here.
2016
+ *
2017
+ * If the track ends normally while the fade-out is still in progress, the
2018
+ * audio stops there; the fade is not adjusted to be shorter if it will last
2019
+ * longer than the audio remaining.
2020
+ *
2021
+ * Once a track has completed any fadeout and come to a stop, it will call its
2022
+ * MIX_TrackStoppedCallback, if any. It is legal to assign the track a new
2023
+ * input and/or restart it during this callback.
2024
+ *
2025
+ * It is legal to halt a track that's already stopped. It does nothing, and
2026
+ * returns true.
2027
+ *
2028
+ * \param track the track to halt.
2029
+ * \param fade_out_frames the number of sample frames to spend fading out to
2030
+ * silence before halting. 0 to stop immediately.
2031
+ * \returns true if the track has stopped, false on error; call SDL_GetError()
2032
+ * for details.
2033
+ *
2034
+ * \threadsafety It is safe to call this function from any thread.
2035
+ *
2036
+ * \since This function is available since SDL_mixer 3.0.0.
2037
+ *
2038
+ * \sa MIX_PlayTrack
2039
+ */
2040
+ extern SDL_DECLSPEC bool SDLCALL MIX_StopTrack(MIX_Track *track, Sint64 fade_out_frames);
2041
+
2042
+ /**
2043
+ * Halt all currently-playing tracks, possibly fading out over time.
2044
+ *
2045
+ * If `fade_out_ms` is > 0, the tracks do not stop mixing immediately, but
2046
+ * rather fades to silence over that many milliseconds before stopping. Note
2047
+ * that this is different than MIX_StopTrack(), which wants sample frames;
2048
+ * this function takes milliseconds because different tracks might have
2049
+ * different sample rates.
2050
+ *
2051
+ * If a track ends normally while the fade-out is still in progress, the audio
2052
+ * stops there; the fade is not adjusted to be shorter if it will last longer
2053
+ * than the audio remaining.
2054
+ *
2055
+ * Once a track has completed any fadeout and come to a stop, it will call its
2056
+ * MIX_TrackStoppedCallback, if any. It is legal to assign the track a new
2057
+ * input and/or restart it during this callback.
2058
+ *
2059
+ * This function does not prevent new play requests from being made; it’s
2060
+ * legal to use this function to begin fading all playing tracks but then
2061
+ * start other tracks playing normally while those fade-outs are still in
2062
+ * progress.
2063
+ *
2064
+ * \param mixer the mixer on which to stop all tracks.
2065
+ * \param fade_out_ms the number of milliseconds to spend fading out to
2066
+ * silence before halting. 0 to stop immediately.
2067
+ * \returns true on success, false on error; call SDL_GetError() for details.
2068
+ *
2069
+ * \threadsafety It is safe to call this function from any thread.
2070
+ *
2071
+ * \since This function is available since SDL_mixer 3.0.0.
2072
+ *
2073
+ * \sa MIX_StopTrack
2074
+ */
2075
+ extern SDL_DECLSPEC bool SDLCALL MIX_StopAllTracks(MIX_Mixer *mixer, Sint64 fade_out_ms);
2076
+
2077
+ /**
2078
+ * Halt all tracks with a specific tag, possibly fading out over time.
2079
+ *
2080
+ * If `fade_out_ms` is > 0, the tracks do not stop mixing immediately, but
2081
+ * rather fades to silence over that many milliseconds before stopping. Note
2082
+ * that this is different than MIX_StopTrack(), which wants sample frames;
2083
+ * this function takes milliseconds because different tracks might have
2084
+ * different sample rates.
2085
+ *
2086
+ * If a track ends normally while the fade-out is still in progress, the audio
2087
+ * stops there; the fade is not adjusted to be shorter if it will last longer
2088
+ * than the audio remaining.
2089
+ *
2090
+ * Once a track has completed any fadeout and come to a stop, it will call its
2091
+ * MIX_TrackStoppedCallback, if any. It is legal to assign the track a new
2092
+ * input and/or restart it during this callback. This function does not
2093
+ * prevent new play requests from being made.
2094
+ *
2095
+ * \param mixer the mixer on which to stop tracks.
2096
+ * \param tag the tag to use when searching for tracks.
2097
+ * \param fade_out_ms the number of milliseconds to spend fading out to
2098
+ * silence before halting. 0 to stop immediately.
2099
+ * \returns true on success, false on error; call SDL_GetError() for details.
2100
+ *
2101
+ * \threadsafety It is safe to call this function from any thread.
2102
+ *
2103
+ * \since This function is available since SDL_mixer 3.0.0.
2104
+ *
2105
+ * \sa MIX_StopTrack
2106
+ * \sa MIX_TagTrack
2107
+ */
2108
+ extern SDL_DECLSPEC bool SDLCALL MIX_StopTag(MIX_Mixer *mixer, const char *tag, Sint64 fade_out_ms);
2109
+
2110
+ /**
2111
+ * Pause a currently-playing track.
2112
+ *
2113
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2114
+ * will not fire if paused, but it won't change state by default, generate
2115
+ * audio, or generally make progress, until it is resumed.
2116
+ *
2117
+ * It is legal to pause a track that's in any state (playing, already paused,
2118
+ * or stopped). Unless the track is currently playing, pausing does nothing,
2119
+ * and returns true. A false return is only used to signal errors here (such
2120
+ * as MIX_Init not being called or `track` being NULL).
2121
+ *
2122
+ * \param track the track to pause.
2123
+ * \returns true if the track has paused, false on error; call SDL_GetError()
2124
+ * for details.
2125
+ *
2126
+ * \threadsafety It is safe to call this function from any thread.
2127
+ *
2128
+ * \since This function is available since SDL_mixer 3.0.0.
2129
+ *
2130
+ * \sa MIX_ResumeTrack
2131
+ */
2132
+ extern SDL_DECLSPEC bool SDLCALL MIX_PauseTrack(MIX_Track *track);
2133
+
2134
+ /**
2135
+ * Pause all currently-playing tracks.
2136
+ *
2137
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2138
+ * will not fire if paused, but it won't change state by default, generate
2139
+ * audio, or generally make progress, until it is resumed.
2140
+ *
2141
+ * This function makes all tracks on the specified mixer that are currently
2142
+ * playing move to a paused state. They can later be resumed.
2143
+ *
2144
+ * \param mixer the mixer on which to pause all tracks.
2145
+ * \returns true on success, false on error; call SDL_GetError() for details.
2146
+ *
2147
+ * \threadsafety It is safe to call this function from any thread.
2148
+ *
2149
+ * \since This function is available since SDL_mixer 3.0.0.
2150
+ *
2151
+ * \sa MIX_ResumeTrack
2152
+ * \sa MIX_ResumeAllTracks
2153
+ */
2154
+ extern SDL_DECLSPEC bool SDLCALL MIX_PauseAllTracks(MIX_Mixer *mixer);
2155
+
2156
+ /**
2157
+ * Pause all tracks with a specific tag.
2158
+ *
2159
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2160
+ * will not fire if paused, but it won't change state by default, generate
2161
+ * audio, or generally make progress, until it is resumed.
2162
+ *
2163
+ * This function makes all currently-playing tracks on the specified mixer,
2164
+ * with a specific tag, move to a paused state. They can later be resumed.
2165
+ *
2166
+ * Tracks that match the specified tag that aren't currently playing are
2167
+ * ignored.
2168
+ *
2169
+ * \param mixer the mixer on which to pause tracks.
2170
+ * \param tag the tag to use when searching for tracks.
2171
+ * \returns true on success, false on error; call SDL_GetError() for details.
2172
+ *
2173
+ * \threadsafety It is safe to call this function from any thread.
2174
+ *
2175
+ * \since This function is available since SDL_mixer 3.0.0.
2176
+ *
2177
+ * \sa MIX_PauseTrack
2178
+ * \sa MIX_ResumeTrack
2179
+ * \sa MIX_ResumeTag
2180
+ * \sa MIX_TagTrack
2181
+ */
2182
+ extern SDL_DECLSPEC bool SDLCALL MIX_PauseTag(MIX_Mixer *mixer, const char *tag);
2183
+
2184
+ /**
2185
+ * Resume a currently-paused track.
2186
+ *
2187
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2188
+ * will not fire if paused, but it won't change state by default, generate
2189
+ * audio, or generally make progress, until it is resumed.
2190
+ *
2191
+ * It is legal to resume a track that's in any state (playing, paused, or
2192
+ * stopped). Unless the track is currently paused, resuming does nothing, and
2193
+ * returns true. A false return is only used to signal errors here (such as
2194
+ * MIX_Init not being called or `track` being NULL).
2195
+ *
2196
+ * \param track the track to resume.
2197
+ * \returns true if the track has resumed, false on error; call SDL_GetError()
2198
+ * for details.
2199
+ *
2200
+ * \threadsafety It is safe to call this function from any thread.
2201
+ *
2202
+ * \since This function is available since SDL_mixer 3.0.0.
2203
+ *
2204
+ * \sa MIX_PauseTrack
2205
+ */
2206
+ extern SDL_DECLSPEC bool SDLCALL MIX_ResumeTrack(MIX_Track *track);
2207
+
2208
+ /**
2209
+ * Resume all currently-paused tracks.
2210
+ *
2211
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2212
+ * will not fire if paused, but it won't change state by default, generate
2213
+ * audio, or generally make progress, until it is resumed.
2214
+ *
2215
+ * This function makes all tracks on the specified mixer that are currently
2216
+ * paused move to a playing state.
2217
+ *
2218
+ * \param mixer the mixer on which to resume all tracks.
2219
+ * \returns true on success, false on error; call SDL_GetError() for details.
2220
+ *
2221
+ * \threadsafety It is safe to call this function from any thread.
2222
+ *
2223
+ * \since This function is available since SDL_mixer 3.0.0.
2224
+ *
2225
+ * \sa MIX_PauseTrack
2226
+ * \sa MIX_PauseAllTracks
2227
+ */
2228
+ extern SDL_DECLSPEC bool SDLCALL MIX_ResumeAllTracks(MIX_Mixer *mixer);
2229
+
2230
+ /**
2231
+ * Resume all tracks with a specific tag.
2232
+ *
2233
+ * A paused track is not considered "stopped," so its MIX_TrackStoppedCallback
2234
+ * will not fire if paused, but it won't change state by default, generate
2235
+ * audio, or generally make progress, until it is resumed.
2236
+ *
2237
+ * This function makes all currently-paused tracks on the specified mixer,
2238
+ * with a specific tag, move to a playing state.
2239
+ *
2240
+ * Tracks that match the specified tag that aren't currently paused are
2241
+ * ignored.
2242
+ *
2243
+ * \param mixer the mixer on which to resume tracks.
2244
+ * \param tag the tag to use when searching for tracks.
2245
+ * \returns true on success, false on error; call SDL_GetError() for details.
2246
+ *
2247
+ * \threadsafety It is safe to call this function from any thread.
2248
+ *
2249
+ * \since This function is available since SDL_mixer 3.0.0.
2250
+ *
2251
+ * \sa MIX_ResumeTrack
2252
+ * \sa MIX_PauseTrack
2253
+ * \sa MIX_PauseTag
2254
+ * \sa MIX_TagTrack
2255
+ */
2256
+ extern SDL_DECLSPEC bool SDLCALL MIX_ResumeTag(MIX_Mixer *mixer, const char *tag);
2257
+
2258
+ /**
2259
+ * Query if a track is currently playing.
2260
+ *
2261
+ * If this returns true, the track is currently contributing to the mixer's
2262
+ * output (it's "playing"). It is not stopped nor paused.
2263
+ *
2264
+ * On various errors (MIX_Init() was not called, the track is NULL), this
2265
+ * returns false, but there is no mechanism to distinguish errors from
2266
+ * non-playing tracks.
2267
+ *
2268
+ * \param track the track to query.
2269
+ * \returns true if playing, false otherwise.
2270
+ *
2271
+ * \threadsafety It is safe to call this function from any thread.
2272
+ *
2273
+ * \since This function is available since SDL_mixer 3.0.0.
2274
+ *
2275
+ * \sa MIX_PlayTrack
2276
+ * \sa MIX_PauseTrack
2277
+ * \sa MIX_ResumeTrack
2278
+ * \sa MIX_StopTrack
2279
+ * \sa MIX_TrackPaused
2280
+ */
2281
+ extern SDL_DECLSPEC bool SDLCALL MIX_TrackPlaying(MIX_Track *track);
2282
+
2283
+ /**
2284
+ * Query if a track is currently paused.
2285
+ *
2286
+ * If this returns true, the track is not currently contributing to the
2287
+ * mixer's output but will when resumed (it's "paused"). It is not playing nor
2288
+ * stopped.
2289
+ *
2290
+ * On various errors (MIX_Init() was not called, the track is NULL), this
2291
+ * returns false, but there is no mechanism to distinguish errors from
2292
+ * non-playing tracks.
2293
+ *
2294
+ * \param track the track to query.
2295
+ * \returns true if paused, false otherwise.
2296
+ *
2297
+ * \threadsafety It is safe to call this function from any thread.
2298
+ *
2299
+ * \since This function is available since SDL_mixer 3.0.0.
2300
+ *
2301
+ * \sa MIX_PlayTrack
2302
+ * \sa MIX_PauseTrack
2303
+ * \sa MIX_ResumeTrack
2304
+ * \sa MIX_StopTrack
2305
+ * \sa MIX_TrackPlaying
2306
+ */
2307
+ extern SDL_DECLSPEC bool SDLCALL MIX_TrackPaused(MIX_Track *track);
2308
+
2309
+
2310
+ /* volume control... */
2311
+
2312
+ /**
2313
+ * Set a mixer's master gain control.
2314
+ *
2315
+ * Each mixer has a master gain, to adjust the volume of the entire mix. Each
2316
+ * sample passing through the pipeline is modulated by this gain value. A gain
2317
+ * of zero will generate silence, 1.0f will not change the mixed volume, and
2318
+ * larger than 1.0f will increase the volume. Negative values are illegal.
2319
+ * There is no maximum gain specified, but this can quickly get extremely
2320
+ * loud, so please be careful with this setting.
2321
+ *
2322
+ * A mixer's master gain defaults to 1.0f.
2323
+ *
2324
+ * This value can be changed at any time to adjust the future mix.
2325
+ *
2326
+ * \param mixer the mixer to adjust.
2327
+ * \param gain the new gain value.
2328
+ * \returns true on success or false on failure; call SDL_GetError() for more
2329
+ * information.
2330
+ *
2331
+ * \threadsafety It is safe to call this function from any thread.
2332
+ *
2333
+ * \since This function is available since SDL_mixer 3.0.0.
2334
+ *
2335
+ * \sa MIX_GetMixerGain
2336
+ * \sa MIX_SetTrackGain
2337
+ */
2338
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetMixerGain(MIX_Mixer *mixer, float gain);
2339
+
2340
+ /**
2341
+ * Get a mixer's master gain control.
2342
+ *
2343
+ * This returns the last value set through MIX_SetMixerGain(), or 1.0f if no
2344
+ * value has ever been explicitly set.
2345
+ *
2346
+ * \param mixer the mixer to query.
2347
+ * \returns the mixer's current master gain.
2348
+ *
2349
+ * \threadsafety It is safe to call this function from any thread.
2350
+ *
2351
+ * \since This function is available since SDL_mixer 3.0.0.
2352
+ *
2353
+ * \sa MIX_SetMixerGain
2354
+ * \sa MIX_GetTrackGain
2355
+ */
2356
+ extern SDL_DECLSPEC float SDLCALL MIX_GetMixerGain(MIX_Mixer *mixer);
2357
+
2358
+ /**
2359
+ * Set a track's gain control.
2360
+ *
2361
+ * Each track has its own gain, to adjust its overall volume. Each sample from
2362
+ * this track is modulated by this gain value. A gain of zero will generate
2363
+ * silence, 1.0f will not change the mixed volume, and larger than 1.0f will
2364
+ * increase the volume. Negative values are illegal. There is no maximum gain
2365
+ * specified, but this can quickly get extremely loud, so please be careful
2366
+ * with this setting.
2367
+ *
2368
+ * A track's gain defaults to 1.0f.
2369
+ *
2370
+ * This value can be changed at any time to adjust the future mix.
2371
+ *
2372
+ * \param track the track to adjust.
2373
+ * \param gain the new gain value.
2374
+ * \returns true on success or false on failure; call SDL_GetError() for more
2375
+ * information.
2376
+ *
2377
+ * \threadsafety It is safe to call this function from any thread.
2378
+ *
2379
+ * \since This function is available since SDL_mixer 3.0.0.
2380
+ *
2381
+ * \sa MIX_GetTrackGain
2382
+ * \sa MIX_SetMixerGain
2383
+ */
2384
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackGain(MIX_Track *track, float gain);
2385
+
2386
+ /**
2387
+ * Get a track's gain control.
2388
+ *
2389
+ * This returns the last value set through MIX_SetTrackGain(), or 1.0f if no
2390
+ * value has ever been explicitly set.
2391
+ *
2392
+ * \param track the track to query.
2393
+ * \returns the track's current gain.
2394
+ *
2395
+ * \threadsafety It is safe to call this function from any thread.
2396
+ *
2397
+ * \since This function is available since SDL_mixer 3.0.0.
2398
+ *
2399
+ * \sa MIX_SetTrackGain
2400
+ * \sa MIX_GetMixerGain
2401
+ */
2402
+ extern SDL_DECLSPEC float SDLCALL MIX_GetTrackGain(MIX_Track *track);
2403
+
2404
+ /**
2405
+ * Set the gain control of all tracks with a specific tag.
2406
+ *
2407
+ * Each track has its own gain, to adjust its overall volume. Each sample from
2408
+ * this track is modulated by this gain value. A gain of zero will generate
2409
+ * silence, 1.0f will not change the mixed volume, and larger than 1.0f will
2410
+ * increase the volume. Negative values are illegal. There is no maximum gain
2411
+ * specified, but this can quickly get extremely loud, so please be careful
2412
+ * with this setting.
2413
+ *
2414
+ * A track's gain defaults to 1.0f.
2415
+ *
2416
+ * This will change the gain control on tracks on the specified mixer that
2417
+ * have the specified tag.
2418
+ *
2419
+ * From the point of view of the mixing process, all tracks that successfully
2420
+ * change gain values will do so at the exact same moment.
2421
+ *
2422
+ * This value can be changed at any time to adjust the future mix.
2423
+ *
2424
+ * \param mixer the mixer on which to look for tagged tracks.
2425
+ * \param tag the tag to use when searching for tracks.
2426
+ * \param gain the new gain value.
2427
+ * \returns true on success or false on failure; call SDL_GetError() for more
2428
+ * information.
2429
+ *
2430
+ * \threadsafety It is safe to call this function from any thread.
2431
+ *
2432
+ * \since This function is available since SDL_mixer 3.0.0.
2433
+ *
2434
+ * \sa MIX_GetTrackGain
2435
+ * \sa MIX_SetTrackGain
2436
+ * \sa MIX_SetMixerGain
2437
+ * \sa MIX_TagTrack
2438
+ */
2439
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTagGain(MIX_Mixer *mixer, const char *tag, float gain);
2440
+
2441
+
2442
+ /* frequency ratio ... */
2443
+
2444
+ /**
2445
+ * Set a mixer's master frequency ratio.
2446
+ *
2447
+ * Each mixer has a master frequency ratio, that affects the entire mix. This
2448
+ * can cause the final output to change speed and pitch. A value greater than
2449
+ * 1.0f will play the audio faster, and at a higher pitch. A value less than
2450
+ * 1.0f will play the audio slower, and at a lower pitch. 1.0f is normal
2451
+ * speed.
2452
+ *
2453
+ * Each track _also_ has a frequency ratio; it will be applied when mixing
2454
+ * that track's audio regardless of the master setting. The master setting
2455
+ * affects the final output after all mixing has been completed.
2456
+ *
2457
+ * A mixer's master frequency ratio defaults to 1.0f.
2458
+ *
2459
+ * This value can be changed at any time to adjust the future mix.
2460
+ *
2461
+ * \param mixer the mixer to adjust.
2462
+ * \param ratio the frequency ratio. Must be between 0.01f and 100.0f.
2463
+ * \returns true on success or false on failure; call SDL_GetError() for more
2464
+ * information.
2465
+ *
2466
+ * \threadsafety It is safe to call this function from any thread.
2467
+ *
2468
+ * \since This function is available since SDL_mixer 3.0.0.
2469
+ *
2470
+ * \sa MIX_GetMixerFrequencyRatio
2471
+ * \sa MIX_SetTrackFrequencyRatio
2472
+ */
2473
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetMixerFrequencyRatio(MIX_Mixer *mixer, float ratio);
2474
+
2475
+ /**
2476
+ * Get a mixer's master frequency ratio.
2477
+ *
2478
+ * This returns the last value set through MIX_SetMixerFrequencyRatio(), or
2479
+ * 1.0f if no value has ever been explicitly set.
2480
+ *
2481
+ * \param mixer the mixer to query.
2482
+ * \returns the mixer's current master frequency ratio.
2483
+ *
2484
+ * \threadsafety It is safe to call this function from any thread.
2485
+ *
2486
+ * \since This function is available since SDL_mixer 3.0.0.
2487
+ *
2488
+ * \sa MIX_SetMixerFrequencyRatio
2489
+ * \sa MIX_GetTrackFrequencyRatio
2490
+ */
2491
+ extern SDL_DECLSPEC float SDLCALL MIX_GetMixerFrequencyRatio(MIX_Mixer *mixer);
2492
+
2493
+
2494
+ /**
2495
+ * Change the frequency ratio of a track.
2496
+ *
2497
+ * The frequency ratio is used to adjust the rate at which audio data is
2498
+ * consumed. Changing this effectively modifies the speed and pitch of the
2499
+ * track's audio. A value greater than 1.0f will play the audio faster, and at
2500
+ * a higher pitch. A value less than 1.0f will play the audio slower, and at a
2501
+ * lower pitch. 1.0f is normal speed.
2502
+ *
2503
+ * The default value is 1.0f.
2504
+ *
2505
+ * This value can be changed at any time to adjust the future mix.
2506
+ *
2507
+ * \param track the track on which to change the frequency ratio.
2508
+ * \param ratio the frequency ratio. Must be between 0.01f and 100.0f.
2509
+ * \returns true on success or false on failure; call SDL_GetError() for more
2510
+ * information.
2511
+ *
2512
+ * \threadsafety It is safe to call this function from any thread.
2513
+ *
2514
+ * \since This function is available since SDL_mixer 3.0.0.
2515
+ *
2516
+ * \sa MIX_GetTrackFrequencyRatio
2517
+ */
2518
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackFrequencyRatio(MIX_Track *track, float ratio);
2519
+
2520
+ /**
2521
+ * Query the frequency ratio of a track.
2522
+ *
2523
+ * The frequency ratio is used to adjust the rate at which audio data is
2524
+ * consumed. Changing this effectively modifies the speed and pitch of the
2525
+ * track's audio. A value greater than 1.0f will play the audio faster, and at
2526
+ * a higher pitch. A value less than 1.0f will play the audio slower, and at a
2527
+ * lower pitch. 1.0f is normal speed.
2528
+ *
2529
+ * The default value is 1.0f.
2530
+ *
2531
+ * On various errors (MIX_Init() was not called, the track is NULL), this
2532
+ * returns 0.0f. Since this is not a valid value to set, this can be seen as
2533
+ * an error state.
2534
+ *
2535
+ * \param track the track on which to query the frequency ratio.
2536
+ * \returns the current frequency ratio, or 0.0f on failure; call
2537
+ * SDL_GetError() for more information.
2538
+ *
2539
+ * \threadsafety It is safe to call this function from any thread.
2540
+ *
2541
+ * \since This function is available since SDL_mixer 3.0.0.
2542
+ *
2543
+ * \sa MIX_GetTrackFrequencyRatio
2544
+ */
2545
+ extern SDL_DECLSPEC float SDLCALL MIX_GetTrackFrequencyRatio(MIX_Track *track);
2546
+
2547
+
2548
+ /* channel maps... */
2549
+
2550
+ /**
2551
+ * Set the current output channel map of a track.
2552
+ *
2553
+ * Channel maps are optional; most things do not need them, instead passing
2554
+ * data in the order that SDL expects.
2555
+ *
2556
+ * The output channel map reorders track data after transformations and before
2557
+ * it is mixed into a mixer group. This can be useful for reversing stereo
2558
+ * channels, for example.
2559
+ *
2560
+ * Each item in the array represents an input channel, and its value is the
2561
+ * channel that it should be remapped to. To reverse a stereo signal's left
2562
+ * and right values, you'd have an array of `{ 1, 0 }`. It is legal to remap
2563
+ * multiple channels to the same thing, so `{ 1, 1 }` would duplicate the
2564
+ * right channel to both channels of a stereo signal. An element in the
2565
+ * channel map set to -1 instead of a valid channel will mute that channel,
2566
+ * setting it to a silence value.
2567
+ *
2568
+ * You cannot change the number of channels through a channel map, just
2569
+ * reorder/mute them.
2570
+ *
2571
+ * Tracks default to no remapping applied. Passing a NULL channel map is
2572
+ * legal, and turns off remapping.
2573
+ *
2574
+ * SDL_mixer will copy the channel map; the caller does not have to save this
2575
+ * array after this call.
2576
+ *
2577
+ * \param track the track to change.
2578
+ * \param chmap the new channel map, NULL to reset to default.
2579
+ * \param count The number of channels in the map.
2580
+ * \returns true on success or false on failure; call SDL_GetError() for more
2581
+ * information.
2582
+ *
2583
+ * \threadsafety It is safe to call this function from any thread.
2584
+ *
2585
+ * \since This function is available since SDL_mixer 3.0.0.
2586
+ */
2587
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackOutputChannelMap(MIX_Track *track, const int *chmap, int count);
2588
+
2589
+
2590
+ /* positional audio... */
2591
+
2592
+ /**
2593
+ * A set of per-channel gains for tracks using MIX_SetTrackStereo().
2594
+ *
2595
+ * When forcing a track to stereo, the app can specify a per-channel gain, to
2596
+ * further adjust the left or right outputs.
2597
+ *
2598
+ * When mixing audio that has been forced to stereo, each channel is modulated
2599
+ * by these values. A value of 1.0f produces no change, 0.0f produces silence.
2600
+ *
2601
+ * A simple panning effect would be to set `left` to the desired value and
2602
+ * `right` to `1.0f - left`.
2603
+ *
2604
+ * \since This struct is available since SDL_mixer 3.0.0.
2605
+ *
2606
+ * \sa MIX_SetTrackStereo
2607
+ */
2608
+ typedef struct MIX_StereoGains
2609
+ {
2610
+ float left; /**< left channel gain */
2611
+ float right; /**< right channel gain */
2612
+ } MIX_StereoGains;
2613
+
2614
+ /**
2615
+ * Force a track to stereo output, with optionally left/right panning.
2616
+ *
2617
+ * This will cause the output of the track to convert to stereo, and then mix
2618
+ * it only onto the Front Left and Front Right speakers, regardless of the
2619
+ * speaker configuration. The left and right channels are modulated by
2620
+ * `gains`, which can be used to produce panning effects. This function may be
2621
+ * called to adjust the gains at any time.
2622
+ *
2623
+ * If `gains` is not NULL, this track will be switched into forced-stereo
2624
+ * mode. If `gains` is NULL, this will disable spatialization (both the
2625
+ * forced-stereo mode of this function and full 3D spatialization of
2626
+ * MIX_SetTrack3DPosition()).
2627
+ *
2628
+ * Negative gains are clamped to zero; there is no clamp for maximum, so one
2629
+ * could set the value > 1.0f to make a channel louder.
2630
+ *
2631
+ * The track's 3D position, reported by MIX_GetTrack3DPosition(), will be
2632
+ * reset to (0, 0, 0).
2633
+ *
2634
+ * \param track the track to adjust.
2635
+ * \param gains the per-channel gains, or NULL to disable spatialization.
2636
+ * \returns true on success or false on failure; call SDL_GetError() for more
2637
+ * information.
2638
+ *
2639
+ * \threadsafety It is safe to call this function from any thread.
2640
+ *
2641
+ * \since This function is available since SDL_mixer 3.0.0.
2642
+ *
2643
+ * \sa MIX_SetTrack3DPosition
2644
+ */
2645
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackStereo(MIX_Track *track, const MIX_StereoGains *gains);
2646
+
2647
+
2648
+ /**
2649
+ * 3D coordinates for MIX_SetTrack3DPosition.
2650
+ *
2651
+ * The coordinates use a "right-handed" coordinate system, like OpenGL and
2652
+ * OpenAL.
2653
+ *
2654
+ * \since This struct is available since SDL_mixer 3.0.0.
2655
+ *
2656
+ * \sa MIX_SetTrack3DPosition
2657
+ */
2658
+ typedef struct MIX_Point3D
2659
+ {
2660
+ float x; /**< X coordinate (negative left, positive right). */
2661
+ float y; /**< Y coordinate (negative down, positive up). */
2662
+ float z; /**< Z coordinate (negative forward, positive back). */
2663
+ } MIX_Point3D;
2664
+
2665
+ /**
2666
+ * Set a track's position in 3D space.
2667
+ *
2668
+ * (Please note that SDL_mixer is not intended to be a extremely powerful 3D
2669
+ * API. It lacks 3D features that other APIs like OpenAL offer: there's no
2670
+ * doppler effect, distance models, rolloff, etc. This is meant to be Good
2671
+ * Enough for games that can use some positional sounds and can even take
2672
+ * advantage of surround-sound configurations.)
2673
+ *
2674
+ * If `position` is not NULL, this track will be switched into 3D positional
2675
+ * mode. If `position` is NULL, this will disable positional mixing (both the
2676
+ * full 3D spatialization of this function and forced-stereo mode of
2677
+ * MIX_SetTrackStereo()).
2678
+ *
2679
+ * In 3D positional mode, SDL_mixer will mix this track as if it were
2680
+ * positioned in 3D space, including distance attenuation (quieter as it gets
2681
+ * further from the listener) and spatialization (positioned on the correct
2682
+ * speakers to suggest direction, either with stereo outputs or full surround
2683
+ * sound).
2684
+ *
2685
+ * For a mono speaker output, spatialization is effectively disabled but
2686
+ * distance attenuation will still work, which is all you can really do with a
2687
+ * single speaker.
2688
+ *
2689
+ * The coordinate system operates like OpenGL or OpenAL: a "right-handed"
2690
+ * coordinate system. See MIX_Point3D for the details.
2691
+ *
2692
+ * The listener is always at coordinate (0,0,0) and can't be changed.
2693
+ *
2694
+ * The track's input will be converted to mono (1 channel) so it can be
2695
+ * rendered across the correct speakers.
2696
+ *
2697
+ * \param track the track for which to set 3D position.
2698
+ * \param position the new 3D position for the track. May be NULL.
2699
+ * \returns true on success or false on failure; call SDL_GetError() for more
2700
+ * information.
2701
+ *
2702
+ * \threadsafety It is safe to call this function from any thread.
2703
+ *
2704
+ * \since This function is available since SDL_mixer 3.0.0.
2705
+ *
2706
+ * \sa MIX_GetTrack3DPosition
2707
+ * \sa MIX_SetTrackStereo
2708
+ */
2709
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrack3DPosition(MIX_Track *track, const MIX_Point3D *position);
2710
+
2711
+ /**
2712
+ * Get a track's current position in 3D space.
2713
+ *
2714
+ * If 3D positioning isn't enabled for this track, through a call to
2715
+ * MIX_SetTrack3DPosition(), this will return (0,0,0).
2716
+ *
2717
+ * \param track the track to query.
2718
+ * \param position on successful return, will contain the track's position.
2719
+ * \returns true on success or false on failure; call SDL_GetError() for more
2720
+ * information.
2721
+ *
2722
+ * \threadsafety It is safe to call this function from any thread.
2723
+ *
2724
+ * \since This function is available since SDL_mixer 3.0.0.
2725
+ *
2726
+ * \sa MIX_SetTrack3DPosition
2727
+ */
2728
+ extern SDL_DECLSPEC bool SDLCALL MIX_GetTrack3DPosition(MIX_Track *track, MIX_Point3D *position);
2729
+
2730
+
2731
+ /* Mix groups... */
2732
+
2733
+ /**
2734
+ * Create a mixing group.
2735
+ *
2736
+ * Tracks are assigned to a mixing group (or if unassigned, they live in a
2737
+ * mixer's internal default group). All tracks in a group are mixed together
2738
+ * and the app can access this mixed data before it is mixed with all other
2739
+ * groups to produce the final output.
2740
+ *
2741
+ * This can be a useful feature, but is completely optional; apps can ignore
2742
+ * mixing groups entirely and still have a full experience with SDL_mixer.
2743
+ *
2744
+ * After creating a group, assign tracks to it with MIX_SetTrackGroup(). Use
2745
+ * MIX_SetGroupPostMixCallback() to access the group's mixed data.
2746
+ *
2747
+ * A mixing group can be destroyed with MIX_DestroyGroup() when no longer
2748
+ * needed. Destroying the mixer will also destroy all its still-existing
2749
+ * mixing groups.
2750
+ *
2751
+ * \param mixer the mixer on which to create a mixing group.
2752
+ * \returns a newly-created mixing group, or NULL on error; call
2753
+ * SDL_GetError() for more information.
2754
+ *
2755
+ * \threadsafety It is safe to call this function from any thread.
2756
+ *
2757
+ * \since This function is available since SDL_mixer 3.0.0.
2758
+ *
2759
+ * \sa MIX_DestroyGroup
2760
+ * \sa MIX_SetTrackGroup
2761
+ * \sa MIX_SetGroupPostMixCallback
2762
+ */
2763
+ extern SDL_DECLSPEC MIX_Group * SDLCALL MIX_CreateGroup(MIX_Mixer *mixer);
2764
+
2765
+ /**
2766
+ * Destroy a mixing group.
2767
+ *
2768
+ * Any tracks currently assigned to this group will be reassigned to the
2769
+ * mixer's internal default group.
2770
+ *
2771
+ * \param group the mixing group to destroy.
2772
+ *
2773
+ * \threadsafety It is safe to call this function from any thread.
2774
+ *
2775
+ * \since This function is available since SDL_mixer 3.0.0.
2776
+ *
2777
+ * \sa MIX_CreateGroup
2778
+ */
2779
+ extern SDL_DECLSPEC void SDLCALL MIX_DestroyGroup(MIX_Group *group);
2780
+
2781
+ /**
2782
+ * Get the properties associated with a group.
2783
+ *
2784
+ * Currently SDL_mixer assigns no properties of its own to a group, but this
2785
+ * can be a convenient place to store app-specific data.
2786
+ *
2787
+ * A SDL_PropertiesID is created the first time this function is called for a
2788
+ * given group.
2789
+ *
2790
+ * \param group the group to query.
2791
+ * \returns a valid property ID on success or 0 on failure; call
2792
+ * SDL_GetError() for more information.
2793
+ *
2794
+ * \threadsafety It is safe to call this function from any thread.
2795
+ *
2796
+ * \since This function is available since SDL_mixer 3.0.0.
2797
+ */
2798
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL MIX_GetGroupProperties(MIX_Group *group);
2799
+
2800
+ /**
2801
+ * Get the MIX_Mixer that owns a MIX_Group.
2802
+ *
2803
+ * This is the mixer pointer that was passed to MIX_CreateGroup().
2804
+ *
2805
+ * \param group the group to query.
2806
+ * \returns the mixer associated with the group, or NULL on error; call
2807
+ * SDL_GetError() for more information.
2808
+ *
2809
+ * \threadsafety It is safe to call this function from any thread.
2810
+ *
2811
+ * \since This function is available since SDL_mixer 3.0.0.
2812
+ */
2813
+ extern SDL_DECLSPEC MIX_Mixer * SDLCALL MIX_GetGroupMixer(MIX_Group *group);
2814
+
2815
+ /**
2816
+ * Assign a track to a mixing group.
2817
+ *
2818
+ * All tracks in a group are mixed together, and that output is made available
2819
+ * to the app before it is mixed into the final output.
2820
+ *
2821
+ * Tracks can only be in one group at a time, and the track and group must
2822
+ * have been created on the same MIX_Mixer.
2823
+ *
2824
+ * Setting a track to a NULL group will remove it from any app-created groups,
2825
+ * and reassign it to the mixer's internal default group.
2826
+ *
2827
+ * \param track the track to set mixing group assignment.
2828
+ * \param group the new mixing group to assign to. May be NULL.
2829
+ * \returns true on success or false on failure; call SDL_GetError() for more
2830
+ * information.
2831
+ *
2832
+ * \threadsafety It is safe to call this function from any thread.
2833
+ *
2834
+ * \since This function is available since SDL_mixer 3.0.0.
2835
+ *
2836
+ * \sa MIX_CreateGroup
2837
+ * \sa MIX_SetGroupPostMixCallback
2838
+ */
2839
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackGroup(MIX_Track *track, MIX_Group *group);
2840
+
2841
+
2842
+
2843
+ /* Hooks... */
2844
+
2845
+ /**
2846
+ * A callback that fires when a MIX_Track is stopped.
2847
+ *
2848
+ * This callback is fired when a track completes playback, either because it
2849
+ * ran out of data to mix (and all loops were completed as well), or it was
2850
+ * explicitly stopped by the app. Pausing a track will not fire this callback.
2851
+ *
2852
+ * It is legal to adjust the track, including changing its input and
2853
+ * restarting it. If this is done because it ran out of data in the middle of
2854
+ * mixing, the mixer will start mixing the new track state in its current run
2855
+ * without any gap in the audio.
2856
+ *
2857
+ * This callback will not fire when a playing track is destroyed.
2858
+ *
2859
+ * \param userdata an opaque pointer provided by the app for its personal use.
2860
+ * \param track the track that has stopped.
2861
+ *
2862
+ * \since This datatype is available since SDL_mixer 3.0.0.
2863
+ *
2864
+ * \sa MIX_SetTrackStoppedCallback
2865
+ */
2866
+ typedef void (SDLCALL *MIX_TrackStoppedCallback)(void *userdata, MIX_Track *track);
2867
+
2868
+ /**
2869
+ * Set a callback that fires when a MIX_Track is stopped.
2870
+ *
2871
+ * When a track completes playback, either because it ran out of data to mix
2872
+ * (and all loops were completed as well), or it was explicitly stopped by the
2873
+ * app, it will fire the callback specified here.
2874
+ *
2875
+ * Each track has its own unique callback.
2876
+ *
2877
+ * Passing a NULL callback here is legal; it disables this track's callback.
2878
+ *
2879
+ * Pausing a track will not fire the callback, nor will the callback fire on a
2880
+ * playing track that is being destroyed.
2881
+ *
2882
+ * It is legal to adjust the track, including changing its input and
2883
+ * restarting it. If this is done because it ran out of data in the middle of
2884
+ * mixing, the mixer will start mixing the new track state in its current run
2885
+ * without any gap in the audio.
2886
+ *
2887
+ * \param track the track to assign this callback to.
2888
+ * \param cb the function to call when the track stops. May be NULL.
2889
+ * \param userdata an opaque pointer provided to the callback for its own
2890
+ * personal use.
2891
+ * \returns true on success or false on failure; call SDL_GetError() for more
2892
+ * information.
2893
+ *
2894
+ * \since This function is available since SDL_mixer 3.0.0.
2895
+ *
2896
+ * \sa MIX_TrackStoppedCallback
2897
+ */
2898
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackStoppedCallback(MIX_Track *track, MIX_TrackStoppedCallback cb, void *userdata);
2899
+
2900
+ /**
2901
+ * A callback that fires when a MIX_Track is mixing at various stages.
2902
+ *
2903
+ * This callback is fired for different parts of the mixing pipeline, and
2904
+ * gives the app visbility into the audio data that is being generated at
2905
+ * various stages.
2906
+ *
2907
+ * The audio data passed through here is _not_ const data; the app is
2908
+ * permitted to change it in any way it likes, and those changes will
2909
+ * propagate through the mixing pipeline.
2910
+ *
2911
+ * An audiospec is provided. Different tracks might be in different formats,
2912
+ * and an app needs to be able to handle that, but SDL_mixer always does its
2913
+ * mixing work in 32-bit float samples, even if the inputs or final output are
2914
+ * not floating point. As such, `spec->format` will always be `SDL_AUDIO_F32`
2915
+ * and `pcm` hardcoded to be a float pointer.
2916
+ *
2917
+ * `samples` is the number of float values pointed to by `pcm`: samples, not
2918
+ * sample frames! There are no promises how many samples will be provided
2919
+ * per-callback, and this number can vary wildly from call to call, depending
2920
+ * on many factors.
2921
+ *
2922
+ * Making changes to the track during this callback is undefined behavior.
2923
+ * Change the data in `pcm` but not the track itself.
2924
+ *
2925
+ * \param userdata an opaque pointer provided by the app for its personal use.
2926
+ * \param track the track that is being mixed.
2927
+ * \param spec the format of the data in `pcm`.
2928
+ * \param pcm the raw PCM data in float32 format.
2929
+ * \param samples the number of float values pointed to by `pcm`.
2930
+ *
2931
+ * \since This datatype is available since SDL_mixer 3.0.0.
2932
+ *
2933
+ * \sa MIX_SetTrackRawCallback
2934
+ * \sa MIX_SetTrackCookedCallback
2935
+ */
2936
+ typedef void (SDLCALL *MIX_TrackMixCallback)(void *userdata, MIX_Track *track, const SDL_AudioSpec *spec, float *pcm, int samples);
2937
+
2938
+ /**
2939
+ * Set a callback that fires when a MIX_Track has initial decoded audio.
2940
+ *
2941
+ * As a track needs to mix more data, it pulls from its input (a MIX_Audio, an
2942
+ * SDL_AudioStream, etc). This input might be a compressed file format, like
2943
+ * MP3, so a little more data is uncompressed from it.
2944
+ *
2945
+ * Once the track has PCM data to start operating on, it can fire a callback
2946
+ * before _any_ changes to the raw PCM input have happened. This lets an app
2947
+ * view the data before it has gone through transformations such as gain, 3D
2948
+ * positioning, fading, etc. It can also change the data in any way it pleases
2949
+ * during this callback, and the mixer will continue as if this data came
2950
+ * directly from the input.
2951
+ *
2952
+ * Each track has its own unique raw callback.
2953
+ *
2954
+ * Passing a NULL callback here is legal; it disables this track's callback.
2955
+ *
2956
+ * \param track the track to assign this callback to.
2957
+ * \param cb the function to call when the track mixes. May be NULL.
2958
+ * \param userdata an opaque pointer provided to the callback for its own
2959
+ * personal use.
2960
+ * \returns true on success or false on failure; call SDL_GetError() for more
2961
+ * information.
2962
+ *
2963
+ * \since This function is available since SDL_mixer 3.0.0.
2964
+ *
2965
+ * \sa MIX_TrackMixCallback
2966
+ * \sa MIX_SetTrackCookedCallback
2967
+ */
2968
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackRawCallback(MIX_Track *track, MIX_TrackMixCallback cb, void *userdata);
2969
+
2970
+ /**
2971
+ * Set a callback that fires when the mixer has transformed a track's audio.
2972
+ *
2973
+ * As a track needs to mix more data, it pulls from its input (a MIX_Audio, an
2974
+ * SDL_AudioStream, etc). This input might be a compressed file format, like
2975
+ * MP3, so a little more data is uncompressed from it.
2976
+ *
2977
+ * Once the track has PCM data to start operating on, and its raw callback has
2978
+ * completed, it will begin to transform the audio: gain, fading, frequency
2979
+ * ratio, 3D positioning, etc.
2980
+ *
2981
+ * A callback can be fired after all these transformations, but before the
2982
+ * transformed data is mixed into other tracks. This lets an app view the data
2983
+ * at the last moment that it is still a part of this track. It can also
2984
+ * change the data in any way it pleases during this callback, and the mixer
2985
+ * will continue as if this data came directly from the input.
2986
+ *
2987
+ * Each track has its own unique cooked callback.
2988
+ *
2989
+ * Passing a NULL callback here is legal; it disables this track's callback.
2990
+ *
2991
+ * \param track the track to assign this callback to.
2992
+ * \param cb the function to call when the track mixes. May be NULL.
2993
+ * \param userdata an opaque pointer provided to the callback for its own
2994
+ * personal use.
2995
+ * \returns true on success or false on failure; call SDL_GetError() for more
2996
+ * information.
2997
+ *
2998
+ * \since This function is available since SDL_mixer 3.0.0.
2999
+ *
3000
+ * \sa MIX_TrackMixCallback
3001
+ * \sa MIX_SetTrackRawCallback
3002
+ */
3003
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackCookedCallback(MIX_Track *track, MIX_TrackMixCallback cb, void *userdata);
3004
+
3005
+ /**
3006
+ * A callback that fires when a MIX_Group has completed mixing.
3007
+ *
3008
+ * This callback is fired when a mixing group has finished mixing: all tracks
3009
+ * in the group have mixed into a single buffer and are prepared to be mixed
3010
+ * into all other groups for the final mix output.
3011
+ *
3012
+ * The audio data passed through here is _not_ const data; the app is
3013
+ * permitted to change it in any way it likes, and those changes will
3014
+ * propagate through the mixing pipeline.
3015
+ *
3016
+ * An audiospec is provided. Different groups might be in different formats,
3017
+ * and an app needs to be able to handle that, but SDL_mixer always does its
3018
+ * mixing work in 32-bit float samples, even if the inputs or final output are
3019
+ * not floating point. As such, `spec->format` will always be `SDL_AUDIO_F32`
3020
+ * and `pcm` hardcoded to be a float pointer.
3021
+ *
3022
+ * `samples` is the number of float values pointed to by `pcm`: samples, not
3023
+ * sample frames! There are no promises how many samples will be provided
3024
+ * per-callback, and this number can vary wildly from call to call, depending
3025
+ * on many factors.
3026
+ *
3027
+ * \param userdata an opaque pointer provided by the app for its personal use.
3028
+ * \param group the group that is being mixed.
3029
+ * \param spec the format of the data in `pcm`.
3030
+ * \param pcm the raw PCM data in float32 format.
3031
+ * \param samples the number of float values pointed to by `pcm`.
3032
+ *
3033
+ * \since This datatype is available since SDL_mixer 3.0.0.
3034
+ *
3035
+ * \sa MIX_SetGroupPostMixCallback
3036
+ */
3037
+ typedef void (SDLCALL *MIX_GroupMixCallback)(void *userdata, MIX_Group *group, const SDL_AudioSpec *spec, float *pcm, int samples);
3038
+
3039
+ /**
3040
+ * Set a callback that fires when a mixer group has completed mixing.
3041
+ *
3042
+ * After all playing tracks in a mixer group have pulled in more data from
3043
+ * their inputs, transformed it, and mixed together into a single buffer, a
3044
+ * callback can be fired. This lets an app view the data at the last moment
3045
+ * that it is still a part of this group. It can also change the data in any
3046
+ * way it pleases during this callback, and the mixer will continue as if this
3047
+ * data came directly from the group's mix buffer.
3048
+ *
3049
+ * Each group has its own unique callback. Tracks that aren't in an explicit
3050
+ * MIX_Group are mixed in an internal grouping that is not available to the
3051
+ * app.
3052
+ *
3053
+ * Passing a NULL callback here is legal; it disables this group's callback.
3054
+ *
3055
+ * \param group the mixing group to assign this callback to.
3056
+ * \param cb the function to call when the group mixes. May be NULL.
3057
+ * \param userdata an opaque pointer provided to the callback for its own
3058
+ * personal use.
3059
+ * \returns true on success or false on failure; call SDL_GetError() for more
3060
+ * information.
3061
+ *
3062
+ * \since This function is available since SDL_mixer 3.0.0.
3063
+ *
3064
+ * \sa MIX_GroupMixCallback
3065
+ */
3066
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetGroupPostMixCallback(MIX_Group *group, MIX_GroupMixCallback cb, void *userdata);
3067
+
3068
+ /**
3069
+ * A callback that fires when all mixing has completed.
3070
+ *
3071
+ * This callback is fired when the mixer has completed all its work. If this
3072
+ * mixer was created with MIX_CreateMixerDevice(), the data provided by this
3073
+ * callback is what is being sent to the audio hardware, minus last
3074
+ * conversions for format requirements. If this mixer was created with
3075
+ * MIX_CreateMixer(), this is what is being output from MIX_Generate(), after
3076
+ * final conversions.
3077
+ *
3078
+ * The audio data passed through here is _not_ const data; the app is
3079
+ * permitted to change it in any way it likes, and those changes will replace
3080
+ * the final mixer pipeline output.
3081
+ *
3082
+ * An audiospec is provided. SDL_mixer always does its mixing work in 32-bit
3083
+ * float samples, even if the inputs or final output are not floating point.
3084
+ * As such, `spec->format` will always be `SDL_AUDIO_F32` and `pcm` hardcoded
3085
+ * to be a float pointer.
3086
+ *
3087
+ * `samples` is the number of float values pointed to by `pcm`: samples, not
3088
+ * sample frames! There are no promises how many samples will be provided
3089
+ * per-callback, and this number can vary wildly from call to call, depending
3090
+ * on many factors.
3091
+ *
3092
+ * \param userdata an opaque pointer provided by the app for its personal use.
3093
+ * \param mixer the mixer that is generating audio.
3094
+ * \param spec the format of the data in `pcm`.
3095
+ * \param pcm the raw PCM data in float32 format.
3096
+ * \param samples the number of float values pointed to by `pcm`.
3097
+ *
3098
+ * \since This datatype is available since SDL_mixer 3.0.0.
3099
+ *
3100
+ * \sa MIX_SetPostMixCallback
3101
+ */
3102
+ typedef void (SDLCALL *MIX_PostMixCallback)(void *userdata, MIX_Mixer *mixer, const SDL_AudioSpec *spec, float *pcm, int samples);
3103
+
3104
+ /**
3105
+ * Set a callback that fires when all mixing has completed.
3106
+ *
3107
+ * After all mixer groups have processed, their buffers are mixed together
3108
+ * into a single buffer for the final output, at which point a callback can be
3109
+ * fired. This lets an app view the data at the last moment before mixing
3110
+ * completes. It can also change the data in any way it pleases during this
3111
+ * callback, and the mixer will continue as if this data is the final output.
3112
+ *
3113
+ * Each mixer has its own unique callback.
3114
+ *
3115
+ * Passing a NULL callback here is legal; it disables this mixer's callback.
3116
+ *
3117
+ * \param mixer the mixer to assign this callback to.
3118
+ * \param cb the function to call when the mixer mixes. May be NULL.
3119
+ * \param userdata an opaque pointer provided to the callback for its own
3120
+ * personal use.
3121
+ * \returns true on success or false on failure; call SDL_GetError() for more
3122
+ * information.
3123
+ *
3124
+ * \since This function is available since SDL_mixer 3.0.0.
3125
+ *
3126
+ * \sa MIX_PostMixCallback
3127
+ */
3128
+ extern SDL_DECLSPEC bool SDLCALL MIX_SetPostMixCallback(MIX_Mixer *mixer, MIX_PostMixCallback cb, void *userdata);
3129
+
3130
+
3131
+ /* Audio generation without an audio device... */
3132
+
3133
+ /**
3134
+ * Generate mixer output when not driving an audio device.
3135
+ *
3136
+ * SDL_mixer allows the creation of MIX_Mixer objects that are not connected
3137
+ * to an audio device, by calling MIX_CreateMixer() instead of
3138
+ * MIX_CreateMixerDevice(). Such mixers will not generate output until
3139
+ * explicitly requested through this function.
3140
+ *
3141
+ * The caller may request as much audio as desired, so long as `buflen` is a
3142
+ * multiple of the sample frame size specified when creating the mixer (for
3143
+ * example, if requesting stereo Sint16 audio, buflen must be a multiple of 4:
3144
+ * 2 bytes-per-channel times 2 channels).
3145
+ *
3146
+ * The mixer will mix as quickly as possible; since it works in sample frames
3147
+ * instead of time, it can potentially generate enormous amounts of audio in a
3148
+ * small amount of time.
3149
+ *
3150
+ * On success, this always fills `buffer` with `buflen` bytes of audio; if all
3151
+ * playing tracks finish mixing, it will fill the remaining buffer with
3152
+ * silence.
3153
+ *
3154
+ * Each call to this function will pick up where it left off, playing tracks
3155
+ * will continue to mix from the point the previous call completed, etc. The
3156
+ * mixer state can be changed between each call in any way desired: tracks can
3157
+ * be added, played, stopped, changed, removed, etc. Effectively this function
3158
+ * does the same thing SDL_mixer does internally when the audio device needs
3159
+ * more audio to play.
3160
+ *
3161
+ * This function can not be used with mixers from MIX_CreateMixerDevice();
3162
+ * those generate audio as needed internally.
3163
+ *
3164
+ * This function returns the number of _bytes_ of real audio mixed, which
3165
+ * might be less than `buflen`. While all `buflen` bytes of `buffer` will be
3166
+ * initialized, if available tracks to mix run out, the end of the buffer will
3167
+ * be initialized with silence; this silence will not be counted in the return
3168
+ * value, so the caller has the option to identify how much of the buffer has
3169
+ * legimitate contents vs appended silence. As such, any value >= 0 signifies
3170
+ * success. A return value of -1 means failure (out of memory, invalid
3171
+ * parameters, etc).
3172
+ *
3173
+ * \param mixer the mixer for which to generate more audio.
3174
+ * \param buffer a pointer to a buffer to store audio in.
3175
+ * \param buflen the number of bytes to store in buffer.
3176
+ * \returns The number of bytes of mixed audio, discounting appended silence,
3177
+ * on success, or -1 on failure; call SDL_GetError() for more
3178
+ * information.
3179
+ *
3180
+ * \threadsafety It is safe to call this function from any thread.
3181
+ *
3182
+ * \since This function is available since SDL_mixer 3.0.0.
3183
+ *
3184
+ * \sa MIX_CreateMixer
3185
+ */
3186
+ extern SDL_DECLSPEC int SDLCALL MIX_Generate(MIX_Mixer *mixer, void *buffer, int buflen);
3187
+
3188
+
3189
+ /* Decode audio files directly without a mixer ... */
3190
+
3191
+ /**
3192
+ * An opaque object that represents an audio decoder.
3193
+ *
3194
+ * Most apps won't need this, as SDL_mixer's usual interfaces will decode
3195
+ * audio as needed. However, if one wants to decode an audio file into a
3196
+ * memory buffer without playing it, this interface offers that.
3197
+ *
3198
+ * These objects are created with MIX_CreateAudioDecoder() or
3199
+ * MIX_CreateAudioDecoder_IO(), and then can use MIX_DecodeAudio() to retrieve
3200
+ * the raw PCM data.
3201
+ *
3202
+ * \since This struct is available since SDL_mixer 3.0.0.
3203
+ */
3204
+ typedef struct MIX_AudioDecoder MIX_AudioDecoder;
3205
+
3206
+ /**
3207
+ * Create a MIX_AudioDecoder from a path on the filesystem.
3208
+ *
3209
+ * Most apps won't need this, as SDL_mixer's usual interfaces will decode
3210
+ * audio as needed. However, if one wants to decode an audio file into a
3211
+ * memory buffer without playing it, this interface offers that.
3212
+ *
3213
+ * This function allows properties to be specified. This is intended to supply
3214
+ * file-specific settings, such as where to find SoundFonts for a MIDI file,
3215
+ * etc. In most cases, the caller should pass a zero to specify no extra
3216
+ * properties.
3217
+ *
3218
+ * SDL_PropertiesID are discussed in
3219
+ * [SDL's documentation](https://wiki.libsdl.org/SDL3/CategoryProperties)
3220
+ * .
3221
+ *
3222
+ * When done with the audio decoder, it can be destroyed with
3223
+ * MIX_DestroyAudioDecoder().
3224
+ *
3225
+ * This function requires SDL_mixer to have been initialized with a successful
3226
+ * call to MIX_Init(), but does not need an actual MIX_Mixer to have been
3227
+ * created.
3228
+ *
3229
+ * \param path the path on the filesystem from which to load data.
3230
+ * \param props decoder-specific properties. May be zero.
3231
+ * \returns an audio decoder, ready to decode.
3232
+ *
3233
+ * \threadsafety It is safe to call this function from any thread.
3234
+ *
3235
+ * \since This function is available since SDL_mixer 3.0.0.
3236
+ *
3237
+ * \sa MIX_CreateAudioDecoder_IO
3238
+ * \sa MIX_DecodeAudio
3239
+ * \sa MIX_DestroyAudioDecoder
3240
+ */
3241
+ extern SDL_DECLSPEC MIX_AudioDecoder * SDLCALL MIX_CreateAudioDecoder(const char *path, SDL_PropertiesID props);
3242
+
3243
+ /**
3244
+ * Create a MIX_AudioDecoder from an SDL_IOStream.
3245
+ *
3246
+ * Most apps won't need this, as SDL_mixer's usual interfaces will decode
3247
+ * audio as needed. However, if one wants to decode an audio file into a
3248
+ * memory buffer without playing it, this interface offers that.
3249
+ *
3250
+ * This function allows properties to be specified. This is intended to supply
3251
+ * file-specific settings, such as where to find SoundFonts for a MIDI file,
3252
+ * etc. Most of the properties available to MIX_LoadAudioWithProperties()
3253
+ * apply here, too. In most cases, the caller should pass a zero to specify no
3254
+ * extra properties.
3255
+ *
3256
+ * If `closeio` is true, then `io` will be closed when this decoder is done
3257
+ * with it. If this function fails and `closeio` is true, then `io` will be
3258
+ * closed before this function returns.
3259
+ *
3260
+ * When done with the audio decoder, it can be destroyed with
3261
+ * MIX_DestroyAudioDecoder().
3262
+ *
3263
+ * This function requires SDL_mixer to have been initialized with a successful
3264
+ * call to MIX_Init(), but does not need an actual MIX_Mixer to have been
3265
+ * created.
3266
+ *
3267
+ * \param io the i/o stream from which to load data.
3268
+ * \param closeio if true, close the i/o stream when done with it.
3269
+ * \param props decoder-specific properties. May be zero.
3270
+ * \returns an audio decoder, ready to decode.
3271
+ *
3272
+ * \threadsafety It is safe to call this function from any thread.
3273
+ *
3274
+ * \since This function is available since SDL_mixer 3.0.0.
3275
+ *
3276
+ * \sa MIX_CreateAudioDecoder_IO
3277
+ * \sa MIX_DecodeAudio
3278
+ * \sa MIX_DestroyAudioDecoder
3279
+ */
3280
+ extern SDL_DECLSPEC MIX_AudioDecoder * SDLCALL MIX_CreateAudioDecoder_IO(SDL_IOStream *io, bool closeio, SDL_PropertiesID props);
3281
+
3282
+ /**
3283
+ * Destroy the specified audio decoder.
3284
+ *
3285
+ * Destroying a NULL MIX_AudioDecoder is a legal no-op.
3286
+ *
3287
+ * \param audiodecoder the audio to destroy.
3288
+ *
3289
+ * \threadsafety It is safe to call this function from any thread.
3290
+ *
3291
+ * \since This function is available since SDL_mixer 3.0.0.
3292
+ */
3293
+ extern SDL_DECLSPEC void SDLCALL MIX_DestroyAudioDecoder(MIX_AudioDecoder *audiodecoder);
3294
+
3295
+ /**
3296
+ * Get the properties associated with a MIX_AudioDecoder.
3297
+ *
3298
+ * SDL_mixer offers some properties of its own, but this can also be a
3299
+ * convenient place to store app-specific data.
3300
+ *
3301
+ * A SDL_PropertiesID is created the first time this function is called for a
3302
+ * given MIX_AudioDecoder, if necessary.
3303
+ *
3304
+ * The file-specific metadata exposed through this function is identical to
3305
+ * those available through MIX_GetAudioProperties(). Please refer to that
3306
+ * function's documentation for details.
3307
+ *
3308
+ * \param audiodecoder the audio decoder to query.
3309
+ * \returns a valid property ID on success or 0 on failure; call
3310
+ * SDL_GetError() for more information.
3311
+ *
3312
+ * \threadsafety It is safe to call this function from any thread.
3313
+ *
3314
+ * \since This function is available since SDL_mixer 3.0.0.
3315
+ *
3316
+ * \sa MIX_GetAudioProperties
3317
+ */
3318
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL MIX_GetAudioDecoderProperties(MIX_AudioDecoder *audiodecoder);
3319
+
3320
+ /**
3321
+ * Query the initial audio format of a MIX_AudioDecoder.
3322
+ *
3323
+ * Note that some audio files can change format in the middle; some explicitly
3324
+ * support this, but a more common example is two MP3 files concatenated
3325
+ * together. In many cases, SDL_mixer will correctly handle these sort of
3326
+ * files, but this function will only report the initial format a file uses.
3327
+ *
3328
+ * \param audiodecoder the audio decoder to query.
3329
+ * \param spec on success, audio format details will be stored here.
3330
+ * \returns true on success or false on failure; call SDL_GetError() for more
3331
+ * information.
3332
+ *
3333
+ * \threadsafety It is safe to call this function from any thread.
3334
+ *
3335
+ * \since This function is available since SDL_mixer 3.0.0.
3336
+ */
3337
+ extern SDL_DECLSPEC bool SDLCALL MIX_GetAudioDecoderFormat(MIX_AudioDecoder *audiodecoder, SDL_AudioSpec *spec);
3338
+
3339
+ /**
3340
+ * Decode more audio from a MIX_AudioDecoder.
3341
+ *
3342
+ * Data is decoded on demand in whatever format is requested. The format is
3343
+ * permitted to change between calls.
3344
+ *
3345
+ * This function will return the number of bytes decoded, which may be less
3346
+ * than requested if there was an error or end-of-file. A return value of zero
3347
+ * means the entire file was decoded, -1 means an unrecoverable error
3348
+ * happened.
3349
+ *
3350
+ * \param audiodecoder the decoder from which to retrieve more data.
3351
+ * \param buffer the memory buffer to store decoded audio.
3352
+ * \param buflen the maximum number of bytes to store to `buffer`.
3353
+ * \param spec the format that audio data will be stored to `buffer`.
3354
+ * \returns number of bytes decoded, or -1 on error; call SDL_GetError() for
3355
+ * more information.
3356
+ *
3357
+ * \threadsafety It is safe to call this function from any thread.
3358
+ *
3359
+ * \since This function is available since SDL_mixer 3.0.0.
3360
+ */
3361
+ extern SDL_DECLSPEC int SDLCALL MIX_DecodeAudio(MIX_AudioDecoder *audiodecoder, void *buffer, int buflen, const SDL_AudioSpec *spec);
3362
+
3363
+ /* Ends C function definitions when using C++ */
3364
+ #ifdef __cplusplus
3365
+ }
3366
+ #endif
3367
+ #include <SDL3/SDL_close_code.h>
3368
+
3369
+ #endif /* SDL_MIXER_H_ */