aiff

package
v0.0.0-...-0ded229 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PCMType is the compression type for PCM (uncompressed) audio.
	PCMType = "NONE"

	// PCMName is the descriptive name for PCM (uncompressed) audio.
	PCMName = "not compressed"
)
View Source
const StandardVersion = 0xA2805140

StardardVersion is the recognized AIFF-C version number.

View Source
const VADPCMLoopSize = 44

VADPCMLoopSize is the size of a VADPCM loop record.

Variables

View Source
var ErrNotAIFF = errors.New("not an AIFF file")

ErrNotAiff indicates that the file is not an AIFF file.

Functions

This section is empty.

Types

type AIFF

type AIFF struct {
	FormatVersion FormatVersion // AIFC only.
	Common        Common
	Chunks        []Chunk // Excludes FormatVersion and Common, above.
}

An AIFF is a decoded AIFF or AIFF-C file.

func Parse

func Parse(data []byte) (*AIFF, error)

Parse an AIFF or AIFF-C file.

func (*AIFF) GetSamples16

func (a *AIFF) GetSamples16() ([]int16, error)

GetSamples16 returns the samples in an AIFF file, converted to signed-16 bit. Not all conversions are supported.

func (*AIFF) IsCompressed

func (a *AIFF) IsCompressed() bool

IsCompressed returns true if this is a compressed AIFF file.

func (*AIFF) Write

func (a *AIFF) Write(kind Kind) ([]byte, error)

type ApplicationData

type ApplicationData struct {
	Signature [4]byte
	Data      []byte
}

A ApplicationData is the APPL chunk in an AIFF file.

func (*ApplicationData) ChunkData

func (c *ApplicationData) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type Chunk

type Chunk interface {
	ChunkData(kind Kind) (id [4]byte, data []byte, err error)
}

A Chunk is a piece of data in an AIFF file.

type Common

type Common struct {
	NumChannels     int
	NumFrames       int
	SampleSize      int
	SampleRate      extended.Extended
	Compression     [4]byte
	CompressionName string
}

A Common is the common chunk in an AIFF file.

func (*Common) ChunkData

func (c *Common) ChunkData(kind Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

func (*Common) IsComprsesed

func (c *Common) IsComprsesed() bool

IsCompressed returns true if this belongs to a compressed AIFF file.

type FormatVersion

type FormatVersion struct {
	Timestamp uint32
}

A FormatVersion is the FVER chunk in an AIFC file.

func (*FormatVersion) ChunkData

func (c *FormatVersion) ChunkData(kind Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type Instrument

type Instrument struct {
	BaseNote     int
	Detune       int
	LowNote      int
	HighNote     int
	LowVelocity  int
	HighVelocity int
	Gain         int
	SustainLoop  Loop
	ReleaseLoop  Loop
}

An Instrument is a chunk describing how to use the data in an AIFF file as a sampled musical instrument.

func (*Instrument) ChunkData

func (c *Instrument) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type Kind

type Kind uint32

A Kind is a kind of AIFF or AIFF-C file.

const (
	// AIFFKind indicates the original AIFF format.
	AIFFKind Kind = iota + 1

	// AIFCKind indicates the extended AIFF-C format.
	AIFCKind
)

type Loop

type Loop struct {
	Mode  LoopMode
	Begin int // Marker ID.
	End   int // Marker ID.
}

A Loop is an audio loop in an AIFF file.

type LoopMode

type LoopMode int

A LoopMode describes how a loop is played back.

const (
	// LoopNone does not loop.
	LoopNone LoopMode = 0
	// LoopForward plays the loop forwards repeatedly.
	LoopForward LoopMode = 1
	// LoopForwardBackward alternates between playing the loop forwards and
	// backwards.
	LoopForwardBackward LoopMode = 2
)

type Marker

type Marker struct {
	ID       int
	Position int
	Name     string
}

A Marker is a named location in an AIFF file.

type Markers

type Markers struct {
	Markers []Marker
}

A Markers is the MARK chunk in an AIFF file.

func (*Markers) ChunkData

func (c *Markers) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type RawChunk

type RawChunk struct {
	ID   [4]byte
	Data []byte
}

A RawChunk is a raw chunk which has not been decoded or interpreted.

func (*RawChunk) ChunkData

func (c *RawChunk) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type SoundData

type SoundData struct {
	Offset    uint32
	BlockSize uint32
	Data      []byte
}

A SoundData is the SSND chunk in an AIFF file.

func (*SoundData) ChunkData

func (c *SoundData) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type VADPCMCodes

type VADPCMCodes struct {
	Version    int
	Order      int
	NumEntries int
	Table      []int16
}

A VADPCMCodes contains the codebook for a VADPCM-compressed file.

func (*VADPCMCodes) ChunkData

func (c *VADPCMCodes) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

type VADPCMLoop

type VADPCMLoop struct {
	Start int
	End   int
	Count int
	State [16]int16
}

A VADPCMLoop is a loop in a VADPCM-encoded file.

func (*VADPCMLoop) Marshal

func (l *VADPCMLoop) Marshal(d []byte)

Marshal writes the loop to the given buffer.

func (*VADPCMLoop) Unmarshal

func (l *VADPCMLoop) Unmarshal(d []byte)

Unmarshal reads the loop from the given buffer.

type VADPCMLoops

type VADPCMLoops struct {
	Loops []VADPCMLoop
}

A VADPCMLoops contains the loop information for a VADPCM-encoded file.

func (*VADPCMLoops) ChunkData

func (c *VADPCMLoops) ChunkData(_ Kind) (id [4]byte, data []byte, err error)

ChunkData implements the Chunk interface.

Jump to

Keyboard shortcuts

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