1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831
|
/*
SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_mixer.h
*
* Header file for SDL_mixer library
*
* A simple library to play and mix sounds and musics
*/
#ifndef SDL_MIXER_H_
#define SDL_MIXER_H_
#include "SDL_stdinc.h"
#include "SDL_rwops.h"
#include "SDL_audio.h"
#include "SDL_endian.h"
#include "SDL_version.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_MIXER_MAJOR_VERSION 2
#define SDL_MIXER_MINOR_VERSION 8
#define SDL_MIXER_PATCHLEVEL 1
/**
* This macro can be used to fill a version structure with the compile-time
* version of the SDL_mixer library.
*/
#define SDL_MIXER_VERSION(X) \
{ \
(X)->major = SDL_MIXER_MAJOR_VERSION; \
(X)->minor = SDL_MIXER_MINOR_VERSION; \
(X)->patch = SDL_MIXER_PATCHLEVEL; \
}
/* Backwards compatibility */
#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION
#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION
#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL
#define MIX_VERSION(X) SDL_MIXER_VERSION(X)
#if SDL_MIXER_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3
/**
* This is the version number macro for the current SDL_mixer version.
*
* In versions higher than 2.9.0, the minor version overflows into the
* thousands digit: for example, 2.23.0 is encoded as 4300. This macro will
* not be available in SDL 3.x or SDL_mixer 3.x.
*
* Deprecated, use SDL_MIXER_VERSION_ATLEAST or SDL_MIXER_VERSION instead.
*/
#define SDL_MIXER_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
#endif /* SDL_MIXER_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3 */
/**
* This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
*/
#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
((SDL_MIXER_MAJOR_VERSION >= X) && \
(SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION >= Y) && \
(SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION > Y || SDL_MIXER_PATCHLEVEL >= Z))
/**
* Query the version of SDL_mixer that the program is linked against.
*
* This function gets the version of the dynamically linked SDL_mixer library.
* This is separate from the SDL_MIXER_VERSION() macro, which tells you what
* version of the SDL_mixer headers you compiled against.
*
* This returns static internal data; do not free or modify it!
*
* \returns a pointer to the version information.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
/**
* Initialization flags
*/
typedef enum MIX_InitFlags
{
MIX_INIT_FLAC = 0x00000001,
MIX_INIT_MOD = 0x00000002,
MIX_INIT_MP3 = 0x00000008,
MIX_INIT_OGG = 0x00000010,
MIX_INIT_MID = 0x00000020,
MIX_INIT_OPUS = 0x00000040,
MIX_INIT_WAVPACK= 0x00000080
} MIX_InitFlags;
/**
* Initialize SDL_mixer.
*
* This function loads dynamic libraries that SDL_mixer needs, and prepares
* them for use.
*
* Note that, unlike other SDL libraries, this call is optional! If you load a
* music file, SDL_mixer will handle initialization on the fly. This function
* will let you know, up front, whether a specific format will be available
* for use.
*
* Flags should be one or more flags from MIX_InitFlags OR'd together. It
* returns the flags successfully initialized, or 0 on failure.
*
* Currently, these flags are:
*
* - `MIX_INIT_FLAC`
* - `MIX_INIT_MOD`
* - `MIX_INIT_MP3`
* - `MIX_INIT_OGG`
* - `MIX_INIT_MID`
* - `MIX_INIT_OPUS`
* - `MIX_INIT_WAVPACK`
*
* More flags may be added in a future SDL_mixer release.
*
* This function may need to load external shared libraries to support various
* codecs, which means this function can fail to initialize that support on an
* otherwise-reasonable system if the library isn't available; this is not
* just a question of exceptional circumstances like running out of memory at
* startup!
*
* Note that you may call this function more than once to initialize with
* additional flags. The return value will reflect both new flags that
* successfully initialized, and also include flags that had previously been
* initialized as well.
*
* As this will return previously-initialized flags, it's legal to call this
* with zero (no flags set). This is a safe no-op that can be used to query
* the current initialization state without changing it at all.
*
* Since this returns previously-initialized flags as well as new ones, and
* you can call this with zero, you should not check for a zero return value
* to determine an error condition. Instead, you should check to make sure all
* the flags you require are set in the return value. If you have a game with
* data in a specific format, this might be a fatal error. If you're a generic
* media player, perhaps you are fine with only having WAV and MP3 support and
* can live without Opus playback, even if you request support for everything.
*
* Unlike other SDL satellite libraries, calls to Mix_Init do not stack; a
* single call to Mix_Quit() will deinitialize everything and does not have to
* be paired with a matching Mix_Init call. For that reason, it's considered
* best practices to have a single Mix_Init and Mix_Quit call in your program.
* While this isn't required, be aware of the risks of deviating from that
* behavior.
*
* After initializing SDL_mixer, the next step is to open an audio device to
* prepare to play sound (with Mix_OpenAudio() or Mix_OpenAudioDevice()), and
* load audio data to play with that device.
*
* \param flags initialization flags, OR'd together.
* \returns all currently initialized flags.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_Quit
*/
extern DECLSPEC int SDLCALL Mix_Init(int flags);
/**
* Deinitialize SDL_mixer.
*
* This should be the last function you call in SDL_mixer, after freeing all
* other resources and closing all audio devices. This will unload any shared
* libraries it is using for various codecs.
*
* After this call, a call to Mix_Init(0) will return 0 (no codecs loaded).
*
* You can safely call Mix_Init() to reload various codec support after this
* call.
*
* Unlike other SDL satellite libraries, calls to Mix_Init do not stack; a
* single call to Mix_Quit() will deinitialize everything and does not have to
* be paired with a matching Mix_Init call. For that reason, it's considered
* best practices to have a single Mix_Init and Mix_Quit call in your program.
* While this isn't required, be aware of the risks of deviating from that
* behavior.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_Init
*/
extern DECLSPEC void SDLCALL Mix_Quit(void);
/**
* The default mixer has 8 simultaneous mixing channels
*/
#ifndef MIX_CHANNELS
#define MIX_CHANNELS 8
#endif
/* Good default values for a PC soundcard */
#define MIX_DEFAULT_FREQUENCY 44100
#define MIX_DEFAULT_FORMAT AUDIO_S16SYS
#define MIX_DEFAULT_CHANNELS 2
#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */
/**
* The internal format for an audio chunk
*/
typedef struct Mix_Chunk {
int allocated;
Uint8 *abuf;
Uint32 alen;
Uint8 volume; /* Per-sample volume, 0-128 */
} Mix_Chunk;
/**
* The different fading types supported
*/
typedef enum Mix_Fading {
MIX_NO_FADING,
MIX_FADING_OUT,
MIX_FADING_IN
} Mix_Fading;
/**
* These are types of music files (not libraries used to load them)
*/
typedef enum Mix_MusicType {
MUS_NONE,
MUS_CMD,
MUS_WAV,
MUS_MOD,
MUS_MID,
MUS_OGG,
MUS_MP3,
MUS_MP3_MAD_UNUSED,
MUS_FLAC,
MUS_MODPLUG_UNUSED,
MUS_OPUS,
MUS_WAVPACK,
MUS_GME
} Mix_MusicType;
/**
* The internal format for a music chunk interpreted via codecs
*/
typedef struct Mix_Music Mix_Music;
/**
* Open the default audio device for playback.
*
* An audio device is what generates sound, so the app must open one to make
* noise.
*
* This function will check if SDL's audio system is initialized, and if not,
* it will initialize it by calling `SDL_Init(SDL_INIT_AUDIO)` on your behalf.
* You are free to (and encouraged to!) initialize it yourself before calling
* this function, as this gives your program more control over the process.
*
* This function might cover all of an application's needs, but for those that
* need more flexibility, the more powerful version of this function is
* Mix_OpenAudioDevice(). This function is equivalent to calling:
*
* ```c
* Mix_OpenAudioDevice(frequency, format, nchannels, chunksize, NULL,
* SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
* SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
* ```
*
* If you aren't particularly concerned with the specifics of the audio
* device, and your data isn't in a specific format, the values you use here
* can just be reasonable defaults. SDL_mixer will convert audio data you feed
* it to the correct format on demand.
*
* That being said, if you have control of your audio data and you know its
* format ahead of time, you may save CPU time by opening the audio device in
* that exact format so SDL_mixer does not have to spend time converting
* anything behind the scenes, and can just pass the data straight through to
* the hardware. On some platforms, where the hardware only supports specific
* settings, you might have to be careful to make everything match, but your
* own data is often easier to control, so aim to open the device for what you
* need.
*
* The other reason to care about specific formats: if you plan to touch the
* mix buffer directly (with Mix_SetPostMix, a registered effect, or
* Mix_HookMusic), you might have code that expects it to be in a specific
* format, and you should specify that here.
*
* The audio device frequency is specified in Hz; in modern times, 48000 is
* often a reasonable default.
*
* The audio device format is one of SDL's AUDIO_* constants. AUDIO_S16SYS
* (16-bit audio) is probably a safe default. More modern systems may prefer
* AUDIO_F32SYS (32-bit floating point audio).
*
* The audio device channels are generally 1 for mono output, or 2 for stereo,
* but the brave can try surround sound configs with 4 (quad), 6 (5.1), 7
* (6.1) or 8 (7.1).
*
* The audio device's chunk size is the number of sample frames (one sample
* per frame for mono output, two samples per frame in a stereo setup, etc)
* that are fed to the device at once. The lower the number, the lower the
* latency, but you risk dropouts if it gets too low. 2048 is often a
* reasonable default, but your app might want to experiment with 1024 or
* 4096.
*
* You may only have one audio device open at a time; if you want to change a
* setting, you must close the device and reopen it, which is not something
* you can do seamlessly during playback.
*
* This function does not allow you to select a specific audio device on the
* system, it always chooses the best default it can on your behalf (which, in
* many cases, is exactly what you want anyhow). If you must choose a specific
* device, you can do so with Mix_OpenAudioDevice() instead.
*
* If this function reports success, you are ready to start making noise! Load
* some audio data and start playing!
*
* The app can use Mix_QuerySpec() to determine the final device settings.
*
* When done with an audio device, probably at the end of the program, the app
* should dispose of the device with Mix_CloseAudio().
*
* \param frequency the frequency to playback audio at (in Hz).
* \param format audio format, one of SDL's AUDIO_* values.
* \param channels number of channels (1 is mono, 2 is stereo, etc).
* \param chunksize audio buffer size in sample FRAMES (total samples divided
* by channel count).
* \returns 0 if successful, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_OpenAudioDevice
* \sa Mix_CloseAudio
*/
extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
/**
* Open a specific audio device for playback.
*
* (A slightly simpler version of this function is available in
* Mix_OpenAudio(), which still might meet most applications' needs.)
*
* An audio device is what generates sound, so the app must open one to make
* noise.
*
* This function will check if SDL's audio system is initialized, and if not,
* it will initialize it by calling `SDL_Init(SDL_INIT_AUDIO)` on your behalf.
* You are free to (and encouraged to!) initialize it yourself before calling
* this function, as this gives your program more control over the process.
*
* If you aren't particularly concerned with the specifics of the audio
* device, and your data isn't in a specific format, the values you use here
* can just be reasonable defaults. SDL_mixer will convert audio data you feed
* it to the correct format on demand.
*
* That being said, if you have control of your audio data and you know its
* format ahead of time, you can save CPU time by opening the audio device in
* that exact format so SDL_mixer does not have to spend time converting
* anything behind the scenes, and can just pass the data straight through to
* the hardware. On some platforms, where the hardware only supports specific
* settings, you might have to be careful to make everything match, but your
* own data is often easier to control, so aim to open the device for what you
* need.
*
* The other reason to care about specific formats: if you plan to touch the
* mix buffer directly (with Mix_SetPostMix, a registered effect, or
* Mix_HookMusic), you might have code that expects it to be in a specific
* format, and you should specify that here.
*
* The audio device frequency is specified in Hz; in modern times, 48000 is
* often a reasonable default.
*
* The audio device format is one of SDL's AUDIO_* constants. AUDIO_S16SYS
* (16-bit audio) is probably a safe default. More modern systems may prefer
* AUDIO_F32SYS (32-bit floating point audio).
*
* The audio device channels are generally 1 for mono output, or 2 for stereo,
* but the brave can try surround sound configs with 4 (quad), 6 (5.1), 7
* (6.1) or 8 (7.1).
*
* The audio device's chunk size is the number of sample frames (one sample
* per frame for mono output, two samples per frame in a stereo setup, etc)
* that are fed to the device at once. The lower the number, the lower the
* latency, but you risk dropouts if it gets too low. 2048 is often a
* reasonable default, but your app might want to experiment with 1024 or
* 4096.
*
* You may only have one audio device open at a time; if you want to change a
* setting, you must close the device and reopen it, which is not something
* you can do seamlessly during playback.
*
* This function allows you to select specific audio hardware on the system
* with the `device` parameter. If you specify NULL, SDL_mixer will choose the
* best default it can on your behalf (which, in many cases, is exactly what
* you want anyhow). SDL_mixer does not offer a mechanism to determine device
* names to open, but you can use SDL_GetNumAudioDevices() to get a count of
* available devices and then SDL_GetAudioDeviceName() in a loop to obtain a
* list. If you do this, be sure to call `SDL_Init(SDL_INIT_AUDIO)` first to
* initialize SDL's audio system!
*
* The `allowed_changes` parameter specifies what settings are flexible. These
* are the `SDL_AUDIO_ALLOW_*` flags from SDL. These tell SDL_mixer that the
* app doesn't mind if a specific setting changes. For example, the app might
* need stereo data in Sint16 format, but if the sample rate or chunk size
* changes, the app can handle that. In that case, the app would specify
* `SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE`. In this
* case, if the system's hardware requires something other than the requested
* format, SDL_mixer can select what the hardware demands instead of the app.
* If the `SDL_AUDIO_ALLOW_` flag is not specified, SDL_mixer must convert
* data behind the scenes between what the app demands and what the hardware
* requires. If your app needs precisely what is requested, specify zero for
* `allowed_changes`.
*
* If changes were allowed, the app can use Mix_QuerySpec() to determine the
* final device settings.
*
* If this function reports success, you are ready to start making noise! Load
* some audio data and start playing!
*
* When done with an audio device, probably at the end of the program, the app
* should dispose of the device with Mix_CloseDevice().
*
* \param frequency the frequency to playback audio at (in Hz).
* \param format audio format, one of SDL's AUDIO_* values.
* \param channels number of channels (1 is mono, 2 is stereo, etc).
* \param chunksize audio buffer size in sample FRAMES (total samples divided
* by channel count).
* \param device the device name to open, or NULL to choose a reasonable
* default.
* \param allowed_changes Allow change flags (see SDL_AUDIO_ALLOW_* flags).
* \returns 0 if successful, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.2.
*
* \sa Mix_OpenAudio
* \sa Mix_CloseDevice
* \sa Mix_QuerySpec
*/
extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
/**
* Suspend or resume the whole audio output.
*
* \param pause_on 1 to pause audio output, or 0 to resume.
*
* \since This function is available since SDL_mixer 2.8.0.
*/
extern DECLSPEC void SDLCALL Mix_PauseAudio(int pause_on);
/**
* Find out what the actual audio device parameters are.
*
* If Mix_OpenAudioDevice() was called with `allowed_changes` set to anything
* but zero, or Mix_OpenAudio() was used, some audio device settings may be
* different from the application's request. This function will report what
* the device is actually running at.
*
* Note this is only important if the app intends to touch the audio buffers
* being sent to the hardware directly. If an app just wants to play audio
* files and let SDL_mixer handle the low-level details, this function can
* probably be ignored.
*
* If the audio device is not opened, this function will return 0.
*
* \param frequency On return, will be filled with the audio device's
* frequency in Hz.
* \param format On return, will be filled with the audio device's format.
* \param channels On return, will be filled with the audio device's channel
* count.
* \returns 1 if the audio device has been opened, 0 otherwise.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_OpenAudio
* \sa Mix_OpenAudioDevice
*/
extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency, Uint16 *format, int *channels);
/**
* Dynamically change the number of channels managed by the mixer.
*
* SDL_mixer deals with "channels," which is not the same thing as the
* mono/stereo channels; they might be better described as "tracks," as each
* one corresponds to a separate source of audio data. Three different WAV
* files playing at the same time would be three separate SDL_mixer channels,
* for example.
*
* An app needs as many channels as it has audio data it wants to play
* simultaneously, mixing them into a single stream to send to the audio
* device.
*
* SDL_mixer allocates `MIX_CHANNELS` (currently 8) channels when you open an
* audio device, which may be more than an app needs, but if the app needs
* more or wants less, this function can change it.
*
* If decreasing the number of channels, any upper channels currently playing
* are stopped. This will deregister all effects on those channels and call
* any callback specified by Mix_ChannelFinished() for each removed channel.
*
* If `numchans` is less than zero, this will return the current number of
* channels without changing anything.
*
* \param numchans the new number of channels, or < 0 to query current channel
* count.
* \returns the new number of allocated channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
/**
* Load a supported audio format into a chunk.
*
* SDL_mixer has two separate data structures for audio data. One it calls a
* "chunk," which is meant to be a file completely decoded into memory up
* front, and the other it calls "music" which is a file intended to be
* decoded on demand. Originally, simple formats like uncompressed WAV files
* were meant to be chunks and compressed things, like MP3s, were meant to be
* music, and you would stream one thing for a game's music and make repeating
* sound effects with the chunks.
*
* In modern times, this isn't split by format anymore, and most are
* interchangeable, so the question is what the app thinks is worth
* predecoding or not. Chunks might take more memory, but once they are loaded
* won't need to decode again, whereas music always needs to be decoded on the
* fly. Also, crucially, there are as many channels for chunks as the app can
* allocate, but SDL_mixer only offers a single "music" channel.
*
* If `freesrc` is non-zero, the RWops will be closed before returning,
* whether this function succeeds or not. SDL_mixer reads everything it needs
* from the RWops during this call in any case.
*
* There is a separate function (a macro, before SDL_mixer 2.6.0) to read
* files from disk without having to deal with SDL_RWops:
* `Mix_LoadWAV("filename.wav")` will call this function and manage those
* details for you.
*
* When done with a chunk, the app should dispose of it with a call to
* Mix_FreeChunk().
*
* \param src an SDL_RWops that data will be read from.
* \param freesrc non-zero to close/free the SDL_RWops before returning, zero
* to leave it open.
* \returns a new chunk, or NULL on error.
*
* \since This function is available since SDL_mixer 2.6.0 (and as a macro
* since 2.0.0).
*
* \sa Mix_LoadWAV
* \sa Mix_FreeChunk
*/
extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
/**
* Load a supported audio format into a chunk.
*
* SDL_mixer has two separate data structures for audio data. One it calls a
* "chunk," which is meant to be a file completely decoded into memory up
* front, and the other it calls "music" which is a file intended to be
* decoded on demand. Originally, simple formats like uncompressed WAV files
* were meant to be chunks and compressed things, like MP3s, were meant to be
* music, and you would stream one thing for a game's music and make repeating
* sound effects with the chunks.
*
* In modern times, this isn't split by format anymore, and most are
* interchangeable, so the question is what the app thinks is worth
* predecoding or not. Chunks might take more memory, but once they are loaded
* won't need to decode again, whereas music always needs to be decoded on the
* fly. Also, crucially, there are as many channels for chunks as the app can
* allocate, but SDL_mixer only offers a single "music" channel.
*
* If you would rather use the abstract SDL_RWops interface to load data from
* somewhere other than the filesystem, you can use Mix_LoadWAV_RW() instead.
*
* When done with a chunk, the app should dispose of it with a call to
* Mix_FreeChunk().
*
* Note that before SDL_mixer 2.6.0, this function was a macro that called
* Mix_LoadWAV_RW(), creating a RWops and setting `freesrc` to 1. This macro
* has since been promoted to a proper API function. Older binaries linked
* against a newer SDL_mixer will still call Mix_LoadWAV_RW directly, as they
* are using the macro, which was available since the dawn of time.
*
* \param file the filesystem path to load data from.
* \returns a new chunk, or NULL on error.
*
* \since This function is available since SDL_mixer 2.6.0 (and as a macro
* since 2.0.0).
*
* \sa Mix_LoadWAV_RW
* \sa Mix_FreeChunk
*/
extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV(const char *file);
/**
* Load a supported audio format into a music object.
*
* SDL_mixer has two separate data structures for audio data. One it calls a
* "chunk," which is meant to be a file completely decoded into memory up
* front, and the other it calls "music" which is a file intended to be
* decoded on demand. Originally, simple formats like uncompressed WAV files
* were meant to be chunks and compressed things, like MP3s, were meant to be
* music, and you would stream one thing for a game's music and make repeating
* sound effects with the chunks.
*
* In modern times, this isn't split by format anymore, and most are
* interchangeable, so the question is what the app thinks is worth
* predecoding or not. Chunks might take more memory, but once they are loaded
* won't need to decode again, whereas music always needs to be decoded on the
* fly. Also, crucially, there are as many channels for chunks as the app can
* allocate, but SDL_mixer only offers a single "music" channel.
*
* When done with this music, the app should dispose of it with a call to
* Mix_FreeMusic().
*
* \param file a file path from where to load music data.
* \returns a new music object, or NULL on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_FreeMusic
*/
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
/**
* Load a supported audio format into a music object.
*
* SDL_mixer has two separate data structures for audio data. One it calls a
* "chunk," which is meant to be a file completely decoded into memory up
* front, and the other it calls "music" which is a file intended to be
* decoded on demand. Originally, simple formats like uncompressed WAV files
* were meant to be chunks and compressed things, like MP3s, were meant to be
* music, and you would stream one thing for a game's music and make repeating
* sound effects with the chunks.
*
* In modern times, this isn't split by format anymore, and most are
* interchangeable, so the question is what the app thinks is worth
* predecoding or not. Chunks might take more memory, but once they are loaded
* won't need to decode again, whereas music always needs to be decoded on the
* fly. Also, crucially, there are as many channels for chunks as the app can
* allocate, but SDL_mixer only offers a single "music" channel.
*
* If `freesrc` is non-zero, the RWops will be closed before returning,
* whether this function succeeds or not. SDL_mixer reads everything it needs
* from the RWops during this call in any case.
*
* As a convenience, there is a function to read files from disk without
* having to deal with SDL_RWops: `Mix_LoadMUS("filename.mp3")` will manage
* those details for you.
*
* This function attempts to guess the file format from incoming data. If the
* caller knows the format, or wants to force it, it should use
* Mix_LoadMUSType_RW() instead.
*
* When done with this music, the app should dispose of it with a call to
* Mix_FreeMusic().
*
* \param src an SDL_RWops that data will be read from.
* \param freesrc non-zero to close/free the SDL_RWops before returning, zero
* to leave it open.
* \returns a new music object, or NULL on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_FreeMusic
*/
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
/**
* Load an audio format into a music object, assuming a specific format.
*
* SDL_mixer has two separate data structures for audio data. One it calls a
* "chunk," which is meant to be a file completely decoded into memory up
* front, and the other it calls "music" which is a file intended to be
* decoded on demand. Originally, simple formats like uncompressed WAV files
* were meant to be chunks and compressed things, like MP3s, were meant to be
* music, and you would stream one thing for a game's music and make repeating
* sound effects with the chunks.
*
* In modern times, this isn't split by format anymore, and most are
* interchangeable, so the question is what the app thinks is worth
* predecoding or not. Chunks might take more memory, but once they are loaded
* won't need to decode again, whereas music always needs to be decoded on the
* fly. Also, crucially, there are as many channels for chunks as the app can
* allocate, but SDL_mixer only offers a single "music" channel.
*
* This function loads music data, and lets the application specify the type
* of music being loaded, which might be useful if SDL_mixer cannot figure it
* out from the data stream itself.
*
* Currently, the following types are supported:
*
* - `MUS_NONE` (SDL_mixer should guess, based on the data)
* - `MUS_WAV` (Microsoft WAV files)
* - `MUS_MOD` (Various tracker formats)
* - `MUS_MID` (MIDI files)
* - `MUS_OGG` (Ogg Vorbis files)
* - `MUS_MP3` (MP3 files)
* - `MUS_FLAC` (FLAC files)
* - `MUS_OPUS` (Opus files)
* - `MUS_WAVPACK` (WavPack files)
*
* If `freesrc` is non-zero, the RWops will be closed before returning,
* whether this function succeeds or not. SDL_mixer reads everything it needs
* from the RWops during this call in any case.
*
* As a convenience, there is a function to read files from disk without
* having to deal with SDL_RWops: `Mix_LoadMUS("filename.mp3")` will manage
* those details for you (but not let you specify the music type explicitly)..
*
* When done with this music, the app should dispose of it with a call to
* Mix_FreeMusic().
*
* \param src an SDL_RWops that data will be read from.
* \param type the type of audio data provided by `src`.
* \param freesrc non-zero to close/free the SDL_RWops before returning, zero
* to leave it open.
* \returns a new music object, or NULL on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_FreeMusic
*/
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
/**
* Load a WAV file from memory as quickly as possible.
*
* Unlike Mix_LoadWAV_RW, this function has several requirements, and unless
* you control all your audio data and know what you're doing, you should
* consider this function unsafe and not use it.
*
* - The provided audio data MUST be in Microsoft WAV format.
* - The provided audio data shouldn't use any strange WAV extensions.
* - The audio data MUST be in the exact same format as the audio device. This
* function will not attempt to convert it, or even verify it's in the right
* format.
* - The audio data must be valid; this function does not know the size of the
* memory buffer, so if the WAV data is corrupted, it can read past the end
* of the buffer, causing a crash.
* - The audio data must live at least as long as the returned Mix_Chunk,
* because SDL_mixer will use that data directly and not make a copy of it.
*
* This function will do NO error checking! Be extremely careful here!
*
* (Seriously, use Mix_LoadWAV_RW instead.)
*
* If this function is successful, the provided memory buffer must remain
* available until Mix_FreeChunk() is called on the returned chunk.
*
* \param mem memory buffer containing of a WAV file.
* \returns a new chunk, or NULL on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_LoadWAV_RW
* \sa Mix_FreeChunk
*/
extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
/**
* Load a raw audio data from memory as quickly as possible.
*
* The audio data MUST be in the exact same format as the audio device. This
* function will not attempt to convert it, or even verify it's in the right
* format.
*
* If this function is successful, the provided memory buffer must remain
* available until Mix_FreeChunk() is called on the returned chunk.
*
* \param mem memory buffer containing raw PCM data.
* \param len length of buffer pointed to by `mem`, in bytes.
* \returns a new chunk, or NULL on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_FreeChunk
*/
extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
/**
* Free an audio chunk.
*
* An app should call this function when it is done with a Mix_Chunk and wants
* to dispose of its resources.
*
* SDL_mixer will stop any channels this chunk is currently playing on. This
* will deregister all effects on those channels and call any callback
* specified by Mix_ChannelFinished() for each removed channel.
*
* \param chunk the chunk to free.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_LoadWAV
* \sa Mix_LoadWAV_RW
* \sa Mix_QuickLoad_WAV
* \sa Mix_QuickLoad_RAW
*/
extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
/**
* Free a music object.
*
* If this music is currently playing, it will be stopped.
*
* If this music is in the process of fading out (via Mix_FadeOutMusic()),
* this function will *block* until the fade completes. If you need to avoid
* this, be sure to call Mix_HaltMusic() before freeing the music.
*
* \param music the music object to free.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_LoadMUS
* \sa Mix_LoadMUS_RW
* \sa Mix_LoadMUSType_RW
*/
extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
/**
* Get a list of chunk decoders that this build of SDL_mixer provides.
*
* This list can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* Appearing in this list doesn't promise your specific audio file will
* decode...but it's handy to know if you have, say, a functioning Ogg Vorbis
* install.
*
* These return values are static, read-only data; do not modify or free it.
* The pointers remain valid until you call Mix_CloseAudio().
*
* \returns number of chunk decoders available.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GetChunkDecoder
* \sa Mix_HasChunkDecoder
*/
extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
/**
* Get a chunk decoder's name.
*
* The requested decoder's index must be between zero and
* Mix_GetNumChunkDecoders()-1. It's safe to call this with an invalid index;
* this function will return NULL in that case.
*
* This list can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* \param index index of the chunk decoder.
* \returns the chunk decoder's name.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GetNumChunkDecoders
*/
extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
/**
* Check if a chunk decoder is available by name.
*
* This result can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* Decoder names are arbitrary but also obvious, so you have to know what
* you're looking for ahead of time, but usually it's the file extension in
* capital letters (some example names are "AIFF", "VOC", "WAV").
*
* \param name the decoder name to query.
* \returns SDL_TRUE if a decoder by that name is available, SDL_FALSE
* otherwise.
*
* \since This function is available since SDL_mixer 2.0.2.
*
* \sa Mix_GetNumChunkDecoders
* \sa Mix_GetChunkDecoder
*/
extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
/**
* Get a list of music decoders that this build of SDL_mixer provides.
*
* This list can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* Appearing in this list doesn't promise your specific audio file will
* decode...but it's handy to know if you have, say, a functioning Ogg Vorbis
* install.
*
* These return values are static, read-only data; do not modify or free it.
* The pointers remain valid until you call Mix_CloseAudio().
*
* \returns number of music decoders available.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GetMusicDecoder
* \sa Mix_HasMusicDecoder
*/
extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
/**
* Get a music decoder's name.
*
* The requested decoder's index must be between zero and
* Mix_GetNumMusicDecoders()-1. It's safe to call this with an invalid index;
* this function will return NULL in that case.
*
* This list can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* \param index index of the music decoder.
* \returns the music decoder's name.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GetNumMusicDecoders
*/
extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
/**
* Check if a music decoder is available by name.
*
* This result can change between builds AND runs of the program, if external
* libraries that add functionality become available. You must successfully
* call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function,
* as decoders are activated at device open time.
*
* Decoder names are arbitrary but also obvious, so you have to know what
* you're looking for ahead of time, but usually it's the file extension in
* capital letters (some example names are "MOD", "MP3", "FLAC").
*
* \param name the decoder name to query.
* \returns SDL_TRUE if a decoder by that name is available, SDL_FALSE
* otherwise.
*
* \since This function is available since SDL_mixer 2.6.0
*
* \sa Mix_GetNumMusicDecoders
* \sa Mix_GetMusicDecoder
*/
extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
/**
* Find out the format of a mixer music.
*
* If `music` is NULL, this will query the currently playing music (and return
* MUS_NONE if nothing is currently playing).
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the Mix_MusicType for the music object.
*
* \since This function is available since SDL_mixer 2.0.0
*/
extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
/**
* Get the title for a music object, or its filename.
*
* This returns format-specific metadata. Not all file formats supply this!
*
* If `music` is NULL, this will query the currently-playing music.
*
* If music's title tag is missing or empty, the filename will be returned. If
* you'd rather have the actual metadata or nothing, use
* Mix_GetMusicTitleTag() instead.
*
* Please note that if the music was loaded from an SDL_RWops instead of a
* filename, the filename returned will be an empty string ("").
*
* This function never returns NULL! If no data is available, it will return
* an empty string ("").
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the music's title if available, or the filename if not, or "".
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_GetMusicTitleTag
* \sa Mix_GetMusicArtistTag
* \sa Mix_GetMusicAlbumTag
* \sa Mix_GetMusicCopyrightTag
*/
extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music);
/**
* Get the title for a music object.
*
* This returns format-specific metadata. Not all file formats supply this!
*
* If `music` is NULL, this will query the currently-playing music.
*
* Unlike this function, Mix_GetMusicTitle() produce a string with the music's
* filename if a title isn't available, which might be preferable for some
* applications.
*
* This function never returns NULL! If no data is available, it will return
* an empty string ("").
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the music's title if available, or "".
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_GetMusicTitle
* \sa Mix_GetMusicArtistTag
* \sa Mix_GetMusicAlbumTag
* \sa Mix_GetMusicCopyrightTag
*/
extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music);
/**
* Get the artist name for a music object.
*
* This returns format-specific metadata. Not all file formats supply this!
*
* If `music` is NULL, this will query the currently-playing music.
*
* This function never returns NULL! If no data is available, it will return
* an empty string ("").
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the music's artist name if available, or "".
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_GetMusicTitleTag
* \sa Mix_GetMusicAlbumTag
* \sa Mix_GetMusicCopyrightTag
*/
extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music);
/**
* Get the album name for a music object.
*
* This returns format-specific metadata. Not all file formats supply this!
*
* If `music` is NULL, this will query the currently-playing music.
*
* This function never returns NULL! If no data is available, it will return
* an empty string ("").
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the music's album name if available, or "".
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_GetMusicTitleTag
* \sa Mix_GetMusicArtistTag
* \sa Mix_GetMusicCopyrightTag
*/
extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music);
/**
* Get the copyright text for a music object.
*
* This returns format-specific metadata. Not all file formats supply this!
*
* If `music` is NULL, this will query the currently-playing music.
*
* This function never returns NULL! If no data is available, it will return
* an empty string ("").
*
* \param music the music object to query, or NULL for the currently-playing
* music.
* \returns the music's copyright text if available, or "".
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_GetMusicTitleTag
* \sa Mix_GetMusicArtistTag
* \sa Mix_GetMusicAlbumTag
*/
extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music);
typedef void (SDLCALL *Mix_MixCallback)(void *udata, Uint8 *stream, int len);
/**
* Set a function that is called after all mixing is performed.
*
* This can be used to provide real-time visual display of the audio stream or
* add a custom mixer filter for the stream data.
*
* The callback will fire every time SDL_mixer is ready to supply more data to
* the audio device, after it has finished all its mixing work. This runs
* inside an SDL audio callback, so it's important that the callback return
* quickly, or there could be problems in the audio playback.
*
* The data provided to the callback is in the format that the audio device
* was opened in, and it represents the exact waveform SDL_mixer has mixed
* from all playing chunks and music for playback. You are allowed to modify
* the data, but it cannot be resized (so you can't add a reverb effect that
* goes past the end of the buffer without saving some state between runs to
* add it into the next callback, or resample the buffer to a smaller size to
* speed it up, etc).
*
* The `arg` pointer supplied here is passed to the callback as-is, for
* whatever the callback might want to do with it (keep track of some ongoing
* state, settings, etc).
*
* Passing a NULL callback disables the post-mix callback until such a time as
* a new one callback is set.
*
* There is only one callback available. If you need to mix multiple inputs,
* be prepared to handle them from a single function.
*
* \param mix_func the callback function to become the new post-mix callback.
* \param arg a pointer that is passed, untouched, to the callback.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_HookMusic
*/
extern DECLSPEC void SDLCALL Mix_SetPostMix(Mix_MixCallback mix_func, void *arg);
/**
* Add your own music player or additional mixer function.
*
* This works something like Mix_SetPostMix(), but it has some crucial
* differences. Note that an app can use this _and_ Mix_SetPostMix() at the
* same time. This allows an app to replace the built-in music playback,
* either with it's own music decoder or with some sort of
* procedurally-generated audio output.
*
* The supplied callback will fire every time SDL_mixer is preparing to supply
* more data to the audio device. This runs inside an SDL audio callback, so
* it's important that the callback return quickly, or there could be problems
* in the audio playback.
*
* Running this callback is the first thing SDL_mixer will do when starting to
* mix more audio. The buffer will contain silence upon entry, so the callback
* does not need to mix into existing data or initialize the buffer.
*
* Note that while a callback is set through this function, SDL_mixer will not
* mix any playing music; this callback is used instead. To disable this
* callback (and thus reenable built-in music playback) call this function
* with a NULL callback.
*
* The data written to by the callback is in the format that the audio device
* was opened in, and upon return from the callback, SDL_mixer will mix any
* playing chunks (but not music!) into the buffer. The callback cannot resize
* the buffer (so you must be prepared to provide exactly the amount of data
* demanded or leave it as silence).
*
* The `arg` pointer supplied here is passed to the callback as-is, for
* whatever the callback might want to do with it (keep track of some ongoing
* state, settings, etc).
*
* As there is only one music "channel" mixed, there is only one callback
* available. If you need to mix multiple inputs, be prepared to handle them
* from a single function.
*
* \param mix_func the callback function to become the new post-mix callback.
* \param arg a pointer that is passed, untouched, to the callback.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_SetPostMix
*/
extern DECLSPEC void SDLCALL Mix_HookMusic(Mix_MixCallback mix_func, void *arg);
typedef void (SDLCALL *Mix_MusicFinishedCallback)(void);
/**
* Set a callback that runs when a music object has stopped playing.
*
* This callback will fire when the currently-playing music has completed, or
* when it has been explicitly stopped from a call to Mix_HaltMusic. As such,
* this callback might fire from an arbitrary background thread at almost any
* time; try to limit what you do here.
*
* It is legal to start a new music object playing in this callback (or
* restart the one that just stopped). If the music finished normally, this
* can be used to loop the music without a gap in the audio playback.
*
* Do not call SDL_LockAudio() from this callback; you will either be inside
* the audio callback, or SDL_mixer will explicitly lock the audio before
* calling your callback.
*
* A NULL pointer will disable the callback.
*
* \param music_finished the callback function to become the new notification
* mechanism.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_HookMusicFinished(Mix_MusicFinishedCallback music_finished);
/**
* Get a pointer to the user data for the current music hook.
*
* This returns the `arg` pointer last passed to Mix_HookMusic(), or NULL if
* that function has never been called.
*
* \returns pointer to the user data previously passed to Mix_HookMusic.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
typedef void (SDLCALL *Mix_ChannelFinishedCallback)(int channel);
/**
* Set a callback that runs when a channel has finished playing.
*
* The callback may be called from the mixer's audio callback or it could be
* called as a result of Mix_HaltChannel(), etc.
*
* The callback has a single parameter, `channel`, which says what mixer
* channel has just stopped.
*
* Do not call SDL_LockAudio() from this callback; you will either be inside
* the audio callback, or SDL_mixer will explicitly lock the audio before
* calling your callback.
*
* A NULL pointer will disable the callback.
*
* \param channel_finished the callback function to become the new
* notification mechanism.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_ChannelFinished(Mix_ChannelFinishedCallback channel_finished);
#define MIX_CHANNEL_POST (-2)
/**
* This is the format of a special effect callback:
*
* myeffect(int chan, void *stream, int len, void *udata);
*
* (chan) is the channel number that your effect is affecting. (stream) is the
* buffer of data to work upon. (len) is the size of (stream), and (udata) is
* a user-defined bit of data, which you pass as the last arg of
* Mix_RegisterEffect(), and is passed back unmolested to your callback. Your
* effect changes the contents of (stream) based on whatever parameters are
* significant, or just leaves it be, if you prefer. You can do whatever you
* like to the buffer, though, and it will continue in its changed state down
* the mixing pipeline, through any other effect functions, then finally to be
* mixed with the rest of the channels and music for the final output stream.
*
* DO NOT EVER call SDL_LockAudio() from your callback function!
*/
typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
/**
* This is a callback that signifies that a channel has finished all its loops
* and has completed playback.
*
* This gets called if the buffer plays out normally, or if you call
* Mix_HaltChannel(), implicitly stop a channel via Mix_AllocateChannels(), or
* unregister a callback while it's still playing.
*
* DO NOT EVER call SDL_LockAudio() from your callback function!
*/
typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
/**
* Register a special effect function.
*
* At mixing time, the channel data is copied into a buffer and passed through
* each registered effect function. After it passes through all the functions,
* it is mixed into the final output stream. The copy to buffer is performed
* once, then each effect function performs on the output of the previous
* effect. Understand that this extra copy to a buffer is not performed if
* there are no effects registered for a given chunk, which saves CPU cycles,
* and any given effect will be extra cycles, too, so it is crucial that your
* code run fast. Also note that the data that your function is given is in
* the format of the sound device, and not the format you gave to
* Mix_OpenAudio(), although they may in reality be the same. This is an
* unfortunate but necessary speed concern. Use Mix_QuerySpec() to determine
* if you can handle the data before you register your effect, and take
* appropriate actions.
*
* You may also specify a callback (Mix_EffectDone_t) that is called when the
* channel finishes playing. This gives you a more fine-grained control than
* Mix_ChannelFinished(), in case you need to free effect-specific resources,
* etc. If you don't need this, you can specify NULL.
*
* You may set the callbacks before or after calling Mix_PlayChannel().
*
* Things like Mix_SetPanning() are just internal special effect functions, so
* if you are using that, you've already incurred the overhead of a copy to a
* separate buffer, and that these effects will be in the queue with any
* functions you've registered. The list of registered effects for a channel
* is reset when a chunk finishes playing, so you need to explicitly set them
* with each call to Mix_PlayChannel*().
*
* You may also register a special effect function that is to be run after
* final mixing occurs. The rules for these callbacks are identical to those
* in Mix_RegisterEffect, but they are run after all the channels and the
* music have been mixed into a single stream, whereas channel-specific
* effects run on a given channel before any other mixing occurs. These global
* effect callbacks are call "posteffects". Posteffects only have their
* Mix_EffectDone_t function called when they are unregistered (since the main
* output stream is never "done" in the same sense as a channel). You must
* unregister them manually when you've had enough. Your callback will be told
* that the channel being mixed is `MIX_CHANNEL_POST` if the processing is
* considered a posteffect.
*
* After all these effects have finished processing, the callback registered
* through Mix_SetPostMix() runs, and then the stream goes to the audio
* device.
*
* DO NOT EVER call SDL_LockAudio() from your callback function! You are
* already running in the audio thread and the lock is already held!
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param chan the channel to register an effect to, or MIX_CHANNEL_POST.
* \param f effect the callback to run when more of this channel is to be
* mixed.
* \param d effect done callback.
* \param arg argument.
* \returns zero if error (no such channel), nonzero if added. Error messages
* can be retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
/**
* Explicitly unregister a special effect function.
*
* You may not need to call this at all, unless you need to stop an effect
* from processing in the middle of a chunk's playback.
*
* Posteffects are never implicitly unregistered as they are for channels (as
* the output stream does not have an end), but they may be explicitly
* unregistered through this function by specifying MIX_CHANNEL_POST for a
* channel.
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel the channel to unregister an effect on, or MIX_CHANNEL_POST.
* \param f effect the callback stop calling in future mixing iterations.
* \returns zero if error (no such channel or effect), nonzero if removed.
* Error messages can be retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
/**
* Explicitly unregister all special effect functions.
*
* You may not need to call this at all, unless you need to stop all effects
* from processing in the middle of a chunk's playback.
*
* Note that this will also shut off some internal effect processing, since
* Mix_SetPanning() and others may use this API under the hood. This is called
* internally when a channel completes playback. Posteffects are never
* implicitly unregistered as they are for channels, but they may be
* explicitly unregistered through this function by specifying
* MIX_CHANNEL_POST for a channel.
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel the channel to unregister all effects on, or
* MIX_CHANNEL_POST.
* \returns zero if error (no such channel), nonzero if all effects removed.
* Error messages can be retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"
/*
* These are the internally-defined mixing effects. They use the same API that
* effects defined in the application use, but are provided here as a
* convenience. Some effects can reduce their quality or use more memory in
* the name of speed; to enable this, make sure the environment variable
* MIX_EFFECTSMAXSPEED (see above) is defined before you call
* Mix_OpenAudio().
*/
/**
* Set the panning of a channel.
*
* The left and right channels are specified as integers between 0 and 255,
* quietest to loudest, respectively.
*
* Technically, this is just individual volume control for a sample with two
* (stereo) channels, so it can be used for more than just panning. If you
* want real panning, call it like this:
*
* ```c
* Mix_SetPanning(channel, left, 255 - left);
* ```
*
* Setting `channel` to MIX_CHANNEL_POST registers this as a posteffect, and
* the panning will be done to the final mixed stream before passing it on to
* the audio device.
*
* This uses the Mix_RegisterEffect() API internally, and returns without
* registering the effect function if the audio device is not configured for
* stereo output. Setting both `left` and `right` to 255 causes this effect to
* be unregistered, since that is the data's normal state.
*
* Note that an audio device in mono mode is a no-op, but this call will
* return successful in that case. Error messages can be retrieved from
* Mix_GetError().
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel The mixer channel to pan or MIX_CHANNEL_POST.
* \param left Volume of stereo left channel, 0 is silence, 255 is full
* volume.
* \param right Volume of stereo right channel, 0 is silence, 255 is full
* volume.
* \returns zero if error (no such channel or Mix_RegisterEffect() fails),
* nonzero if panning effect enabled.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_SetPosition
* \sa Mix_SetDistance
*/
extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
/**
* Set the position of a channel.
*
* `angle` is an integer from 0 to 360, that specifies the location of the
* sound in relation to the listener. `angle` will be reduced as necessary
* (540 becomes 180 degrees, -100 becomes 260). Angle 0 is due north, and
* rotates clockwise as the value increases. For efficiency, the precision of
* this effect may be limited (angles 1 through 7 might all produce the same
* effect, 8 through 15 are equal, etc). `distance` is an integer between 0
* and 255 that specifies the space between the sound and the listener. The
* larger the number, the further away the sound is. Using 255 does not
* guarantee that the channel will be removed from the mixing process or be
* completely silent. For efficiency, the precision of this effect may be
* limited (distance 0 through 5 might all produce the same effect, 6 through
* 10 are equal, etc). Setting `angle` and `distance` to 0 unregisters this
* effect, since the data would be unchanged.
*
* If you need more precise positional audio, consider using OpenAL for
* spatialized effects instead of SDL_mixer. This is only meant to be a basic
* effect for simple "3D" games.
*
* If the audio device is configured for mono output, then you won't get any
* effectiveness from the angle; however, distance attenuation on the channel
* will still occur. While this effect will function with stereo voices, it
* makes more sense to use voices with only one channel of sound, so when they
* are mixed through this effect, the positioning will sound correct. You can
* convert them to mono through SDL before giving them to the mixer in the
* first place if you like.
*
* Setting the channel to MIX_CHANNEL_POST registers this as a posteffect, and
* the positioning will be done to the final mixed stream before passing it on
* to the audio device.
*
* This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel The mixer channel to position, or MIX_CHANNEL_POST.
* \param angle angle, in degrees. North is 0, and goes clockwise.
* \param distance distance; 0 is the listener, 255 is maxiumum distance away.
* \returns zero if error (no such channel or Mix_RegisterEffect() fails),
* nonzero if position effect is enabled. Error messages can be
* retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
/**
* Set the "distance" of a channel.
*
* `distance` is an integer from 0 to 255 that specifies the location of the
* sound in relation to the listener. Distance 0 is overlapping the listener,
* and 255 is as far away as possible. A distance of 255 does not guarantee
* silence; in such a case, you might want to try changing the chunk's volume,
* or just cull the sample from the mixing process with Mix_HaltChannel(). For
* efficiency, the precision of this effect may be limited (distances 1
* through 7 might all produce the same effect, 8 through 15 are equal, etc).
* (distance) is an integer between 0 and 255 that specifies the space between
* the sound and the listener. The larger the number, the further away the
* sound is. Setting the distance to 0 unregisters this effect, since the data
* would be unchanged. If you need more precise positional audio, consider
* using OpenAL for spatialized effects instead of SDL_mixer. This is only
* meant to be a basic effect for simple "3D" games.
*
* Setting the channel to MIX_CHANNEL_POST registers this as a posteffect, and
* the distance attenuation will be done to the final mixed stream before
* passing it on to the audio device.
*
* This uses the Mix_RegisterEffect() API internally.
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel The mixer channel to attenuate, or MIX_CHANNEL_POST.
* \param distance distance; 0 is the listener, 255 is maxiumum distance away.
* \returns zero if error (no such channel or Mix_RegisterEffect() fails),
* nonzero if position effect is enabled. Error messages can be
* retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
/**
* Cause a channel to reverse its stereo.
*
* This is handy if the user has his speakers hooked up backwards, or you
* would like to have a trippy sound effect.
*
* Calling this function with `flip` set to non-zero reverses the chunks's
* usual channels. If `flip` is zero, the effect is unregistered.
*
* This uses the Mix_RegisterEffect() API internally, and thus is probably
* more CPU intensive than having the user just plug in his speakers
* correctly. Mix_SetReverseStereo() returns without registering the effect
* function if the audio device is not configured for stereo output.
*
* If you specify MIX_CHANNEL_POST for `channel`, then this effect is used on
* the final mixed stream before sending it on to the audio device (a
* posteffect).
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param channel The mixer channel to reverse, or MIX_CHANNEL_POST.
* \param flip non-zero to reverse stereo, zero to disable this effect.
* \returns zero if error (no such channel or Mix_RegisterEffect() fails),
* nonzero if reversing effect is enabled. Note that an audio device
* in mono mode is a no-op, but this call will return successful in
* that case. Error messages can be retrieved from Mix_GetError().
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
/* end of effects API. */
/**
* Reserve the first channels for the application.
*
* While SDL_mixer will use up to the number of channels allocated by
* Mix_AllocateChannels(), this sets channels aside that will not be available
* when calling Mix_PlayChannel with a channel of -1 (play on the first unused
* channel). In this case, SDL_mixer will treat reserved channels as "used"
* whether anything is playing on them at the moment or not.
*
* This is useful if you've budgeted some channels for dedicated audio and the
* rest are just used as they are available.
*
* Calling this function will set channels 0 to `n - 1` to be reserved. This
* will not change channel allocations. The number of reserved channels will
* be clamped to the current number allocated.
*
* By default, no channels are reserved.
*
* \param num number of channels to reserve, starting at index zero.
* \returns the number of reserved channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
/* Channel grouping functions */
/**
* Assign a tag to a channel.
*
* A tag is an arbitary number that can be assigned to several mixer channels,
* to form groups of channels.
*
* If 'tag' is -1, the tag is removed (actually -1 is the tag used to
* represent the group of all the channels).
*
* This function replaces the requested channel's current tag; you may only
* have one tag per channel.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* \param which the channel to set the tag on.
* \param tag an arbitrary value to assign a channel.
* \returns non-zero on success, zero on error (no such channel).
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
/**
* Assign several consecutive channels to the same tag.
*
* A tag is an arbitary number that can be assigned to several mixer channels,
* to form groups of channels.
*
* If 'tag' is -1, the tag is removed (actually -1 is the tag used to
* represent the group of all the channels).
*
* This function replaces the requested channels' current tags; you may only
* have one tag per channel.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* Note that this returns success and failure in the _opposite_ way from
* Mix_GroupChannel(). We regret the API design mistake.
*
* \param from the first channel to set the tag on.
* \param to the last channel to set the tag on, inclusive.
* \param tag an arbitrary value to assign a channel.
* \returns 0 if successful, negative on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
/**
* Finds the first available channel in a group of channels.
*
* A tag is an arbitary number that can be assigned to several mixer channels,
* to form groups of channels.
*
* This function searches all channels with a specified tag, and returns the
* channel number of the first one it finds that is currently unused.
*
* If no channels with the specified tag are unused, this function returns -1.
*
* \param tag an arbitrary value, assigned to channels, to search for.
* \returns first available channel, or -1 if none are available.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
/**
* Returns the number of channels in a group.
*
* If tag is -1, this will return the total number of channels allocated,
* regardless of what their tag might be.
*
* \param tag an arbitrary value, assigned to channels, to search for.
* \returns the number of channels assigned the specified tag.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
/**
* Find the "oldest" sample playing in a group of channels.
*
* Specifically, this function returns the channel number that is assigned the
* specified tag, is currently playing, and has the lowest start time, based
* on the value of SDL_GetTicks() when the channel started playing.
*
* If no channel with this tag is currently playing, this function returns -1.
*
* \param tag an arbitrary value, assigned to channels, to search through.
* \returns the "oldest" sample playing in a group of channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GroupNewer
*/
extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
/**
* Find the "most recent" sample playing in a group of channels.
*
* Specifically, this function returns the channel number that is assigned the
* specified tag, is currently playing, and has the highest start time, based
* on the value of SDL_GetTicks() when the channel started playing.
*
* If no channel with this tag is currently playing, this function returns -1.
*
* \param tag an arbitrary value, assigned to channels, to search through.
* \returns the "most recent" sample playing in a group of channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GroupOldest
*/
extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
/**
* Play an audio chunk on a specific channel.
*
* If the specified channel is -1, play on the first free channel (and return
* -1 without playing anything new if no free channel was available).
*
* If a specific channel was requested, and there is a chunk already playing
* there, that chunk will be halted and the new chunk will take its place.
*
* If `loops` is greater than zero, loop the sound that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* Note that before SDL_mixer 2.6.0, this function was a macro that called
* Mix_PlayChannelTimed() with a fourth parameter ("ticks") of -1. This
* function still does the same thing, but promotes it to a proper API
* function. Older binaries linked against a newer SDL_mixer will still call
* Mix_PlayChannelTimed directly, as they are using the macro, which was
* available since the dawn of time.
*
* \param channel the channel on which to play the new chunk.
* \param chunk the new chunk to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \returns which channel was used to play the sound, or -1 if sound could not
* be played.
*
* \since This function is available since SDL_mixer 2.6.0 (and as a macro
* since 2.0.0).
*/
extern DECLSPEC int SDLCALL Mix_PlayChannel(int channel, Mix_Chunk *chunk, int loops);
/**
* Play an audio chunk on a specific channel for a maximum time.
*
* If the specified channel is -1, play on the first free channel (and return
* -1 without playing anything new if no free channel was available).
*
* If a specific channel was requested, and there is a chunk already playing
* there, that chunk will be halted and the new chunk will take its place.
*
* If `loops` is greater than zero, loop the sound that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* `ticks` specifies the maximum number of milliseconds to play this chunk
* before halting it. If you want the chunk to play until all data has been
* mixed, specify -1.
*
* Note that this function does not block for the number of ticks requested;
* it just schedules the chunk to play and notes the maximum for the mixer to
* manage later, and returns immediately.
*
* \param channel the channel on which to play the new chunk.
* \param chunk the new chunk to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \param ticks the maximum number of milliseconds of this chunk to mix for
* playback.
* \returns which channel was used to play the sound, or -1 if sound could not
* be played.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
/**
* Play a new music object.
*
* This will schedule the music object to begin mixing for playback.
*
* There is only ever one music object playing at a time; if this is called
* when another music object is playing, the currently-playing music is halted
* and the new music will replace it.
*
* Please note that if the currently-playing music is in the process of fading
* out (via Mix_FadeOutMusic()), this function will *block* until the fade
* completes. If you need to avoid this, be sure to call Mix_HaltMusic()
* before starting new music.
*
* \param music the new music object to schedule for mixing.
* \param loops the number of loops to play the music for (0 means "play once
* and stop").
* \returns zero on success, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
/**
* Play a new music object, fading in the audio.
*
* This will start the new music playing, much like Mix_PlayMusic() will, but
* will start the music playing at silence and fade in to its normal volume
* over the specified number of milliseconds.
*
* If there is already music playing, that music will be halted and the new
* music object will take its place.
*
* If `loops` is greater than zero, loop the music that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* Fading music will change it's volume progressively, as if Mix_VolumeMusic()
* was called on it (which is to say: you probably shouldn't call
* Mix_VolumeMusic() on fading music).
*
* \param music the new music object to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \param ms the number of milliseconds to spend fading in.
* \returns zero on success, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
/**
* Play a new music object, fading in the audio, from a starting position.
*
* This will start the new music playing, much like Mix_PlayMusic() will, but
* will start the music playing at silence and fade in to its normal volume
* over the specified number of milliseconds.
*
* If there is already music playing, that music will be halted and the new
* music object will take its place.
*
* If `loops` is greater than zero, loop the music that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* Fading music will change it's volume progressively, as if Mix_VolumeMusic()
* was called on it (which is to say: you probably shouldn't call
* Mix_VolumeMusic() on fading music).
*
* This function allows the caller to start the music playback past the
* beginning of its audio data. You may specify a start position, in seconds,
* and the playback and fade-in will start there instead of with the first
* samples of the music.
*
* An app can specify a `position` of 0.0 to start at the beginning of the
* music (or just call Mix_FadeInMusic() instead).
*
* To convert from milliseconds, divide by 1000.0.
*
* \param music the new music object to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \param ms the number of milliseconds to spend fading in.
* \param position the start position within the music, in seconds, where
* playback should start.
* \returns zero on success, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
/**
* Play an audio chunk on a specific channel, fading in the audio.
*
* This will start the new sound playing, much like Mix_PlayChannel() will,
* but will start the sound playing at silence and fade in to its normal
* volume over the specified number of milliseconds.
*
* If the specified channel is -1, play on the first free channel (and return
* -1 without playing anything new if no free channel was available).
*
* If a specific channel was requested, and there is a chunk already playing
* there, that chunk will be halted and the new chunk will take its place.
*
* If `loops` is greater than zero, loop the sound that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* A fading channel will change it's volume progressively, as if Mix_Volume()
* was called on it (which is to say: you probably shouldn't call Mix_Volume()
* on a fading channel).
*
* Note that before SDL_mixer 2.6.0, this function was a macro that called
* Mix_FadeInChannelTimed() with a fourth parameter ("ticks") of -1. This
* function still does the same thing, but promotes it to a proper API
* function. Older binaries linked against a newer SDL_mixer will still call
* Mix_FadeInChannelTimed directly, as they are using the macro, which was
* available since the dawn of time.
*
* \param channel the channel on which to play the new chunk, or -1 to find
* any available.
* \param chunk the new chunk to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \param ms the number of milliseconds to spend fading in.
* \returns which channel was used to play the sound, or -1 if sound could not
* be played.
*
* \since This function is available since SDL_mixer 2.6.0 (and as a macro
* since 2.0.0).
*/
extern DECLSPEC int SDLCALL Mix_FadeInChannel(int channel, Mix_Chunk *chunk, int loops, int ms);
/**
* Play an audio chunk on a specific channel, fading in the audio, for a
* maximum time.
*
* This will start the new sound playing, much like Mix_PlayChannel() will,
* but will start the sound playing at silence and fade in to its normal
* volume over the specified number of milliseconds.
*
* If the specified channel is -1, play on the first free channel (and return
* -1 without playing anything new if no free channel was available).
*
* If a specific channel was requested, and there is a chunk already playing
* there, that chunk will be halted and the new chunk will take its place.
*
* If `loops` is greater than zero, loop the sound that many times. If `loops`
* is -1, loop "infinitely" (~65000 times).
*
* `ticks` specifies the maximum number of milliseconds to play this chunk
* before halting it. If you want the chunk to play until all data has been
* mixed, specify -1.
*
* Note that this function does not block for the number of ticks requested;
* it just schedules the chunk to play and notes the maximum for the mixer to
* manage later, and returns immediately.
*
* A fading channel will change it's volume progressively, as if Mix_Volume()
* was called on it (which is to say: you probably shouldn't call Mix_Volume()
* on a fading channel).
*
* \param channel the channel on which to play the new chunk, or -1 to find
* any available.
* \param chunk the new chunk to play.
* \param loops the number of times the chunk should loop, -1 to loop (not
* actually) infinitely.
* \param ms the number of milliseconds to spend fading in.
* \param ticks the maximum number of milliseconds of this chunk to mix for
* playback.
* \returns which channel was used to play the sound, or -1 if sound could not
* be played.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
/**
* Set the volume for a specific channel.
*
* The volume must be between 0 (silence) and MIX_MAX_VOLUME (full volume).
* Note that MIX_MAX_VOLUME is 128. Values greater than MIX_MAX_VOLUME are
* clamped to MIX_MAX_VOLUME.
*
* Specifying a negative volume will not change the current volume; as such,
* this can be used to query the current volume without making changes, as
* this function returns the previous (in this case, still-current) value.
*
* If the specified channel is -1, this function sets the volume for all
* channels, and returns _the average_ of all channels' volumes prior to this
* call.
*
* The default volume for a channel is MIX_MAX_VOLUME (no attenuation).
*
* \param channel the channel on set/query the volume on, or -1 for all
* channels.
* \param volume the new volume, between 0 and MIX_MAX_VOLUME, or -1 to query.
* \returns the previous volume. If the specified volume is -1, this returns
* the current volume. If `channel` is -1, this returns the average
* of all channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
/**
* Set the volume for a specific chunk.
*
* In addition to channels having a volume setting, individual chunks also
* maintain a separate volume. Both values are considered when mixing, so both
* affect the final attenuation of the sound. This lets an app adjust the
* volume for all instances of a sound in addition to specific instances of
* that sound.
*
* The volume must be between 0 (silence) and MIX_MAX_VOLUME (full volume).
* Note that MIX_MAX_VOLUME is 128. Values greater than MIX_MAX_VOLUME are
* clamped to MIX_MAX_VOLUME.
*
* Specifying a negative volume will not change the current volume; as such,
* this can be used to query the current volume without making changes, as
* this function returns the previous (in this case, still-current) value.
*
* The default volume for a chunk is MIX_MAX_VOLUME (no attenuation).
*
* \param chunk the chunk whose volume to adjust.
* \param volume the new volume, between 0 and MIX_MAX_VOLUME, or -1 to query.
* \returns the previous volume. If the specified volume is -1, this returns
* the current volume. If `chunk` is NULL, this returns -1.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
/**
* Set the volume for the music channel.
*
* The volume must be between 0 (silence) and MIX_MAX_VOLUME (full volume).
* Note that MIX_MAX_VOLUME is 128. Values greater than MIX_MAX_VOLUME are
* clamped to MIX_MAX_VOLUME.
*
* Specifying a negative volume will not change the current volume; as such,
* this can be used to query the current volume without making changes, as
* this function returns the previous (in this case, still-current) value.
*
* The default volume for music is MIX_MAX_VOLUME (no attenuation).
*
* \param volume the new volume, between 0 and MIX_MAX_VOLUME, or -1 to query.
* \returns the previous volume. If the specified volume is -1, this returns
* the current volume.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
/**
* Query the current volume value for a music object.
*
* \param music the music object to query.
* \returns the music's current volume, between 0 and MIX_MAX_VOLUME (128).
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC int SDLCALL Mix_GetMusicVolume(Mix_Music *music);
/**
* Set the master volume for all channels.
*
* SDL_mixer keeps a per-channel volume, a per-chunk volume, and a master
* volume, and considers all three when mixing audio. This function sets the
* master volume, which is applied to all playing channels when mixing.
*
* The volume must be between 0 (silence) and MIX_MAX_VOLUME (full volume).
* Note that MIX_MAX_VOLUME is 128. Values greater than MIX_MAX_VOLUME are
* clamped to MIX_MAX_VOLUME.
*
* Specifying a negative volume will not change the current volume; as such,
* this can be used to query the current volume without making changes, as
* this function returns the previous (in this case, still-current) value.
*
* Note that the master volume does not affect any playing music; it is only
* applied when mixing chunks. Use Mix_VolumeMusic() for that.\
*
* \param volume the new volume, between 0 and MIX_MAX_VOLUME, or -1 to query.
* \returns the previous volume. If the specified volume is -1, this returns
* the current volume.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC int SDLCALL Mix_MasterVolume(int volume);
/**
* Halt playing of a particular channel.
*
* This will stop further playback on that channel until a new chunk is
* started there.
*
* Specifying a channel of -1 will halt _all_ channels, except for any playing
* music.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* before this function returns.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* \param channel channel to halt, or -1 to halt all channels.
* \returns 0 on success, or -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
/**
* Halt playing of a group of channels by arbitrary tag.
*
* This will stop further playback on all channels with a specific tag, until
* a new chunk is started there.
*
* A tag is an arbitrary number that can be assigned to several mixer
* channels, to form groups of channels.
*
* The default tag for a channel is -1.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* before this function returns.
*
* \param tag an arbitrary value, assigned to channels, to search for.
* \returns zero, whether any channels were halted or not.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
/**
* Halt playing of the music stream.
*
* This will stop further playback of music until a new music object is
* started there.
*
* Any halted music will call any callback specified by
* Mix_HookMusicFinished() before this function returns.
*
* \returns zero, regardless of whether any music was halted.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
/**
* Change the expiration delay for a particular channel.
*
* The channel will halt after the 'ticks' milliseconds have elapsed, or
* remove the expiration if 'ticks' is -1.
*
* This overrides the value passed to the fourth parameter of
* Mix_PlayChannelTimed().
*
* Specifying a channel of -1 will set an expiration for _all_ channels.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* once the halt occurs.
*
* Note that this function does not block for the number of ticks requested;
* it just schedules the chunk to expire and notes the time for the mixer to
* manage later, and returns immediately.
*
* \param channel the channel to change the expiration time on.
* \param ticks number of milliseconds from now to let channel play before
* halting, -1 to not halt.
* \returns the number of channels that changed expirations.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
/**
* Halt a channel after fading it out for a specified time.
*
* This will begin a channel fading from its current volume to silence over
* `ms` milliseconds. After that time, the channel is halted.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* once the halt occurs.
*
* A fading channel will change it's volume progressively, as if Mix_Volume()
* was called on it (which is to say: you probably shouldn't call Mix_Volume()
* on a fading channel).
*
* Note that this function does not block for the number of milliseconds
* requested; it just schedules the chunk to fade and notes the time for the
* mixer to manage later, and returns immediately.
*
* \param which the channel to fade out.
* \param ms number of milliseconds to fade before halting the channel.
* \returns the number of channels scheduled to fade.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
/**
* Halt a playing group of channels by arbitrary tag, after fading them out
* for a specified time.
*
* This will begin fading a group of channels with a specific tag from their
* current volumes to silence over `ms` milliseconds. After that time, those
* channels are halted.
*
* A tag is an arbitrary number that can be assigned to several mixer
* channels, to form groups of channels.
*
* The default tag for a channel is -1.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* once the halt occurs.
*
* A fading channel will change it's volume progressively, as if Mix_Volume()
* was called on it (which is to say: you probably shouldn't call Mix_Volume()
* on a fading channel).
*
* Note that this function does not block for the number of milliseconds
* requested; it just schedules the group to fade and notes the time for the
* mixer to manage later, and returns immediately.
*
* \param tag an arbitrary value, assigned to channels, to search for.
* \param ms number of milliseconds to fade before halting the group.
* \returns the number of channels that were scheduled for fading.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
/**
* Halt the music stream after fading it out for a specified time.
*
* This will begin the music fading from its current volume to silence over
* `ms` milliseconds. After that time, the music is halted.
*
* Any halted music will call any callback specified by
* Mix_HookMusicFinished() once the halt occurs.
*
* Fading music will change it's volume progressively, as if Mix_VolumeMusic()
* was called on it (which is to say: you probably shouldn't call
* Mix_VolumeMusic() on a fading channel).
*
* Note that this function does not block for the number of milliseconds
* requested; it just schedules the music to fade and notes the time for the
* mixer to manage later, and returns immediately.
*
* \param ms number of milliseconds to fade before halting the channel.
* \returns non-zero if music was scheduled to fade, zero otherwise. If no
* music is currently playing, this returns zero.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
/**
* Query the fading status of the music stream.
*
* This reports one of three values:
*
* - `MIX_NO_FADING`
* - `MIX_FADING_OUT`
* - `MIX_FADING_IN`
*
* If music is not currently playing, this returns `MIX_NO_FADING`.
*
* \returns the current fading status of the music stream.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
/**
* Query the fading status of a channel.
*
* This reports one of three values:
*
* - `MIX_NO_FADING`
* - `MIX_FADING_OUT`
* - `MIX_FADING_IN`
*
* If nothing is currently playing on the channel, or an invalid channel is
* specified, this returns `MIX_NO_FADING`.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* You may not specify -1 for all channels; only individual channels may be
* queried.
*
* \param which the channel to query.
* \returns the current fading status of the channel.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
/**
* Pause a particular channel.
*
* Pausing a channel will prevent further playback of the assigned chunk but
* will maintain the chunk's current mixing position. When resumed, this
* channel will continue to mix the chunk where it left off.
*
* A paused channel can be resumed by calling Mix_Resume().
*
* A paused channel with an expiration will not expire while paused (the
* expiration countdown will be adjusted once resumed).
*
* It is legal to halt a paused channel. Playing a new chunk on a paused
* channel will replace the current chunk and unpause the channel.
*
* Specifying a channel of -1 will pause _all_ channels. Any music is
* unaffected.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* \param channel the channel to pause, or -1 to pause all channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_Pause(int channel);
/**
* Resume a particular channel.
*
* It is legal to resume an unpaused or invalid channel; it causes no effect
* and reports no error.
*
* If the paused channel has an expiration, its expiration countdown resumes
* now, as well.
*
* Specifying a channel of -1 will resume _all_ paused channels. Any music is
* unaffected.
*
* \param channel the channel to resume, or -1 to resume all paused channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_Resume(int channel);
/**
* Query whether a particular channel is paused.
*
* If an invalid channel is specified, this function returns zero.
*
* \param channel the channel to query, or -1 to query all channels.
* \return 1 if channel paused, 0 otherwise. If `channel` is -1, returns the
* number of paused channels.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_Paused(int channel);
/**
* Pause the music stream.
*
* Pausing the music stream will prevent further playback of the assigned
* music object, but will maintain the object's current mixing position. When
* resumed, this channel will continue to mix the music where it left off.
*
* Paused music can be resumed by calling Mix_ResumeMusic().
*
* It is legal to halt paused music. Playing a new music object when music is
* paused will replace the current music and unpause the music stream.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
/**
* Resume the music stream.
*
* It is legal to resume an unpaused music stream; it causes no effect and
* reports no error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
/**
* Rewind the music stream.
*
* This causes the currently-playing music to start mixing from the beginning
* of the music, as if it were just started.
*
* It's a legal no-op to rewind the music stream when not playing.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
/**
* Query whether the music stream is paused.
*
* \return 1 if music is paused, 0 otherwise.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_PauseMusic
* \sa Mix_ResumeMusic
*/
extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
/**
* Jump to a given order in mod music.
*
* This only applies to MOD music formats.
*
* \param order order.
* \returns 0 if successful, or -1 if failed or isn't implemented.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC int SDLCALL Mix_ModMusicJumpToOrder(int order);
/**
* Start a track in music object.
*
* This only applies to GME music formats.
*
* \param music the music object.
* \param track the track number to play. 0 is the first track.
* \returns 0 if successful, or -1 if failed or isn't implemented.
*
* \since This function is available since SDL_mixer 2.8.0.
*/
extern DECLSPEC int SDLCALL Mix_StartTrack(Mix_Music *music, int track);
/**
* Get number of tracks in music object.
*
* This only applies to GME music formats.
*
* \param music the music object.
* \returns number of tracks if successful, or -1 if failed or isn't
* implemented.
*
* \since This function is available since SDL_mixer 2.8.0.
*/
extern DECLSPEC int SDLCALL Mix_GetNumTracks(Mix_Music *music);
/**
* Set the current position in the music stream, in seconds.
*
* To convert from milliseconds, divide by 1000.0.
*
* This function is only implemented for MOD music formats (set pattern order
* number) and for WAV, OGG, FLAC, MP3, and MODPLUG music at the moment.
*
* \param position the new position, in seconds (as a double).
* \returns 0 if successful, or -1 if it failed or not implemented.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
/**
* Get the time current position of music stream, in seconds.
*
* To convert to milliseconds, multiply by 1000.0.
*
* \param music the music object to query.
* \returns -1.0 if this feature is not supported for some codec.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music);
/**
* Get a music object's duration, in seconds.
*
* To convert to milliseconds, multiply by 1000.0.
*
* If NULL is passed, returns duration of current playing music.
*
* \param music the music object to query.
* \returns music duration in seconds, or -1.0 on error.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC double SDLCALL Mix_MusicDuration(Mix_Music *music);
/**
* Get the loop start time position of music stream, in seconds.
*
* To convert to milliseconds, multiply by 1000.0.
*
* If NULL is passed, returns duration of current playing music.
*
* \param music the music object to query.
* \returns -1.0 if this feature is not used for this music or not supported
* for some codec.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music);
/**
* Get the loop end time position of music stream, in seconds.
*
* To convert to milliseconds, multiply by 1000.0.
*
* If NULL is passed, returns duration of current playing music.
*
* \param music the music object to query.
* \returns -1.0 if this feature is not used for this music or not supported
* for some codec.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music);
/**
* Get the loop time length of music stream, in seconds.
*
* To convert to milliseconds, multiply by 1000.0.
*
* If NULL is passed, returns duration of current playing music.
*
* \param music the music object to query.
* \returns -1.0 if this feature is not used for this music or not supported
* for some codec.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music);
/**
* Check the playing status of a specific channel.
*
* If the channel is currently playing, this function returns 1. Otherwise it
* returns 0.
*
* If the specified channel is -1, all channels are checked, and this function
* returns the number of channels currently playing.
*
* You may not specify MAX_CHANNEL_POST for a channel.
*
* Paused channels are treated as playing, even though they are not currently
* making forward progress in mixing.
*
* \param channel channel.
* \returns non-zero if channel is playing, zero otherwise. If `channel` is
* -1, return the total number of channel playings.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_Playing(int channel);
/**
* Check the playing status of the music stream.
*
* If music is currently playing, this function returns 1. Otherwise it
* returns 0.
*
* Paused music is treated as playing, even though it is not currently making
* forward progress in mixing.
*
* \returns non-zero if music is playing, zero otherwise.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
/**
* Run an external command as the music stream.
*
* This halts any currently-playing music, and next time the music stream is
* played, SDL_mixer will spawn a process using the command line specified in
* `command`. This command is not subject to shell expansion, and beyond some
* basic splitting up of arguments, is passed to execvp() on most platforms,
* not system().
*
* The command is responsible for generating sound; it is NOT mixed by
* SDL_mixer! SDL_mixer will kill the child process if asked to halt the
* music, but otherwise does not have any control over what the process does.
*
* You are strongly encouraged not to use this function without an extremely
* good reason.
*
* \param command command.
* \returns 0 if successful, -1 on error.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
/**
* This function does nothing, do not use.
*
* This was probably meant to expose a feature, but no codecs support it, so
* it only remains for binary compatibility.
*
* Calling this function is a legal no-op that returns -1.
*
* \param value this parameter is ignored.
* \returns -1.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
/**
* This function does nothing, do not use.
*
* This was probably meant to expose a feature, but no codecs support it, so
* it only remains for binary compatibility.
*
* Calling this function is a legal no-op that returns -1.
*
* \returns -1.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
/**
* Set SoundFonts paths to use by supported MIDI backends.
*
* You may specify multiple paths in a single string by separating them with
* semicolons; they will be searched in the order listed.
*
* This function replaces any previously-specified paths.
*
* Passing a NULL path will remove any previously-specified paths.
*
* Note that unlike most SDL and SDL_mixer functions, this function returns
* zero if there's an error, not on success. We apologize for the API design
* inconsistency here.
*
* \param paths Paths on the filesystem where SoundFonts are available,
* separated by semicolons.
* \returns 1 if successful, 0 on error (out of memory).
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
/**
* Get SoundFonts paths to use by supported MIDI backends.
*
* There are several factors that determine what will be reported by this
* function:
*
* - If the boolean _SDL hint_ `"SDL_FORCE_SOUNDFONTS"` is set, AND the
* `"SDL_SOUNDFONTS"` _environment variable_ is also set, this function will
* return that environment variable regardless of whether
* Mix_SetSoundFounts() was ever called.
* - Otherwise, if Mix_SetSoundFonts() was successfully called with a non-NULL
* path, this function will return the string passed to that function.
* - Otherwise, if the `"SDL_SOUNDFONTS"` variable is set, this function will
* return that environment variable.
* - Otherwise, this function will search some common locations on the
* filesystem, and if it finds a SoundFont there, it will return that.
* - Failing everything else, this function returns NULL.
*
* This returns a pointer to internal (possibly read-only) memory, and it
* should not be modified or free'd by the caller.
*
* \returns semicolon-separated list of sound font paths.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
typedef int (SDLCALL *Mix_EachSoundFontCallback)(const char*, void*);
/**
* Iterate SoundFonts paths to use by supported MIDI backends.
*
* This function will take the string reported by Mix_GetSoundFonts(), split
* it up into separate paths, as delimited by semicolons in the string, and
* call a callback function for each separate path.
*
* If there are no paths available, this returns 0 without calling the
* callback at all.
*
* If the callback returns non-zero, this function stops iterating and returns
* non-zero. If the callback returns 0, this function will continue iterating,
* calling the callback again for further paths. If the callback never returns
* 1, this function returns 0, so this can be used to decide if an available
* soundfont is acceptable for use.
*
* \param function the callback function to call once per path.
* \param data a pointer to pass to the callback for its own personal use.
* \returns non-zero if callback ever returned non-zero, 0 on error or the
* callback never returned non-zero.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_GetSoundFonts
*/
extern DECLSPEC int SDLCALL Mix_EachSoundFont(Mix_EachSoundFontCallback function, void *data);
/**
* Set full path of the Timidity config file.
*
* For example, "/etc/timidity.cfg"
*
* This is obviously only useful if SDL_mixer is using Timidity internally to
* play MIDI files.
*
* \param path path to a Timidity config file.
* \returns 1 if successful, 0 on error.
*
* \since This function is available since SDL_mixer 2.6.0.
*/
extern DECLSPEC int SDLCALL Mix_SetTimidityCfg(const char *path);
/**
* Get full path of a previously-specified Timidity config file.
*
* For example, "/etc/timidity.cfg"
*
* If a path has never been specified, this returns NULL.
*
* This returns a pointer to internal memory, and it should not be modified or
* free'd by the caller.
*
* \returns the previously-specified path, or NULL if not set.
*
* \since This function is available since SDL_mixer 2.6.0.
*
* \sa Mix_SetTimidityCfg
*/
extern DECLSPEC const char* SDLCALL Mix_GetTimidityCfg(void);
/**
* Get the Mix_Chunk currently associated with a mixer channel.
*
* You may not specify MAX_CHANNEL_POST or -1 for a channel.
*
* \param channel the channel to query.
* \returns the associated chunk, if any, or NULL if it's an invalid channel.
*
* \since This function is available since SDL_mixer 2.0.0.
*/
extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
/**
* Close the mixer, halting all playing audio.
*
* Any halted channels will have any currently-registered effects
* deregistered, and will call any callback specified by Mix_ChannelFinished()
* before this function returns.
*
* Any halted music will call any callback specified by
* Mix_HookMusicFinished() before this function returns.
*
* Do not start any new audio playing during callbacks in this function.
*
* This will close the audio device. Attempting to play new audio after this
* function returns will fail, until another successful call to
* Mix_OpenAudio() or Mix_OpenAudioDevice().
*
* Note that (unlike Mix_OpenAudio optionally calling SDL_Init(SDL_INIT_AUDIO)
* on the app's behalf), this will _not_ deinitialize the SDL audio subsystem
* in any case. At some point after calling this function and Mix_Quit(), some
* part of the application should be responsible for calling SDL_Quit() to
* deinitialize all of SDL, including its audio subsystem.
*
* This function should be the last thing you call in SDL_mixer before
* Mix_Quit(). However, the following notes apply if you don't follow this
* advice:
*
* Note that this will not free any loaded chunks or music; you should dispose
* of those resources separately. It is probably poor form to dispose of them
* _after_ this function, but it is safe to call Mix_FreeChunk() and
* Mix_FreeMusic() after closing the device.
*
* Note that any chunks or music you don't free may or may not work if you
* call Mix_OpenAudio again, as the audio device may be in a new format and
* the existing chunks will not be converted to match.
*
* \since This function is available since SDL_mixer 2.0.0.
*
* \sa Mix_Quit
*/
extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
/* We'll use SDL for reporting errors */
/**
* Report SDL_mixer errors
*
* \sa Mix_GetError
*/
#define Mix_SetError SDL_SetError
/**
* Get last SDL_mixer error
*
* \sa Mix_SetError
*/
#define Mix_GetError SDL_GetError
/**
* Clear last SDL_mixer error
*
* \sa Mix_SetError
*/
#define Mix_ClearError SDL_ClearError
/**
* Set OutOfMemory error
*/
#define Mix_OutOfMemory SDL_OutOfMemory
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* SDL_MIXER_H_ */
|