minimp3

package module
v0.0.0-...-872fc94 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 4 Imported by: 1

README

Golang binding for the minimp3 mp3 decoder: https://github.com/lieff/minimp3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder decode the mp3 stream by minimp3

func NewDecoder

func NewDecoder(source io.Reader) *Decoder

NewDecoder creates and returns a new mp3 decoder with the default internal buffer size.

func (*Decoder) Bitrate

func (d *Decoder) Bitrate() int

Bitrate returns the mp3 bitrate of the last decoded frame. If no frames have been decoded yet, then it will return 0.

func (*Decoder) Channels

func (d *Decoder) Channels() int

Channels returns the number of channels of the last decoded frame. If no frames have been decoded yet, then it will return 0.

func (*Decoder) Read

func (d *Decoder) Read(p []float32) (int, error)

Read copies the decoded audio data from the internal buffer to p and returns the number of items copied. If the internal buffer is empty, then Read first tries to read mp3 data from the source and decode it. If len(p) == 0, then Read will return zero bytes, but if the internal buffer is empty, then before that it will still try to decode one frame and fill the internal buffer.

func (*Decoder) SampleRate

func (d *Decoder) SampleRate() int

SampleRate returns the sample rate of the last decoded frame. If no frames have been decoded yet, then it will return 0.

func (*Decoder) Seek

func (d *Decoder) Seek(offset int64, whence int) (int64, error)

Seek sets a new position for reading audio data. At least one decoded frame is required to set a new position. If there are no decoded frames, then Seek will return an error. The mp3 data source must support the io.Seeker interface. If the source doesn't support io.Seeker, then Seek will panic.

Jump to

Keyboard shortcuts

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