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

Optimize Memory and Performance in waveform.js #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mplawner
Copy link

This pull request introduces a series of optimizations aimed at improving the performance and memory usage of the waveform.js file. The changes focus on pre-allocating arrays where possible, optimizing array manipulations, and replacing library-specific methods with native JavaScript alternatives where appropriate.

Key Changes:

  • Pre-allocated the samples array as a Float64Array to reduce dynamic memory allocations.
  • Introduced sampleCount to keep track of the number of samples, allowing us to trim the pre-allocated samples array to its actual size.
  • Replaced the non-existent d3.maxIndex function with native JavaScript code to find the index of the maximum RMS value.

These changes aim to enhance the performance and reduce the memory footprint of the getWaveform function, especially when working with large audio files.

Please review and test these changes thoroughly to ensure they meet all functional and performance requirements.

This pull request introduces a series of optimizations aimed at improving the performance and memory usage of the waveform.js file. The changes focus on pre-allocating arrays where possible, optimizing array manipulations, and replacing library-specific methods with native JavaScript alternatives where appropriate.

Key Changes:
- Pre-allocated the samples array as a Float64Array to reduce dynamic memory allocations.
- Introduced sampleCount to keep track of the number of samples, allowing us to trim the pre-allocated samples array to its actual size.
- Replaced the non-existent d3.maxIndex function with native JavaScript code to find the index of the maximum RMS value.

These changes aim to enhance the performance and reduce the memory footprint of the getWaveform function, especially when working with large audio files.

Please review and test these changes thoroughly to ensure they meet all functional and performance requirements.
@TworkC
Copy link

TworkC commented Jan 5, 2024

Do you have this building successfully locally or through docker? I've been running into issues with the original branch on Docker.

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

Successfully merging this pull request may close these issues.

None yet

2 participants