Documentation ¶
Overview ¶
Package audio provides access to 3D sound capability. The expected usage is to initialize the audio system and load sound data. Then play sounds that are close enough to the sound listener to be audible.
Package audio is provided as part of the vu (virtual universe) 3D engine.
Index ¶
- type Audio
- type Data
- type NoAudio
- func (na *NoAudio) BindSound(sound, buff *uint64, d *Data) error
- func (na *NoAudio) Dispose()
- func (na *NoAudio) Init() error
- func (na *NoAudio) PlaceListener(x, y, z float64)
- func (na *NoAudio) PlaySound(sound uint64, x, y, z float64)
- func (na *NoAudio) ReleaseSound(sound uint64)
- func (na *NoAudio) SetGain(gain float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Audio ¶
type Audio interface { Init() error // Get the audio layer up and running. Dispose() // Closes and cleans up the audio layer. SetGain(gain float64) // Volume control: valid values are 0->1. // BindSound copies the sound data to the sound card and returns // references that can be used to dispose of the sound with ReleaseSound. // sound : updated reference to the bound sound. // buff : updated reference to the sound data buffer. // d : sound data bytes and settings to be bound. BindSound(sound, buff *uint64, d *Data) error ReleaseSound(sound uint64) // Control sounds by setting the x,y,z locations for a listener // and the played sounds. While there is only ever one listener, // there can be many sounds. PlaceListener(x, y, z float64) // Only ever one listener. PlaySound(sound uint64, x, y, z float64) // Play the bound sound. }
Audio interacts with the underlying audio layer which in turn interfaces to the sound drivers and hardware. Audio must be initialized once before sounds can be bound and played.
type Data ¶
type Data struct { Name string // Unique sound name. AudioData []byte // The raw audio data. Channels uint16 // Number of audio channels. SampleBits uint16 // 8 bits = 8, 16 bits = 16, etc. Frequency uint32 // 8000, 44100, etc. DataSize uint32 // Audio data size: total file size minus header size. }
Data is a shared audio resource that is used to load sound data onto a sound card using BindSound().
type NoAudio ¶
type NoAudio struct{}
NoAudio can be used to mock out audio when audio initialization fails.
func (*NoAudio) Dispose ¶
func (na *NoAudio) Dispose()
Dispose is mocked method for Audio interface.
func (*NoAudio) PlaceListener ¶
PlaceListener is mocked method for Audio interface.
func (*NoAudio) ReleaseSound ¶
ReleaseSound is mocked method for Audio interface.