Documentation ¶
Overview ¶
Package aubio is a Go binding to the aubio audio analysis library http://aubio.org/.
Index ¶
- Constants
- func DbSpl(buf *SimpleBuffer) float64
- func HzToMel(freq float64) float64
- func HzToMelHTK(freq float64) float64
- func LevelDetection(buf *SimpleBuffer, threshold float64) float64
- func LevelLin(buf *SimpleBuffer) float64
- func MelToHz(mel float64) float64
- func MelToHzHTK(mel float64) float64
- func SilenceDetection(buf *SimpleBuffer, threshold float64) bool
- func Unwrap2pi(phase float64) float64
- func ZeroCrossingRate(buf *SimpleBuffer) float64
- type Analyzer
- type BeatTracker
- type ComplexBuffer
- type Filter
- func NewFilter(order, bufSize uint) (*Filter, error)
- func NewFilterAWeighting(samplerate, bufSize uint) (*Filter, error)
- func NewFilterBiquad(b0 float64, b1 float64, b2 float64, a0 float64, a1 float64, bufSize uint) (*Filter, error)
- func NewFilterCWeighting(samplerate, bufSize uint) (*Filter, error)
- func (f *Filter) Buffer() *SimpleBuffer
- func (f *Filter) Do(in *SimpleBuffer)
- func (f *Filter) DoFwdBack(in *SimpleBuffer, workBufSize uint)
- func (f *Filter) DoOutplace(in *SimpleBuffer)
- func (f *Filter) Feedback() *LongSampleBuffer
- func (f *Filter) Feedforward() *LongSampleBuffer
- func (f *Filter) Free()
- func (f *Filter) Order() uint
- func (f *Filter) Reset()
- func (f *Filter) Samplerate() uint
- func (f *Filter) SetAWeighting(samplerate uint)
- func (f *Filter) SetBiquad(b0 float64, b1 float64, b2 float64, a0 float64, a1 float64)
- func (f *Filter) SetCWeighting(samplerate uint)
- func (f *Filter) SetSamplerate(rate uint)
- type FilterBank
- func (fb *FilterBank) Buffer() *SimpleBuffer
- func (fb *FilterBank) Coeffs() *MatrixBuffer
- func (fb *FilterBank) Do(in *ComplexBuffer)
- func (fb *FilterBank) GetCoeffs() [][]float64
- func (fb *FilterBank) GetNorm() float64
- func (fb *FilterBank) GetPower() float64
- func (fb *FilterBank) NormalizeCoeffs()
- func (fb *FilterBank) SetCoeffs(coeffs [][]float64)
- func (fb *FilterBank) SetMelCoeffs(sample uint, fmin uint, fmax uint)
- func (fb *FilterBank) SetMelCoeffsHTK(sample uint, fmin uint, fmax uint)
- func (fb *FilterBank) SetMelCoeffsSlaney(sample uint)
- func (fb *FilterBank) SetNorm(norm float64)
- func (fb *FilterBank) SetPower(power float64)
- func (fb *FilterBank) SetTriangleBands(freqs *SimpleBuffer, sample uint)
- type LongSampleBuffer
- type MFCC
- func (mfcc *MFCC) Coeffs() *SimpleBuffer
- func (mfcc *MFCC) Do(in *ComplexBuffer)
- func (mfcc *MFCC) Free()
- func (mfcc *MFCC) GetPower() float64
- func (mfcc *MFCC) GetScale() float64
- func (mfcc *MFCC) SetMelCoeffs(fmin uint, fmax uint)
- func (mfcc *MFCC) SetMelCoeffsHTK(fmin uint, fmax uint)
- func (mfcc *MFCC) SetMelCoeffsSlaney()
- func (mfcc *MFCC) SetPower(power float64)
- func (mfcc *MFCC) SetScale(scale float64)
- type MatrixBuffer
- type Onset
- type PhaseVoc
- type Pitch
- type ProcessFunc
- type Resampler
- type ReverseComplexAnalyzer
- type SimpleBuffer
- func (buf *SimpleBuffer) Abs()
- func (buf *SimpleBuffer) Ceil()
- func (buf *SimpleBuffer) Clamp(absmax float64)
- func (buf *SimpleBuffer) Cos()
- func (buf *SimpleBuffer) Exp()
- func (buf *SimpleBuffer) Floor()
- func (b *SimpleBuffer) Free()
- func (b *SimpleBuffer) Get(i uint) float64
- func (buf *SimpleBuffer) Log()
- func (buf *SimpleBuffer) Log10()
- func (buf *SimpleBuffer) Pow(pow float64)
- func (buf *SimpleBuffer) Round()
- func (b *SimpleBuffer) SetData(data []float64)
- func (b *SimpleBuffer) SetDataF32(data []float32)
- func (b *SimpleBuffer) SetDataFast(data []float32)
- func (b *SimpleBuffer) SetDataUnsafe(data []float32)
- func (buf *SimpleBuffer) Sin()
- func (b *SimpleBuffer) Size() uint
- func (b *SimpleBuffer) Slice() []float64
- func (buf *SimpleBuffer) Sqrt()
- type SimplePipeline
- type Sink
- type Source
- type TSS
- type Tempo
Constants ¶
const ( // Onset Detection functions see: https://github.com/piem/aubio/blob/develop/src/spectral/specdesc.h // Energy based onset detection function Energy onsetMode = "energy" // High Frequency Content onset detection function HFC onsetMode = "hfc" // Complex Domain Method onset detection function Complex onsetMode = "complex" // Phase based Method onset detection function Phase onsetMode = "phase" // Spectral difference method onset detection function SpecDiff onsetMode = "specdiff" // Kullback-Liebler onset detection function K1 onsetMode = "k1" // Modified Kullback-Liebler onset detection function MK1 onsetMode = "mk1" // Spectral Flux SpecFlux onsetMode = "specflux" )
const ( // Pitch detection function // see: https://github.com/piem/aubio/blob/develop/src/pitch/pitch.c PitchDefault pitchMode = "default" PitchYin pitchMode = "yin" PitchMcomb pitchMode = "mcomb" PitchSchmitt pitchMode = "schmitt" PitchFcomb pitchMode = "fcomb" PitchYinfft pitchMode = "default" )
const ( // Pitch detection output modes // see: https://github.com/piem/aubio/blob/develop/src/pitch/pitch.c PitchOutFreq = "freq" PitchOutMidi = "midi" PitchOutCent = "cent" PitchOutBin = "bin" PitchOutDefault = "default" )
Variables ¶
This section is empty.
Functions ¶
func HzToMel ¶
Convert frequency (Hz) to mel. Converts a scalar from the frequency domain to the mel scale using Slaney Auditory Toolbox's implementation
func HzToMelHTK ¶
Convert frequency (Hz) to mel using HTK scaling. Converts a scalar from the frequency domain to the mel scale, using the equation defined by O'Shaughnessy, as implemented in the HTK speech recognition toolkit
func LevelDetection ¶
func LevelDetection(buf *SimpleBuffer, threshold float64) float64
Get level in dB SPL if level >= threshold, otherwise 1.
func MelToHz ¶
Convert mel to frequency (Hz). Converts a scalar from the mel scale to the frequency domain using Slaney Auditory Toolbox's implementation
func MelToHzHTK ¶
Convert mel to frequency (Hz) using HTK scaling. Converts a scalar from the mel scale to the frequency domain, using the equation defined by O'Shaughnessy, as implemented in the HTK speech recognition toolkit
func SilenceDetection ¶
func SilenceDetection(buf *SimpleBuffer, threshold float64) bool
Check if buffer level in dB SPL is under a given threshold True if level is under threshold, false otherwise
func Unwrap2pi ¶
Compute the principal argument. This function maps the input phase to its corresponding value wrapped in the range [−π,π].
func ZeroCrossingRate ¶
func ZeroCrossingRate(buf *SimpleBuffer) float64
The zero-crossing rate is the number of times a signal changes sign, divided by the length of this signal.
Types ¶
type Analyzer ¶
type Analyzer interface {
Do(input *SimpleBuffer)
}
type BeatTracker ¶
type BeatTracker struct {
// contains filtered or unexported fields
}
BeatTracker is a wrapper for the aubio_beattracking_t beattracking detection object. See https://github.com/piem/aubio/blob/develop/src/tempo/beattracking.h for more details.
func NewBeatTracker ¶
func NewBeatTracker(bufSize, blockSize, samplerate uint) (*BeatTracker, error)
NewBeatTracker constructs a new BeatTracker object. It is the Callers responsibility to call Free on the returned BeatTracker object or leak memory.
t, err := NewBeatTracker(bufSize, blockSize, samplerate) if err != nil { // handle error } defer t.Free()
func (*BeatTracker) Buffer ¶
func (t *BeatTracker) Buffer() *SimpleBuffer
Get the detected beat locations
func (*BeatTracker) Do ¶
func (t *BeatTracker) Do(input *SimpleBuffer)
Do executes the beattracking detection on an input Buffer. The beat locations are stored in the BeatTracker struct's buf
func (*BeatTracker) Free ¶
func (t *BeatTracker) Free()
Free frees the aubio_temp_t object's memory.
func (*BeatTracker) GetBpm ¶
func (t *BeatTracker) GetBpm() float64
GetBpm returns the bpm after running Do on an input Buffer
t, err := NewBeatTracker(bufSize, blockSize, samplerate) if err != nil { } defer t.Close() t.Do(buf) fmt.Println("BPM: ", t.GetBpm())
func (*BeatTracker) GetConfidence ¶
func (t *BeatTracker) GetConfidence() float64
GetConfidence returns the confidence after running Do on an input Buffer
t, err := NewBeatTracker(mode, bufSize, blockSize, samplerate) if err != nil { } defer t.Close() t.Do(buf) fmt.Println("Confidence: ", t.GetConfidence())
type ComplexBuffer ¶
type ComplexBuffer struct {
// contains filtered or unexported fields
}
ComplexBuffer is a wrapper for the aubio cvec_t type. It contains complex sample data.
func NewComplexBuffer ¶
func NewComplexBuffer(size uint) *ComplexBuffer
NewComplexBuffer constructs a buffer.
The caller is responsible for calling Free on the returned ComplexBuffer to release memory when done.
buf := NewComplexBuffer(bufSize) defer buf.Free()
func NewComplexBufferData ¶
func NewComplexBufferData(size uint, data []float64) *ComplexBuffer
NewComplexBuffer constructs a buffer with data.
func (*ComplexBuffer) Free ¶
func (cb *ComplexBuffer) Free()
Free frees the memory aubio has allocated for this buffer.
func (*ComplexBuffer) Norm ¶
func (cb *ComplexBuffer) Norm() []float64
Norm returns the slice of norm data. The data is copies so the slice is still valid after the buffer has changed.
func (*ComplexBuffer) Phase ¶
func (cb *ComplexBuffer) Phase() []float64
Norm returns the slice of phase data. The data is copies so the slice is still valid after the buffer has changed.
func (*ComplexBuffer) Size ¶
func (cb *ComplexBuffer) Size() uint
Size returns the size of this ComplexBuffer.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a wrapper for the aubio_filter_t object.
func NewFilter ¶
Constructs a Filter. Filters maintain their own working buffer which will get freed when the Filters Free method is called. The caller is responsible for calling Free on the constructed Filter or risk leaking memory.
func NewFilterAWeighting ¶
Constructs an A-design Filter Samplerate should be one of 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and 192000 Hz
func NewFilterBiquad ¶
func NewFilterBiquad( b0 float64, b1 float64, b2 float64, a0 float64, a1 float64, bufSize uint, ) (*Filter, error)
Constructs a biquad Filter
func NewFilterCWeighting ¶
Constructs an C-design Filter Samplerate should be one of 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and 192000 Hz
func (*Filter) Buffer ¶
func (f *Filter) Buffer() *SimpleBuffer
Buffer returns the output buffer for this Filter. The buffer is populated by calls to DoOutplace and is owned by the Filter object. Subsequent calls to DoOutplace may change the data contained in this buffer.
func (*Filter) Do ¶
func (f *Filter) Do(in *SimpleBuffer)
Do does an in-place filter on the input vector. The output buffer is not used.
func (*Filter) DoFwdBack ¶
func (f *Filter) DoFwdBack(in *SimpleBuffer, workBufSize uint)
DoFwdBack runs the aubio_filter_do_filtfilt function on this Filter.
func (*Filter) DoOutplace ¶
func (f *Filter) DoOutplace(in *SimpleBuffer)
TODO(jwall): maybe the outplace filter should be a seperate type? DoOutPlace does filters the input vector into the Filter's output Buffer. Each call to this method will change the data contained in the output buffer. This buffer can be retrieved though the Buffer method.
func (*Filter) Feedback ¶
func (f *Filter) Feedback() *LongSampleBuffer
Feedback returns the buffer containing the feedback coefficients.
func (*Filter) Feedforward ¶
func (f *Filter) Feedforward() *LongSampleBuffer
Feedback returns the buffer containing the feedforward coefficients.
func (*Filter) Free ¶
func (f *Filter) Free()
Free frees up the memory allocatd by aubio for this Filter.
func (*Filter) Samplerate ¶
Samplerate returns this Filters samplerate.
func (*Filter) SetAWeighting ¶
Apply A-weighting to a filter
func (*Filter) SetCWeighting ¶
Apply C-weighting to a filter
func (*Filter) SetSamplerate ¶
SetSamplerate sets the samplerate for this Filter.
type FilterBank ¶
type FilterBank struct {
// contains filtered or unexported fields
}
filterbank
func NewFilterBank ¶
func NewFilterBank(filters uint, win_s uint) *FilterBank
func (*FilterBank) Buffer ¶
func (fb *FilterBank) Buffer() *SimpleBuffer
func (*FilterBank) Coeffs ¶
func (fb *FilterBank) Coeffs() *MatrixBuffer
func (*FilterBank) Do ¶
func (fb *FilterBank) Do(in *ComplexBuffer)
func (*FilterBank) GetCoeffs ¶
func (fb *FilterBank) GetCoeffs() [][]float64
func (*FilterBank) GetNorm ¶
func (fb *FilterBank) GetNorm() float64
func (*FilterBank) GetPower ¶
func (fb *FilterBank) GetPower() float64
func (*FilterBank) NormalizeCoeffs ¶
func (fb *FilterBank) NormalizeCoeffs()
Normalize the filterbank triangles to a consistent height for an even melbank.
func (*FilterBank) SetCoeffs ¶
func (fb *FilterBank) SetCoeffs(coeffs [][]float64)
func (*FilterBank) SetMelCoeffs ¶
func (fb *FilterBank) SetMelCoeffs(sample uint, fmin uint, fmax uint)
func (*FilterBank) SetMelCoeffsHTK ¶
func (fb *FilterBank) SetMelCoeffsHTK(sample uint, fmin uint, fmax uint)
func (*FilterBank) SetMelCoeffsSlaney ¶
func (fb *FilterBank) SetMelCoeffsSlaney(sample uint)
func (*FilterBank) SetNorm ¶
func (fb *FilterBank) SetNorm(norm float64)
func (*FilterBank) SetPower ¶
func (fb *FilterBank) SetPower(power float64)
func (*FilterBank) SetTriangleBands ¶
func (fb *FilterBank) SetTriangleBands(freqs *SimpleBuffer, sample uint)
The coeffs will be normalized by the triangles area which results in an uneven melbank. Recommended you call NormaliseCoeffs after setting triangle bands.
type LongSampleBuffer ¶
type LongSampleBuffer struct {
// contains filtered or unexported fields
}
Buffer for Long sample data (64 bits)
func NewLBuffer ¶
func NewLBuffer(size uint) *LongSampleBuffer
NewLBuffer constructs a *LongSampleBuffer.
The caller is responsible for calling Free on the returned LongSampleBuffer to release memory when done.
buf := NewLBuffer(bufSize) defer buf.Free()
func (*LongSampleBuffer) Free ¶
func (lb *LongSampleBuffer) Free()
Free frees the memory allocated by aubio for this buffer.
func (*LongSampleBuffer) Size ¶
func (lb *LongSampleBuffer) Size() uint
Size returns this buffers size.
func (*LongSampleBuffer) Slice ¶
func (lb *LongSampleBuffer) Slice() []float64
Returns the contents of this buffer as a slice. The data is copied so the slices are still valid even after the buffer has changed.
type MFCC ¶
type MFCC struct {
// contains filtered or unexported fields
}
func (*MFCC) Coeffs ¶
func (mfcc *MFCC) Coeffs() *SimpleBuffer
func (*MFCC) Do ¶
func (mfcc *MFCC) Do(in *ComplexBuffer)
func (*MFCC) SetMelCoeffs ¶
func (*MFCC) SetMelCoeffsHTK ¶
func (*MFCC) SetMelCoeffsSlaney ¶
func (mfcc *MFCC) SetMelCoeffsSlaney()
type MatrixBuffer ¶
func NewMatrixBuffer ¶
func NewMatrixBuffer(height, length uint) *MatrixBuffer
NewMatBuffer constructs a *MatrixBuffer. Height is the number of channels Length is the length of a channel
The caller is responsible for calling Free on the returned LongSampleBuffer to release memory when done.
buf := NewLBuffer(bufSize) defer buf.Free()
func NewMatrixBufferFromFmat ¶
func NewMatrixBufferFromFmat(mat *C.fmat_t) *MatrixBuffer
func (*MatrixBuffer) Free ¶
func (mb *MatrixBuffer) Free()
Free frees the memory allocated by aubio for this buffer.
func (*MatrixBuffer) GetChannel ¶
func (mb *MatrixBuffer) GetChannel(channel uint) []float64
func (*MatrixBuffer) GetChannels ¶
func (mb *MatrixBuffer) GetChannels() [][]float64
Returns the full contents of this matrix buffer as a 2d slice (Length, Height). Think of it as a [Height]Channel, where Channel is [Length]float64 The data is copied so the slices are still valid even after the buffer has changed.
func (*MatrixBuffer) SetChannel ¶
func (mb *MatrixBuffer) SetChannel(channel uint, data []float64)
func (*MatrixBuffer) SetChannels ¶
func (mb *MatrixBuffer) SetChannels(data [][]float64)
func (*MatrixBuffer) Size ¶
func (mb *MatrixBuffer) Size() uint
type Onset ¶
type Onset struct {
// contains filtered or unexported fields
}
Tempo is a wrapper for the aubio_tempo_t tempo detection object.
func NewOnset ¶
NewOnset constructs a new Onset object. It is the Callers responsibility to call Free on the returned Onset object or leak memory.
t, err := NewOnset(mode, bufSize, blockSize, samplerate) if err != nil { // handle error } defer t.Free()
func OnsetOrDie ¶
OnsetOrDie constructs a new Onset object. It panics on any errors.
func (*Onset) Buffer ¶
func (t *Onset) Buffer() *SimpleBuffer
func (*Onset) Do ¶
func (t *Onset) Do(input *SimpleBuffer)
Do executes the onset detection on an input Buffer. It returns the estimated beat locations in a new buffer.
func (*Onset) SetSilence ¶
SetSilence sets the onset detection silence threshold.
func (*Onset) SetThreshold ¶
SetThreshold sets the onset detection peak picking threshold.
type PhaseVoc ¶
type PhaseVoc struct {
// contains filtered or unexported fields
}
func NewPhaseVoc ¶
func (*PhaseVoc) Do ¶
func (pv *PhaseVoc) Do(in *SimpleBuffer)
func (*PhaseVoc) Grain ¶
func (pv *PhaseVoc) Grain() *ComplexBuffer
func (*PhaseVoc) ReverseDo ¶
func (pv *PhaseVoc) ReverseDo(out *SimpleBuffer)
type Pitch ¶
type Pitch struct {
// contains filtered or unexported fields
}
Pitch is a wrapper for the aubio_pitch_t pitch detection object.
func NewPitch ¶
NewPitch constructs a new Pitch object. It is the Callers responsibility to call Free on the returned Pitch object or leak memory.
p := NewPitch(mode, bufSize, blockSize, samplerate) defer p.Free()
func (*Pitch) Buffer ¶
func (p *Pitch) Buffer() *SimpleBuffer
func (*Pitch) Do ¶
func (p *Pitch) Do(in *SimpleBuffer)
Do runs one step of the pitch detection as determined by the bufSize.
func (*Pitch) Free ¶
func (p *Pitch) Free()
Free frees the memory allocated by the aubio library for this object.
func (*Pitch) SetTolerance ¶
SetTolerance sets the yin or yinfft tolerance threshold.
type ProcessFunc ¶
type ProcessFunc func(input *SimpleBuffer)
type Resampler ¶
type Resampler struct {
// contains filtered or unexported fields
}
Resampler Ratio: output_sample_rate / input_sample_rate Quality: Resample quality (0 is best, 4 is fastest)
func NewResampler ¶
bufSize is the size of the input buffer. output buffer is size bufSize * ratio
func (*Resampler) Buffer ¶
func (r *Resampler) Buffer() *SimpleBuffer
func (*Resampler) Do ¶
func (r *Resampler) Do(in *SimpleBuffer)
type ReverseComplexAnalyzer ¶
type ReverseComplexAnalyzer interface { Analyzer ReverseDo(input *ComplexBuffer) }
type SimpleBuffer ¶
type SimpleBuffer struct {
// contains filtered or unexported fields
}
SimpleBuffer is a wrapper for the aubio fvec_t type. It is used as the buffer for processing audio data in an aubio pipeline. It is a short sample buffer (32 or 64 bits in size).
func NewSimpleBuffer ¶
func NewSimpleBuffer(size uint) *SimpleBuffer
NewSimpleBuffer constructs a new SimpleBuffer.
The caller is responsible for calling Free on the returned SimpleBuffer to release memory when done.
buf := NewSimpleBuffer(bufSize) defer buf.Free()
func NewSimpleBufferData ¶
func NewSimpleBufferData(size uint, data []float64) *SimpleBuffer
NewSimpleBuffer constructs a new SimpleBuffer.
The caller is responsible for calling Free on the returned SimpleBuffer to release memory when done.
buf := NewSimpleBuffer(bufSize) defer buf.Free()
func (*SimpleBuffer) Abs ¶
func (buf *SimpleBuffer) Abs()
Inplace compute the abs(x) of each vector elements
func (*SimpleBuffer) Ceil ¶
func (buf *SimpleBuffer) Ceil()
Inplace compute the ceil(x) of each vector elements
func (*SimpleBuffer) Clamp ¶
func (buf *SimpleBuffer) Clamp(absmax float64)
Inplace clamp the values of a buffer within the range [-abs(max), abs(max)]
func (*SimpleBuffer) Cos ¶
func (buf *SimpleBuffer) Cos()
Inplace compute the cos(x) of each vector elements
func (*SimpleBuffer) Exp ¶
func (buf *SimpleBuffer) Exp()
Inplace compute the exp(x) of each vector elements
func (*SimpleBuffer) Floor ¶
func (buf *SimpleBuffer) Floor()
Inplace compute the floor(x) of each vector elements
func (*SimpleBuffer) Free ¶
func (b *SimpleBuffer) Free()
Free frees the memory aubio allocated for this buffer.
func (*SimpleBuffer) Get ¶
func (b *SimpleBuffer) Get(i uint) float64
func (*SimpleBuffer) Log ¶
func (buf *SimpleBuffer) Log()
Inplace compute the log(x) (natural log, ln) of each vector elements
func (*SimpleBuffer) Log10 ¶
func (buf *SimpleBuffer) Log10()
Inplace compute the log10(x) of each vector elements
func (*SimpleBuffer) Pow ¶
func (buf *SimpleBuffer) Pow(pow float64)
Inplace raise each vector elements to the power pow
func (*SimpleBuffer) Round ¶
func (buf *SimpleBuffer) Round()
Inplace compute the round(x) of each vector elements
func (*SimpleBuffer) SetData ¶
func (b *SimpleBuffer) SetData(data []float64)
Update the values of the buffer from float64 data
func (*SimpleBuffer) SetDataF32 ¶
func (b *SimpleBuffer) SetDataF32(data []float32)
Update the values of the buffer from float64 data
func (*SimpleBuffer) SetDataFast ¶
func (b *SimpleBuffer) SetDataFast(data []float32)
uses a c wrapper to set the data in a single c call, much faster
func (*SimpleBuffer) SetDataUnsafe ¶
func (b *SimpleBuffer) SetDataUnsafe(data []float32)
Update the values of the buffer using C type casting to avoid conversion overheads. This function uses unsafe pointers (careful!) The only reason this works is because C.smpl_t is just a float32 under the hood. There isn't really any speedup compared to SetDataF32 so no reason to use this.
func (*SimpleBuffer) Sin ¶
func (buf *SimpleBuffer) Sin()
Inplace compute the sin(x) of each vector elements
func (*SimpleBuffer) Size ¶
func (b *SimpleBuffer) Size() uint
Size returns the size of this buffer.
func (*SimpleBuffer) Slice ¶
func (b *SimpleBuffer) Slice() []float64
Returns the contents of this buffer as a slice. The data is copied so the slices are still valid even after the buffer has changed.
func (*SimpleBuffer) Sqrt ¶
func (buf *SimpleBuffer) Sqrt()
Inplace compute the sqrt(x) of each vector elements
type SimplePipeline ¶
type SimplePipeline struct {
// contains filtered or unexported fields
}
Pipeline pipes data from a Source to a Sink.
func NewSimplePipeline ¶
func NewSimplePipeline(in *Source, out *Sink, bufSize uint) *SimplePipeline
NewPipeline constructs a Pipeline between a Source and an optional Sink using a Buffer of bufSize. It will run any ProcessFuncs passed to it as it pulls from the source.
The Pipeline assumes ownership of the source and sink so calling Close on the Pipeline will close the source as well as the sink.
pitch := NewPitch(...) fn := func(in, out *Buffer) { pitch.Do(in, out) // do something with that data. } p := NewPipeline(OpenSource(sourceUri, samplerate, hopSize), OpenSink(sinkUri, samplerate), bufSize, fn) defer p.Close() p.DoAll() // pipe all the data in source to the sink
func PipelineFromUris ¶
func PipelineFromUris(inUri, outUri string, samplerate, blockSize, bufSize uint) (*SimplePipeline, error)
PipelineFromUris constructs a pipe from two URIs. If samplerate is 0 it detects the samplerate from the source and uses that for the sink.
func (*SimplePipeline) BlockSize ¶
func (p *SimplePipeline) BlockSize() uint
BlockSize returns the BlockSize used by this Pipeline.
func (*SimplePipeline) BufSize ¶
func (p *SimplePipeline) BufSize() uint
BufSize returns the current buffer size the Pipeline is using.
func (*SimplePipeline) Close ¶
func (p *SimplePipeline) Close()
Close closes the the Source, Sink, and frees the Buffer.
func (*SimplePipeline) Do ¶
func (p *SimplePipeline) Do(fs ...ProcessFunc) uint
Do pipes up to BufSize data from the source to a sink if there is one. It returns the number of frames processed.
func (*SimplePipeline) DoAll ¶
func (p *SimplePipeline) DoAll(fs ...ProcessFunc) (total uint)
DoAll runs Do until the source has been exhausted. It returns the number of frames processed.
func (*SimplePipeline) DoN ¶
func (p *SimplePipeline) DoN(n int, fs ...ProcessFunc) (total uint)
DoN runs Do up to n times. It returns the number of frames processed.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is a wrapper for an aubio_sink_t object.
func OpenSink ¶
OpenSink opens an aubio_sink_t from the uri. It uses the samplerate to write data to the sink.
The caller is responsible for calling close on the returned Sink to release memory.
s := OpenSink(uri, 44100) defer s.Close()
func (*Sink) Do ¶
func (s *Sink) Do(buf *SimpleBuffer, n uint) uint
Do writes to the sink from the buffer. It returns the amount of data written.
func (*Sink) Samplerate ¶
Samplerate returns the samplerate for this Sink.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is a wrapper for an aubio_source_t object.
func OpenSource ¶
OpenSource opens an aubio_source_t from the uri. It uses the given samplerate and hopSize for processing the audio source stream.
The caller is responsible for calling close on the returned Source to release memory.
s := OpenSource(uri, 44100, 1024) defer s.Close()
func (*Source) Close ¶
func (s *Source) Close()
Close closes the aubio_source_t and frees the memory.
func (*Source) Do ¶
func (s *Source) Do(buf *SimpleBuffer) uint
Do reads from a source into a buffer. It returns the amount of data read.
func (*Source) Samplerate ¶
Samplerate returns the sample rate of a Source.
type TSS ¶
type TSS struct {
// contains filtered or unexported fields
}
func (*TSS) Do ¶
func (tss *TSS) Do(in *ComplexBuffer)
func (*TSS) SetThreshold ¶
func (*TSS) Stead ¶
func (tss *TSS) Stead() *ComplexBuffer
func (*TSS) Trans ¶
func (tss *TSS) Trans() *ComplexBuffer
type Tempo ¶
type Tempo struct {
// contains filtered or unexported fields
}
Tempo is a wrapper for the aubio_tempo_t tempo detection object.
func NewTempo ¶
NewTempo constructs a new Tempo object. It is the Callers responsibility to call Free on the returned Tempo object or leak memory.
t, err := NewTempo(mode, bufSize, blockSize, samplerate) if err != nil { // handle error } defer t.Free()
func TempoOrDie ¶
TempoOrDie constructs a new Tempo object. It panics on any errors.
func (*Tempo) Buffer ¶
func (t *Tempo) Buffer() *SimpleBuffer
func (*Tempo) Do ¶
func (t *Tempo) Do(input *SimpleBuffer)
Do executes the tempo detection on an input Buffer. It returns the estimated beat locations in a new buffer.
func (*Tempo) GetBpm ¶
GetBpm returns the bpm after running Do on an input Buffer
t, err := NewTempo(mode, bufSize, blockSize, samplerate) if err != nil { } defer t.Close() t.Do(buf) fmt.Println("BPM: ", t.GetBpm())
func (*Tempo) GetConfidence ¶
GetConfidence returns the confidence after running Do on an input Buffer
t, err := NewTempo(mode, bufSize, blockSize, samplerate) if err != nil { } defer t.Close() t.Do(buf) fmt.Println("Confidence: ", t.GetConfidence())
func (*Tempo) SetSilence ¶
SetSilence sets the tempo detection silence threshold.
func (*Tempo) SetThreshold ¶
SetThreshold sets the tempo detection peak picking threshold.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
onset
tempo is an aubio example application.
|
tempo is an aubio example application. |
pitch
pitch is an aubio example application.
|
pitch is an aubio example application. |
sink
sink is an aubio example application.
|
sink is an aubio example application. |
tempo
tempo is an aubio example application.
|
tempo is an aubio example application. |