audio

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package audio provides audio processing and playback functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {

	// CreateMedia creates a new Media object based on the specified info.
	CreateMedia(info MediaInfo) Media

	// Play plays the specified media as soon as possible.
	Play(media Media, info PlayInfo) Playback
}

API provides access to a low-level audio manipulation and playback.

func NewNopAPI added in v0.15.0

func NewNopAPI() API

NewNopAPI returns an API that does nothing.

type Media added in v0.15.0

type Media interface {

	// Length returns the duration of the media.
	Length() time.Duration

	// Delete frees any resources used by this media.
	Delete()
}

Media represents a playable audio sequence.

type MediaDataType added in v0.15.0

type MediaDataType int8

MediaDataType indicates the type of media data contained in a data block.

const (
	// MediaDataTypeAuto indicates that the media data type should be
	// automatically detected based on the data.
	MediaDataTypeAuto MediaDataType = iota

	// MediaDataTypeWAV indicates that the media data is in WAV format.
	MediaDataTypeWAV

	// MediaDataTypeMP3 indicates that the media data is in MP3 format.
	MediaDataTypeMP3
)

type MediaInfo added in v0.15.0

type MediaInfo struct {

	// Data is the raw media data.
	Data []byte

	// DataType indicates the type of media data.
	DataType MediaDataType
}

MediaInfo contains the necessary information to create a Media.

type PlayInfo added in v0.15.0

type PlayInfo struct {

	// Loop indicates whether the playback should loop.
	Loop bool

	// Gain indicates the amount of volume, where 1.0 is max and 0.0 is min.
	Gain float64

	// Pan indicates the sound panning, where -1.0 is left, 0.0 is center, and
	// 1.0 is right.
	Pan float64
}

PlayInfo specifies conditions for the playback.

type Playback added in v0.15.0

type Playback interface {

	// Stop causes the playback to stop.
	Stop()
}

Playback represents the audio playback of a media file.

Jump to

Keyboard shortcuts

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