Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zoom optimisation for Waves and matching implementation for Spectrogr…
…ams (#2646) * Used setTimeout() method to require a minimum time period passes before redrawing/recalculating to reduce CPU requirements while zooming in on waveforms. Currently displaying a waveform image in example/zoom which will be used to hide the lack of wave drawing while zooming. * Implemented a backimage mimicking the wave to display zoom level faster TO DO: Hide the real wave while zooming Hide the backimage after zooming Zoom in on current timestamp while zooming on backimage FUTURE: Split or crop backimage for longer waves Re-render backimage to match the colour style of the wave with selected timestamp * Added hiding/showing of elements while zooming Since the coloured section of the wave is also handled by canvas objects within a wave I am going to move the backimage functionality into the canvasentry.js file so that each canvas handles it's own image, which should resolve the issue as well as segment the image into sections. * backimages are stored and drawn for each canvas entry. Current issue is the left offsets of each backimage are not being calculated correctly and images are overlapping. * Zooming now correctly handles progress positions. Creates backimages for progress wave Left offset of canvas elements are handled correctly. * Zooming out now works without any issues Zooming in needs a viewable region boundary implemented so that canvases don't become too large. Progress tracking and regions plugin work without any issues now. * Zoom optimisations have been made Canvases not in frame are cleared and not rendered Canvases that become too large are clipped Progress location is maintained * Added priority drawing for canvases in view Currently, changing zoom level before all canvases have been loaded causes issues, my next goal is to fix this by either improving the handling of missing canvases or preventing zoom change until all canvases have loaded. * Zoom slider locks up if rendering isn't finished I'll use and hopefully instead of locking up I can return to a backup render of the wave. * Allows zooming immediately after release This is done by cancelling loading and showing only loaded sections * Improved backup image that can handle large waves Zooming out on partially loaded waves loads a backup image, this features works regardless of wave size. * Optimisation checks if there is a wrapper With this change the branch now passes the included tests * Fixed issues with back image generation Low zoom level previously caused issue with back image generation, the issue has been resolved. * Added zooming to spectrogram example This will allow testing of the intended multicanvas implementation * Spectrogram successfully split into two canvases Canvases are equally sized Calculation is on the whole spectrogram and then converted to seperate canvases This is a starting point for scaling up to an adaptive number of canvases, similar to the multicanvas drawer used for the main wave. Ideally calculation can be moved such that it is done for each canvas, this would mean speed could be improved by calcuating visible spectrogram canvases. Right now this offers no noticeable speed improvement, but could improve the ability to display zoomable spectrograms without creating images too large for browsers. * Working for arbitrary number of canvases Image still generated first then split, limiting max size Committing a working version before attempting fix * spectrogram sections are generated per-canvas Currently trying to draw all canvases at once causes failure Next I'm going to implement staggering of the canvases to hopefully allowing further zooming even without performance improvements * Spectrogram can now display at unlimited width Fixed an issue where resample() was creating full-size arrays instead of limiting to the canvas size Fixed an issue where render() was being called twice as a result of an incorrect event fire in wavesurfer.js Removed placeholder text in zoom example * Spectrogram only draws viewable canvases After this I will implement delays rendering of low-priority canvases * Rearranged variables to allow for setting delays * Canvases stretch to zoom * Zoom now scales correctly against waveform Fixed issue where progress wasn't accurate during zoom * Improved zooming functionality for wavesurfer Removed functions that were no longer necessary backimages are no longer required, existing canvases are stretched during zoom. backup image is no longer required, canvases can continue rendering during the zooming process. * Implemented priority rendering for spectrogram Removed/changed comments referring to the removed backimage/backupimage * Added timeout clearing to prevent drawing old canvases after zoom level changes * Removed unecessary class variables * Patched in a fix so that original zooming behaviour is preserved Upon first call of the stretchCanvases() function the drawer will switch over to the optimised zoom functionality * Removed unecessary changes to formatting * Removed more unecessary changes --------- Co-authored-by: Luke Harrison <s4587520@student.uq.edu.au>
- Loading branch information