bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.2k stars 278 forks source link

Thoughts on zoom strategy - continuous zoom and long audio files #91

Open lowpitch opened 10 years ago

lowpitch commented 10 years ago

Having played around with peaks.js zooming for a couple of days, using data generated from long audio files (2 - 3 hours), I've made the following observations (ignoring the bug reported in #90).

I think it would be nice to support continuous zooming - rather than stepping up and down between pre-defined zoom levels, being able to zoom to any level between the minimum and maximum without a significant performance hit. For example, moving a zoom slider, or using the trackpad to zoom in or out. The existing behaviour would still be supported - jumping up or down to the next zoom level would see peaks animating the current zoom from one level to the other, just as if the user had altered the position of a slider from one level to the other.

Some thoughts on how this could be achieved (just a starting point...):

Concerns / assumptions / things to check:

Just a starting point for discussion.

thom4parisot commented 10 years ago

Yep what you explain is right, even with partial resampling, zooming from an overview level will demand a lot of CPU to run the animation, especially for a long programme ;-( In term of scaling, the more atop we are, and the longer the programme is, the more intense is the computation.

Some options to consider for the processing:

I know that on the original zooming work, avoiding the resampling has been considered but the visual quality of the outcome was poor enough to opt in for the partial resampling. Have you read the paper written by Manvir? If not, I can send it to you or Rob can do it.

Maybe the Scale feature of Kinetic has not been tried so it could eventually be interesting to investigate that way.

Thanks for sparking the conversation on that tough topic :-)

lowpitch commented 10 years ago

Thanks for this! I haven't read the paper - I will ask Rob for a copy. Sounds interesting...

I should get some time over the next couple of days to knock up a quick test of the zooming version. I do think there will be some visual differences as it switches out from one level to another, but if it's quick enough it might work quite nicely. Back in the Flash days, this is how I would have tackled a similar problem.

ServiceWorker / memoized data would be cool - or even passing in pre-generated resampled data in external files (to keep basic browser support).

I'll think about this some more and keep adding thoughts here...!

thom4parisot commented 10 years ago

Thinking again about it, things we can consider:

If this is visually good looking, it would be hard to be faster than a simple filter/loop over thousands of elements.

lowpitch commented 10 years ago

an accurate frame when the animation ends;

Agree with this!

I had another thought too. What if we...

Or something...

thom4parisot commented 9 years ago

@lowpitch yep your proposal is even cheaper in term of computation!

Your solution is a good starting point to see if it's worth trying in order to see if skipping n-frames is consistent across the zoom operation.