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 ¶
const ( FollowSpeed = "speed" FollowDepth = "depth" FollowSteady = "steady" )
Follow profiles: what the vibration level follows.
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.
const ( // SpeedWindowMillis is the look-back window for averaged absolute // velocity, one pacer tick, so each stroke's own speed comes through. // Averaging |dp| over the window keeps a reversal from cancelling, which // an endpoint difference would. SpeedWindowMillis = 100 // FadeMillis is the fade-in at every Play and Resume. FadeMillis = 2000 )
Rendering constants. The smoothing, the speed scale and the user's timing offset are tuned together, because smoothing, radio and motor lag add up. The first physical test found the 250 ms window and release left following speed close to constant: about one motor step per stroke (ADR 0063).
Variables ¶
This section is empty.
Functions ¶
func Output ¶
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 ¶
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. A positive level keeps at least the lowest step the ceiling allows, so a turnaround's dip does not switch the motor off and on with every stroke (ADR 0063); only a zero level is silent.
func SpeedPercentLevel ¶
SpeedPercentLevel places a commanded speed within the saved speed band on the same scale as following speed: companion.SpeedBandFloor 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 ¶
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 ¶
NewRenderer returns a renderer for profile.
func (*Renderer) Drive ¶
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 ¶
DriveEnvelope reads engine-sampled drive, keeping the same coverage and startup fade. The conversion profile does not reshape an independent lane.
func (*Renderer) Restart ¶
Restart begins a new or resumed stream at streamMillis: smoothing resets and output fades in from zero.
func (*Renderer) SetProfile ¶
SetProfile applies a new profile from the next level on.