breakpoint

package
v0.0.0-...-8bb1f52 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MinMaxValue

func MinMaxValue(bs []Breakpoint) (smallest float64, largest float64)

MinMaxValue returns the smallest and largest value found in the breakpoint file

func ValueAt

func ValueAt(bs []Breakpoint, time float64, startIndex int) (index int, value float64)

ValueAt returns the expected value at a given time (expressed as float64) by linear interpolation Returns the index at which we found our value as well as the value itself.

Types

type Breakpoint

type Breakpoint struct {
	Time, Value float64
}

Breakpoint represents a time:value pair

func ParseBreakpoints

func ParseBreakpoints(in io.Reader) ([]Breakpoint, error)

ParseBreakpoints reads the breakpoints from an io.Reader and turns them into a slice. A file is expected to be [time: value] formatted Will panic if file format is wrong TODO: don't panic

type BreakpointStream

type BreakpointStream struct {
	Breakpoints     Breakpoints
	Left            Breakpoint
	Right           Breakpoint
	IndexLeft       int
	IndexRight      int
	CurrentPosition float64 // current position in timeframes
	Increment       float64
	Width           float64
	Height          float64
	HasMore         bool
}

BreakpointStream can be used to to treat breakpoints as a stream of data Each 'tick' can manipulate the state of the breakpoint stream

func NewBreakpointStream

func NewBreakpointStream(bs []Breakpoint, sr int) (*BreakpointStream, error)

NewBreakpointStream represents a slice of breakpoints streamed at a given sample rate

func (*BreakpointStream) Tick

func (b *BreakpointStream) Tick() (out float64)

Tick returns the next value in the breakpoint stream

type Breakpoints

type Breakpoints []Breakpoint

Breakpoints is a collection of Breakpoint (time:value) pairs

func (Breakpoints) Any

func (bs Breakpoints) Any(f func(Breakpoint) bool) bool

Any returns true if any breakpoint matches the filter.

Jump to

Keyboard shortcuts

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