audio

package module
v0.0.0-...-cabcf74 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2016 License: MIT Imports: 2 Imported by: 0

README

See sub packages

GoDoc

Build Status

Documentation

Overview

Package audio is a work in progress package containing audio related sub packages.

The APIs are not stable, the code is unfinalized and should not be used in production.

See sub packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvgInt

func AvgInt(xs ...int) int

AvgInt averages the int values passed

func IeeeFloatToInt

func IeeeFloatToInt(b [10]byte) int

IeeeFloatToInt converts a 10 byte IEEE float into an int.

func IntMaxSignedValue

func IntMaxSignedValue(b int) int

IntMaxSignedValue returns the max value of an integer based on its memory size

func IntToIeeeFloat

func IntToIeeeFloat(i int) [10]byte

IntToIeeeFloat converts an int into a 10 byte IEEE float.

func SlicedFValues

func SlicedFValues(fs FloatFrames) []float64

SlicedFValues converts AudioFloatFrames into a 1 dimensional slice of floats.

func SlicedValues

func SlicedValues(fs Frames) []int

SlicedValues converts AudioFrames into a 1 dimensional slice of ints.

func Uint24to32

func Uint24to32(bytes []byte) uint32

Uint24to32 converts a 3 byte uint23 into a uint32

func Uint32toUint24Bytes

func Uint32toUint24Bytes(n uint32) []byte

Uint32toUint24Bytes converts a uint32 into a 3 byte uint24 representation

Types

type Chunk

type Chunk struct {
	ID   [4]byte
	Size int
	Pos  int
	R    io.Reader
}

type FloatFrames

type FloatFrames [][]float64

FloatFrames are a representation similar to Frames but containing float values [] <- channels []float64 <- frame float values.

func (FloatFrames) MonoRMS

func (fs FloatFrames) MonoRMS() []float64

MonoRMS is a representation of the audio frames (in mono) rms = sqrt ( (1/n) * (x12 + x22 + … + xn2) ) multiplying by 1/n effectively assigns equal weights to all the terms, making it a rectangular window. Other window equations can be used instead which would favor terms in the middle of the window. This results in even greater accuracy of the RMS value since brand new samples (or old ones at the end of the window) have less influence over the signal’s power.)

type FrameInfo

type FrameInfo struct {
	// Channels represent the number of audio channels
	// (e.g. 1 for mono, 2 for stereo).
	Channels int
	// Bit depth is the number of bits used to represent
	// a single sample.
	BitDepth int

	// Sample rate is the number of samples to be played each second.
	SampleRate int64
}

FrameInfo represents the frame-level information.

type Frames

type Frames [][]int

Frames are a representation of audio frames across multiple channels [] <- channels []int <- frame int values.

func ToMonoFrames

func ToMonoFrames(fs Frames) Frames

ToMonoFrames converts stereo into mono frames by averaging each samples. Note that a stereo frame could have 2 samples in phase opposition which would lead to a zero value. This edge case isn't taken in consideration.

func (Frames) ToFloatFrames

func (f Frames) ToFloatFrames(srcBitDepth int) FloatFrames

ToFloatFrames converts the frame int values to values in the -1, 1 range.

func (Frames) ToMonoFrames

func (f Frames) ToMonoFrames() Frames

ToMonoFrames returns a new mono audio frame set.

type FramesFloat64

type FramesFloat64 []float64

func (FramesFloat64) Get

func (f FramesFloat64) Get(channel, n int) float64

type FramesInt

type FramesInt []int

FramesInt is the representation of audio frames made of of a series of samples using one or more channels.

func (FramesInt) Get

func (f FramesInt) Get(channels, n int) int

Get returns the sample contained in the given frame position.

type PCM

type PCM interface {
	// Ints populates the passed frames of ints and returns the number of read frames.
	Ints(samples FramesInt) (n int, err error)
	// Floats64s populates the passed frames of float64 and returns the number of read frames.
	Float64s(frames FramesFloat64) (n int, err error)

	// NextInts reads up to n frames (as ints)
	NextInts(n int) (FramesInt, error)
	// NextFloat64s reads up to n frames (as float64)
	NextFloat64s(n int) (FramesFloat64, error)

	// Read reads the PCM data into the passed buffer and returns the
	// number of read frames.
	Read(buf []byte) (n int, err error)
	// Offset returns the current frame we are at.
	Offset() int64

	// SeekFrames allows to seek the audio content.
	SeekFrames(frameOffset int64, whence int) (offset int64, err error)
	// Info returns basic PCM information.
	Info() (numChannels, bitDepth int, sampleRate int64, err error)
	// Size returns the amount of frames available in the PCM data.
	Size() int64
}

Directories

Path Synopsis
Package aiff is a AIFF/AIFC decoder and encoder.
Package aiff is a AIFF/AIFC decoder and encoder.
aiffinfo
aiffinfo is a command line tool to gather information about aiff/aifc files.
aiffinfo is a command line tool to gather information about aiff/aifc files.
caf package implements an Apple Core Audio Format (CAF) parser.
caf package implements an Apple Core Audio Format (CAF) parser.
given a PCM audio file, convert it to mono and decimates it.
given a PCM audio file, convert it to mono and decimates it.
dsp
cmd
generator example
generator example
MIDI package is a midi format parser that parses the content of a midi stream and asyncronously send the data to a provided channel or collect the data into an accessible struct,
MIDI package is a midi format parser that parses the content of a midi stream and asyncronously send the data to a provided channel or collect the data into an accessible struct,
DEPRECATED WILL BE DELETED
DEPRECATED WILL BE DELETED
Package riff is package implementing a simple Resource Interchange File Format (RIFF) parser with basic support for sub formats such as WAV.
Package riff is package implementing a simple Resource Interchange File Format (RIFF) parser with basic support for sub formats such as WAV.
riffinfo
riffinfo is a command line tool used to gather information about riff files.
riffinfo is a command line tool used to gather information about riff files.
wav
DEPRECATED PACKAGE, see github.com/mattetti/audio/wav
DEPRECATED PACKAGE, see github.com/mattetti/audio/wav
wav/wavinfo
wavinfo is a command line tool extracting metadata information from a wav file.
wavinfo is a command line tool extracting metadata information from a wav file.
Package wav is a package allowing developers to decode and encode audio PCM data using the Waveform Audio File Format https://en.wikipedia.org/wiki/WAV
Package wav is a package allowing developers to decode and encode audio PCM data using the Waveform Audio File Format https://en.wikipedia.org/wiki/WAV

Jump to

Keyboard shortcuts

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