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

feature request: spectral waveform #528

Open
realies opened this issue May 19, 2024 · 3 comments
Open

feature request: spectral waveform #528

realies opened this issue May 19, 2024 · 3 comments

Comments

@realies
Copy link

realies commented May 19, 2024

Colouring the audio waveform by using the spectral centroid of a sequence of short-interval samples to map frequencies to colors can enhance content navigation and aid in understanding how the timbre and intensity of the sound change over time.

I've taken a look at places like:

However, I still have not been able to get a working demo.

I decided to post this feature request here as no apparent web library supports a visualisation mode like this.

I think Native Instruments Traktor provides a great example of displaying a song's waveform. The main view here shows how the timbre changes from predominantly high-frequency content (mapped to blue hues) to mid-frequencies (mapped to green hues) and eventually to bass and sub-bass frequencies (mapped to purple and red hues). I've also attached a few zoomed-in variants of the same playhead position.

@chrisn
Copy link
Member

chrisn commented May 19, 2024

When you say you haven't been able to get a working demo, is that because those projects don't produce the effect you want, or is something else preventing them working?

Adding this would require some substantial changes to Peaks.js. Currently the waveform is just a solid filled (or gradient) colour, so the waveform rendering code would need reworking. Then we'd need a new waveform data format that can store frequency information, and a mapping from that to colours.

@realies
Copy link
Author

realies commented May 19, 2024

When you say you haven't been able to get a working demo, is that because those projects don't produce the effect you want, or is something else preventing them working?

Mainly because of basic implementation issues such as drawing on the canvas and computing the correct centroid values per audio segment. There will probably be a need for segments smoothing and varying the amount of segments rendered based on the zoom level. Not giving up just yet.

Adding this would require some substantial changes to Peaks.js. Currently the waveform is just a solid filled (or gradient) colour, so the waveform rendering code would need reworking. Then we'd need a new waveform data format that can store frequency information, and a mapping from that to colours.

Does that mean Peaks.js is probably not the best place to implement this because of the major restructure? I assume if a frontend algorithm is able to draw the frequency data without a huge compute impact, it could be ported to audiowaveform with the new data structure. The frequency ranges to colour hues mapping sounds somewhat trivial in the overall context.

@chrisn
Copy link
Member

chrisn commented May 19, 2024

I think to start with, I'd want to have audiowaveform produce the data, and Peaks.js just does rendering. If we need the computation to also be done in the web front end, waveform-data.js would be the place to implement that. Changing the rendering in Peaks.js is doable but means rewriting that part of the code, so it's not really a major restructure.

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

No branches or pull requests

2 participants