Documentation
¶
Index ¶
- Constants
- func NormalizeSigned[T ~int | ~int16 | ~int32](sample T, bits int) float32
- func ResampledFrameCount(sourceFrames int64, sourceRate int) int64
- func Resume() error
- func Suspend() error
- type Clip
- type DecodedAudio
- type Decoder
- type DecoderSet
- type Format
- type FormatDecoder
- type MemorySource
- type NoDecoder
- type Player
- func (p *Player) Close() error
- func (p *Player) Duration() time.Duration
- func (p *Player) Err() error
- func (p *Player) IsPlaying() bool
- func (p *Player) Pause() error
- func (p *Player) Play() error
- func (p *Player) Position() time.Duration
- func (p *Player) Seek(position time.Duration) error
- func (p *Player) SetVolume(volume float64) error
- func (p *Player) Stop() error
- func (p *Player) Volume() float64
- type Source
Constants ¶
const ( OutputSampleRate = 48000 OutputChannels = 2 BytesPerSample = 4 BytesPerFrame = OutputChannels * BytesPerSample BytesPerSecond = OutputSampleRate * BytesPerFrame )
Variables ¶
This section is empty.
Functions ¶
func ResampledFrameCount ¶
Types ¶
type Clip ¶
type Clip struct {
// contains filtered or unexported fields
}
func DecodeClip ¶
func DecodeClip(format Format, source Source, decode func([]byte) (DecodedAudio, error)) (*Clip, error)
DecodeClip decodes a static source and releases it before returning.
func NewClip ¶
func NewClip(format Format, decoded DecodedAudio) (*Clip, error)
NewClip prepares decoded samples at the engine's fixed stereo sample rate.
func NewStreamingClip ¶
func NewStreamingClip(format Format, source Source, sampleRate int, sourceFrames int64, open func(Source) (io.ReadSeekCloser, error)) (*Clip, error)
NewStreamingClip creates a clip whose format implementation supplies its stream reader. The callback is installed once while loading the resource and is not a runtime registry.
type DecodedAudio ¶
DecodedAudio is the PCM data supplied by an audio format decoder.
type Decoder ¶
Decoder decodes one statically selected collection of audio formats. Implementations are passed to project resource features as type arguments.
type DecoderSet ¶
type DecoderSet[A, B, C, D FormatDecoder] struct{}
DecoderSet is a compile-time collection of audio format decoders. It does not register formats or allocate while choosing a decoder.
func (DecoderSet[A, B, C, D]) DecodeAudio ¶
type FormatDecoder ¶
type FormatDecoder interface {
SupportsAudioFormat(Format) bool
DecodeAudio(Source, Format, bool) (*Clip, error)
}
FormatDecoder handles one audio format in DecoderSet.
type MemorySource ¶
type MemorySource struct {
// contains filtered or unexported fields
}
MemorySource owns one immutable encoded audio byte slice.
func NewMemorySource ¶
func NewMemorySource(data []byte) *MemorySource
NewMemorySource takes ownership of data. It must not be mutated afterward.
func (*MemorySource) Bytes ¶
func (s *MemorySource) Bytes() ([]byte, error)
func (*MemorySource) Close ¶
func (s *MemorySource) Close() error
func (*MemorySource) Open ¶
func (s *MemorySource) Open() (io.ReadSeekCloser, error)
func (*MemorySource) Size ¶
func (s *MemorySource) Size() int64
type NoDecoder ¶
type NoDecoder struct{}
NoDecoder fills an unused DecoderSet slot.