Add feature to pad or trim audio sources#22
Open
Curucail wants to merge 1 commit intoaudiolabs:masterfrom
Open
Add feature to pad or trim audio sources#22Curucail wants to merge 1 commit intoaudiolabs:masterfrom
Curucail wants to merge 1 commit intoaudiolabs:masterfrom
Conversation
…d end-offset-ms attributes
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.
Add support for padding or trimming of audio source clips (ts-source elements), allowing more flexible playback alignment as propsed in #21 .
Changes
Audio track timing and scheduling:
trackTimingarray to store timing metadata (trims, pads, effective duration) for each track, using the newcalculateTrackTimingmethod to parse optionalstart-offset-msandend-offset-msattributes from source elements. [1] [2] [3]startAudiomethod to use the timing metadata for each track when scheduling playback, ensuring correct alignment with trims, pads, and offsets. This includes calculating when to start each track, how much to play, and handling edge cases where the position is outside the effective audio region.findLongestmethod to use the effective duration fromtrackTimingif available, ensuring accurate determination of the longest track for synchronization.Audio source management and robustness:
stopAudiomethod to safely stop only initialized audio sources, preventing errors if a source is missing.startAudiofor better readability and maintainability.Usage Example
You can now add optional start and end offsets on each ts-source using the attributes start-offset-ms and end-offset-ms (values in milliseconds). Positive values trim audio (cut from start/end), while negative values add padding (silence before/after), so you can align tracks without re-exporting files. The player automatically includes these offsets when calculating the overall multitrack duration.
Example:
This starts the guitar 120 ms later (padded at start) and cuts 250 ms from its end.