audio

package
v0.0.0-...-f3d8a94 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Interleaved = iota + 1
	NonInterleaved
	Mono
)

layouts (earlier are considered better)

View Source
const (
	Float32Type = iota + 1
	Int16Type
)

types (earlier are considered better)

View Source
const Unspecified = 0

Variables

View Source
var AudioEnvT = &abc.Type{"audio", true, abc.IsType((*context)(nil))}
View Source
var Debug = false
View Source
var SamplesT = &abc.Type{"samples", false, abc.IsType((*node)(nil))}
View Source
var TimeT = &abc.Type{"time", true, abc.IsType(Time{})}

Functions

func CustomWave

func CustomWave(rate int, samples []float32) (w *waveWidget)

func Level

func Level(level float32, rate int) *levelWidget

func Register

func Register(name string, kind widgetKind, argtype map[string]abc.Socket, fn func(status *abc.Status, args map[string]interface{}) Widget)

func SinWave

func SinWave(freq float64, rate int) (w *waveWidget)

func WriteWav

func WriteWav(filename string, input Widget) os.Error

Types

type Buffer

type Buffer interface {
	Len() int
	Zero(i0, i1 int)
	Copy(i0 int, src Buffer, j0, j1 int)
	Slice(i0, i1 int) Buffer
	GetFormat() Format
}

type ContiguousFloat32Buffer

type ContiguousFloat32Buffer interface {
	Buffer
	AsFloat32Buf() Float32Buf
	AllocFromFloat32Buf(buf Float32Buf) ContiguousFloat32Buffer
}

type ConverterWidget

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

func Converter

func Converter(input Widget, f Format) (w *ConverterWidget)

func (*ConverterWidget) GetFormat

func (w *ConverterWidget) GetFormat(name string) (f Format)

func (*ConverterWidget) Init

func (w *ConverterWidget) Init(inputs map[string]Widget)

func (*ConverterWidget) ReadSamples

func (w *ConverterWidget) ReadSamples(b Buffer, t int64) bool

type DelayWidget

type DelayWidget struct {
	Format
	// contains filtered or unexported fields
}

func (*DelayWidget) Init

func (w *DelayWidget) Init(inputs map[string]Widget)

func (*DelayWidget) ReadSamples

func (w *DelayWidget) ReadSamples(samples Buffer, p0 int64) bool

type EnvelopeWidget

type EnvelopeWidget struct {
	Format
	// contains filtered or unexported fields
}

func Envelope

func Envelope(t0 int64, rate int, attack, decay, sustain, release int64, sustainlev float32) *EnvelopeWidget

func (*EnvelopeWidget) Init

func (w *EnvelopeWidget) Init(_ map[string]Widget)

func (*EnvelopeWidget) ReadSamples

func (w *EnvelopeWidget) ReadSamples(b Buffer, t int64) (r bool)

func (*EnvelopeWidget) SetFormat

func (w *EnvelopeWidget) SetFormat(f Format)

type Float32Buf

type Float32Buf []float32

func (Float32Buf) Copy

func (b Float32Buf) Copy(i0 int, src Buffer, j0, j1 int)

func (Float32Buf) GetFormat

func (b Float32Buf) GetFormat() Format

func (Float32Buf) Len

func (b Float32Buf) Len() int

func (Float32Buf) Slice

func (b Float32Buf) Slice(i0, i1 int) Buffer

func (Float32Buf) Zero

func (b Float32Buf) Zero(i0, i1 int)

type Float32NBuf

type Float32NBuf []Float32Buf

n separate channels

func AllocFloat32NBuf

func AllocFloat32NBuf(nchans, n int) Float32NBuf

func (Float32NBuf) Copy

func (b0 Float32NBuf) Copy(i0 int, b1 Buffer, j0, j1 int)

func (Float32NBuf) GetFormat

func (b Float32NBuf) GetFormat() Format

func (Float32NBuf) Len

func (b Float32NBuf) Len() int

func (Float32NBuf) Permute

func (b0 Float32NBuf) Permute(p []int) Float32NBuf

each item in p represents a channel in the new buffer; its value is which channel it comes from. if it's -1, then we create a zero'd buffer

func (Float32NBuf) Slice

func (b Float32NBuf) Slice(i0, i1 int) Buffer

func (Float32NBuf) Zero

func (b Float32NBuf) Zero(i0, i1 int)

type Format

type Format struct {
	NumChans int // number of channels (0 if unset)
	Rate     int // samples per second (0 if unset)
	Layout   int
	Type     int
}

func (Format) AllocBuffer

func (f Format) AllocBuffer(n int) Buffer

func (Format) Combine

func (f0 Format) Combine(f1 Format) Format

set all the unspecified fields in f0 to values taken from f1.

func (Format) CombineBest

func (f0 Format) CombineBest(f1 Format) Format

func (Format) Eq

func (f0 Format) Eq(f1 Format) bool

func (Format) FullySpecified

func (f Format) FullySpecified() bool

func (Format) GetFormat

func (f Format) GetFormat(_ string) Format

func (Format) Match

func (f0 Format) Match(f1 Format) bool

func (Format) TimeToSamples

func (f Format) TimeToSamples(t Time) int64

type FormatSetter

type FormatSetter interface {
	SetFormat(f Format)
}

type Formatted

type Formatted interface {
	GetFormat(name string) Format
}

type GraphWidget

type GraphWidget struct {
	Format
	// contains filtered or unexported fields
}

func (*GraphWidget) Init

func (w *GraphWidget) Init(inputs map[string]Widget)

func (*GraphWidget) ReadSamples

func (w *GraphWidget) ReadSamples(_ Buffer, _ int64) bool

type Int16Buf

type Int16Buf []int16

func (Int16Buf) Copy

func (b Int16Buf) Copy(i0 int, src Buffer, j0, j1 int)

func (Int16Buf) GetFormat

func (b Int16Buf) GetFormat() Format

func (Int16Buf) Len

func (b Int16Buf) Len() int

func (Int16Buf) Slice

func (b Int16Buf) Slice(i0, i1 int) Buffer

func (Int16Buf) Zero

func (b Int16Buf) Zero(i0, i1 int)

type LayoutConverterWidget

type LayoutConverterWidget struct {
	Format
	// contains filtered or unexported fields
}

func (*LayoutConverterWidget) GetFormat

func (w *LayoutConverterWidget) GetFormat(name string) Format

func (*LayoutConverterWidget) Init

func (w *LayoutConverterWidget) Init(_ map[string]Widget)

func (*LayoutConverterWidget) ReadSamples

func (w *LayoutConverterWidget) ReadSamples(b Buffer, t int64) bool

type MixWidget

type MixWidget struct {
	Format
	// contains filtered or unexported fields
}

func Mixer

func Mixer(carryOn bool, ws []Widget) *MixWidget

func (*MixWidget) Init

func (w *MixWidget) Init(inputs map[string]Widget)

func (*MixWidget) ReadSamples

func (w *MixWidget) ReadSamples(buf Buffer, t int64) bool

type MultiplierWidget

type MultiplierWidget struct {
	Format
	// contains filtered or unexported fields
}

func Multiplier

func Multiplier(w0, w1 Widget) *MultiplierWidget

func (*MultiplierWidget) Init

func (w *MultiplierWidget) Init(inputs map[string]Widget)

func (*MultiplierWidget) ReadSamples

func (w *MultiplierWidget) ReadSamples(b Buffer, t int64) bool

type NFloat32Buf

type NFloat32Buf struct {
	NumChans int
	Size     int
	Buf      Float32Buf
}

n channels interleaved

func AllocNFloat32Buf

func AllocNFloat32Buf(nchans, n int) NFloat32Buf

func (NFloat32Buf) AllocFromFloat32Buf

func (b NFloat32Buf) AllocFromFloat32Buf(buf Float32Buf) ContiguousFloat32Buffer

func (NFloat32Buf) AsFloat32Buf

func (b NFloat32Buf) AsFloat32Buf() Float32Buf

func (NFloat32Buf) Copy

func (b0 NFloat32Buf) Copy(i0 int, b1 Buffer, j0, j1 int)

func (NFloat32Buf) GetFormat

func (b NFloat32Buf) GetFormat() Format

func (NFloat32Buf) Len

func (b NFloat32Buf) Len() int

func (NFloat32Buf) Slice

func (b NFloat32Buf) Slice(i0, i1 int) Buffer

func (NFloat32Buf) Zero

func (b NFloat32Buf) Zero(i0, i1 int)

type PermuteWidget

type PermuteWidget struct {
	Format
	// contains filtered or unexported fields
}

func Permute

func Permute(input Widget, p []int) *PermuteWidget

func (*PermuteWidget) Init

func (w *PermuteWidget) Init(inputs map[string]Widget)

func (*PermuteWidget) ReadSamples

func (w *PermuteWidget) ReadSamples(b Buffer, t int64) bool

type PhaserState

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

type PhaserWidget

type PhaserWidget struct {
	Format
	// contains filtered or unexported fields
}

func (*PhaserWidget) Init

func (w *PhaserWidget) Init(inputs map[string]Widget)

func (*PhaserWidget) ReadSamples

func (w *PhaserWidget) ReadSamples(b Buffer, t int64) bool

type Rerror

type Rerror string

type RingBufReader

type RingBufReader struct {
	Lag      int  // time delta (i.e. latency); zero implies primary output
	Blocking bool // Read can block for this reader?
	// contains filtered or unexported fields
}

func (*RingBufReader) Close

func (r *RingBufReader) Close()

func (*RingBufReader) GetFormat

func (r *RingBufReader) GetFormat(name string) Format

func (*RingBufReader) Init

func (r *RingBufReader) Init(_ map[string]Widget)

func (*RingBufReader) ReadSamples

func (r *RingBufReader) ReadSamples(samples Buffer, p0 int64) bool

func (*RingBufReader) SetFormat

func (r *RingBufReader) SetFormat(f Format)

type RingBufWidget

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

func RingBuf

func RingBuf(input Widget, size, maxsize int, readBufSize int) *RingBufWidget

func (*RingBufWidget) Close

func (b *RingBufWidget) Close()

func (*RingBufWidget) GetFormat

func (b *RingBufWidget) GetFormat(name string) Format

func (*RingBufWidget) Init

func (b *RingBufWidget) Init(inputs map[string]Widget)

func (*RingBufWidget) ReadSamples

func (b *RingBufWidget) ReadSamples(_ Buffer, _ int64) bool

func (*RingBufWidget) Reader

func (b *RingBufWidget) Reader(blocking bool, lag int) *RingBufReader

func (*RingBufWidget) SetFormat

func (b *RingBufWidget) SetFormat(fmt Format)

func (*RingBufWidget) SetMaxSize

func (b *RingBufWidget) SetMaxSize(bufsize int)

func (*RingBufWidget) SetSizes

func (b *RingBufWidget) SetSizes(size, maxsize, readBufSize int)

type Time

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

func ParseTime

func ParseTime(s string) (t Time, err os.Error)

ParseTime parses the time interval from s, and returns it as nanoseconds, if it is representable in seconds (with isNanoSeconds true), or sample count (with isNanoSeconds false) if not.

type WavReader

type WavReader struct {
	Format
	// contains filtered or unexported fields
}

func OpenWavReader

func OpenWavReader(filename string) (r *WavReader, err os.Error)

func (*WavReader) Init

func (w *WavReader) Init(_ map[string]Widget)

func (*WavReader) ReadSamples

func (r *WavReader) ReadSamples(b Buffer, p int64) bool

type WavWriter

type WavWriter struct {
	Format
	// contains filtered or unexported fields
}

func (*WavWriter) Init

func (w *WavWriter) Init(inputs map[string]Widget)

func (*WavWriter) ReadSamples

func (w *WavWriter) ReadSamples(_ Buffer, _ int64) bool

type Widget

type Widget interface {
	Formatted
	Init(inputs map[string]Widget)
	ReadSamples(buf Buffer, t int64) bool
}

func Delay

func Delay(input Widget, delay int) Widget

func LayoutConverter

func LayoutConverter(input Widget, layout int) Widget

type WritableRingBufWidget

type WritableRingBufWidget struct {
	RingBufWidget
}

func WriteableRingBuf

func WriteableRingBuf(size, maxsize int, wblocking bool, fmt Format) *WritableRingBufWidget

func (*WritableRingBufWidget) SampleWrite

func (b *WritableRingBufWidget) SampleWrite(samples Buffer, p0 int64)

Jump to

Keyboard shortcuts

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