go-sdl2: github.com/veandco/go-sdl2/mix Index | Files

package mix

import "github.com/veandco/go-sdl2/mix"

Package mix is an audio mixer library based on the SDL library.

Index

Package Files

midi.go sdl_mixer.go sdl_mixer_cgo.go

Constants

const (
    INIT_FLAC = C.MIX_INIT_FLAC
    INIT_MOD  = C.MIX_INIT_MOD
    INIT_MP3  = C.MIX_INIT_MP3
    INIT_OGG  = C.MIX_INIT_OGG
)

Dynamic libraries init flags used in mix.Init(). (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_9.html)

const (
    CHANNELS          = 8
    DEFAULT_FREQUENCY = C.MIX_DEFAULT_FREQUENCY
    DEFAULT_FORMAT    = C.MIX_DEFAULT_FORMAT
    DEFAULT_CHANNELS  = C.MIX_DEFAULT_CHANNELS
    MAX_VOLUME        = C.MIX_MAX_VOLUME
    CHANNEL_POST      = -2
    EFFECTSMAXSPEED   = "MIX_EFFECTSMAXSPEED"
)

Good default values for a PC soundcard. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_91.html)

const DEFAULT_CHUNKSIZE = 1024

DEFAULT_CHUNKSIZE is the default size of a chunk.

func AllocateChannels Uses

func AllocateChannels(numchans int) int

AllocateChannels dynamically changes the number of channels managed by the mixer. If decreasing the number of channels, the upper channels are stopped. This function returns the new number of allocated channels. Returns: The number of channels allocated. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_26.html)

func ChannelFinished Uses

func ChannelFinished(channelFinished func(int))

ChannelFinished sets the specified channel_finished function to called when channel playback is halted. The channel parameter will contain the channel number that has finished. NOTE: NEVER call SDL_Mixer functions, nor sdl.LockAudio(), from a callback function. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_37.html)

func CloseAudio Uses

func CloseAudio()

CloseAudio shuts down and cleanup the mixer API. After calling this all audio is stopped, the device is closed, and the SDL_mixer functions should not be used. You may, of course, use mix.OpenAudio() to start the functionality again. Note: This function doesn't do anything until you have called it the same number of times that you called mix.OpenAudio(). You may use mix.QuerySpec() to find out how many times mix.CloseAudio() needs to be called before the device is actually closed. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_12.html)

func EachSoundFont Uses

func EachSoundFont(function func(string) int) int

EachSoundFont iterates over SoundFonts paths to use by supported MIDI backends.

func ExpireChannel Uses

func ExpireChannel(channel, ticks int) int

ExpireChannel halts channel playback, or all channels if -1 is passed in, after ticks milliseconds. Any callback set by mix.ChannelFinished() will be called when the channel expires. Returns: Number of channels set to expire. Whether or not they are active. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_35.html)

func FadeOutChannel Uses

func FadeOutChannel(which, ms int) int

FadeOutChannel gradually fades out which channel over ms milliseconds starting from now. The channel will be halted after the fade out is completed. Only channels that are playing are set to fade out, including paused channels. Any callback set by mix.ChannelFinished() will be called when the channel finishes fading out. Returns: The number of channels set to fade out. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_36.html)

func FadeOutGroup Uses

func FadeOutGroup(tag, ms int) int

FadeOutGroup gradually fades out channels in group tag over ms milliseconds starting from now. The channels will be halted after the fade out is completed. Only channels that are playing are set to fade out, including paused channels. Any callback set by mix.ChannelFinished() will be called when each channel finishes fading out. Returns: The number of channels set to fade out. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_50.html)

func FadeOutMusic Uses

func FadeOutMusic(ms int) bool

FadeOutMusic gGradually fades out the music over ms milliseconds starting from now. The music will be halted after the fade out is completed. Only when music is playing and not fading already are set to fade out, including paused channels. Any callback set by mix.HookMusicFinished() will be called when the music finishes fading out. Returns: TRUE on success, FALSE on failure. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_68.html)

func GetChunkDecoder Uses

func GetChunkDecoder(index int) string

GetChunkDecoder reutns the name of the indexed sample chunk decoder. You need to get the number of sample chunk decoders available using the mix.GetNumChunkDecoders() function. Returns: The name of the indexed sample chunk decoder. This string is owned by the SDL_mixer library, do not modify or free it. It is valid until you call mix.CloseAudio() the final time. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_18.html)

func GetMusicDecoder Uses

func GetMusicDecoder(index int) string

GetMusicDecoder returns the name of the indexed music decoder. You need to get the number of music decoders available using the mix.GetNumMusicDecoders() function. Returns: The name of the indexed music decoder. This string is owned by the SDL_mixer library, do not modify or free it. It is valid until you call mix.CloseAudio() the final time. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_54.html)

func GetNumChunkDecoders Uses

func GetNumChunkDecoders() int

GetNumChunkDecoders returns the number of sample chunk decoders available from the mix.GetChunkDecoder() function. This number can be different for each run of a program, due to the change in availability of shared libraries that support each format. Returns: The number of sample chunk decoders available. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_17.html)

func GetNumMusicDecoders Uses

func GetNumMusicDecoders() int

GetNumMusicDecoders returns the number of music decoders available from the mix.GetMusicDecoder() function. This number can be different for each run of a program, due to the change in availability of shared libraries that support each format. Returns: The number of music decoders available. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_53.html)

func GetSoundFonts Uses

func GetSoundFonts() string

GetSoundFonts returns SoundFonts paths to use by supported MIDI backends.

func GetSynchroValue Uses

func GetSynchroValue() int

GetSynchroValue returns the synchro value.

func GroupAvailable Uses

func GroupAvailable(tag int) int

GroupAvailable finds the first available (not playing) channel in group tag. Returns: The channel found on success. -1 is returned when no channels in the group are available. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_47.html)

func GroupChannel Uses

func GroupChannel(which, tag int) bool

GroupChannel adds which channel to group tag, or reset it's group to the default group tag (-1). Returns: True on success. False is returned when the channel specified is invalid. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_44.html)

func GroupChannels Uses

func GroupChannels(from, to, tag int) int

GroupChannels adds channels starting at from up through to to group tag, or reset it's group to the default group tag (-1). Returns: The number of tagged channels on success. If that number is less than to-from+1 then some channels were no tagged because they didn't exist. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_45.html)

func GroupCount Uses

func GroupCount(tag int) int

GroupCount returns the number of channels in group tag. Returns: The number of channels found in the group. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_46.html)

func GroupNewer Uses

func GroupNewer(tag int) int

GroupNewer finds the newest, most recently started, actively playing channel in group tag. Returns: The channel found on success. -1 is returned when no channels in the group are playing or the group is empty. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_49.html)

func GroupOldest Uses

func GroupOldest(tag int) int

GroupOldest finds the oldest actively playing channel in group tag. Returns: The channel found on success. -1 is returned when no channels in the group are playing or the group is empty. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_48.html)

func HaltChannel Uses

func HaltChannel(channel int)

HaltChannel halts the channels playback, or all channels if -1 is passed in. Any callback set by mix.ChannelFinished() will be called. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_34.html)

func HaltGroup Uses

func HaltGroup(tag int)

HaltGroup halts playback on all channels in group tag. Any callback set by mix.ChannelFinished() will be called once for each channel that stops. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_51.html)

func HaltMusic Uses

func HaltMusic()

HaltMusic halts playback of music. This interrupts music fader effects. Any callback set by mix.HookMusicFinished() will be called when the music stops (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_67.html)

func HookMusic Uses

func HookMusic(musicFunc func([]uint8))

HookMusic sets up a custom music player function. The function will be called with arg passed into the udata parameter when the musicFunc is called. The stream parameter passes in the audio stream buffer to be filled with len bytes of music. The music player will then be called automatically when the mixer needs it. Music playing will start as soon as this is called. All the music playing and stopping functions have no effect on music after this. Pause and resume will work. Using a custom music player and the internal music player is not possible, the custom music player takes priority. To stop the custom music player call mix.HookMusic(nil, nil). NOTE: NEVER call SDL_Mixer functions, nor sdl.LockAudio(), from a callback function. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_60.html)

func HookMusicFinished Uses

func HookMusicFinished(musicFinished func())

HookMusicFinished sets up a function to be called when music playback is halted. Any time music stops, the music_finished function will be called. Call with nil to remove the callback. NOTE: NEVER call SDL_Mixer functions, nor sdl.LockAudio, from a callback function. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_69.html)

func Init Uses

func Init(flags int) error

Init loads dynamic libraries and prepares them for use. Flags should be one or more flags from mix.InitFlags OR'd together. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_9.html)

func OpenAudio Uses

func OpenAudio(frequency int, format uint16, channels, chunksize int) error

OpenAudio opens the mixer with a certain audio format. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_11.html)

func Pause Uses

func Pause(channel int)

Pause pauses channel, or all playing channels if -1 is passed in. You may still halt a paused channel. Note: Only channels which are actively playing will be paused. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_32.html)

func PauseMusic Uses

func PauseMusic()

PauseMusic pauses the music playback. You may halt paused music. Note: Music can only be paused if it is actively playing. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_62.html)

func Paused Uses

func Paused(channel int) int

Paused reports whether the channel is paused, or not. Note: Does not check if the channel has been halted after it was paused, which may seem a little weird. Returns: Zero if the channel is not paused. Otherwise if you passed in -1, the number of paused channels is returned. If you passed in a specific channel, then 1 is returned if it is paused. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_39.html)

func PausedMusic Uses

func PausedMusic() bool

PausedMusic reports whether music is paused, or not. Note: Does not check if the music was been halted after it was paused, which may seem a little weird. Returns: FALSE if music is not paused. TRUE if it is paused. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_72.html)

func Playing Uses

func Playing(channel int) int

Playing reports whether the channel is playing, or not. Note: Does not check if the channel has been paused. Returns: Zero if the channel is not playing. Otherwise if you passed in -1, the number of channels playing is returned. If you passed in a specific channel, then 1 is returned if it is playing. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_38.html)

func PlayingMusic Uses

func PlayingMusic() bool

PlayingMusic reports whether music is actively playing, or not. Note: Does not check if the channel has been paused. Returns: Zero if the music is not playing, or 1 if it is playing. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_71.html)

func QuerySpec Uses

func QuerySpec() (frequency int, format uint16, channels int, open int, err error)

QuerySpec returns the actual audio device parameters. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_15.html)

func Quit Uses

func Quit()

Quit unloads libraries loaded with mix.Init(). (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_10.html)

func RegisterEffect Uses

func RegisterEffect(channel int, f EffectFuncT, d EffectDoneT) error

RegisterEffect hooks a processor function f into a channel for post processing effects. You may just be reading the data and displaying it, or you may be altering the stream to add an echo. Most processors also have state data that they allocate as they are in use, this would be stored in the arg pointer data space. When a processor is finished being used, any function passed into d will be called, which is when your processor should clean up the data in the arg data space. The effects are put into a linked list, and always appended to the end, meaning they always work on previously registered effects output. Effects may be added multiple times in a row. Effects are cumulative this way. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_76.html)

func ReserveChannels Uses

func ReserveChannels(num int) int

ReserveChannels reserves num channels from being used when playing samples when passing in -1 as a channel number to playback functions. The channels are reserved starting from channel 0 to num-1. Passing in zero will unreserve all channels. Normally mix starts without any channels reserved. Returns: The number of channels reserved. Never fails, but may return less channels than you ask for, depending on the number of channels previously allocated. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_43.html)

func Resume Uses

func Resume(channel int)

Resume unpauses channel, or all playing and paused channels if -1 is passed in. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_33.html)

func ResumeMusic Uses

func ResumeMusic()

ResumeMusic unpauses the music. This is safe to use on halted, paused, and already playing music. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_63.html)

func RewindMusic Uses

func RewindMusic()

RewindMusic rewinds the music to the start. This is safe to use on halted, paused, and already playing music. It is not useful to rewind the music immediately after starting playback, because it starts at the beginning by default. This function only works for these streams: MOD, OGG, MP3, Native MIDI. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_64.html)

func SetDistance Uses

func SetDistance(channel int, distance uint8) error

SetDistance simulates a simple attenuation of volume due to distance. The volume never quite reaches silence, even at max distance. NOTE: Using a distance of 0 will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use mix.UnregisterAllEffects() on the channel. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_81.html)

func SetMusicCMD Uses

func SetMusicCMD(command string) error

SetMusicCMD sets up a command line music player to use to play music. Any music playing will be halted. The music file to play is set by calling mix.LoadMUS(filename), and the filename is appended as the last argument on the commandline. This allows you to reuse the music command to play multiple files. The command will be sent signals SIGTERM to halt, SIGSTOP to pause, and SIGCONT to resume. The command program should react correctly to those signals for it to function properly with SDL_Mixer. mix.VolumeMusic has no effect when using an external music player, and mix.GetError will have an error code set. You should set the music volume in the music player's command if the music player supports that. Looping music works, by calling the command again when the previous music player process has ended. Playing music through a command uses a forked process to execute the music command. To use the internal music players set the command to nil. NOTE: External music is not mixed by SDL_mixer, so no post-processing hooks will be for music. NOTE: Playing music through an external command may not work if the sound driver does not support multiple openings of the audio device, since SDL_Mixer already has the audio device open for playing samples through channels. NOTE: Commands are not totally portable, so be careful. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_66.html)

func SetMusicPosition Uses

func SetMusicPosition(position int64) error

SetMusicPosition sets the position of the currently playing music. The position takes different meanings for different music sources. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_65.html)

func SetPanning Uses

func SetPanning(channel int, left, right uint8) error

SetPanning sets a panning effect on audio channel. This effect will only work on stereo audio. Meaning you called mix.OpenAudio() with 2 channels (mix.DEFAULT_CHANNELS). The easiest way to do true panning is to call Mix_SetPanning(channel, left, 254 - left); so that the total volume is correct, if you consider the maximum volume to be 127 per channel for center, or 254 max for left, this works, but about halves the effective volume. This Function registers the effect for you, so don't try to mix.RegisterEffect() it yourself. NOTE: Setting both left and right to 255 will unregister the effect from channel. You cannot unregister it any other way, unless you use mix.UnregisterAllEffects() on the channel. NOTE: Using this function on a mono audio device will not register the effect, nor will it return an error status. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_80.html)

func SetPosition Uses

func SetPosition(channel int, angle int16, distance uint8) error

SetPosition emulates a simple 3D audio effect. It's not all that realistic, but it can help improve some level of realism. By giving it the angle and distance from the camera's point of view, the effect pans and attenuates volumes. If you are looking for better positional audio, using OpenAL is suggested. NOTE: Using angle and distance of 0, will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use mix.UnregisterAllEffects() on the channel. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_82.html)

func SetPostMix Uses

func SetPostMix(mixFunc func([]uint8))

SetPostMix hooks a processor function mixFunc to the postmix stream for post processing effects. You may just be reading the data and displaying it, or you may be altering the stream to add an echo. Most processors also have state data that they allocate as they are in use, this would be stored in the arg pointer data space. This processor is never really finished, until the audio device is closed, or you pass nil as the mixFunc. There can only be one postmix function used at a time through this method. Use mix.RegisterEffect(MIX_CHANNEL_POST, mixFunc, nil, arg) to use multiple postmix processors. This postmix processor is run AFTER all the registered postmixers set up by mix.RegisterEffect(). (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_79.html)

func SetReverseStereo Uses

func SetReverseStereo(channel, flip int) error

SetReverseStereo swaps left and right channel sound. NOTE: Using a flip of 0, will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use mix.UnregisterAllEffects() on the channel. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_83.html)

func SetSoundFonts Uses

func SetSoundFonts(paths string) bool

SetSoundFonts sets SoundFonts paths to use by supported MIDI backends.

func SetSynchroValue Uses

func SetSynchroValue(value int) bool

SetSynchroValue sets the synchro value.

func UnregisterAllEffects Uses

func UnregisterAllEffects(channel int) error

UnregisterAllEffects removes all effects registered to channel. If the channel is active all the registered effects will have their mix.EffectDoneT functions called, if they were specified in mix.RegisterEffect(). (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_78.html)

func Volume Uses

func Volume(channel, volume int) int

Volume sets the volume for any allocated channel. If channel is -1 then all channels at are set at once. The volume is applied during the final mix, along with the sample volume. So setting this volume to 64 will halve the output of all samples played on the specified channel. All channels default to a volume of 128, which is the max. Newly allocated channels will have the max volume set, so setting all channels volumes does not affect subsequent channel allocations. Returns: current volume of the channel. If channel is -1, the average volume is returned. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_27.html)

func VolumeMusic Uses

func VolumeMusic(volume int) int

VolumeMusic sets the musics volume, if it is 0 or greater, and return the previous volume setting. Setting the volume during a fade will not work, the faders use this function to perform their effect! Setting volume while using an external music player set by mix.SetMusicCMD() will have no effect, and mix.GetError() will show the reason why not. Returns: The previous volume setting. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_61.html)

type Chunk Uses

type Chunk struct {
    // contains filtered or unexported fields
}

Chunk is the internal format for an audio chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_85.html)

func GetChunk Uses

func GetChunk(channel int) *Chunk

GetChunk returns the most recent sample chunk pointer played on channel. This pointer may be currently playing, or just the last used. Note: The actual chunk may have been freed, so this pointer may not be valid anymore. Returns: Pointer to the mix.Chunk. nil is returned if the channel is not allocated, or if the channel has not played any samples yet. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_41.html)

func LoadWAV Uses

func LoadWAV(file string) (chunk *Chunk, err error)

LoadWAV loads file for use as a sample. This is actually mix.LoadWAVRW(sdl.RWFromFile(file, "rb"), 1). This can load WAVE, AIFF, RIFF, OGG, and VOC files. Note: You must call SDL_OpenAudio before this. It must know the output characteristics so it can convert the sample for playback, it does this conversion at load time. Returns: a pointer to the sample as a mix.Chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_19.html)

func LoadWAVRW Uses

func LoadWAVRW(src *sdl.RWops, freesrc bool) (chunk *Chunk, err error)

LoadWAVRW loads src for use as a sample. This can load WAVE, AIFF, RIFF, OGG, and VOC formats. Note: You must call mix.OpenAudio() before this. It must know the output characteristics so it can convert the sample for playback, it does this conversion at load time. Returns: a pointer to the sample as a mix.Chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_20.html)

func QuickLoadRAW Uses

func QuickLoadRAW(mem *uint8, len_ uint32) (chunk *Chunk, err error)

QuickLoadRAW loads mem as a raw sample. The data in mem must be already in the output format. If you aren't sure what you are doing, this is not a good function for you! Note: This function does very little checking. If the format mismatches the output format it will not return an error. This is probably a dangerous function to use. Returns: a pointer to the sample as a mix.Chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_22.html)

func QuickLoadWAV Uses

func QuickLoadWAV(mem []byte) (chunk *Chunk, err error)

QuickLoadWAV loads mem as a WAVE/RIFF file into a new sample. The WAVE in mem must be already in the output format. It would be better to use mix.LoadWAVRW() if you aren't sure. Note: This function does very little checking. If the format mismatches the output format, or if the buffer is not a WAVE, it will not return an error. This is probably a dangerous function to use. Returns: a pointer to the sample as a mix.Chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_21.html)

func (*Chunk) FadeIn Uses

func (chunk *Chunk) FadeIn(channel, loops, ms int) (channel_ int, err error)

FadeIn plays chunk on channel, or if channel is -1, pick the first free unreserved channel. The channel volume starts at 0 and fades up to full volume over ms milliseconds of time. The sample may end before the fade-in is complete if it is too short or doesn't have enough loops. The sample will play for loops+1 number of times, unless stopped by halt, or fade out, or setting a new expiration time of less time than it would have originally taken to play the loops, or closing the mixer. Note: this just calls mix.FadeInTimed() with ticks set to -1. Returns: the channel the sample is played on. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_30.html)

func (*Chunk) FadeInTimed Uses

func (chunk *Chunk) FadeInTimed(channel, loops, ms, ticks int) (channel_ int, err error)

FadeInTimed plays chunk on channel, or if channel is -1, pick the first free unreserved channel. The channel volume starts at 0 and fades up to full volume over ms milliseconds of time. The sample may end before the fade-in is complete if it is too short or doesn't have enough loops. The sample will play for loops+1 number of times, unless stopped by halt, or fade out, or setting a new expiration time of less time than it would have originally taken to play the loops, or closing the mixer. If the sample is long enough and has enough loops then the sample will stop after ticks milliseconds. Otherwise this function is the same as mix.FadeIn. Returns: the channel the sample is played on. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_31.html)

func (*Chunk) Free Uses

func (chunk *Chunk) Free()

Free frees the memory used in chunk, and frees chunk itself as well. Do not use chunk after this without loading a new sample to it. Note: It's a bad idea to free a chunk that is still being played... (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_24.html)

func (*Chunk) LengthInMs Uses

func (chunk *Chunk) LengthInMs() int

LengthInMs returns the playing time of the chunk in milliseconds.

func (*Chunk) Play Uses

func (chunk *Chunk) Play(channel, loops int) (channel_ int, err error)

Play plays chunk on channel, or if channel is -1, pick the first free unreserved channel. The sample will play for loops+1 number of times, unless stopped by halt, or fade out, or setting a new expiration time of less time than it would have originally taken to play the loops, or closing the mixer. Note: this just calls mix.PlayChannelTimed() with ticks set to -1. Returns: the channel the sample is played on. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_28.html)

func (*Chunk) PlayTimed Uses

func (chunk *Chunk) PlayTimed(channel, loops, ticks int) (channel_ int, err error)

PlayTimed plays chunk on channel, or if channel is -1, pick the first free unreserved channel. The sample will play for loops+1 number of times, unless stopped by halt, or fade out, or setting a new expiration time of less time than it would have originally taken to play the loops, or closing the mixer. If the sample is long enough and has enough loops then the sample will stop after ticks milliseconds. Otherwise this function is the same as mix.PlayChannel(). Returns: the channel the sample is played on. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_29.html)

func (*Chunk) Volume Uses

func (chunk *Chunk) Volume(volume int) int

Volume sets the chunks volume. The volume setting will take effect when the chunk is used on a channel, being mixed into the output. Returns: previous chunks volume setting. If you passed a negative value for volume then this volume is still the current volume for the chunk. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_23.html)

type EffectDoneT Uses

type EffectDoneT func(channel int)

EffectDoneT is the prototype for effect processing functions. These functions are used to apply effects processing on a sample chunk. As a channel plays a sample, the registered effect functions are called. Each effect would then read and perhaps alter the len bytes of stream. It may also be advantageous to keep the effect state in the udata, with would be setup when registering the effect function on a channel. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_90.html)

type EffectFuncT Uses

type EffectFuncT func(channel int, stream []byte)

EffectFuncT is the prototype for effect processing functions. These functions are used to apply effects processing on a sample chunk. As a channel plays a sample, the registered effect functions are called. Each effect would then read and perhaps alter the len bytes of stream. It may also be advantageous to keep the effect state in the udata, with would be setup when registering the effect function on a channel. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_89.html)

type Fading Uses

type Fading int

Fading ia a return value from mix.FadingMusic() and mix.FadingChannel(). If no fading is taking place on the queried channel or music, then mix.NO_FADING is returned. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_88.html)

const (
    NO_FADING Fading = iota
    FADING_OUT
    FADING_IN
)

The different supported fading types. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_88.html)

func FadingChannel Uses

func FadingChannel(which int) Fading

FadingChannel reports whether which channel is fading in, out, or not. Does not tell you if the channel is playing anything, or paused, so you'd need to test that separately. Returns: the fading status. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_40.html)

func FadingMusic Uses

func FadingMusic() Fading

FadingMusic reports whether music is fading in, out, or not at all. Does not tell you if the channel is playing anything, or paused, so you'd need to test that separately. Returns: the fading status. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_73.html)

type Music Uses

type Music C.Mix_Music

Music is a data type used for Music data. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_86.html)

func LoadMUS Uses

func LoadMUS(file string) (mus *Music, err error)

LoadMUS loads music file to use. This can load WAVE, MOD, MIDI, OGG, MP3, FLAC, and any file that you use a command to play with. If you are using an external command to play the music, you must call mix.SetMusicCMD before this, otherwise the internal players will be used. Alternatively, if you have set an external command up and don't want to use it, you must call Mix_SetMusicCMD(nil) to use the built-in players again. Returns: A pointer to a mix.Music. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_55.html)

func LoadMUSRW Uses

func LoadMUSRW(src *sdl.RWops, freesrc int) (mus *Music, err error)

LoadMUSRW loads a music file from an sdl.RWop object (Ogg and MikMod specific currently).

func LoadMUSTypeRW Uses

func LoadMUSTypeRW(src *sdl.RWops, type_ MusicType, freesrc int) (mus *Music, err error)

LoadMUSTypeRW loads a music file from an sdl.RWop object assuming a specific format.

func (*Music) FadeIn Uses

func (music *Music) FadeIn(loops, ms int) error

FadeIn fades in over ms milliseconds of time, the loaded music, playing it loop times through from start to finish. The fade in effect only applies to the first loop. Any previous music will be halted, or if it is fading out it will wait (blocking) for the fade to complete. This function is the same as mix.*Music.FadeInPos(loops, ms, 0). (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_58.html)

func (*Music) FadeInPos Uses

func (music *Music) FadeInPos(loops, ms int, position float64) error

FadeInPos fades in over ms milliseconds of time, the loaded music, playing it loop times through from start to finish. The fade in effect only applies to the first loop. The first time the music is played, it posistion will be set to posistion, which means different things for different types of music files, see mix.SetMusicPosition() for more info on that. Any previous music will be halted, or if it is fading out it will wait (blocking) for the fade to complete. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_59.html)

func (*Music) Free Uses

func (music *Music) Free()

Free frees the loaded music. If music is playing it will be halted. If music is fading out, then this function will wait (blocking) until the fade out is complete. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_56.html)

func (*Music) Play Uses

func (music *Music) Play(loops int) error

Play plays the loaded music loop times through from start to finish. The previous music will be halted, or if fading out it waits (blocking) for that to finish. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_57.html)

func (*Music) Type Uses

func (music *Music) Type() MusicType

Type tells you the file format encoding of the music. This may be handy when used with mix.SetMusicPosition(), and other music functions that vary based on the type of music being played. If you want to know the type of music currently being played, pass in nil to music. Returns: The type of music or if music is nil then the currently playing music type, otherwise NONE if no music is playing. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_70.html)

type MusicType Uses

type MusicType int

MusicType is a file format encoding of the music. (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_87.html)

const (
    NONE MusicType = iota
    CMD
    WAV
    MOD
    MID
    OGG
    MP3
    MP3_MAD
    FLAC
    MODPLUG
)

These are types of music files (not libraries used to load them) (https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_87.html)

Package mix imports 4 packages (graph) and is imported by 8 packages. Updated 2019-03-12. Refresh now. Tools for package owners.