Categorygithub.com/go-audio/audio
modulepackage
1.0.0
Repository: https://github.com/go-audio/audio.git
Documentation: pkg.go.dev

# README

audio

GoDoc

audio is a generic Go package designed to define a common interface to analyze and/or process audio data.

At the heart of the package is the Buffer interface and its implementations:

  • FloatBuffer
  • Float32Buffer
  • IntBuffer

Decoders, encoders, processors, analyzers and transformers can be written to accept or return these types and share a common interface.

The idea is that audio libraries can define this interface or its implementations as input and return an audio.Buffer interface allowing all audio libraries to be chainable.

Performance

The buffer implementations are designed so a buffer can be reused and mutated avoiding allocation penalties.

It is recommended to avoid using Float32Buffer unless performance is critical. The major drawback of using float32s is that the Go stdlib was designed to work with float64 and therefore the access to standard packages is limited.

Usage

Examples of how to use this interface is available under the go-audio organization.

# Functions

IEEEFloatToInt converts a 10 byte IEEE float into an int.
Int24BETo32 converts an int24 value from 3 bytes into an int32 value.
Int24LETo32 converts an int24 value from 3 bytes into an int32 value.
Int32toInt24BEBytes converts an int32 into a big endian 3 byte int24 representation.
Int32toInt24LEBytes converts an int32 into a little endian 3 byte int24 representation.
IntMaxSignedValue returns the max value of an integer based on its memory size.
IntToIEEEFloat converts an int into a 10 byte IEEE float.
Uint24to32 converts a 3 byte uint23 into a uint32 BigEndian!.
Uint32toUint24Bytes converts a uint32 into a 3 byte uint24 representation.

# Constants

DataTypeF32 indicates that the content of the audio buffer made of 32-bit floats.
DataTypeF64 indicates that the content of the audio buffer made of 64-bit floats.
DataTypeI16 indicates that the content of the audio buffer made of 16-bit integers.
DataTypeI32 indicates that the content of the audio buffer made of 32-bit integers.
DataTypeI8 indicates that the content of the audio buffer made of 8-bit integers.
DataTypeUnknown refers to an unknown format.

# Variables

ErrInvalidBuffer is a generic error returned when trying to read/write to an invalid buffer.
FormatMono22500 is mono 22.5kHz format.
FormatMono44100 is mono 8bit 44.1kHz format.
FormatMono48000 is mono 48kHz format.
FormatMono96000 is mono 96kHz format.
FormatStereo22500 is stereo 22.5kHz format.
FormatStereo44100 is stereo 8bit 44.1kHz format.
FormatStereo48000 is stereo 48kHz format.
FormatStereo96000 is stereo 96kHz format.

# Structs

Float32Buffer is an audio buffer with its PCM data formatted as float32.
FloatBuffer is an audio buffer with its PCM data formatted as float64.
Format is a high level representation of the underlying data.
IntBuffer is an audio buffer with its PCM data formatted as int.
PCMBuffer encapsulates uncompressed audio data and provides useful methods to read/manipulate this PCM data.

# Interfaces

Buffer is the representation of an audio buffer.

# Type aliases

PCMDataFormat is an enum type to indicate the underlying data format used.