audio

package
v0.0.0-...-4f05266 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTL_PLAY = iota
	CTL_PAUSE
	CTL_SKIP
)
View Source
const (
	PCM_TYPE_INT = iota
	PCM_TYPE_FLOAT
)
View Source
const (
	NOT_FOUND = "Unknown"
)

Variables

This section is empty.

Functions

func Clamp

func Clamp(x int, min int, max int) int

func InitializeAudioAPI

func InitializeAudioAPI() error

func PCMWaveFormatToWaveFormatEx

func PCMWaveFormatToWaveFormatEx(pcm *PCMWaveFormat) *win32.WaveFormatExtensible

Types

type AudioClient

type AudioClient interface {
	GetPCMWaveFormat() *PCMWaveFormat

	GetBufferSize() (int, error)
	GetBufferPadding() (int, error)
	LoadToBuffer([]byte) (int, error)
	ClearBuffer() error

	Start() error
	Stop() (bool, error)
}

type AudioSource

type AudioSource interface {
	ReadNext() ([]byte, error)
	SetPCMWaveFormat(*PCMWaveFormat) error
	GetPCMWaveFormat() (*PCMWaveFormat, error)

	GetMetadata() Metadata
}

type AudioSourceProvider

type AudioSourceProvider struct {
	GetAudioSourceFromFile func(filepath string) (AudioSource, error)
}

func GetAudioSourceProvider

func GetAudioSourceProvider() *AudioSourceProvider

type Metadata

type Metadata struct {
	Filepath string

	Title  string
	Artist string
}

func NewMetadata

func NewMetadata() (m *Metadata)

type PCMWaveFormat

type PCMWaveFormat struct {
	NumChannels uint16
	SampleRate  uint32
	SampleDepth uint16
	PCMType     uint32
}

type Player

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

func NewPlayer

func NewPlayer(sources ...AudioSource) (player *Player, err error)

func (*Player) AddSourceToQueue

func (p *Player) AddSourceToQueue(s AudioSource)

func (*Player) Skip

func (p *Player) Skip()

func (*Player) Start

func (p *Player) Start()

func (*Player) Stop

func (p *Player) Stop()

type WinAudioClient

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

func (*WinAudioClient) ClearBuffer

func (winClient *WinAudioClient) ClearBuffer() (err error)

func (*WinAudioClient) GetBufferPadding

func (winClient *WinAudioClient) GetBufferPadding() (padding int, err error)

func (*WinAudioClient) GetBufferSize

func (winClient *WinAudioClient) GetBufferSize() (size int, err error)

func (*WinAudioClient) GetPCMWaveFormat

func (winClient *WinAudioClient) GetPCMWaveFormat() (format *PCMWaveFormat)

func (*WinAudioClient) LoadToBuffer

func (winClient *WinAudioClient) LoadToBuffer(data []byte) (size int, err error)

func (*WinAudioClient) Start

func (winClient *WinAudioClient) Start() (err error)

func (*WinAudioClient) Stop

func (winClient *WinAudioClient) Stop() (wasPlaying bool, err error)

type WinAudioSource

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

func (*WinAudioSource) GetMetadata

func (winSource *WinAudioSource) GetMetadata() Metadata

func (*WinAudioSource) GetPCMWaveFormat

func (winSource *WinAudioSource) GetPCMWaveFormat() (wav *PCMWaveFormat, err error)

func (*WinAudioSource) ReadNext

func (winSource *WinAudioSource) ReadNext() (data []byte, err error)

func (*WinAudioSource) SetPCMWaveFormat

func (winSource *WinAudioSource) SetPCMWaveFormat(wav *PCMWaveFormat) (err error)

Jump to

Keyboard shortcuts

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