| 1 | package SDL3::Mixer v0.0.7 { | ||
| 2 | use v5.40; | ||
| 3 | use base 'Exporter'; | ||
| 4 | use Affix qw[:all]; | ||
| 5 | use Alien::SDL3; | ||
| 6 | use SDL3 qw[:all]; # Needs core types... | ||
| 7 | use Carp qw[confess croak]; | ||
| 8 | use Config qw[%Config]; | ||
| 9 | |||
| 10 | =encoding utf-8 | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | SDL3::Mixer - Audio File support for SDL3 | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | use v5.40; | ||
| 19 | use SDL3 qw[:all :main]; | ||
| 20 | use SDL3::Mixer qw[:all]; | ||
| 21 | |||
| 22 | # | ||
| 23 | my ( $window, $renderer ); | ||
| 24 | |||
| 25 | # | ||
| 26 | sub SDL_AppInit( $appstate, $argc, @argv ) { | ||
| 27 | return SDL_APP_FAILURE unless SDL_Init(SDL_INIT_VIDEO); | ||
| 28 | return SDL_APP_FAILURE unless SDL_CreateWindowAndRenderer( 'Doooooo', 640, 480, SDL_WINDOW_RESIZABLE, $window, $renderer ); | ||
| 29 | return SDL_APP_FAILURE unless MIX_Init(); | ||
| 30 | |||
| 31 | # Create a mixer on the default audio device. Don't care about the specific audio format. | ||
| 32 | my $mixer = MIX_CreateMixerDevice( SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, undef ) || return SDL_APP_FAILURE; | ||
| 33 | my $audio = MIX_CreateSineWaveAudio( $mixer, 300, 0.25, -1 ) || return SDL_APP_FAILURE; | ||
| 34 | my $track = MIX_CreateTrack($mixer) || return SDL_APP_FAILURE; | ||
| 35 | MIX_SetTrackAudio( $track, $audio ); | ||
| 36 | MIX_PlayTrack( $track, 0 ); | ||
| 37 | return SDL_APP_CONTINUE; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub SDL_AppEvent( $appstate, $event ) { $event->{type} == SDL_EVENT_QUIT ? SDL_APP_SUCCESS : SDL_APP_CONTINUE } | ||
| 41 | |||
| 42 | sub SDL_AppIterate($appstate) { # Does nothing... | ||
| 43 | SDL_RenderClear($renderer); | ||
| 44 | SDL_RenderPresent($renderer); | ||
| 45 | return SDL_APP_CONTINUE; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub SDL_AppQuit( $appstate, $result ) { MIX_Quit() } | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | C<SDL3::Mixer> is a library to make complicated audio processing tasks easier. | ||
| 53 | |||
| 54 | It offers audio file decoding, mixing multiple sounds together, basic 3D positional audio, and various audio effects. | ||
| 55 | |||
| 56 | It can mix sound to multiple audio devices in real time, or generate mixed audio data to a memory buffer for any other | ||
| 57 | use. It can do both at the same time! | ||
| 58 | |||
| 59 | To use the library, first call C<MIX_Init( )>. Then create a mixer with C<MIX_CreateMixerDevice( ... )> (or | ||
| 60 | C<MIX_CreateMixer( ... )> to render to memory). | ||
| 61 | |||
| 62 | Once you have a mixer, you can load sound data with C<MIX_LoadAudio( ... )>, C<MIX_LoadAudio_IO( ... )> , or | ||
| 63 | C<MIX_LoadAudioWithProperties( ... )>. Data gets loaded once and can be played over and over. | ||
| 64 | |||
| 65 | When loading audio, SDL_mixer can parse out several metadata tag formats, such as ID3 and APE tags, and exposes this | ||
| 66 | information through the C<MIX_GetAudioProperties( ... )> function. | ||
| 67 | |||
| 68 | To play audio, you create a track with C<MIX_CreateTrack( [...] )>. You need one track for each sound that will be | ||
| 69 | played simultaneously; think of tracks as individual sliders on a mixer board. You might have loaded hundreds of audio | ||
| 70 | files, but you probably only have a handful of tracks that you assign those loaded files to when they are ready to | ||
| 71 | play, and reuse those tracks with different audio later. Tracks take their input from a C<MIX_Audio> (static data to be | ||
| 72 | played multiple times) or an C<SDL_AudioStream> (streaming PCM audio the app supplies, possibly as needed). A third | ||
| 73 | option is to supply an C<SDL_IOStream>, to load and decode on the fly, which might be more efficient for background | ||
| 74 | music that is only used once, etc. | ||
| 75 | |||
| 76 | Assign input to a C<MIX_Track> with C<MIX_SetTrackAudio( ... )>, C<MIX_SetTrackAudioStream( ... )>, or | ||
| 77 | C<MIX_SetTrackIOStream( ... )>. | ||
| 78 | |||
| 79 | Once a track has an input, start it playing with MIX_PlayTrack(). There are many options to this function to dictate | ||
| 80 | mixing features: looping, fades, etc. | ||
| 81 | |||
| 82 | Tracks can be tagged with arbitrary strings, like "music" or "ingame" or "ui". These tags can be used to start, stop, | ||
| 83 | and pause a selection of tracks at the same moment. | ||
| 84 | |||
| 85 | All significant portions of the mixing pipeline have callbacks, so that an app can hook in to the appropriate locations | ||
| 86 | to examine or modify audio data as it passes through the mixer: a "raw" callback for raw PCM data decoded from an audio | ||
| 87 | file without any modifications, a "cooked" callback for that same data after all transformations (fade, positioning, | ||
| 88 | etc) have been processed, a "stopped" callback for when the track finishes mixing, a "postmix" callback for the final | ||
| 89 | mixed audio about to be sent to the audio hardware to play. Additionally, you can use MIX_Group objects to mix a subset | ||
| 90 | of playing tracks and access the data before it is mixed in with other tracks. All of this is optional, but allows for | ||
| 91 | powerful access and control of the mixing process. | ||
| 92 | |||
| 93 | C<SDL::Mixer> can also be used for decoding audio files without actually rendering a mix. This is done with | ||
| 94 | C<MIX_AudioDecoder>. Even though C<SDL_mixer> handles decoding transparently when used as the audio engine for an app, | ||
| 95 | and probably won't need this interface in that normal scenario, this can be useful when using a different audio library | ||
| 96 | to access many file formats. | ||
| 97 | |||
| 98 | This library offers several features on top of mixing sounds together: a track can have its own gain, to adjust its | ||
| 99 | volume, in addition to a master gain applied as well. One can set the "frequency ratio" of a track or the final mixed | ||
| 100 | output, to speed it up or slow it down, which also adjusts its pitch. A channel map can also be applied per-track, to | ||
| 101 | change what speaker a given channel of audio is output to. | ||
| 102 | |||
| 103 | Almost all timing in SDL_mixer is in sample frames. Stereo PCM audio data in Sint16 format takes 4 bytes per sample | ||
| 104 | frame (2 bytes per sample times 2 channels), for example. This allows everything in SDL_mixer to run at sample-perfect | ||
| 105 | accuracy, and it lets it run without concern for wall clock time--you can produce audio faster than real-time, if | ||
| 106 | desired. The problem, though, is different pieces of audio at different sample rates will produce a different number of | ||
| 107 | sample frames for the same length of time. To deal with this, conversion routines are offered: C<MIX_TrackMSToFrames( | ||
| 108 | ... )>, C<MIX_TrackFramesToMS( ... )>, etc. Functions that operate on multiple tracks at once will deal with time in | ||
| 109 | milliseconds, so it can do these conversions internally; be sure to read the documentation for these small quirks! | ||
| 110 | |||
| 111 | C<SDL::Mixer> offers basic positional audio: a simple 3D positioning API through C<MIX_SetTrack3DPosition( ... )> and | ||
| 112 | C<MIX_SetTrackStereo( ... )>. The former will do simple distance attenuation and spatialization--on a stereo setup, you | ||
| 113 | will hear sounds move from left to right--and on a surround-sound configuration, individual tracks can move around the | ||
| 114 | user. The latter, C<MIX_SetTrackStereo( ... )>, will force a sound to the Front Left and Front Right speakers and let | ||
| 115 | the app pan it left and right as desired. Either effect can be useful for different situations. C<SDL::Mixer> is not | ||
| 116 | meant to be a full 3D audio engine, but rather Good Enough for many purposes; if something more powerful in terms of 3D | ||
| 117 | audio is needed, consider a proper 3D library like OpenAL. | ||
| 118 | |||
| 119 | There are a few examples in this distribution's C<eg/mixer> directory. | ||
| 120 | |||
| 121 | =head2 Features | ||
| 122 | |||
| 123 | Each feature listed below is a tag you may use. | ||
| 124 | |||
| 125 | =head3 C<:all> - SDL3_mixer Audio Functions | ||
| 126 | |||
| 127 | This binds all functions, defines all types, and imports them into your package. | ||
| 128 | |||
| 129 | See L<the SDL3_mixer Wiki|https://wiki.libsdl.org/SDL3_mixer/FrontPage> for documentation of the functions and types | ||
| 130 | you will have access to with this import tag. | ||
| 131 | |||
| 132 | =cut | ||
| 133 | |||
| 134 | my $alien = Alien::SDL3->new; | ||
| 135 | my $info = $alien->alt('libsdl3_mixer')->package_info; | ||
| 136 | croak 'SDL3_mixer is not installed' unless $info; | ||
| 137 | my ($lib) = @{ $info->libfiles }; | ||
| 138 | $ENV{PATH} = join( $Config{path_sep}, ( map { @{ $_->bindirs // [] } } $info ), $ENV{PATH} // '' ); | ||
| 139 | our ( %EXPORT_TAGS, @EXPORT_OK ); | ||
| 140 | |||
| 141 | sub import ( $pkg, @wants ) { | ||
| 142 | { | ||
| 143 | no strict 'refs'; | ||
| 144 | (s[^:][_]r)->() for @wants; | ||
| 145 | } | ||
| 146 | require List::Util; | ||
| 147 | @EXPORT_OK = sort map {@$_} values %EXPORT_TAGS; | ||
| 148 | $EXPORT_TAGS{all} = [@EXPORT_OK]; | ||
| 149 | __PACKAGE__->export_to_level( 1, $pkg, @wants ); | ||
| 150 | } | ||
| 151 | |||
| 152 | sub _affix_and_export ( $name, $args, $ret ) { | ||
| 153 | my ( $n, $r ) = ref $name ? @$name : ( $name, $name ); | ||
| 154 | confess "Failed to affix $n" unless affix( $lib, $name, $args, $ret ); | ||
| 155 | push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $n; | ||
| 156 | } | ||
| 157 | |||
| 158 | sub _const_and_export ( $name, $value ) { | ||
| 159 | no strict 'refs'; | ||
| 160 | *{$name} = sub () {$value}; | ||
| 161 | push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name; | ||
| 162 | } | ||
| 163 | |||
| 164 | sub _func_and_export ( $name, $sub ) { | ||
| 165 | no strict 'refs'; | ||
| 166 | *{$name} = $sub; | ||
| 167 | push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name; | ||
| 168 | } | ||
| 169 | |||
| 170 | sub _typedef_and_export ( $name, $type //= () ) { | ||
| 171 | no strict 'refs'; | ||
| 172 | if ( defined $type ) { | ||
| 173 | typedef $name, $type; | ||
| 174 | } | ||
| 175 | else { | ||
| 176 | typedef $name; | ||
| 177 | } | ||
| 178 | push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name; | ||
| 179 | } | ||
| 180 | |||
| 181 | sub _mixer () { | ||
| 182 | state $done++ && return; | ||
| 183 | _typedef_and_export MIX_Mixer => Void; | ||
| 184 | _typedef_and_export MIX_Audio => Void; | ||
| 185 | _typedef_and_export MIX_Track => Void; | ||
| 186 | _typedef_and_export MIX_Group => Void; | ||
| 187 | _typedef_and_export MIX_AudioDecoder => Void; | ||
| 188 | _affix_and_export MIX_Version => [], Int; | ||
| 189 | _func_and_export MIX_MAJOR_VERSION => sub () { SDL3::SDL_VERSIONNUM_MAJOR( MIX_Version() ) }; | ||
| 190 | _func_and_export MIX_MINOR_VERSION => sub () { SDL3::SDL_VERSIONNUM_MINOR( MIX_Version() ) }; | ||
| 191 | _func_and_export MIX_MICRO_VERSION => sub () { SDL3::SDL_VERSIONNUM_MICRO( MIX_Version() ) }; | ||
| 192 | _func_and_export MIX_VERSION => sub () { SDL3::SDL_VERSIONNUM( MIX_MAJOR_VERSION(), MIX_MINOR_VERSION(), MIX_MICRO_VERSION() ) }; | ||
| 193 | _func_and_export MIX_VERSIONNUM => sub ( $major, $minor, $patch ) { ( ($major) * 1000000 + ($minor) * 1000 + ($patch) ) }; | ||
| 194 | _func_and_export MIX_VERSIONNUM_MAJOR => sub ($version) { int( ($version) / 1000000 ) }; | ||
| 195 | _func_and_export MIX_VERSIONNUM_MINOR => sub ($version) { int( ( ($version) / 1000 ) % 1000 ) }; | ||
| 196 | _func_and_export MIX_VERSIONNUM_MICRO => sub ($version) { int( ($version) % 1000 ) }; | ||
| 197 | _func_and_export MIX_VERSION_ATLEAST => sub ( $X, $Y, $Z ) { ( MIX_VERSION() >= MIX_VERSIONNUM( $X, $Y, $Z ) ) }; | ||
| 198 | _affix_and_export MIX_Init => [], Bool; | ||
| 199 | _affix_and_export MIX_Quit => [], Void; | ||
| 200 | _affix_and_export MIX_GetNumAudioDecoders => [], Int; | ||
| 201 | _affix_and_export MIX_GetAudioDecoder => [Int], String; | ||
| 202 | _affix_and_export MIX_CreateMixerDevice => [ UInt32, Pointer [Void] ], Pointer [ MIX_Mixer() ]; | ||
| 203 | _affix_and_export MIX_CreateMixer => [ Pointer [ SDL3::SDL_AudioSpec() ] ], Pointer [ MIX_Mixer() ]; | ||
| 204 | _affix_and_export MIX_DestroyMixer => [ Pointer [ MIX_Mixer() ] ], Void; | ||
| 205 | _affix_and_export MIX_GetMixerProperties => [ Pointer [ MIX_Mixer() ] ], SDL3::SDL_PropertiesID(); | ||
| 206 | _const_and_export MIX_PROP_MIXER_DEVICE_NUMBER => 'SDL_mixer.mixer.device'; | ||
| 207 | _affix_and_export MIX_GetMixerFormat => [ Pointer [ MIX_Mixer() ], Pointer [ SDL3::SDL_AudioSpec() ] ], Bool; | ||
| 208 | _affix_and_export MIX_LockMixer => [ Pointer [ MIX_Mixer() ] ], Void; | ||
| 209 | _affix_and_export MIX_UnlockMixer => [ Pointer [ MIX_Mixer() ] ], Void; | ||
| 210 | _affix_and_export MIX_LoadAudio_IO => [ Pointer [ MIX_Mixer() ], Pointer [ SDL3::SDL_IOStream() ], Bool, Bool ], Pointer [ MIX_Audio() ]; | ||
| 211 | _affix_and_export MIX_LoadAudio => [ Pointer [ MIX_Mixer() ], String, Bool ], Pointer [ MIX_Audio() ]; | ||
| 212 | _affix_and_export MIX_LoadAudioNoCopy => [ Pointer [ MIX_Mixer() ], Pointer [Void], Size_t, Bool ], Pointer [ MIX_Audio() ]; | ||
| 213 | _affix_and_export MIX_LoadAudioWithProperties => [ SDL3::SDL_PropertiesID() ], Pointer [ MIX_Audio() ]; | ||
| 214 | _const_and_export MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER => 'SDL_mixer.audio.load.iostream'; | ||
| 215 | _const_and_export MIX_PROP_AUDIO_LOAD_CLOSEIO_BOOLEAN => 'SDL_mixer.audio.load.closeio'; | ||
| 216 | _const_and_export MIX_PROP_AUDIO_LOAD_PREDECODE_BOOLEAN => 'SDL_mixer.audio.load.predecode'; | ||
| 217 | _const_and_export MIX_PROP_AUDIO_LOAD_PREFERRED_MIXER_POINTER => 'SDL_mixer.audio.load.preferred_mixer'; | ||
| 218 | _const_and_export MIX_PROP_AUDIO_LOAD_SKIP_METADATA_TAGS_BOOLEAN => 'SDL_mixer.audio.load.skip_metadata_tags'; | ||
| 219 | _const_and_export MIX_PROP_AUDIO_LOAD_IGNORE_LOOPS_BOOLEAN => 'SDL_mixer.audio.load.ignore_loops'; | ||
| 220 | _const_and_export MIX_PROP_AUDIO_DECODER_STRING => 'SDL_mixer.audio.decoder'; | ||
| 221 | _affix_and_export | ||
| 222 | MIX_LoadRawAudio_IO => [ Pointer [ MIX_Mixer() ], Pointer [ SDL3::SDL_IOStream() ], Pointer [ SDL3::SDL_AudioSpec() ], Bool ], | ||
| 223 | Pointer [ MIX_Audio() ]; | ||
| 224 | _affix_and_export | ||
| 225 | MIX_LoadRawAudio => [ Pointer [ MIX_Mixer() ], Pointer [Void], Size_t, Pointer [ SDL3::SDL_AudioSpec() ] ], | ||
| 226 | Pointer [ MIX_Audio() ]; | ||
| 227 | _affix_and_export | ||
| 228 | MIX_LoadRawAudioNoCopy => [ Pointer [ MIX_Mixer() ], Pointer [Void], Size_t, Pointer [ SDL3::SDL_AudioSpec() ], Bool ], | ||
| 229 | Pointer [ MIX_Audio() ]; | ||
| 230 | _affix_and_export MIX_CreateSineWaveAudio => [ Pointer [ MIX_Audio() ], Int, Float, SInt64 ], Pointer [ MIX_Audio() ]; | ||
| 231 | _affix_and_export MIX_GetAudioProperties => [ Pointer [ MIX_Audio() ] ], SDL3::SDL_PropertiesID(); | ||
| 232 | _const_and_export MIX_PROP_METADATA_TITLE_STRING => 'SDL_mixer.metadata.title'; | ||
| 233 | _const_and_export MIX_PROP_METADATA_ARTIST_STRING => 'SDL_mixer.metadata.artist'; | ||
| 234 | _const_and_export MIX_PROP_METADATA_ALBUM_STRING => 'SDL_mixer.metadata.album'; | ||
| 235 | _const_and_export MIX_PROP_METADATA_COPYRIGHT_STRING => 'SDL_mixer.metadata.copyright'; | ||
| 236 | _const_and_export MIX_PROP_METADATA_TRACK_NUMBER => 'SDL_mixer.metadata.track'; | ||
| 237 | _const_and_export MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER => 'SDL_mixer.metadata.total_tracks'; | ||
| 238 | _const_and_export MIX_PROP_METADATA_YEAR_NUMBER => 'SDL_mixer.metadata.year'; | ||
| 239 | _const_and_export MIX_PROP_METADATA_DURATION_FRAMES_NUMBER => 'SDL_mixer.metadata.duration_frames'; | ||
| 240 | _const_and_export MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN => 'SDL_mixer.metadata.duration_infinite'; | ||
| 241 | _affix_and_export MIX_GetAudioDuration => [ Pointer [ MIX_Audio() ] ], SInt64; | ||
| 242 | _const_and_export MIX_DURATION_UNKNOWN => -1; | ||
| 243 | _const_and_export MIX_DURATION_INFINITE => -2; | ||
| 244 | _affix_and_export MIX_GetAudioFormat => [ Pointer [ MIX_Audio() ], Pointer [ SDL3::SDL_AudioSpec() ] ], Bool; | ||
| 245 | _affix_and_export MIX_DestroyAudio => [ Pointer [ MIX_Audio() ] ], Void; | ||
| 246 | _affix_and_export MIX_CreateTrack => [ Pointer [ MIX_Mixer() ] ], Pointer [ MIX_Track() ]; | ||
| 247 | _affix_and_export MIX_DestroyTrack => [ Pointer [ MIX_Track() ] ], Void; | ||
| 248 | _affix_and_export MIX_GetTrackProperties => [ Pointer [ MIX_Track() ] ], SDL3::SDL_PropertiesID(); | ||
| 249 | _affix_and_export MIX_GetTrackMixer => [ Pointer [ MIX_Track() ] ], Pointer [ MIX_Mixer() ]; | ||
| 250 | _affix_and_export MIX_SetTrackAudio => [ Pointer [ MIX_Track() ], Pointer [ MIX_Audio() ] ], Bool; | ||
| 251 | _affix_and_export MIX_SetTrackAudioStream => [ Pointer [ MIX_Track() ], Pointer [ SDL3::SDL_AudioStream() ] ], Bool; | ||
| 252 | _affix_and_export MIX_SetTrackIOStream => [ Pointer [ MIX_Track() ], Pointer [ SDL3::SDL_IOStream() ], Bool ], Bool; | ||
| 253 | _affix_and_export | ||
| 254 | MIX_SetTrackRawIOStream => [ Pointer [ MIX_Track() ], Pointer [ SDL3::SDL_IOStream() ], Pointer [ SDL3::SDL_AudioSpec() ], Bool ], | ||
| 255 | Bool; | ||
| 256 | _affix_and_export MIX_TagTrack => [ Pointer [ MIX_Track() ], String ], Bool; | ||
| 257 | _affix_and_export MIX_UntagTrack => [ Pointer [ MIX_Track() ], String ], Void; | ||
| 258 | _affix_and_export MIX_GetTrackTags => [ Pointer [ MIX_Track() ], Pointer [Int] ], Pointer [String]; | ||
| 259 | _affix_and_export MIX_GetTaggedTracks => [ Pointer [ MIX_Mixer() ], String, Pointer [Int] ], Pointer [ Pointer [ MIX_Track() ] ]; | ||
| 260 | _affix_and_export MIX_SetTrackPlaybackPosition => [ Pointer [ MIX_Track() ], SInt64 ], Bool; | ||
| 261 | _affix_and_export MIX_GetTrackPlaybackPosition => [ Pointer [ MIX_Track() ] ], SInt64; | ||
| 262 | _affix_and_export MIX_GetTrackFadeFrames => [ Pointer [ MIX_Track() ] ], SInt64; | ||
| 263 | _affix_and_export MIX_GetTrackLoops => [ Pointer [ MIX_Track() ] ], Int; | ||
| 264 | _affix_and_export MIX_SetTrackLoops => [ Pointer [ MIX_Track() ], Int ], Bool; | ||
| 265 | _affix_and_export MIX_GetTrackAudio => [ Pointer [ MIX_Track() ] ], Pointer [ MIX_Audio() ]; | ||
| 266 | _affix_and_export MIX_GetTrackAudioStream => [ Pointer [ MIX_Track() ] ], Pointer [ SDL3::SDL_AudioStream() ]; | ||
| 267 | _affix_and_export MIX_GetTrackRemaining => [ Pointer [ MIX_Track() ] ], SInt64; | ||
| 268 | _affix_and_export MIX_TrackMSToFrames => [ Pointer [ MIX_Track() ], SInt64 ], SInt64; | ||
| 269 | _affix_and_export MIX_TrackFramesToMS => [ Pointer [ MIX_Track() ], SInt64 ], SInt64; | ||
| 270 | _affix_and_export MIX_AudioMSToFrames => [ Pointer [ MIX_Audio() ], SInt64 ], SInt64; | ||
| 271 | _affix_and_export MIX_AudioFramesToMS => [ Pointer [ MIX_Audio() ], SInt64 ], SInt64; | ||
| 272 | _affix_and_export MIX_MSToFrames => [ Int, SInt64 ], SInt64; | ||
| 273 | _affix_and_export MIX_FramesToMS => [ Int, SInt64 ], SInt64; | ||
| 274 | _affix_and_export MIX_PlayTrack => [ Pointer [ MIX_Track() ], SDL3::SDL_PropertiesID() ], Bool; | ||
| 275 | _const_and_export MIX_PROP_PLAY_LOOPS_NUMBER => 'SDL_mixer.play.loops'; | ||
| 276 | _const_and_export MIX_PROP_PLAY_MAX_FRAME_NUMBER => 'SDL_mixer.play.max_frame'; | ||
| 277 | _const_and_export MIX_PROP_PLAY_MAX_MILLISECONDS_NUMBER => 'SDL_mixer.play.max_milliseconds'; | ||
| 278 | _const_and_export MIX_PROP_PLAY_START_FRAME_NUMBER => 'SDL_mixer.play.start_frame'; | ||
| 279 | _const_and_export MIX_PROP_PLAY_START_MILLISECOND_NUMBER => 'SDL_mixer.play.start_millisecond'; | ||
| 280 | _const_and_export MIX_PROP_PLAY_START_ORDER_NUMBER => 'SDL_mixer.play.start_order'; | ||
| 281 | _const_and_export MIX_PROP_PLAY_LOOP_START_FRAME_NUMBER => 'SDL_mixer.play.loop_start_frame'; | ||
| 282 | _const_and_export MIX_PROP_PLAY_LOOP_START_MILLISECOND_NUMBER => 'SDL_mixer.play.loop_start_millisecond'; | ||
| 283 | _const_and_export MIX_PROP_PLAY_FADE_IN_FRAMES_NUMBER => 'SDL_mixer.play.fade_in_frames'; | ||
| 284 | _const_and_export MIX_PROP_PLAY_FADE_IN_MILLISECONDS_NUMBER => 'SDL_mixer.play.fade_in_milliseconds'; | ||
| 285 | _const_and_export MIX_PROP_PLAY_FADE_IN_START_GAIN_FLOAT => 'SDL_mixer.play.fade_in_start_gain'; | ||
| 286 | _const_and_export MIX_PROP_PLAY_APPEND_SILENCE_FRAMES_NUMBER => 'SDL_mixer.play.append_silence_frames'; | ||
| 287 | _const_and_export MIX_PROP_PLAY_APPEND_SILENCE_MILLISECONDS_NUMBER => 'SDL_mixer.play.append_silence_milliseconds'; | ||
| 288 | _const_and_export MIX_PROP_PLAY_HALT_WHEN_EXHAUSTED_BOOLEAN => 'SDL_mixer.play.halt_when_exhausted'; | ||
| 289 | _affix_and_export MIX_PlayTag => [ Pointer [ MIX_Mixer() ], String, SDL3::SDL_PropertiesID() ], Bool; | ||
| 290 | _affix_and_export MIX_PlayAudio => [ Pointer [ MIX_Mixer() ], Pointer [ MIX_Audio() ] ], Bool; | ||
| 291 | _affix_and_export MIX_StopTrack => [ Pointer [ MIX_Track() ], SInt64 ], Bool; | ||
| 292 | _affix_and_export MIX_StopAllTracks => [ Pointer [ MIX_Mixer() ], SInt64 ], Bool; | ||
| 293 | _affix_and_export MIX_StopTag => [ Pointer [ MIX_Mixer() ], String, SInt64 ], Bool; | ||
| 294 | _affix_and_export MIX_PauseTrack => [ Pointer [ MIX_Track() ] ], Bool; | ||
| 295 | _affix_and_export MIX_PauseAllTracks => [ Pointer [ MIX_Mixer() ] ], Bool; | ||
| 296 | _affix_and_export MIX_PauseTag => [ Pointer [ MIX_Mixer() ], String ], Bool; | ||
| 297 | _affix_and_export MIX_ResumeTrack => [ Pointer [ MIX_Track() ] ], Bool; | ||
| 298 | _affix_and_export MIX_ResumeAllTracks => [ Pointer [ MIX_Mixer() ] ], Bool; | ||
| 299 | _affix_and_export MIX_ResumeTag => [ Pointer [ MIX_Mixer() ], String ], Bool; | ||
| 300 | _affix_and_export MIX_TrackPlaying => [ Pointer [ MIX_Track() ] ], Bool; | ||
| 301 | _affix_and_export MIX_TrackPaused => [ Pointer [ MIX_Track() ] ], Bool; | ||
| 302 | _affix_and_export MIX_SetMixerGain => [ Pointer [ MIX_Mixer() ], Float ], Bool; | ||
| 303 | _affix_and_export MIX_GetMixerGain => [ Pointer [ MIX_Mixer() ] ], Float; | ||
| 304 | _affix_and_export MIX_SetTrackGain => [ Pointer [ MIX_Track() ], Float ], Bool; | ||
| 305 | _affix_and_export MIX_GetTrackGain => [ Pointer [ MIX_Track() ] ], Float; | ||
| 306 | _affix_and_export MIX_SetTagGain => [ Pointer [ MIX_Mixer() ], String, Float ], Bool; | ||
| 307 | _affix_and_export MIX_SetMixerFrequencyRatio => [ Pointer [ MIX_Mixer() ], Float ], Bool; | ||
| 308 | _affix_and_export MIX_GetMixerFrequencyRatio => [ Pointer [ MIX_Mixer() ] ], Float; | ||
| 309 | _affix_and_export MIX_SetTrackFrequencyRatio => [ Pointer [ MIX_Track() ], Float ], Bool; | ||
| 310 | _affix_and_export MIX_GetTrackFrequencyRatio => [ Pointer [ MIX_Track() ] ], Float; | ||
| 311 | _affix_and_export MIX_SetTrackOutputChannelMap => [ Pointer [ MIX_Track() ], Pointer [Int], Int ], Bool; | ||
| 312 | _typedef_and_export MIX_StereoGains => Struct [ left => Float, right => Float ]; | ||
| 313 | _affix_and_export MIX_SetTrackStereo => [ Pointer [ MIX_Track() ], Pointer [ MIX_StereoGains() ] ], Bool; | ||
| 314 | _typedef_and_export MIX_Point3D => Struct [ x => Float, y => Float, z => Float ]; | ||
| 315 | _affix_and_export MIX_SetTrack3DPosition => [ Pointer [ MIX_Track() ], Pointer [ MIX_Point3D() ] ], Bool; | ||
| 316 | _affix_and_export MIX_GetTrack3DPosition => [ Pointer [ MIX_Track() ], Pointer [ MIX_Point3D() ] ], Bool; | ||
| 317 | _affix_and_export MIX_CreateGroup => [ Pointer [ MIX_Mixer() ] ], Pointer [ MIX_Group() ]; | ||
| 318 | _affix_and_export MIX_DestroyGroup => [ Pointer [ MIX_Group() ] ], Void; | ||
| 319 | _affix_and_export MIX_GetGroupProperties => [ Pointer [ MIX_Group() ] ], SDL3::SDL_PropertiesID(); | ||
| 320 | _affix_and_export MIX_GetGroupMixer => [ Pointer [ MIX_Group() ] ], Pointer [ MIX_Mixer() ]; | ||
| 321 | _affix_and_export MIX_SetTrackGroup => [ Pointer [ MIX_Track() ], Pointer [ MIX_Group() ] ], Bool; | ||
| 322 | _typedef_and_export MIX_TrackStoppedCallback => Callback [ [ Pointer [Void], Pointer [ MIX_Track() ] ] => Void ]; | ||
| 323 | _affix_and_export MIX_SetTrackStoppedCallback => [ Pointer [ MIX_Track() ], MIX_TrackStoppedCallback(), Pointer [Void] ], Bool; | ||
| 324 | _typedef_and_export MIX_TrackMixCallback => | ||
| 325 | Callback [ [ Pointer [Void], Pointer [ MIX_Track() ], Pointer [ SDL3::SDL_AudioSpec() ], Pointer [Float], Int ] => Void ]; | ||
| 326 | _affix_and_export MIX_SetTrackRawCallback => [ Pointer [ MIX_Track() ], MIX_TrackMixCallback(), Pointer [Void] ], Bool; | ||
| 327 | _affix_and_export MIX_SetTrackCookedCallback => [ Pointer [ MIX_Track() ], MIX_TrackMixCallback(), Pointer [Void] ], Bool; | ||
| 328 | _typedef_and_export MIX_GroupMixCallback => | ||
| 329 | Callback [ [ Pointer [Void], Pointer [ MIX_Group() ], Pointer [ SDL3::SDL_AudioSpec() ], Pointer [Float], Int ] => Void ]; | ||
| 330 | _affix_and_export MIX_SetGroupPostMixCallback => [ Pointer [ MIX_Group() ], MIX_GroupMixCallback(), Pointer [Void] ], Bool; | ||
| 331 | _typedef_and_export MIX_PostMixCallback => | ||
| 332 | Callback [ [ Pointer [Void], Pointer [ MIX_Mixer() ], Pointer [ SDL3::SDL_AudioSpec() ], Pointer [Float], Int ] => Void ]; | ||
| 333 | _affix_and_export MIX_SetPostMixCallback => [ Pointer [ MIX_Mixer() ], MIX_PostMixCallback(), Pointer [Void] ], Bool; | ||
| 334 | _affix_and_export MIX_Generate => [ Pointer [ MIX_Mixer() ], Pointer [Void], Int ], Int; | ||
| 335 | _affix_and_export MIX_CreateAudioDecoder => [ String, SDL3::SDL_PropertiesID() ], Pointer [ MIX_AudioDecoder() ]; | ||
| 336 | _affix_and_export | ||
| 337 | MIX_CreateAudioDecoder_IO => [ Pointer [ SDL3::SDL_IOStream() ], Bool, SDL3::SDL_PropertiesID() ], | ||
| 338 | Pointer [ MIX_AudioDecoder() ]; | ||
| 339 | _affix_and_export MIX_DestroyAudioDecoder => [ Pointer [ MIX_AudioDecoder() ] ], Void; | ||
| 340 | _affix_and_export MIX_GetAudioDecoderProperties => [ Pointer [ MIX_AudioDecoder() ] ], SDL3::SDL_PropertiesID(); | ||
| 341 | _affix_and_export MIX_GetAudioDecoderFormat => [ Pointer [ MIX_AudioDecoder() ], Pointer [ SDL3::SDL_AudioSpec() ] ], Bool; | ||
| 342 | _affix_and_export MIX_DecodeAudio => [ Pointer [ MIX_AudioDecoder() ], Pointer [Void], Int, Pointer [ SDL3::SDL_AudioSpec() ] ], Int; | ||
| 343 | } | ||
| 344 | |||
| 345 | sub _all () { | ||
| 346 | state $done++ && return; | ||
| 347 | _mixer(); | ||
| 348 | } | ||
| 349 | } | ||
| 350 | 1; | ||
| 351 | |||
| 352 | =head1 See Also | ||
| 353 | |||
| 354 | The project's repo: L<https://github.com/Perl-SDL3/> | ||
| 355 | |||
| 356 | The SDL3_mixer Wiki: L<https://wiki.libsdl.org/SDL3_mixer/FrontPage> | ||
| 357 | |||
| 358 | L<SDL3> | ||
| 359 | |||
| 360 | L<Affix> | ||
| 361 | |||
| 362 | =head1 LICENSE | ||
| 363 | |||
| 364 | This software is Copyright (c) 2026 by Sanko Robinson. | ||
| 365 | |||
| 366 | This is free software, licensed under: | ||
| 367 | |||
| 368 | The Artistic License 2.0 (GPL Compatible) | ||
| 369 | |||
| 370 | See the F<LICENSE> file for full text. | ||
| 371 | |||
| 372 | =head1 AUTHOR | ||
| 373 | |||
| 374 | Sanko Robinson L<https://github.com/sanko> | ||
| 375 | |||
| 376 | =begin stopwords | ||
| 377 | |||
| 378 | |||
| 379 | =end stopwords | ||
| 380 | |||
| 381 | =cut |