SDL2 mixer services

Introduced properties

fun close_audio

sdl2 :: Mix :: close_audio

Shutdown and cleanup the mixer API
fun default_format: MixFormat

sdl2 :: Mix :: default_format

Default format for open_audio
fun default_frequency: Int

sdl2 :: Mix :: default_frequency

Default frequency for open_audio (22050)
fun error: CString

sdl2 :: Mix :: error

Last error produced by the mixer API
fun expire_channel(channel: Int, ticks: Int): Int

sdl2 :: Mix :: expire_channel

Halt channel in ticks milliseconds and return the number of channels set to expire
fun flac: MixInitFlags

sdl2 :: Mix :: flac

FLAC format support, for initialize
fun halt_channel(channel: Int)

sdl2 :: Mix :: halt_channel

Halt/stop channel playback
fun initialize(flags: MixInitFlags): MixInitFlags

sdl2 :: Mix :: initialize

Initialize supports for loading formats in flags
fun load_mus(file: CString): MixMusic

sdl2 :: Mix :: load_mus

Load music from file
fun load_wav(file: CString): MixChunk

sdl2 :: Mix :: load_wav

Load file for use as a sample
fun max_volume: Int

sdl2 :: Mix :: max_volume

Maximum volume value for volume_music and volume_chunk
fun mod: MixInitFlags

sdl2 :: Mix :: mod

MOD format support, for initialize
fun mp3: MixInitFlags

sdl2 :: Mix :: mp3

MP3 format support, for initialize
fun ogg: MixInitFlags

sdl2 :: Mix :: ogg

OGG format support, for initialize
fun open_audio(frequency: Int, format: MixFormat, channels: Int, chunk_size: Int): Bool

sdl2 :: Mix :: open_audio

Initialize and configure the mixer API
fun pause(channel: Int)

sdl2 :: Mix :: pause

Pause channel, or all playing channels if -1
fun pause_music

sdl2 :: Mix :: pause_music

Pause music playback
fun play_channel(channel: Int, chunk: MixChunk, loops: Int): Int

sdl2 :: Mix :: play_channel

Play chunk on channel
fun play_channel_timed(channel: Int, chunk: MixChunk, loops: Int, ticks: Int): Int

sdl2 :: Mix :: play_channel_timed

Play chunk on channel
fun play_music(music: MixMusic, loops: Int): Bool

sdl2 :: Mix :: play_music

Play music loops times
fun quit

sdl2 :: Mix :: quit

Clean up all dynamically loaded library handles
fun reserve_channels(num: Int): Int

sdl2 :: Mix :: reserve_channels

Reserve num channels from being used by play_channel(-1...)
fun resume(channel: Int)

sdl2 :: Mix :: resume

Unpause channel, or all paused channels if -1
fun resume_music

sdl2 :: Mix :: resume_music

Resume music playback
fun volume(channel: Int, volume: Int): Int

sdl2 :: Mix :: volume

Set the volume of channel, out of mix.max_volume
fun volume_chunk(chunk: MixChunk, volume: Int)

sdl2 :: Mix :: volume_chunk

Set the volume for chunk, out of mix.max_volume
fun volume_music(volume: Int): Int

sdl2 :: Mix :: volume_music

Set the music volume out of mix.max_volume and return the previous value

Redefined properties

redef type SELF: Mix

sdl2 $ Mix :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun close_audio

sdl2 :: Mix :: close_audio

Shutdown and cleanup the mixer API
fun default_format: MixFormat

sdl2 :: Mix :: default_format

Default format for open_audio
fun default_frequency: Int

sdl2 :: Mix :: default_frequency

Default frequency for open_audio (22050)
fun error: CString

sdl2 :: Mix :: error

Last error produced by the mixer API
fun expire_channel(channel: Int, ticks: Int): Int

sdl2 :: Mix :: expire_channel

Halt channel in ticks milliseconds and return the number of channels set to expire
fun flac: MixInitFlags

sdl2 :: Mix :: flac

FLAC format support, for initialize
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun halt_channel(channel: Int)

sdl2 :: Mix :: halt_channel

Halt/stop channel playback
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun initialize(flags: MixInitFlags): MixInitFlags

sdl2 :: Mix :: initialize

Initialize supports for loading formats in flags
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun load_mus(file: CString): MixMusic

sdl2 :: Mix :: load_mus

Load music from file
fun load_wav(file: CString): MixChunk

sdl2 :: Mix :: load_wav

Load file for use as a sample
fun max_volume: Int

sdl2 :: Mix :: max_volume

Maximum volume value for volume_music and volume_chunk
fun mod: MixInitFlags

sdl2 :: Mix :: mod

MOD format support, for initialize
fun mp3: MixInitFlags

sdl2 :: Mix :: mp3

MP3 format support, for initialize
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun ogg: MixInitFlags

sdl2 :: Mix :: ogg

OGG format support, for initialize
fun open_audio(frequency: Int, format: MixFormat, channels: Int, chunk_size: Int): Bool

sdl2 :: Mix :: open_audio

Initialize and configure the mixer API
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun pause(channel: Int)

sdl2 :: Mix :: pause

Pause channel, or all playing channels if -1
fun pause_music

sdl2 :: Mix :: pause_music

Pause music playback
fun play_channel(channel: Int, chunk: MixChunk, loops: Int): Int

sdl2 :: Mix :: play_channel

Play chunk on channel
fun play_channel_timed(channel: Int, chunk: MixChunk, loops: Int, ticks: Int): Int

sdl2 :: Mix :: play_channel_timed

Play chunk on channel
fun play_music(music: MixMusic, loops: Int): Bool

sdl2 :: Mix :: play_music

Play music loops times
fun quit

sdl2 :: Mix :: quit

Clean up all dynamically loaded library handles
fun reserve_channels(num: Int): Int

sdl2 :: Mix :: reserve_channels

Reserve num channels from being used by play_channel(-1...)
fun resume(channel: Int)

sdl2 :: Mix :: resume

Unpause channel, or all paused channels if -1
fun resume_music

sdl2 :: Mix :: resume_music

Resume music playback
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun volume(channel: Int, volume: Int): Int

sdl2 :: Mix :: volume

Set the volume of channel, out of mix.max_volume
fun volume_chunk(chunk: MixChunk, volume: Int)

sdl2 :: Mix :: volume_chunk

Set the volume for chunk, out of mix.max_volume
fun volume_music(volume: Int): Int

sdl2 :: Mix :: volume_music

Set the music volume out of mix.max_volume and return the previous value
package_diagram sdl2::Mix Mix core::Object Object sdl2::Mix->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

sdl2 $ Mix
# SDL2 mixer services
class Mix
	# Initialize supports for loading formats in `flags`
	#
	# Returns the initialized supports.
	fun initialize(flags: MixInitFlags): MixInitFlags `{
		return Mix_Init(flags);
	`}

	# FLAC format support, for `initialize`
	fun flac: MixInitFlags `{ return MIX_INIT_FLAC; `}

	# MOD format support, for `initialize`
	fun mod: MixInitFlags `{ return MIX_INIT_MOD; `}

	# MP3 format support, for `initialize`
	fun mp3: MixInitFlags `{ return MIX_INIT_MP3; `}

	# OGG format support, for `initialize`
	fun ogg: MixInitFlags `{ return MIX_INIT_OGG; `}

	# Clean up all dynamically loaded library handles
	#
	# May be called after loading all the sounds.
	fun quit `{ Mix_Quit(); `}

	# Initialize and configure the mixer API
	#
	# Playback is configured with:
	# * The output sample `frequency`, in samples per second (Hz).
	# * The output sample `format`, may be `mix_default_format`.
	# * The number of sound `channels`, 1 for mono or 2 for stereo.
	# * The number of bytes used by output sample size as `chunk_size`.
	fun open_audio(frequency: Int, format: MixFormat, channels, chunk_size: Int): Bool `{
		return Mix_OpenAudio(frequency, format, channels, chunk_size) == 0;
	`}

	# Default frequency for `open_audio` (22050)
	fun default_frequency: Int `{ return MIX_DEFAULT_FREQUENCY; `}

	# Default format for `open_audio`
	fun default_format: MixFormat `{ return MIX_DEFAULT_FORMAT; `}
	# TODO other formats: AUDIO_U8, AUDIO_S8, etc.

	# Shutdown and cleanup the mixer API
	fun close_audio `{ Mix_CloseAudio(); `}

	# Last error produced by the mixer API
	fun error: CString `{ return (char*)Mix_GetError(); `}

	# ---
	# Chunks/sounds

	# Load `file` for use as a sample
	#
	# Returns a null pointer on error.
	#
	# Can load WAVE, AIFF, RIFF, OGG and VOC files.
	fun load_wav(file: CString): MixChunk `{ return Mix_LoadWAV(file); `}

	# Play `chunk` on `channel`
	#
	# If `channel == -1` the first unreserved channel is used.
	# The sound is repeated `loops` times, `loops == 0` plays it once,
	# `loops == 1` plays it twice and `loops == -1` loops infinitely.
	#
	# Returns the channel used, or `-1` on error.
	fun play_channel(channel: Int, chunk: MixChunk, loops: Int): Int `{
		return Mix_PlayChannel(channel, chunk, loops);
	`}

	# Play `chunk` on `channel`
	#
	# If `channel == -1` the first unreserved channel is used.
	# The sound is repeated `loops` times, `loops == 0` plays it once,
	# `loops == 1` plays it twice and `loops == -1` loops infinitely.
	# If `ticks != -1`, the sample plays for at most `ticks` milliseconds.
	fun play_channel_timed(channel: Int, chunk: MixChunk, loops, ticks: Int): Int `{
		return Mix_PlayChannelTimed(channel, chunk, loops, ticks);
	`}

	# Halt/stop `channel` playback
	#
	# If `channel == -1`, halt all channels.
	fun halt_channel(channel: Int) `{
		Mix_HaltChannel(channel);
	`}

	# Halt `channel` in `ticks` milliseconds and return the number of channels set to expire
	#
	# If `channel == -1`, halt all channels.
	fun expire_channel(channel, ticks: Int): Int `{
		return Mix_ExpireChannel(channel, ticks);
	`}

	# Reserve `num` channels from being used by `play_channel(-1...)`
	#
	# Returns the number of of channels reserved.
	fun reserve_channels(num: Int): Int `{
		return Mix_ReserveChannels(num);
	`}

	# Set the `volume` of `channel`, out of `mix.max_volume`
	#
	# If `channel == -1`, set the volume of all channels.
	#
	# Returns the current volume of the channel, or if `channel == -1` the average volume.
	fun volume(channel, volume: Int): Int `{
		return Mix_Volume(channel, volume);
	`}

	# Set the `volume` for `chunk`, out of `mix.max_volume`
	#
	# If `volume == -1`, only read the previous value.
	#
	# Returns the previous volume value.
	fun volume_chunk(chunk: MixChunk, volume: Int) `{
		Mix_VolumeChunk(chunk, volume);
	`}

	# Pause `channel`, or all playing channels if -1
	fun pause(channel: Int) `{
		Mix_Pause(channel);
	`}

	# Unpause `channel`, or all paused channels if -1
	fun resume(channel: Int) `{
		Mix_Resume(channel);
	`}

	# ---
	# Music

	# Load music from `file`
	#
	# Returns a null pointer on error.
	#
	# WAVE, MOD, MIDI, OGG, MP3, FLAC VOC files
	fun load_mus(file: CString): MixMusic `{ return Mix_LoadMUS(file); `}

	# Play `music` `loops` times
	#
	# The music is plays once if `loops == 1` and repeats infinitely if `loops == -1`.
	fun play_music(music: MixMusic, loops: Int): Bool `{
		return Mix_PlayMusic(music, loops) == 0;
	`}

	# Pause music playback
	fun pause_music `{ Mix_PauseMusic(); `}

	# Resume music playback
	fun resume_music `{ Mix_ResumeMusic(); `}

	# Set the music volume out of `mix.max_volume` and return the previous value
	#
	# Use `volume = -1` to only read the previous value.
	fun volume_music(volume: Int): Int `{
		return Mix_VolumeMusic(volume);
	`}

	# Maximum volume value for `volume_music` and `volume_chunk`
	fun max_volume: Int `{ return MIX_MAX_VOLUME; `}
end
lib/sdl2/mixer.nit:31,1--193,3