feat: synchronized audio + haptics (iOS, Android, RN, Flutter, KMP) - #162
Open
piaskowyk wants to merge 6 commits into
Open
feat: synchronized audio + haptics (iOS, Android, RN, Flutter, KMP)#162piaskowyk wants to merge 6 commits into
piaskowyk wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds synchronized audio + haptics to Pulsar: play a short authored sound locked to a haptic pattern, via a new
parsePatternWithSoundentry point on the Pattern Composer. Implemented across native iOS, native Android, React Native, Flutter, and KMP.Why
Pulsar could vibrate but not play a paired sound in sync. The existing
AudioSimulatoronly synthesizes an audible preview of the haptic envelope (a dev/simulator aid) — it can't play a real audio file. This PR adds true sound playback aligned to the haptics.Design (per platform)
CHHapticEngine.registerAudioResourceand folded into the discreteCHHapticPatternas aCHHapticEvent. Audio and haptics share one player/timeline → sample-accurate..oggwith baked haptic channels drives the vibrator directly (audio-coupled, perfect sync) when the device supports it. Otherwise — including any non-.oggfile (.wav/.mp3), auto-detected — it falls back to playing the audio while Pulsar's own generatedVibrationEffectfires in parallel.{ uri, volume, offset };hapticChannelsis native-default (true) + auto-detection, so it isn't surfaced to app developers.registerAudioResourceinterop + the audio-event fold).Public API
Providing audio files
.caf/.wav(PCM), local/bundled; Core Haptics can't register remote URLs..mp3works if the OS registers it, else falls back to haptics-only..oggwith haptic channels for coupled sync; any other format is played as plain audio + Pulsar haptics.sound.uriaccepts arequire()(resolved viaImage.resolveAssetSource) or a string. Note arequire()resolves to a remote Metro URL in dev but a local file in release — test synced sound on a release build / device.Verification
compileKotlinIosSimulatorArm64(common + Kotlin/Native Core Haptics interop) — ✅ (surfaced & fixed a realNSURLforward-declaration mismatch).compileAndroidMainwith-PUSE_LOCAL_PULSAR_ANDROID=1(also recompiles the canonicalAndroid/Pulsarchanges) — ✅.dart analyze lib— ✅ clean.tsc— ✅.Reviewer notes
com.swmansion:pulsarMaven artifact, which won't have this API until it's published (or built with-PUSE_LOCAL_PULSAR_ANDROID=1).xcodebuild— they call the same canonical APIs that did compile.docs/.../config.tschange in the working tree is intentionally not part of this PR.