mp3

package
v0.0.0-...-967540c Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STEREO         = iota
	JOINT_STEREO   // stereo
	DUAL_CHANNE    // two mono chans
	SINGLE_CHANNEL // mono
)

Variables

View Source
var APEHeader = []byte{'A', 'P', 'E', 'T'}

Lookup by Version, Layer, and Bitrate Index

View Source
var ID3v1Header = []byte{'T', 'A', 'G'}
View Source
var ID3v1Size = 128
View Source
var ID3v2Header = []byte{'I', 'D', '3'}
View Source
var MPEG1BitrateTable = [][]uint64{
	ZeroedBitrates,
	{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0},
	{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0},
	{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0},
}
View Source
var MPEG2L1Bitrates = []uint64{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0}
View Source
var MPEG2L2L3Bitrates = []uint64{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}
View Source
var SamplerateLookupTable = [][]uint64{
	{11025, 12000, 8000, 0},
	{0, 0, 0, 0},
	{22050, 24000, 16000, 0},
	{44100, 48000, 32000, 0},
}

Lookup by Version, Samplerate Index

View Source
var SamplesLookupTable = [][]uint64{
	{0, 576, 1152, 384},
	{0, 0, 0, 0},
	{0, 576, 1152, 384},
	{0, 1152, 1152, 384},
}

Lookup by Version, Layer

View Source
var ZeroedBitrates = []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Functions

This section is empty.

Types

type ApeTag

type ApeTag struct {
	Version  uint32
	Size     uint32
	NumItems uint32
	Flags    uint32
}

type AudioFrame

type AudioFrame struct {
	Version         MPEGVersion
	Layer           MPEGLayer
	CRC             bool
	BitrateIndex    uint8
	SamplerateIndex uint8
	Padding         uint8
	Private         bool
	Mode            uint8
	ModeExt         uint8
	Copyright       bool
	Original        bool
	Emphasis        uint8

	Bitrate    uint64
	Samplerate uint64

	Size uint64
}

information about one mp3 audio frame

type ID3v2Tag

type ID3v2Tag struct {
	Version  uint8
	Revision uint8
	Flags    uint16
	Size     uint32
}

type MP3Info

type MP3Info struct {
	Bitrate       uint64
	IsVBR         bool
	HasXingHeader bool
	HasVBRiHeader bool

	Samplerate uint64

	Duration time.Duration

	HasID3v1 bool
	ID3v2    *ID3v2Tag
	Ape      *ApeTag

	FoundLayer1 bool
	FoundLayer2 bool
	FoundLayer3 bool

	FoundMPEG1  bool
	FoundMPEG2  bool
	FoundMPEG25 bool

	UnknownBytes uint64

	FrameCount   int
	StartGarbage int64
}

func InspectFile

func InspectFile(path string) (*MP3Info, error)

type MPEGLayer

type MPEGLayer int
const (
	LAYER_RESERVED MPEGLayer = iota
	LAYER3
	LAYER2
	LAYER1
)

type MPEGVersion

type MPEGVersion int
const (
	MPEG25 MPEGVersion = iota
	MPEG_RESERVED
	MPEG2
	MPEG1
)

type Scanner

type Scanner struct {
	FrameCount int

	Info *MP3Info
	// contains filtered or unexported fields
}

func NewMP3Scanner

func NewMP3Scanner(f io.ReadSeeker) (*Scanner, error)

func NewScanner

func NewScanner(f io.ReadSeeker, version MPEGVersion, layer MPEGLayer) (*Scanner, error)

func (*Scanner) NextFrame

func (s *Scanner) NextFrame() (*AudioFrame, uint64, error)

Jump to

Keyboard shortcuts

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