pcm

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Unlicense Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// SampleDataFormat8BitUnsigned is for unsigned 8-bit data
	SampleDataFormat8BitUnsigned = SampleDataFormat(iota)
	// SampleDataFormat8BitSigned is for signed 8-bit data
	SampleDataFormat8BitSigned
	// SampleDataFormat16BitLEUnsigned is for unsigned, little-endian, 16-bit data
	SampleDataFormat16BitLEUnsigned
	// SampleDataFormat16BitLESigned is for signed, little-endian, 16-bit data
	SampleDataFormat16BitLESigned
	// SampleDataFormat16BitBEUnsigned is for unsigned, big-endian, 16-bit data
	SampleDataFormat16BitBEUnsigned
	// SampleDataFormat16BitBESigned is for signed, big-endian, 16-bit data
	SampleDataFormat16BitBESigned
	// SampleDataFormat32BitLEFloat is for little-endian, 32-bit floating-point data
	SampleDataFormat32BitLEFloat
	// SampleDataFormat32BitBEFloat is for big-endian, 32-bit floating-point data
	SampleDataFormat32BitBEFloat
	// SampleDataFormat64BitLEFloat is for little-endian, 64-bit floating-point data
	SampleDataFormat64BitLEFloat
	// SampleDataFormat64BitBEFloat is for big-endian, 64-bit floating-point data
	SampleDataFormat64BitBEFloat
)

Variables

View Source
var (
	// ErrIndexOutOfRange is for when a slice is iterated with an index that's out of the range
	ErrIndexOutOfRange = errors.New("index out of range")
)

Functions

This section is empty.

Types

type NativeSampleData added in v1.0.4

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

func (*NativeSampleData) Channels added in v1.0.4

func (s *NativeSampleData) Channels() int

Channels returns the channel count from the sample data

func (*NativeSampleData) Length added in v1.0.4

func (s *NativeSampleData) Length() int

Length returns the sample length from the sample data

func (*NativeSampleData) Seek added in v1.0.4

func (s *NativeSampleData) Seek(pos int)

Seek sets the current position in the sample data

func (*NativeSampleData) Tell added in v1.0.4

func (s *NativeSampleData) Tell() int

Tell returns the current position in the sample data

type PCMReader added in v1.1.0

type PCMReader[TConverter SampleConverter] struct {
	SampleData
	// contains filtered or unexported fields
}

func (*PCMReader[T]) Read added in v1.1.0

func (s *PCMReader[T]) Read() (volume.Matrix, error)

type Sample

type Sample interface {
	SampleReader
	Channels() int
	Length() int
	Seek(pos int)
	Tell() int
}

Sample is the interface to a sample

func ConvertTo added in v1.0.3

func ConvertTo(from Sample, format SampleDataFormat) (Sample, error)

func NewSample

func NewSample(data []byte, length int, channels int, format SampleDataFormat) Sample

NewSample constructs a sampler that can handle the requested sampler format

func NewSampleNative added in v1.0.4

func NewSampleNative(data []volume.Matrix, length int, channels int) Sample

type Sample16BitSigned

type Sample16BitSigned struct{}

Sample16BitSigned is a signed 16-bit sample

func (Sample16BitSigned) ReadAt

func (s Sample16BitSigned) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample16BitSigned) Size

func (s Sample16BitSigned) Size() int

Size returns the size of the sample in bytes

type Sample16BitUnsigned

type Sample16BitUnsigned struct{}

Sample16BitUnsigned is an unsigned 16-bit sample

func (Sample16BitUnsigned) ReadAt

func (s Sample16BitUnsigned) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample16BitUnsigned) Size

func (s Sample16BitUnsigned) Size() int

Size returns the size of the sample in bytes

type Sample32BitFloat added in v1.0.3

type Sample32BitFloat struct{}

Sample32BitFloat is a 32-bit floating-point sample

func (Sample32BitFloat) ReadAt added in v1.0.3

func (s Sample32BitFloat) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample32BitFloat) Size added in v1.0.3

func (s Sample32BitFloat) Size() int

Size returns the size of the sample in bytes

type Sample64BitFloat added in v1.0.3

type Sample64BitFloat struct{}

Sample64BitFloat is a 64-bit floating-point sample

func (Sample64BitFloat) ReadAt added in v1.0.3

func (s Sample64BitFloat) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample64BitFloat) Size added in v1.0.3

func (s Sample64BitFloat) Size() int

Size returns the size of the sample in bytes

type Sample8BitSigned

type Sample8BitSigned struct{}

Sample8BitSigned is a signed 8-bit sample

func (Sample8BitSigned) ReadAt

func (s Sample8BitSigned) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample8BitSigned) Size

func (s Sample8BitSigned) Size() int

Size returns the size of the sample in bytes

type Sample8BitUnsigned

type Sample8BitUnsigned struct{}

Sample8BitUnsigned is an unsigned 8-bit sample

func (Sample8BitUnsigned) ReadAt

func (s Sample8BitUnsigned) ReadAt(d *SampleData, ofs int64) (volume.Volume, error)

ReadAt reads a value from the reader provided in the byte order provided

func (Sample8BitUnsigned) Size

func (s Sample8BitUnsigned) Size() int

Size returns the size of the sample in bytes

type SampleConverter

type SampleConverter interface {
	Size() int
	ReadAt(s *SampleData, ofs int64) (volume.Volume, error)
}

SampleConverter is an interface to a sample converter

type SampleData

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

func (*SampleData) Channels

func (s *SampleData) Channels() int

Channels returns the channel count from the sample data

func (*SampleData) Length

func (s *SampleData) Length() int

Length returns the sample length from the sample data

func (*SampleData) Seek

func (s *SampleData) Seek(pos int)

Seek sets the current position in the sample data

func (*SampleData) Tell

func (s *SampleData) Tell() int

Tell returns the current position in the sample data

type SampleDataFormat

type SampleDataFormat uint8

SampleDataFormat is the format of the sample data

type SampleReader

type SampleReader interface {
	Read() (volume.Matrix, error)
}

SampleReader is a reader interface that can return a whole multichannel sample at the current position

type SampleReaderNative added in v1.0.4

type SampleReaderNative struct {
	NativeSampleData
}

SampleReaderNative is a native (pre-converted) PCM sample reader

func (*SampleReaderNative) Read added in v1.0.4

func (s *SampleReaderNative) Read() (volume.Matrix, error)

Read returns the next multichannel sample

type SampleType added in v1.1.0

type SampleType interface {
	~int8 | ~uint8 | ~int16 | ~uint16 | ~float32 | ~float64
}

Jump to

Keyboard shortcuts

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