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

Audio wave normalization has unexpected behaviour when using the normalize Wavesurfer option while also using the ZoomPlugin #3554

Open
filipkoukal opened this issue Feb 15, 2024 · 1 comment
Labels

Comments

@filipkoukal
Copy link

Bug description

Audio wave normalization doesn't work as expected when using the normalize Wavesurfer option while also using the ZoomPlugin.
How to reproduce:

  1. Zoom in on an area
  2. Move right or left along the audio wave to view a before unseen part of audio wave

Environment

  • Browser: Chrome

Minimal code snippet

import WaveSurfer from 'wavesurfer.js'
import ZoomPlugin from 'wavesurfer.js/dist/plugins/zoom';


const wavesurfer = WaveSurfer.create({
    container: document.body,
    waveColor: 'rgb(200, 0, 200)',
    progressColor: 'rgb(100, 0, 100)',
    url: '/examples/audio/demo.wav',
    normalize: true,
})

wavesurfer.registerPlugin(ZoomPlugin.create())

wavesurfer.on('interaction', () => {
  wavesurfer.play()
})

Expected result

The audio wave is stable even when moving left or right along the wave when using the normalize option.

Obtained result

When moving left or right along the zoomed audio wave, previously unseen parts aren't normalized correctly.

Screenshots

1 2 3
@katspaugh
Copy link
Owner

Good catch. The reason is the normalization is performed on render, for each visible chunk individually. It should instead normalize by max value across the entire array of peaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants