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.16k stars 277 forks source link

overviewWaveformColor and zoomWaveformColor not working #461

Closed suterma closed 1 year ago

suterma commented 1 year ago

Although I use the overviewWaveformColor and zoomWaveformColor like documented in the readme, they do not work. These example options do not change the colors of neither waveform:

zoomWaveformColor: 'orange',
overviewHighlightColor: 'purple',
overviewWaveformColor: 'blue',
axisLabelColor: 'black',

This (full) example however, works, with the waveform colors changed.

  const options: PeaksOptions = {
    overview: {
      container: overviewCustomConfig.value,
      waveformColor: 'lightgreen',
      playedWaveformColor: 'darkgreen',
      highlightColor: 'lightsalmon',
      highlightOffset: 0
    },
    zoomview: {
      container: zoomviewCustomConfig.value,
      waveformColor: 'lightsalmon',
      playedWaveformColor: 'darkorange'
    },
    mediaElement: audioCustomConfig.value as unknown as HTMLMediaElement | undefined,
    webAudio: { audioContext: new AudioContext() },
    zoomLevels: [1024, 2048, 4096],
    playheadColor: 'red'
  };

Interestingly the playheadColor always works. I suspect that the various variants for the options do somehow interfere or are not currently or nor properly interpreted. I get no TS error for the non-working example. In fact the PeaksOptions type does implement these properties.

chrisn commented 1 year ago

Thanks for reporting this, it's really very helpful.

The overviewWaveformColor, zoomWaveformColor, and overviewHighlightColor options are actually deprecated, replaced by overview.waveformColor, zoomview.waveformColor, and overview.highlightColor. I have updated the TypeScript declarations to mark these as @deprecated.

I don't use TypeScript, so the declarations sometimes get out of sync (my fault...). The README is definitive, so any difference points to a bug in the TypeScript declarations.

suterma commented 1 year ago

The same as reported also seems to apply to

showPlayheadTime

To work, it must be defined on the views, but the types suggest otherwise.

There are maybe more such discrepancies.