vibration

package
v0.1.0-alpha.79 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-3.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vibration converts the shared motion frame into a vibrator drive level. It is a pure function of the frame, the user's profile and its own smoothing state: it never invents motion, never reshapes the frame, and never raises a level above the user's live intensity.

Index

Constants

View Source
const (
	FollowSpeed  = "speed"
	FollowDepth  = "depth"
	FollowSteady = "steady"
)

Follow profiles: what the vibration level follows.

View Source
const (
	DepthBase = "base"
	DepthTip  = "tip"
)

Depth ends in the frame's semantic coordinates: base is position 0 and tip is position 100. The stroker's reverse-direction setting corrects how a stroker is mounted and does not change them.

View Source
const (
	// SpeedWindowMillis is the look-back window for averaged absolute
	// velocity. Averaging |dp| over the window keeps a reversal from
	// cancelling, which an endpoint difference would.
	SpeedWindowMillis = 250

	// FadeMillis is the fade-in at every Play and Resume.
	FadeMillis = 2000
)

Rendering constants. They are starting points, not measured values: the smoothing, the speed scale and the user's timing offset are tuned together during hardware acceptance, because smoothing, radio and motor lag add up.

Variables

This section is empty.

Functions

func Output

func Output(drive, minimum, intensity float64) float64

Output maps a drive fraction into the range from the minimum up to the live intensity. At an intensity of zero the vibrator is silent whatever the motion does, and a zero drive is always exactly zero.

func Quantize

func Quantize(level float64, steps, last int, ceiling float64) int

Quantize picks the actuator step for level with steps steps. last is the step sent before, or -1. The ceiling quantizes downward: a coarse motor gets its nearest step at or below it, never above.

func SpeedPercentLevel

func SpeedPercentLevel(speed, low, high int) float64

SpeedPercentLevel places a commanded speed within the saved speed band on the same scale as following speed: 35% at the slowest saved speed up to 1 at the fastest. It is The Handy's intensity for profiles that do not follow speed.

Types

type Profile

type Profile struct {
	Follow    string
	DepthEnd  string
	SpeedLow  float64
	SpeedHigh float64
}

Profile is the user's conversion profile. SpeedLow and SpeedHigh are the averaged carriage speeds, in full spans per second, at the user's slowest and fastest saved Handy speeds; zero keeps the saturating curve.

type Renderer

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

Renderer converts the frame into a drive fraction in 0..1.

func NewRenderer

func NewRenderer(profile Profile) *Renderer

NewRenderer returns a renderer for profile.

func (*Renderer) Drive

func (r *Renderer) Drive(timeline *companion.Timeline, streamMillis float64) (float64, bool)

Drive returns the drive fraction at streamMillis and whether the frame covered it. Uncovered time is silent: the owner reports starvation instead of holding the last level.

func (*Renderer) DriveEnvelope

func (r *Renderer) DriveEnvelope(timeline *companion.Timeline, at float64) (float64, bool)

DriveEnvelope reads engine-sampled drive, keeping the same coverage and startup fade. The conversion profile does not reshape an independent lane.

func (*Renderer) Restart

func (r *Renderer) Restart(streamMillis float64)

Restart begins a new or resumed stream at streamMillis: smoothing resets and output fades in from zero.

func (*Renderer) SetProfile

func (r *Renderer) SetProfile(profile Profile)

SetProfile applies a new profile from the next level on.

Jump to

Keyboard shortcuts

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