editor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cut

func Cut(c *cast.Cast, from, to float64) (err error)

Cut removes a piece of the cast event stream as specified by `from` and `to`.

It assumes that the provided `cast` is entirely valid (see `github.com/gvcgo/asciinema-edit/cast#Validate`).

If `from == to`:

the exact timestamp is removed.

If `from < to`:

all timestamps from `from` to `to` are removed (both included).

1. search a time that is close to `from`; then 2. search a time that is close to `to`; then 3. remove all in between; then 4. adjust the time of the remaining.

func FindIndex

func FindIndex(eventStream []*cast.Event, from, to float64) (start, end int)

func Quantize

func Quantize(c *cast.Cast, ranges []QuantizeRange) (err error)

Quantize constraints a set of inputs that lie in a range to a single value that corresponds to the lower bound of such range.

For instance, consider the following timestamps:

1  2  5  9 10 11

Assuming that we quantize over [2,6), we'd cut any delays between 2 and 6 seconds to 2 second:

1  2  4  6  7  8

This can be more easily visualized by looking at the delay quantization:

delta = 1.000000 | qdelta = 1.000000
delta = 3.000000 | qdelta = 2.000000
delta = 4.000000 | qdelta = 2.000000
delta = 1.000000 | qdelta = 1.000000
delta = 1.000000 | qdelta = 1.000000

The euristic is:

  1. capture all delays
  2. for each delay, check if it's within an acceptable delay range
  3. if it fits, reduce the delay to the maximum allowed (floor of the quantization range).
  4. adjust the rest of the event stream.

func Speed

func Speed(c *cast.Cast, factor, from, to float64) (err error)

Speed updates the cast speed by multiplying all of the timestamps in a given range by a given factor.

Types

type QuantizeRange

type QuantizeRange struct {
	// From indicates the start of the range
	From float64
	// To indicates the end of the range
	To float64
}

QuantizeRange describes a quantization range.

When applied to a quantization function, any values that lie in the range are trimmed to `from`.

func (*QuantizeRange) InRange

func (q *QuantizeRange) InRange(value float64) bool

InRange verifies whether a given value lies within the quantization range.

func (*QuantizeRange) RangeOverlaps

func (q *QuantizeRange) RangeOverlaps(another QuantizeRange) bool

Overlaps verifies whether a given range (`another`) overlaps with this range.

Jump to

Keyboard shortcuts

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