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

Feat: [Spectrogram] add gain, range and scale options #3790

Merged
merged 2 commits into from
Jul 22, 2024
Merged

Feat: [Spectrogram] add gain, range and scale options #3790

merged 2 commits into from
Jul 22, 2024

Conversation

pengzhendong
Copy link
Contributor

@pengzhendong pengzhendong commented Jul 19, 2024

Short description

Resolves #1648

Based on:

  1. add options gainDB and rangeDB
  • Gain (dB): Increases / decreases the brightness of the display. For small signals where the display is mostly "blue" (dark) you can increase this value to see brighter colors and give more detail. If the display has too much "white", decrease this value. The default is 20dB and corresponds to a -20 dB signal at a particular frequency being displayed as "white".
  • Range (dB): Affects the range of signal sizes that will be displayed as colors. The default is 80 dB and means that you will not see anything for signals 80 dB below the value set for "Gain".
  1. add Mel scale
  2. add colormap roseus: https://github.com/dofuuz/roseus/blob/main/roseus/cmap/roseus.py

Screenshots

Screenshot 2024-07-19 at 23 03 01

Checklist

  • This PR is covered by e2e tests
  • It introduces no breaking API changes

Copy link
Owner

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@pengzhendong
Copy link
Contributor Author

pengzhendong commented Jul 20, 2024

@katspaugh Could you help me to fix the e2e test errors? I'm not familiar with the cypress.

It's covered by e2e tests in my local computer, but it's failed in github actions.

local:

Screenshot 2024-07-20 at 13 13 11

github actions:

WaveSurfer Spectrogram plugin tests -- should render a spectrogram (failed)

WaveSurfer Spectrogram plugin tests -- should render a spectrogram when initialised into a hidden div (failed)

WaveSurfer Spectrogram plugin tests -- should render a spectrogram without labels (failed)

@katspaugh
Copy link
Owner

Strange, the images look the same. I’ll check.

@katspaugh katspaugh merged commit 0cbda3c into katspaugh:main Jul 22, 2024
1 of 2 checks passed
@katspaugh
Copy link
Owner

On my local machine, the tests are also passing. 🤷 Anyway, merged the PR.

Thanks a lot! ❤️

@pablodz
Copy link

pablodz commented Aug 15, 2024

Awesome work, just using it

@puneet-yadav
Copy link

@pablodz Are you not having issues with height of the spectrogram? can you please provide the code.

@pablodz
Copy link

pablodz commented Aug 15, 2024

fixed with linear property @puneet-yadav

import WaveSurfer from 'wavesurfer.js';
import Spectrogram from 'wavesurfer.js/dist/plugins/spectrogram.esm.js';


...
const ws = WaveSurfer.create({
  container: `#waveform-${this.uniqueId}`,
  waveColor: '#7F5FC0',
  progressColor: '#5A3A7E',
  mediaControls: true,
  height: 100,
  plugins: [
    Spectrogram.create({
      scale: 'linear',
      height: 100,
      labels: true,
      container: `#spectrogram-${this.uniqueId}`,
    }),
  ],
});

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.

Logarithm scale on Y axis in Spectrogram plugin
4 participants