peaks.js icon indicating copy to clipboard operation
peaks.js copied to clipboard

Question: customization of waveform

Open LukaMoria opened this issue 4 years ago • 8 comments

Earlier I used wavesurfer for customization waveform drawing with params like: barWidth : 2px and barGap :1px. I wanna to customize draw of full waveform. Can I do it with peaks.js?

LukaMoria avatar Mar 03 '21 08:03 LukaMoria

@chrisn any idea about it? Example: generating with customization by wavesurfer image the same track generated by peaks.js image

LukaMoria avatar Mar 08 '21 09:03 LukaMoria

We don't currently have a way for user customisation (apart from waveform colour) but I'm very much open to making it more configurable. This could be either by adding more options, or defining an extension API where you could fully take over how the rendering is done, similar to how we allow marker customisation (see https://github.com/bbc/peaks.js/blob/master/customizing.md).

In your use case, do you simply want a bar style display, as in your example, or do you want full control?

Related issues: https://github.com/bbc/peaks.js/issues/214, https://github.com/bbc/peaks.js/issues/193

chrisn avatar Mar 08 '21 11:03 chrisn

We are working on this same thing in our app. The design is to use the bar style waveform that fills with color as the track progresses but this is not possible with peaks. I've only found wavesurfer to do this and would love to avoid having to pull it in just for this waveform styling.

BKnightSHiFi avatar Mar 10 '21 22:03 BKnightSHiFi

@chrisn I have another question about customization, hope you wouldn't mind:)

Is it possible to define the length (duration) of the view? For example I would like to create a Peaks instance with an audio file that's 3 seconds long, while the view would show 10 seconds (of course the remaining 7 seconds would be with no sound).

noaLeibman avatar Apr 27 '21 15:04 noaLeibman

Does the setZoom() method do what you need? I recommend trying out the demo pages, in particular the zoomable-waveform demo, which uses setZoom().

chrisn avatar Apr 27 '21 17:04 chrisn

Is there a way to change the background color of a segment? Or some other way to show that two segments overlap?

If there isn't at the moment, could this also be add to the options or the extension API?!

tidoni avatar May 11 '21 15:05 tidoni

If there isn't at the moment, could this also be add to the options or the extension API?!

At the moment, there isn't. Can you provide an example image of the effect you want to see?

chrisn avatar May 11 '21 18:05 chrisn

I just took the sample image from the git root and added some color.

peaks_mod

Maybe this could be done, simply by adding a background-color setting to the segments.

  segments: [{
    startTime: 4,
    endTime: 14,
    editable: false,
    color: "blue",
    labelText: "Mic open"
  },
  {
    startTime: 4,
    endTime: 8,
    editable: false,
    background-color: "red",
    labelText: "Jingle"
  },
  {
    startTime: 15,
    endTime: 17,
    editable: false,
    background-color: "red",
    labelText: "Jingle"
  },
  {
    startTime: 29,
    endTime: 33,
    editable: false,
    color: "violett",
    labelText: "Mic open"
  }],

tidoni avatar May 13 '21 09:05 tidoni