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
addPrimitivecall: 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.Compositionprimitives 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
bytesinto mono AudioData, entirely in Dart. -
overlay(
Iterable< HapticPattern> patterns) → HapticPattern -
Merges
patternsonto a shared timeline: all events and curves play at their original times, layered together. -
sequence(
Iterable< HapticPattern> patterns, {Duration gap = Duration.zero}) → HapticPattern -
Combines
patternsback to back into one pattern, with an optional silentgapbetween consecutive patterns. -
wavToAudioData(
Wav wav) → AudioData -
Downmixes a decoded
Wavto mono AudioData by averaging its channels.
Exceptions / Errors
- AudioDecodeException
- Thrown when audio cannot be decoded.