diff options
Diffstat (limited to 'tools/spectral_editor/script.js')
| -rw-r--r-- | tools/spectral_editor/script.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/spectral_editor/script.js b/tools/spectral_editor/script.js index 4053aef..677a823 100644 --- a/tools/spectral_editor/script.js +++ b/tools/spectral_editor/script.js @@ -1543,20 +1543,20 @@ function spectrogramToAudio(spectrogram, dctSize, numFrames) { const window = hanningWindowArray; for (let frameIdx = 0; frameIdx < numFrames; frameIdx++) { - // Extract frame + // Extract frame and apply window to spectrum (matches C++ synth.cc) const frame = new Float32Array(dctSize); for (let b = 0; b < dctSize; b++) { - frame[b] = spectrogram[frameIdx * dctSize + b]; + frame[b] = spectrogram[frameIdx * dctSize + b] * window[b]; } // IDCT const timeFrame = javascript_idct_512(frame); - // Apply window and overlap-add + // Overlap-add (no additional windowing - window already applied to spectrum) const frameStart = frameIdx * hopSize; for (let i = 0; i < dctSize; i++) { if (frameStart + i < audioLength) { - audioData[frameStart + i] += timeFrame[i] * window[i]; + audioData[frameStart + i] += timeFrame[i]; } } } |
