audio

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: BSD-2-Clause, Zlib Imports: 4 Imported by: 0

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

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.

func New

func New() Audio

New provides a default audio implementation.

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().

func (*Data) Set

func (d *Data) Set(channels, sampleBits uint16, frequency, dataSize uint32, data []byte)

Set is a convenience method that populates sound data with the given information. It attempts to reuse the existing sound buffer.

type NoAudio added in v0.8.1

type NoAudio struct{}

NoAudio can be used to mock out audio when audio initialization fails.

func (*NoAudio) BindSound added in v0.8.1

func (na *NoAudio) BindSound(sound, buff *uint64, d *Data) error

BindSound is mocked method for Audio interface.

func (*NoAudio) Dispose added in v0.8.1

func (na *NoAudio) Dispose()

Dispose is mocked method for Audio interface.

func (*NoAudio) Init added in v0.8.1

func (na *NoAudio) Init() error

Init is mocked method for Audio interface.

func (*NoAudio) PlaceListener added in v0.8.1

func (na *NoAudio) PlaceListener(x, y, z float64)

PlaceListener is mocked method for Audio interface.

func (*NoAudio) PlaySound added in v0.8.1

func (na *NoAudio) PlaySound(sound uint64, x, y, z float64)

PlaySound is mocked method for Audio interface.

func (*NoAudio) ReleaseSound added in v0.8.1

func (na *NoAudio) ReleaseSound(sound uint64)

ReleaseSound is mocked method for Audio interface.

func (*NoAudio) SetGain added in v0.8.1

func (na *NoAudio) SetGain(gain float64)

SetGain is mocked method for Audio interface.

Directories

Path Synopsis
Package al provides golang audio library bindings for OpenAL.
Package al provides golang audio library bindings for OpenAL.

Jump to

Keyboard shortcuts

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