lpc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

README

Linear Predictive Coding

Linear predictive coding is a standard method for modelling signals. This package provides a basic implementation based on the autocorrelation method with filter stability enforcement.

Documentation

Overview

Package lpc provides a linear predictive coding interface.

The LPC modelling algorithm is based on the autocorrelation method with the addition of a numerical tweak to enforce stability of the resulting model.

Package lpc supports modelling, predicting and generation/synthesis.

Package lpc does not yet support line spectral frequencies or conversion to other coefficient representations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State encapsulates linear prediction state for incremental usage in synthesis and prediction.

func (*State) Consume

func (s *State) Consume(d float64) float64

Consume advances the state one element (d), and returns the residue of the model for d.

func (*State) Predict

func (s *State) Predict() float64

Predict returns the current prediction for the next value.

func (*State) Produce

func (s *State) Produce(r float64) float64

Produce synthesizes the next state from the residue r.

type T

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

T holds states for doing linear predictive coding of a given order.

func New

func New(order int) *T

New returns a new linear predictive coder.

func (*T) Model

func (p *T) Model(d []float64) float64

Model causes p to learn coeficients for d, returning the model error.

func (*T) Order

func (p *T) Order() int

Order returns the order of p.

func (*T) R0

func (p *T) R0() float64

R0 returns the zero autocorrelation value, useful for normalizing error.

func (*T) Residue

func (p *T) Residue(d []float64)

Residue applies the model to d and for d[p.Order():] replaces the value of the input with the error (aka residue) of the model.

func (*T) Restore

func (p *T) Restore(d []float64)

Restore restores d if d[p.Order():] is a residue generated from d[:p.Order()].

func (*T) State

func (p *T) State(seed []float64) *State

State returns an lpc state for incrementally predicting and synthesizing values according to the model in p.

Jump to

Keyboard shortcuts

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