signal

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 3 Imported by: 0

README

Signal

GoDoc Go Report Card Build Status codecov

Manipulate digital signal with ease. Check godoc for more information.

Documentation

Overview

Package signal provides functionality for manipulate digital signals and its attributes.

Index

Constants

View Source
const (
	// BitDepth8 is 8 bit depth.
	BitDepth8 = BitDepth(8)
	// BitDepth16 is 16 bit depth.
	BitDepth16 = BitDepth(16)
	// BitDepth24 is 32 bit depth.
	BitDepth24 = BitDepth(24)
	// BitDepth32 is 32 bit depth.
	BitDepth32 = BitDepth(32)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BitDepth

type BitDepth uint

BitDepth is the number of bits of information in each sample.

func (BitDepth) String

func (b BitDepth) String() string

type Float64

type Float64 [][]float64

Float64 is a non-interleaved float64 signal.

func Float64Buffer

func Float64Buffer(numChannels, bufferSize int) Float64

Float64Buffer returns an Float64 buffer of specified dimentions.

func (Float64) Append

func (floats Float64) Append(source Float64) Float64

Append buffers to existing one. New buffer is returned if b is nil.

func (Float64) AsInterInt

func (floats Float64) AsInterInt(bitDepth BitDepth, unsigned bool) InterInt

AsInterInt allocates new interleaved int buffer of the same size and copies signal values there. If unsigned is true, then all values are shifted and result will be in unsigned range.

func (Float64) CopyToInterInt added in v0.4.0

func (floats Float64) CopyToInterInt(ints InterInt)

CopyToInterInt buffer the values of Float64 buffer. If number of channels is not equal, function will panic.

func (Float64) NumChannels

func (floats Float64) NumChannels() int

NumChannels returns number of channels in this sample slice.

func (Float64) Size

func (floats Float64) Size() int

Size returns number of samples in single block in this sample slice.

func (Float64) Slice

func (floats Float64) Slice(start, len int) Float64

Slice creates a new buffer that refers to floats data from start position with defined legth. Shorten block is returned if buffer doesn't have enough samples. If start is less than 0 or more than buffer size, nil is returned. If len goes beyond the buffer size, it's truncated up to length of the buffer.

func (Float64) Sum added in v0.4.0

func (floats Float64) Sum(b Float64) Float64

Sum adds values from one buffer to another. The lesser dimensions are used.

type Int

type Int [][]int

Int is a non-interleaved int signal.

type InterInt

type InterInt struct {
	Data        []int
	NumChannels int
	BitDepth
	Unsigned bool
}

InterInt is an interleaved int signal.

func (InterInt) AsFloat64

func (ints InterInt) AsFloat64() Float64

AsFloat64 allocates new Float64 buffer of the same size and copies signal values there.

func (InterInt) CopyToFloat64 added in v0.4.0

func (ints InterInt) CopyToFloat64(floats Float64)

CopyToFloat64 buffer the values of InterInt buffer. If number of channels is not equal, function will panic.

func (InterInt) Size added in v0.4.0

func (ints InterInt) Size() int

Size of non-interleaved data.

type SampleRate added in v0.2.0

type SampleRate uint

SampleRate is the number of samples obtained in one second.

func (SampleRate) DurationOf added in v0.2.0

func (rate SampleRate) DurationOf(samples int) time.Duration

DurationOf returns time duration of samples at this sample rate.

func (SampleRate) SamplesIn added in v0.2.0

func (rate SampleRate) SamplesIn(d time.Duration) int

SamplesIn returns number of samples for time duration at this sample rate.

Jump to

Keyboard shortcuts

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