audio

package
v1.0.1-0...-c7f6355 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package audio provides support for Allegro's audio addon.

Index

Constants

View Source
const (
	MIXER_QUALITY_POINT  MixerQuality = C.ALLEGRO_MIXER_QUALITY_POINT
	MIXER_QUALITY_LINEAR              = C.ALLEGRO_MIXER_QUALITY_LINEAR
	MIXER_QUALITY_CUBIC               = C.ALLEGRO_MIXER_QUALITY_CUBIC
)
View Source
const (
	AUDIO_DEPTH_INT8     Depth = C.ALLEGRO_AUDIO_DEPTH_INT8
	AUDIO_DEPTH_INT16          = C.ALLEGRO_AUDIO_DEPTH_INT16
	AUDIO_DEPTH_INT24          = C.ALLEGRO_AUDIO_DEPTH_INT24
	AUDIO_DEPTH_FLOAT32        = C.ALLEGRO_AUDIO_DEPTH_FLOAT32
	AUDIO_DEPTH_UNSIGNED       = C.ALLEGRO_AUDIO_DEPTH_UNSIGNED
	AUDIO_DEPTH_UINT8          = C.ALLEGRO_AUDIO_DEPTH_UINT8
	AUDIO_DEPTH_UINT16         = C.ALLEGRO_AUDIO_DEPTH_UINT16
	AUDIO_DEPTH_UINT24         = C.ALLEGRO_AUDIO_DEPTH_UINT24
)
View Source
const (
	CHANNEL_CONF_1   ChannelConf = C.ALLEGRO_CHANNEL_CONF_1
	CHANNEL_CONF_2               = C.ALLEGRO_CHANNEL_CONF_2
	CHANNEL_CONF_3               = C.ALLEGRO_CHANNEL_CONF_3
	CHANNEL_CONF_4               = C.ALLEGRO_CHANNEL_CONF_4
	CHANNEL_CONF_5_1             = C.ALLEGRO_CHANNEL_CONF_5_1
	CHANNEL_CONF_6_1             = C.ALLEGRO_CHANNEL_CONF_6_1
	CHANNEL_CONF_7_1             = C.ALLEGRO_CHANNEL_CONF_7_1
)
View Source
const (
	PLAYMODE_ONCE  PlayMode = C.ALLEGRO_PLAYMODE_ONCE
	PLAYMODE_LOOP           = C.ALLEGRO_PLAYMODE_LOOP
	PLAYMODE_BIDIR          = C.ALLEGRO_PLAYMODE_BIDIR
)
View Source
const AUDIO_PAN_NONE float32 = -1000.0

Variables

View Source
var ErrCantWriteFragment = errors.New("failed to write to audio stream fragment")
View Source
var ErrNoAvailableFragments = errors.New("no available fragments for audio stream")

Functions

func Install

func Install() error

Install the audio subsystem.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_install_audio

func IsAudioInstalled

func IsAudioInstalled() bool

Returns true if al_install_audio was called previously and returned successfully.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_is_audio_installed

func ReserveSamples

func ReserveSamples(reserve_samples int) error

Reserves a number of sample instances, attaching them to the default mixer. If no default mixer is set when this function is called, then it will create one and attach it to the default voice. If no default voice has been set, it, too, will be created.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_reserve_samples

func RestoreDefaultMixer

func RestoreDefaultMixer() error

Restores Allegro's default mixer and attaches it to the default voice. If the default mixer hasn't been created before, it will be created. If the default voice hasn't been set via al_set_default_voice or created before, it will also be created. All samples started with al_play_sample will be stopped and all sample instances returned by al_lock_sample_id will be invalidated.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_restore_default_mixer

func SetDefaultMixer

func SetDefaultMixer(mixer *Mixer) error

Sets the default mixer. All samples started with al_play_sample will be stopped and all sample instances returned by al_lock_sample_id will be invalidated. If you are using your own mixer, this should be called before al_reserve_samples.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_default_mixer

func StopSamples

func StopSamples()

Stop all samples started by al_play_sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_stop_samples

func Uninstall

func Uninstall()

Uninstalls the audio subsystem.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_uninstall_audio

func Version

func Version() (major, minor, revision, release uint8)

Returns the (compiled) version of the addon, in the same format as al_get_allegro_version.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_allegro_audio_version

Types

type AudioStreamFinished

type AudioStreamFinished interface {
	// contains filtered or unexported methods
}

type AudioStreamFragment

type AudioStreamFragment interface {
	// contains filtered or unexported methods
}

type ChannelConf

type ChannelConf C.ALLEGRO_CHANNEL_CONF

func (ChannelConf) ChannelCount

func (conf ChannelConf) ChannelCount() uint

Return the number of channels for the given channel configuration, which is one of the values listed under ALLEGRO_CHANNEL_CONF.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_channel_count

type Depth

type Depth C.ALLEGRO_AUDIO_DEPTH

func (Depth) Size

func (depth Depth) Size() uint

Return the size of a sample, in bytes, for the given format. The format is one of the values listed under ALLEGRO_AUDIO_DEPTH.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_depth_size

type Mixer

type Mixer C.ALLEGRO_MIXER

func CreateMixer

func CreateMixer(freq uint, depth Depth, chan_conf ChannelConf) (*Mixer, error)

Creates a mixer to attach sample instances, audio streams, or other mixers to. It will mix into a buffer at the requested frequency (in Hz) and channel count.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_create_mixer

func DefaultMixer

func DefaultMixer() *Mixer

Return the default mixer, or NULL if one has not been set. Although different configurations of mixers and voices can be used, in most cases a single mixer attached to a voice is what you want. The default mixer is used by al_play_sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_default_mixer

func (*Mixer) AttachToMixer

func (m *Mixer) AttachToMixer(mixer *Mixer) error

Attaches the mixer passed as the first argument onto the mixer passed as the second argument. The first mixer (that is going to be attached) must not already be attached to anything. Both mixers must use the same frequency, audio depth and channel configuration.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_mixer_to_mixer

func (*Mixer) AttachToVoice

func (m *Mixer) AttachToVoice(voice *Voice) error

Attaches a mixer to a voice. It must have the same frequency and channel configuration, but the depth may be different.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_mixer_to_voice

func (*Mixer) Attached

func (m *Mixer) Attached() bool

Return true if the mixer is attached to something.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_attached

func (*Mixer) Channels

func (m *Mixer) Channels() ChannelConf

Return the mixer channel configuration.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_channels

func (*Mixer) Depth

func (m *Mixer) Depth() Depth

Return the mixer audio depth.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_depth

func (*Mixer) Destroy

func (m *Mixer) Destroy()

Destroys the mixer.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_destroy_mixer

func (*Mixer) Detach

func (m *Mixer) Detach() error

Detach the mixer from whatever it is attached to, if anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_detach_mixer

func (*Mixer) Frequency

func (m *Mixer) Frequency() uint

Return the mixer frequency (in Hz).

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_frequency

func (*Mixer) Gain

func (m *Mixer) Gain() float32

Return the mixer gain (amplification factor). The default is 1.0.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_gain

func (*Mixer) Playing

func (m *Mixer) Playing() bool

Return true if the mixer is playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_playing

func (*Mixer) Quality

func (m *Mixer) Quality() MixerQuality

Return the mixer quality.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_mixer_quality

func (*Mixer) SetFrequency

func (m *Mixer) SetFrequency(val uint) error

Set the mixer frequency (in Hz). This will only work if the mixer is not attached to anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_mixer_frequency

func (*Mixer) SetGain

func (m *Mixer) SetGain(val float32) error

Set the mixer gain (amplification factor).

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_mixer_gain

func (*Mixer) SetPlaying

func (m *Mixer) SetPlaying(val bool) error

Change whether the mixer is playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_mixer_playing

func (*Mixer) SetQuality

func (m *Mixer) SetQuality(quality MixerQuality) error

Set the mixer quality. This can only succeed if the mixer does not have anything attached to it.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_mixer_quality

type MixerQuality

type MixerQuality C.ALLEGRO_MIXER_QUALITY

type PlayMode

type PlayMode C.ALLEGRO_PLAYMODE

type Sample

type Sample C.ALLEGRO_SAMPLE

func CreateSample

func CreateSample(samples, freq uint, depth Depth, chan_conf ChannelConf) *Sample

Create a sample data structure from the supplied buffer. If free_buf is true then the buffer will be freed with al_free when the sample data structure is destroyed. For portability (especially Windows), the buffer should have been allocated with al_malloc. Otherwise you should free the sample data yourself.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_create_sample

func LoadSample

func LoadSample(filename string) (*Sample, error)

Loads a few different audio file formats based on their extension.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_load_sample

func LoadSampleF

func LoadSampleF(f *allegro.File, ident string) (*Sample, error)

Loads an audio file from an ALLEGRO_FILE stream into an ALLEGRO_SAMPLE. The file type is determined by the passed 'ident' parameter, which is a file name extension including the leading dot.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_load_sample_f

func (*Sample) Channels

func (s *Sample) Channels() ChannelConf

Return the channel configuration of the sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_channels

func (*Sample) Data

func (s *Sample) Data() uintptr

Return a pointer to the raw sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_data

func (*Sample) Depth

func (s *Sample) Depth() Depth

Return the audio depth of the sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_depth

func (*Sample) Destroy

func (s *Sample) Destroy()

Free the sample data structure. If it was created with the free_buf parameter set to true, then the buffer will be freed with al_free.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_destroy_sample

func (*Sample) Frequency

func (s *Sample) Frequency() uint

Return the frequency (in Hz) of the sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_frequency

func (*Sample) Length

func (s *Sample) Length() uint

Return the length of the sample in sample values.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_length

func (*Sample) Play

func (s *Sample) Play(gain, pan, speed float32, loop PlayMode) (*SampleID, error)

Plays a sample on one of the sample instances created by al_reserve_samples. Returns true on success, false on failure. Playback may fail because all the reserved sample instances are currently used.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_play_sample

func (*Sample) Save

func (s *Sample) Save(filename string) error

Writes a sample into a file. Currently, wav is the only supported format, and the extension must be ".wav".

See https://liballeg.org/a5docs/5.2.6/audio.html#al_save_sample

func (*Sample) SaveF

func (s *Sample) SaveF(f *allegro.File, ident string) error

Writes a sample into a ALLEGRO_FILE filestream. Currently, wav is the only supported format, and the extension must be ".wav".

See https://liballeg.org/a5docs/5.2.6/audio.html#al_save_sample_f

type SampleID

type SampleID C.ALLEGRO_SAMPLE_ID

func (*SampleID) Stop

func (s *SampleID) Stop()

Stop the sample started by al_play_sample.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_stop_sample

type SampleInstance

type SampleInstance C.ALLEGRO_SAMPLE_INSTANCE

func CreateSampleInstance

func CreateSampleInstance(sample_data *Sample) *SampleInstance

Creates a sample instance, using the supplied sample data. The instance must be attached to a mixer (or voice) in order to actually produce output.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_create_sample_instance

func (*SampleInstance) AttachToMixer

func (s *SampleInstance) AttachToMixer(mixer *Mixer) error

Attach a sample instance to a mixer. The instance must not already be attached to anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_sample_instance_to_mixer

func (*SampleInstance) AttachToVoice

func (s *SampleInstance) AttachToVoice(voice *Voice) error

Attaches a sample instance to a voice, and allows it to play. The instance's gain and loop mode will be ignored, and it must have the same frequency, channel configuration and depth (including signed-ness) as the voice. This function may fail if the selected driver doesn't support preloading sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_sample_instance_to_voice

func (*SampleInstance) Attached

func (s *SampleInstance) Attached() bool

Return whether the sample instance is attached to something.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_attached

func (*SampleInstance) Channels

func (s *SampleInstance) Channels() ChannelConf

Return the channel configuration of the sample instance's sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_channels

func (*SampleInstance) Depth

func (s *SampleInstance) Depth() Depth

Return the audio depth of the sample instance's sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_depth

func (*SampleInstance) Destroy

func (s *SampleInstance) Destroy()

Detaches the sample instance from anything it may be attached to and frees it (the sample data, i.e. its ALLEGRO_SAMPLE, is not freed!).

See https://liballeg.org/a5docs/5.2.6/audio.html#al_destroy_sample_instance

func (*SampleInstance) Detach

func (s *SampleInstance) Detach() error

Detach the sample instance from whatever it's attached to, if anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_detach_sample_instance

func (*SampleInstance) Frequency

func (s *SampleInstance) Frequency() uint

Return the frequency (in Hz) of the sample instance's sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_frequency

func (*SampleInstance) Gain

func (s *SampleInstance) Gain() float32

Return the playback gain of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_gain

func (*SampleInstance) Length

func (s *SampleInstance) Length() uint

Return the length of the sample instance in sample values. This property may differ from the length of the instance's sample data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_length

func (*SampleInstance) Pan

func (s *SampleInstance) Pan() float32

Get the pan value of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_pan

func (*SampleInstance) Play

func (s *SampleInstance) Play() error

Play the sample instance. Returns true on success, false on failure.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_play_sample_instance

func (*SampleInstance) PlayMode

func (s *SampleInstance) PlayMode() PlayMode

Return the playback mode of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_playmode

func (*SampleInstance) Playing

func (s *SampleInstance) Playing() bool

Return true if the sample instance is in the playing state. This may be true even if the instance is not attached to anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_playing

func (*SampleInstance) Position

func (s *SampleInstance) Position() uint

Get the playback position of a sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_position

func (*SampleInstance) SetGain

func (s *SampleInstance) SetGain(val float32) error

Set the playback gain of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_gain

func (*SampleInstance) SetLength

func (s *SampleInstance) SetLength(val uint) error

Set the length of the sample instance in sample values. This can be used to play only parts of the underlying sample. Be careful not to exceed the actual length of the sample data, though.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_length

func (*SampleInstance) SetPan

func (s *SampleInstance) SetPan(val float32) error

Set the pan value on a sample instance. A value of -1.0 means to play the sample only through the left speaker; +1.0 means only through the right speaker; 0.0 means the sample is centre balanced. A special value ALLEGRO_AUDIO_PAN_NONE disables panning and plays the sample at its original level. This will be louder than a pan value of 0.0.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_pan

func (*SampleInstance) SetPlayMode

func (s *SampleInstance) SetPlayMode(val PlayMode) error

Set the playback mode of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_playmode

func (*SampleInstance) SetPlaying

func (s *SampleInstance) SetPlaying(val bool) error

Change whether the sample instance is playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_playing

func (*SampleInstance) SetPosition

func (s *SampleInstance) SetPosition(val uint) error

Set the playback position of a sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_position

func (*SampleInstance) SetSpeed

func (s *SampleInstance) SetSpeed(val float32) error

Set the relative playback speed of the sample instance. 1.0 means normal speed.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_sample_instance_speed

func (*SampleInstance) Speed

func (s *SampleInstance) Speed() float32

Return the relative playback speed of the sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_speed

func (*SampleInstance) Stop

func (s *SampleInstance) Stop() error

Stop an sample instance playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_stop_sample_instance

func (*SampleInstance) Time

func (s *SampleInstance) Time() float32

Return the length of the sample instance in seconds, assuming a playback speed of 1.0.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_sample_instance_time

type Stream

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

func CreateStream

func CreateStream(fragment_count, frag_samples, freq uint, depth Depth, chan_conf ChannelConf) *Stream

Creates an ALLEGRO_AUDIO_STREAM. The stream will be set to play by default. It will feed audio data from a buffer, which is split into a number of fragments.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_create_audio_stream

func LoadStream

func LoadStream(filename string, buffer_count, samples uint) (*Stream, error)

Loads an audio file from disk as it is needed.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_load_audio_stream

func LoadStreamF

func LoadStreamF(f *allegro.File, ident string, buffer_count, samples uint) (*Stream, error)

Loads an audio file from ALLEGRO_FILE stream as it is needed.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_load_audio_stream_f

func (*Stream) AttachToMixer

func (s *Stream) AttachToMixer(mixer *Mixer) error

Attach an audio stream to a mixer. The stream must not already be attached to anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_audio_stream_to_mixer

func (*Stream) AttachToVoice

func (s *Stream) AttachToVoice(voice *Voice) error

Attaches an audio stream to a voice. The same rules as al_attach_sample_instance_to_voice apply. This may fail if the driver can't create a voice with the buffer count and buffer size the stream uses.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_attach_audio_stream_to_voice

func (*Stream) Attached

func (s *Stream) Attached() bool

Return whether the stream is attached to something.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_attached

func (*Stream) AvailableFragments

func (s *Stream) AvailableFragments() uint

Returns the number of available fragments in the stream, that is, fragments which are not currently filled with data for playback.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_available_audio_stream_fragments

func (*Stream) Channels

func (s *Stream) Channels() ChannelConf

Return the stream channel configuration.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_channels

func (*Stream) Depth

func (s *Stream) Depth() Depth

Return the stream audio depth.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_depth

func (*Stream) Destroy

func (s *Stream) Destroy()

Destroy an audio stream which was created with al_create_audio_stream or al_load_audio_stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_destroy_audio_stream

func (*Stream) Detach

func (s *Stream) Detach() error

Detach the stream from whatever it's attached to, if anything.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_detach_audio_stream

func (*Stream) Drain

func (s *Stream) Drain()

You should call this to finalise an audio stream that you will no longer be feeding, to wait for all pending buffers to finish playing. The stream's playing state will change to false.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_drain_audio_stream

func (*Stream) EventSource

func (s *Stream) EventSource() *allegro.EventSource

Retrieve the associated event source.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_event_source

func (*Stream) Fragments

func (s *Stream) Fragments() uint

Returns the number of fragments this stream uses. This is the same value as passed to al_create_audio_stream when a new stream is created.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_fragments

func (*Stream) Frequency

func (s *Stream) Frequency() uint

Return the stream frequency (in Hz).

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_frequency

func (*Stream) Gain

func (s *Stream) Gain() float32

Return the playback gain of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_gain

func (*Stream) Length

func (s *Stream) Length() uint

Return the stream length in samples.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_length

func (*Stream) LengthSecs

func (s *Stream) LengthSecs() float64

Return the length of the stream in seconds, if known. Otherwise returns zero.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_length_secs

func (*Stream) Pan

func (s *Stream) Pan() float32

Get the pan value of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_pan

func (*Stream) PlayMode

func (s *Stream) PlayMode() PlayMode

Return the playback mode of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_playmode

func (*Stream) Playing

func (s *Stream) Playing() bool

Return true if the stream is playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_playing

func (*Stream) PositionSecs

func (s *Stream) PositionSecs() float64

Return the position of the stream in seconds. Currently this can only be called on streams created with al_load_audio_stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_position_secs

func (*Stream) Rewind

func (s *Stream) Rewind() error

Set the streaming file playing position to the beginning. Returns true on success. Currently this can only be called on streams created with al_load_audio_stream, al_load_audio_stream_f and the format-specific functions underlying those functions.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_rewind_audio_stream

func (*Stream) SeekSecs

func (s *Stream) SeekSecs(time float64) error

Set the streaming file playing position to time. Returns true on success. Currently this can only be called on streams created with al_load_audio_stream, al_load_audio_stream_f and the format-specific functions underlying those functions.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_seek_audio_stream_secs

func (*Stream) SetGain

func (s *Stream) SetGain(val float32) error

Set the playback gain of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_gain

func (*Stream) SetLoopSecs

func (s *Stream) SetLoopSecs(start, end float64) error

Sets the loop points for the stream in seconds. Currently this can only be called on streams created with al_load_audio_stream, al_load_audio_stream_f and the format-specific functions underlying those functions.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_loop_secs

func (*Stream) SetPan

func (s *Stream) SetPan(val float32) error

Set the pan value on an audio stream. A value of -1.0 means to play the stream only through the left speaker; +1.0 means only through the right speaker; 0.0 means the sample is centre balanced. A special value ALLEGRO_AUDIO_PAN_NONE disables panning and plays the stream at its original level. This will be louder than a pan value of 0.0.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_pan

func (*Stream) SetPlayMode

func (s *Stream) SetPlayMode(val PlayMode) error

Set the playback mode of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_playmode

func (*Stream) SetPlaying

func (s *Stream) SetPlaying(val bool) error

Change whether the stream is playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_playing

func (*Stream) SetSpeed

func (s *Stream) SetSpeed(val float32) error

Set the relative playback speed of the stream. 1.0 means normal speed.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_speed

func (*Stream) Speed

func (s *Stream) Speed() float32

Return the relative playback speed of the stream.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_audio_stream_speed

func (*Stream) Write

func (s *Stream) Write(p []byte) (n int, err error)

This function needs to be called for every successful call of al_get_audio_stream_fragment to indicate that the buffer (pointed to by val) is filled with new data.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_audio_stream_fragment

type Voice

type Voice C.ALLEGRO_VOICE

func CreateVoice

func CreateVoice(freq uint, depth Depth, chan_conf ChannelConf) *Voice

Creates a voice structure and allocates a voice from the digital sound driver. The passed frequency (in Hz), sample format and channel configuration are used as a hint to what kind of data will be sent to the voice. However, the underlying sound driver is free to use non-matching values. For example, it may be the native format of the sound hardware.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_create_voice

func (*Voice) Channels

func (v *Voice) Channels() ChannelConf

Return the channel configuration of the voice.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_voice_channels

func (*Voice) Depth

func (v *Voice) Depth() Depth

Return the audio depth of the voice.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_voice_depth

func (*Voice) Destroy

func (v *Voice) Destroy()

Destroys the voice and deallocates it from the digital driver. Does nothing if the voice is NULL.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_destroy_voice

func (*Voice) Detach

func (v *Voice) Detach()

Detaches the mixer, sample instance or audio stream from the voice.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_detach_voice

func (*Voice) Frequency

func (v *Voice) Frequency() uint

Return the frequency of the voice (in Hz), e.g. 44100.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_voice_frequency

func (*Voice) IsPlaying

func (v *Voice) IsPlaying() bool

Return true if the voice is currently playing.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_voice_playing

func (*Voice) Position

func (v *Voice) Position() uint

When the voice has a non-streaming object attached to it, e.g. a sample, returns the voice's current sample position. Otherwise, returns zero.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_get_voice_position

func (*Voice) SetPlaying

func (v *Voice) SetPlaying(val bool) error

Change whether a voice is playing or not. This can only work if the voice has a non-streaming object attached to it, e.g. a sample instance. On success the voice's current sample position is reset.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_voice_playing

func (*Voice) SetPosition

func (v *Voice) SetPosition(val uint) error

Set the voice position. This can only work if the voice has a non-streaming object attached to it, e.g. a sample instance.

See https://liballeg.org/a5docs/5.2.6/audio.html#al_set_voice_position

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL