question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Waveform not in sync with MediaElement backend audio when zooming

See original GitHub issue

When zooming in enough it’s clear that the majority of beats are heard before the actual section of the waveform is hit. It’s a small amount but noticeable for the the project I am using it for. It appears that the audio is 0.04 seconds ahead of the progress bar. The song I am using is about 3 minutes long if that makes any difference.

Wavesurfer.js Version 3.0.0

Firefox Developer Version 69.0b9 (64-bit) Windows 10

<script>var wavesurfer = WaveSurfer.create({
	container: '#waveform',
	waveColor: '#222222',
	progressColor: 'orange',
	backend: 'MediaElement',
	plugins: [
		WaveSurfer.cursor.create({
			showTime: true,
			opacity: 1,
			color: 'blue',
			customShowTimeStyle: {
				'background-color': '#000',
				color: '#fff',
				padding: '2px',
				'font-size': '10px'
			}
		})
	]
});
wavesurfer.load(song);


//Zoom slider
var slider = document.querySelector('[data-action="zoom"]');

slider.value = wavesurfer.params.minPxPerSec;
slider.min = wavesurfer.params.minPxPerSec;

slider.addEventListener('input', function() {
	wavesurfer.zoom(Number(this.value));
})

//Set initial zoom to match slider value
wavesurfer.zoom(slider.value);

function playPause() {
	wavesurfer.playPause();
}</script>

<div id="waveform"></div>
<input data-action="zoom" type="range" min="20" max="200" value="0" style="width: 100%">
<button onClick="playPause()">Play/Pause</button>

I can reproduce it with any of the songs that I currently have set up with my project.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
seklumcommented, Aug 2, 2019

Ok so far I’ve at least looked over all the code in the mediaelement file. I can’t see anything that looks like it would cause this. I’ve verified that the waveforms are not different they still display the same so it’s something with the audio only.

Here is one interesting thing I was able to find. At the end of the waveform when using the mediaelement backend the cursor extends a .02 seconds past the edge of the window extending it. This does not occur with the default backend. I don’t know how to check the beginning but it appears that mediaelement has some sort of different duration value. It does appear to be approximately .04 which could be related to the .02 second extended duration at the end.

The audio is being clipped out for the first .04 seconds of the file and and extra .02s added to the end. I couldn’t find anything in the code that would move the start of the audio file up but I’ll keep looking.

0reactions
thijstriemstracommented, Aug 2, 2019

does it happen with just that audio file or all?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Audio waveforms are out of sync when zoomed out
Below is the same waveform with the timeline zoomed out by one tick, now being displayed incorrectly and out of sync with the...
Read more >
WaveSurfer Methods
wavesurfer.js is an HTML 5 audio player and waveform visualizer, made with JavaScript and Web Audio.
Read more >
Audio waveform is not in sync with the actual audio
My source comes from a Panasonic SD-600 HD camcorder (avchd format in mp4), audio track from a Zoom H1 microphone in mp3 format...
Read more >
peaks.js - npm
JavaScript UI component for displaying audio waveforms. ... to make accurate clippings of audio content in the browser, using a backend API ...
Read more >
Untitled
The viewer runs completely in the web browser, with no backend server and no ... 5 audio player and waveform visualizer, made with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found