Documentation
¶
Overview ¶
Package: github.com/Foxenfurter/foxAudioLib/foxConvolver filename foxConvolver.go Package is designed to manage convolution of Filter Impulse Responses includes any logic neeeded to prepare the filter for convolution, such as Resampling and Normalization
Package: github.com/Foxenfurter/foxAudioLib/foxConvolver filename foxConvolver.go Package is designed to manage convolution of Filter Impulse Responses includes any logic neeeded to prepare the filter for convolution, such as Resampling and Normalization
Package: github.com/Foxenfurter/foxAudioLib/foxConvolver filename foxConvolver.go Package is designed to manage convolution of Filter Impulse Responses includes any logic neeeded to prepare the filter for convolution, such as Resampling and Normalization
Index ¶
- Constants
- func CalculateFFT(input []complex128) []complex128
- func CalculateInverseFFT(input []complex128) []complex128
- func CalculateMaxGain(audioData []float64) float64
- func ConvolveSlow(impulse1 []float64, impulse2 []float64) []float64
- func CopyAndPad(dest, src []complex128, srcSize int)
- func DustyConvolver(signalBlock []float64, impulse []float64) []float64
- func InverseTukeyFFT(X []complex128) []complex128
- func NewComplexMultiplyAccumulate(result []complex128, a, b []complex128)
- func NextPowerOf2(x int) int
- func Normalize(inputSamples [][]float64, targetLevel float64) float64
- func OldComplexMultiplyAccumulate(result, a, b SplitComplexOld)
- func ReadnResampleFirFile(filePath string, targetSampleRate int) (*bytes.Reader, error)
- func ResampleChannel(inputSamples []float64, fromSampleRate, toSampleRate, quality int) ([]float64, error)
- func SetZero(dest []complex128)
- func Sum(result, a, b []float64, len int)
- func TargetGain(fromSampleRate, toSampleRate int) float64
- func TukeyFFT(X []complex128) []complex128
- type Convolver
- func (myConvolver *Convolver) AmendFilterImpulse(impulse []float64)
- func (myConvolver *Convolver) ConvolveChannel(inputSignalChannel, outputSignalChannel chan []float64)
- func (myConvolver *Convolver) ConvolveFFT(signal []float64) []float64
- func (myConvolver *Convolver) ConvolveOverlapSave(signalBlock []float64) []float64
- func (myConvolver *Convolver) ConvolveSlow(signalBlock []float64) []float64
- func (myConvolver *Convolver) DustyConvolver(signalBlock []float64) []float64
- func (myConvolver *Convolver) GetPaddedLength() int
- func (myConvolver *Convolver) InitForStreaming()
- func (myConvolver *Convolver) Resample(inputSamples [][]float64, fromSampleRate, toSampleRate, quality int) error
- type FFTConvolver
- type SplitComplex
- type SplitComplexOld
Constants ¶
const (
PI = math.Pi
)
Variables ¶
This section is empty.
Functions ¶
func CalculateFFT ¶
func CalculateFFT(input []complex128) []complex128
func CalculateInverseFFT ¶
func CalculateInverseFFT(input []complex128) []complex128
func CalculateMaxGain ¶
Calculates the Maximum Gain Value - used for Normalization functions
func ConvolveSlow ¶
Simple convolver multiplication calculation for baseline testing
func CopyAndPad ¶
func CopyAndPad(dest, src []complex128, srcSize int)
CopyAndPad copies the source array into the destination buffer and pads the destination buffer with zeros if necessary.
func DustyConvolver ¶
func InverseTukeyFFT ¶
func InverseTukeyFFT(X []complex128) []complex128
simple Cooley-Tukey based inverse FFT for baseline benchmark
func NewComplexMultiplyAccumulate ¶
func NewComplexMultiplyAccumulate(result []complex128, a, b []complex128)
func NextPowerOf2 ¶
return the next power of 2 that is greater than the input
func OldComplexMultiplyAccumulate ¶
func OldComplexMultiplyAccumulate(result, a, b SplitComplexOld)
ComplexMultiplyAccumulate multiplies the elements of complex arrays a and b and adds the result to the complex array result.
func ReadnResampleFirFile ¶
In case you want to use sox as an input.
func ResampleChannel ¶
func ResampleChannel(inputSamples []float64, fromSampleRate, toSampleRate, quality int) ([]float64, error)
So far the best solution for internal resampling, although it works well for upsampling and poorly for downsampling
func SetZero ¶
func SetZero(dest []complex128)
func TargetGain ¶
Calculate the target gain level based on the sampling frequency parameters: From Sample Rate, To Sample Rate (int) returns the target gain level as float64
func TukeyFFT ¶
func TukeyFFT(X []complex128) []complex128
simple Cooley-Tukey based FFT for baseline benchmark
Types ¶
type Convolver ¶
type Convolver struct { FilterImpulse []float64 // Impulse response Buffer []float64 // Buffer to manage difference between streamed signal size and target size for convolution //streaming bool DebugFunc func(string) WarningFunc func(string) // contains filtered or unexported fields }
Convolver represents a convolver structure
func NewConvolver ¶
Init initializes the convolver structure supply FIR filter impulse and overlap factor as a value between 0.1 and 0.9
func (*Convolver) AmendFilterImpulse ¶
Allows the impulse to be changed, but forces the length to be updated and nominally wrong so that the convolver process will recalulcate PaddedLength and FilterImpulseFFT values
func (*Convolver) ConvolveChannel ¶
func (myConvolver *Convolver) ConvolveChannel(inputSignalChannel, outputSignalChannel chan []float64)
Convolver optimized for go channels. Reads an Input Channel and Sends to an output Channel Processing size is optimised for FFT performance hence is derived from the impulse length Must use overlap and save mechanism for convolving to avoid dropouts and other glitches.
func (*Convolver) ConvolveFFT ¶
use convolver structure with precomputed Impulse values and then convolve signal
func (*Convolver) ConvolveOverlapSave ¶
func (*Convolver) ConvolveSlow ¶
Simple convolver multiplication calculation for baseline testing, setup to use pre fft Impulse
func (*Convolver) DustyConvolver ¶
func (*Convolver) GetPaddedLength ¶
func (*Convolver) InitForStreaming ¶
func (myConvolver *Convolver) InitForStreaming()
Initialise Convolver for Streaming convolution - prebuilds the Impulse FFT and sets up the overlap calculates the target size for the signal
type FFTConvolver ¶
type FFTConvolver struct {
// contains filtered or unexported fields
}
FFTConvolver struct represents the FFT convolver.
func NewFFTConvolver ¶
func NewFFTConvolver() *FFTConvolver
NewFFTConvolver creates a new instance of FFTConvolver.
func (*FFTConvolver) Init ¶
func (convolver *FFTConvolver) Init(blockSize int, ir []float64, irLen int) bool
Init initializes the FFTConvolver with the given parameters. param blockSize Block size internally used by the convolver (partition size) param ir The impulse response param irLen Length of the impulse response return true: Success - false: Failed
func (*FFTConvolver) Process ¶
func (convolver *FFTConvolver) Process(input []float64) []float64
Process processes the input data and produces the output. Convolves the the given input samples and immediately outputs the result param input The input samples param output The convolution result param len Number of input/output samples
func (*FFTConvolver) Reset ¶
func (convolver *FFTConvolver) Reset()
Reset resets the FFTConvolver to its initial state.
type SplitComplex ¶
type SplitComplex []complex128
type SplitComplexOld ¶
type SplitComplexOld struct {
// contains filtered or unexported fields
}
SplitComplex represents a buffer for split-complex representation of FFT results.
func (*SplitComplexOld) Im ¶
func (sc *SplitComplexOld) Im() []float64
Im returns the imaginary part of the split-complex buffer.
func (*SplitComplexOld) Re ¶
func (sc *SplitComplexOld) Re() []float64
NewSplitComplex creates a new SplitComplex instance with the specified initial size.
func NewSplitComplex(initialSize int) *SplitComplex { sc := &SplitComplex{} sc.Resize(initialSize) return sc }
// Clear clears the split-complex buffer.
func (sc *SplitComplex) Clear() { sc.re.Clear() sc.im.Clear() sc.size = 0 }
// Resize resizes the split-complex buffer to the specified size.
func (sc *SplitComplex) Resize(newSize int) { sc.re.Resize(newSize) sc.im.Resize(newSize) sc.size = newSize }
// SetZero sets all elements of the split-complex buffer to zero.
func (sc *SplitComplex) SetZero() { sc.re.SetZero() sc.im.SetZero() }
// CopyFrom copies the content of another SplitComplex instance to this instance.
func (sc *SplitComplex) CopyFrom(other *SplitComplex) { sc.re.CopyFrom(other.re) sc.im.CopyFrom(other.im) }
Re returns the real part of the split-complex buffer.
func (*SplitComplexOld) Size ¶
func (sc *SplitComplexOld) Size() int
Size returns the size of the split-complex buffer.