Skip to content

Commit

Permalink
Optimized Method for Calculating Overlap Size in Spectrogram Resampli…
Browse files Browse the repository at this point in the history
…ng (#3848)

* Optimized Method for Calculating Overlap Size in Spectrogram Resampling

* Update src/plugins/spectrogram.ts

---------

Co-authored-by: katspaugh <[email protected]>
  • Loading branch information
shellRaining and katspaugh authored Sep 2, 2024
1 parent 5f32d82 commit 4567c99
Showing 1 changed file with 1 addition and 5 deletions.
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))

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

0 comments on commit 4567c99

Please sign in to comment.