fix: canvas scaling quality, copyTransformTo, and pitch-preserving speed change - #488
Open
PiedPiper911 wants to merge 4 commits into
Open
fix: canvas scaling quality, copyTransformTo, and pitch-preserving speed change#488PiedPiper911 wants to merge 4 commits into
PiedPiper911 wants to merge 4 commits into
Conversation
…ment - Set imageSmoothingQuality to high in BaseSprite._render() to fix blurry video when scaling down (WebAV-Tech#482). - Add copyTransformTo() method that copies only position/rotation, preserving the target sprite's own dimensions (WebAV-Tech#481).
Integrates soundtouch-ts to implement time-stretching without pitch shift. Wraps AudioClip with a SoundTouch processor that decouples playback speed from pitch. Uses dynamic import so soundtouch-ts is an optional dependency. Closes WebAV-Tech#487
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
Three improvements to the WebAV canvas rendering and audio processing:
Fix #482 - Video blurs after manual scale-down
Set
imageSmoothingQuality = 'high'inBaseSprite._render()before any drawing operations. The Canvas 2D API defaults to low-quality interpolation, which causes visible blurriness when high-resolution video is scaled down on the canvas.This applies to all sprite types (VisibleSprite, OffscreenSprite) since they all call
super._render(ctx)beforedrawImage().Fix #481 - Text sprite bounding box doesn't follow after copyStateTo
Added a new
copyTransformTo()method onBaseSpritethat copies only position and rotation (x, y, angle) while preserving the target sprite's own dimensions (w, h).The existing
copyStateTo()behavior is unchanged for backward compatibility.Fix #487 - Pitch-preserving speed change (SoundTouch integration)
Added
SpeedAudioClipclass andcreateSpeedAudioClip()factory function that wraps anAudioClipwith SoundTouch time-stretching. This decouples playback speed from pitch:OffscreenSpritespeed change: changes both speed AND pitchSpeedAudioClip: changes speed while keeping original pitchsoundtouch-tsis added as an optional peer dependency - dynamically imported only whenSpeedAudioClipis used, so users who don't need this feature pay zero cost.Usage:
Test plan
copyTransformTo()to transfer position - bounding box should follow correctlycopyStateTo()still works as before (copies all properties including dimensions)soundtouch-ts, create aSpeedAudioClipat 1.5x speed - audio should be faster but pitch unchangedcreateSpeedAudioClip(clip, 1.0)returns the original clip (no overhead)