Documentation ¶
Overview ¶
Package audio provides access to 3D sound capability. The package is comprised of three interfaces:
- The overall audio system that needs to be initialized on application startup and shutdown on application close. It also needs sound data to be loaded from persistent store and bound to the sound card.
- Sound makers that are associated with a sound, location and volume.
- Sound listeners that are associated with a location.
The expected usage is to initialize the audio system and load some sounds. Then create sound listeners and sound makers. Associate the sound makers with sounds. Finally have the sound makers play sounds that are close enough to the sound listeners to be audible.
Package audio is provided as part of the vu (virtual universe) 3D engine.
Index ¶
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. Shutdown() // Closes and cleans up the audio layer. Mute(mute bool) // Turns the listener gain on/off. BindSound(s *data.Sound) (err error) // Copy sound data to the sound card. }
Audio interacts with the underlying audio layer which in turn interfaces to the sound drivers and hardware. This must be initialized before SoundMakers or SoundListeners can be created and used.
type SoundListener ¶
type SoundListener interface { SetLocation(x, y, z float64) // Listener location. SetVelocity(x, y, z float64) // Listeners movement. SetGain(gain float64) // Crank this up for the hard of hearing. }
SoundListener is the sound receiver. The listeners location relative to where the noise was played determines how much sound comes out of the speakers.
func NewSoundListener ¶
func NewSoundListener() SoundListener
NewSoundListener provides an audio receiver.
type SoundMaker ¶
type SoundMaker interface { SetLocation(x, y, z float64) // Where the noise occurs. SetPitch(pitch float64) // Noise pitch. SetGain(gain float64) // Noise volume. Play() // Make the noise happen now. }
SoundMaker associates a sound with a location and other information. A sound maker will only produce an audible sound if there are active sound listeners within a reasonable distance.
func NewSoundMaker ¶
func NewSoundMaker(sound *data.Sound) SoundMaker
NewSoundMaker provides an audio generator.