feat(sdk): audio play-window (start/duration) on Pattern.sound - #195
Merged
Conversation
Adds optional start/duration (ms) to Sound so the whole audio file can be shipped once and a trimmed window played from it, in sync with the haptics — there is no runtime seek on the audio, so the native side slices to the window. - RN: Sound.start/duration, threaded through usePatternComposer and the PatternComposer_parsePatternWithSound TurboModule spec + both bridges. - iOS: slice the decoded buffer to a temp .caf and register it with Core Haptics (keeps sample-accurate coupling); cleaned up on next parse/dispose. - Android: windowed (non-coupled) clips play via MediaPlayer (seekTo + delayed stop); SoundPool still handles whole-file / coupled .ogg playback.
Threads Sound.start/duration through the remaining bindings so Flutter and KMP honor the same trim window as RN. - Flutter: Dart Sound gains start/duration + toMap; the iOS and Android plugins read them and pass to the (already-capable) native cores. - KMP: commonMain SoundData gains startMs/durationMs; the Android side threads them to the core; the iOS side — which reimplements Core Haptics in Kotlin/ Native rather than using the Swift core — gets the buffer-slice ported into its own makeAudioEvent (AVAudioFile read → slice → temp .caf → register). Verified: KMP compileKotlinIosSimulatorArm64 + androidMain compile; flutter analyze.
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.
Part of the media-synced-haptics feature (SDK slice).
Adds an optional play-window to
Pattern.soundso the whole audio file can be shipped once and a trimmed window played from it, in sync with the haptics — there's no runtime seek on the audio, so the native side slices to the window.Sound.start/Sound.duration(ms), threaded throughusePatternComposerand thePatternComposer_parsePatternWithSoundTurboModule spec + iOS/Android bridges..cafand register it with Core Haptics (keeps sample-accurate coupling); temp cleaned up on next parse/dispose.MediaPlayer(seekTo + delayed stop);SoundPoolstill handles whole-file / coupled.ogg.Verification: iOS Swift core
BUILD SUCCEEDED; Android core + RN moduleBUILD SUCCESSFUL(codegen regenerated the 6-arg signature and the Kotlin bridge matches).Backward-compatible:
start/durationdefault to 0 (whole file), so existingsoundusage is unchanged. No dependency on the other PRs.