Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Method for Calculating Overlap Size in Spectrogram Resampling #3848

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/plugins/spectrogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,8 @@ class SpectrogramPlugin extends BasePlugin<SpectrogramPluginEvents, SpectrogramP
const oldEnd = oldStart + oldPiece
const newStart = i * newPiece
const newEnd = newStart + newPiece
const overlap = Math.max(0, Math.min(oldEnd, newEnd) - Math.max(oldStart, newStart));
katspaugh marked this conversation as resolved.
Show resolved Hide resolved

const overlap =
oldEnd <= newStart || newEnd <= oldStart
? 0
: Math.min(Math.max(oldEnd, newStart), Math.max(newEnd, oldStart)) -
Math.max(Math.min(oldEnd, newStart), Math.min(newEnd, oldStart))
let k
/* eslint-disable max-depth */
if (overlap > 0) {
Expand Down