transforms

package
v0.0.0-...-c5379f9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CrusherMinFactor = 1.0
	CrusherMaxFactor = 2097152.0
)

Functions

func BitCrush

func BitCrush(buf *audio.PCMBuffer, factor float64)

BitCrush reduces the resolution of the sample to the target bit depth Note that bit crusher effects are usually made of this feature + a decimator

func Decimate

func Decimate(buf *audio.PCMBuffer, factor int) (err error)

Decimate drops samples to switch to a lower sample rate. Factor is the decimation factor, for instance a factor of 2 of a 44100Hz buffer will convert the buffer in a 22500 buffer.

func FullWaveRectifier

func FullWaveRectifier(buf *audio.PCMBuffer) error

FullWaveRectifier to make all signal positive See https://en.wikipedia.org/wiki/Rectifier#Full-wave_rectification

func MonoDownmix

func MonoDownmix(buf *audio.PCMBuffer) error

MonoDownmix converts the buffer to a mono buffer by downmixing the channels together.

func MonoRMS

func MonoRMS(b *audio.PCMBuffer, windowSize int) error

MonoRMS converts the buffer to mono and apply an RMS treatment. 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.) TODO: use a sine wave at amplitude of 1: rectication + average = 1.4 (1/square root of 2)

func NominalScale

func NominalScale(buf *audio.PCMBuffer) error

NominalScale converts the input to a -1.0 / +1.0 scale

func NormalizeMax

func NormalizeMax(buf *audio.PCMBuffer)

NormalizeMax sets the max value to 1 and normalize the rest of the data.

func PCMScale

func PCMScale(buf *audio.PCMBuffer) error

PCMScale converts a buffer with audio content from -1 to 1 into the PCM scale based on the buffer's bitdepth.

func Quantize

func Quantize(buf *audio.PCMBuffer, bitDepth int)

Quantize quantizes the audio signal to match the target bitDepth

func Resample

func Resample(buf *audio.PCMBuffer, fs float64) error

Resample down or up samples the buffer. Note that the amplitude will be affected by upsampling.

Types

This section is empty.

Directories

Path Synopsis
filters implement easy to use audio filters.
filters implement easy to use audio filters.

Jump to

Keyboard shortcuts

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