fix(web): render web haptics audio as a fixed-frequency, fixed-amplitude buzz#77
Open
piaskowyk wants to merge 1 commit into
Open
fix(web): render web haptics audio as a fixed-frequency, fixed-amplitude buzz#77piaskowyk wants to merge 1 commit into
piaskowyk wants to merge 1 commit into
Conversation
…ude buzz Web haptics drive the vibration motor at a single fixed frequency and amplitude; navigator.vibrate can only gate the motor on and off, so intensity and sharpness are expressed purely through PWM timing. AudioGenerator.renderInterval previously derived pitch (lerp 220->95Hz) and loudness (lerp 0.14->0.42) from each pulse's duration, so short vs long pulses came out as different notes at different volumes — musical and unfaithful to the real actuator. Now every "on" window renders the identical buzz: fixed carrier (CARRIER_FREQUENCY_HZ), fixed amplitude (PULSE_VOLUME), and a fixed integer-harmonic timbre. Only the on/off timing varies, mirroring the real fixed-frequency motor. Remove the now-dead duration-mapping helpers and the unused Engine timing dependency. Add a regression test asserting a 40ms and a 180ms pulse produce the same frequency and amplitude, and document the constraint in AGENT_CONTEXT.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
On web, haptics drive the vibration motor at a single fixed frequency and amplitude —
navigator.vibratecan only control when the motor is on. Intensity and sharpness are therefore expressed purely through PWM timing (longer shots feel stronger, tighter shots feel buzzier), which is exactly whatPatternComposeralready produces.The audio simulation was not honoring this.
AudioGenerator.renderIntervalderived pitch and loudness from each pulse's duration:So short vs long pulses came out as different notes at different volumes (plus a 1.5× perfect-fifth triangle harmonic), making it sound musical/electronic rather than like a real actuator.
Change
Every "on" window now renders the identical buzz; only the on/off timing varies:
CARRIER_FREQUENCY_HZ = 180— one fixed carrier (representative LRA resonance)PULSE_VOLUME = 0.5— one fixed amplitudeBUZZ_HARMONICS— fixed 1×/2×/3× sine stack (integer harmonics → reads as a buzzing actuator, not a chord)Removed the now-dead
normalizeIntervalDuration/lerphelpers, the unusedtimingCapabilitiesfield, and theEngineimport.Tests
AudioGeneratortests pass.Notes
web/Pulsar). The separate docs-site + FigmaAudioPatternUtilityengine still maps amplitude→volume and frequency→pitch sweeps; left untouched for now.web/Pulsar/AGENT_CONTEXT.mdso future work doesn't reintroduce duration-based pitch/volume.🤖 Generated with Claude Code