haptify library

Type-safe, composable haptic pattern authoring.

Define a haptic pattern once and export it to AHAP JSON for iOS Core Haptics or to Android waveform data — no platform channels, just data for the playback plugin you already use.

Classes

AhapDecoder
Parses AHAP (Apple Haptic and Audio Pattern) JSON into a HapticPattern.
AhapEncoder
Encodes a HapticPattern into AHAP (Apple Haptic and Audio Pattern) JSON, the format Core Haptics plays on iOS.
AnalysisOptions
Tuning knobs for AudioAnalyzer.
AndroidWaveform
A haptic pattern rendered for Android's VibrationEffect.createWaveform(long[] timings, int[] amplitudes, int repeat).
AudioAnalyzer
Turns decoded audio into a HapticPattern: transient events at detected onsets layered over continuous events that follow the loudness envelope.
AudioData
Decoded audio: mono samples in [-1, 1] at a fixed sample rate.
AudioDecoder
Decodes audio files into mono AudioData.
ContinuousEvent
A sustained haptic vibration. See HapticEvent.continuous.
ConversionWarning
A note about information lost or approximated during a lossy conversion.
CurvePoint
A single control point on a HapticCurve.
HapticCurve
A piecewise-linear modulation of a dynamic parameter over the pattern's timeline.
HapticEnvelope
The amplitude envelope of a continuous haptic event.
HapticEvent
A single haptic event on a pattern's timeline.
HapticMetadata
Optional descriptive metadata attached to a pattern.
HapticPattern
An immutable haptic pattern: a set of events on a shared timeline, optionally modulated by curves.
PrimitiveComposition
A haptic pattern rendered as an Android VibrationEffect.Composition: an ordered list of primitives with scales and inter-primitive delays.
PrimitivesEncoder
Renders a HapticPattern into an Android VibrationEffect.Composition — a sequence of device primitives.
PrimitiveSpec
One addPrimitive call: which primitive, how strong, and how long to pause after the previous primitive before starting it.
TransientEvent
A momentary haptic tap. See HapticEvent.transient.
WaveformEncoder
Renders a HapticPattern into an AndroidWaveform by sampling its intensity envelope at a fixed resolution.

Enums

AudioFormat
An audio container format haptify can decode from raw bytes without any external tools or filesystem access.
ConversionWarningCode
Machine-readable categories for ConversionWarning.
HapticCurveParameter
The dynamic parameter a HapticCurve modulates over time.
HapticPrimitive
The Android VibrationEffect.Composition primitives haptify can emit.

Extensions

AhapEncoding on HapticPattern
AHAP export entry points on HapticPattern.
HapticDurationX on num
Numeric sugar for authoring durations: 250.ms, 0.5.s.
HapticPatternCombinators on HapticPattern
Pure combinators for composing HapticPatterns.
PrimitivesEncoding on HapticPattern
Android composition export entry point on HapticPattern.
WaveformEncoding on HapticPattern
Android waveform export entry point on HapticPattern.

Functions

decodeAudioBytes(Uint8List bytes, {AudioFormat? format}) AudioData
Decodes in-memory audio bytes into mono AudioData, entirely in Dart.
overlay(Iterable<HapticPattern> patterns) HapticPattern
Merges patterns onto a shared timeline: all events and curves play at their original times, layered together.
sequence(Iterable<HapticPattern> patterns, {Duration gap = Duration.zero}) HapticPattern
Combines patterns back to back into one pattern, with an optional silent gap between consecutive patterns.
wavToAudioData(Wav wav) AudioData
Downmixes a decoded Wav to mono AudioData by averaging its channels.

Exceptions / Errors

AudioDecodeException
Thrown when audio cannot be decoded.