src/drawer.multicanvas.js
/**
     * Draw a waveform with bars
     *
     * @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
     * for split channel rendering
     * @param {number} channelIndex The index of the current channel. Normally
     * should be 0. Must be an integer.
     * @param {number} start The x-offset of the beginning of the area that
     * should be rendered
     * @param {number} end The x-offset of the end of the area that should be
     * rendered
     * @returns {void}
     */
Draw a waveform with bars
@param {number[]|Number.} peaks Can also be an array of arrays
for split channel rendering
@param {number} channelIndex The index of the current channel. Normally
should be 0. Must be an integer.
@param {number} start The x-offset of the beginning of the area that
should be rendered
@param {number} end The x-offset of the end of the area that should be
rendered
@returns {void}
Draw a waveform with bars @param { number [] |Number . } peaks Can also be an array of arrays for split channel rendering @param { number } channelIndex The index of the current channel . Normally should be 0 . Must be an integer . @param { number } start The x - offset of the beginning of the area that should be rendered @param { number } end The x - offset of the end of the area that should be rendered @returns { void }
drawBars(peaks, channelIndex, start, end) {
        return this.prepareDraw(
            peaks,
            channelIndex,
            start,
            end,
            ({ absmax, hasMinVals, height, offsetY, halfH, peaks }) => {
                if (start === undefined) {
                    return;
                }
                const peakIndexScale = hasMinVals ? 2 : 1;
                const length = peaks.length / peakIndexScale;
                const bar = this.params.barWidth * this.params.pixelRatio;
                const gap =
                    this.params.barGap === null
                        ? Math.max(this.params.pixelRatio, ~~(bar / 2))
                        : Math.max(
                              this.params.pixelRatio,
                              this.params.barGap * this.params.pixelRatio
                          );
                const step = bar + gap;
                const scale = length / this.width;
                const first = start;
                const last = end;
                let i = first;
                for (i; i < last; i += step) {
                    const peak =
                        peaks[Math.floor(i * scale * peakIndexScale)] || 0;
                    const h = Math.round((peak / absmax) * halfH);
                    this.fillRect(
                        i + this.halfPixel,
                        halfH - h + offsetY,
                        bar + this.halfPixel,
                        h * 2
                    );
                }
            }
        );
    }
drawBars ( peaks , channelIndex , start , end ) { return this . prepareDraw ( peaks , channelIndex , start , end , ( { absmax , hasMinVals , height , offsetY , halfH , peaks } ) => { if ( start === undefined ) { return ; } const peakIndexScale = hasMinVals ? 2 : 1 ; const length = peaks . length / peakIndexScale ; const bar = this . params . barWidth * this . params . pixelRatio ; const gap = this . params . barGap === null ? Math . max ( this . params . pixelRatio , ~ ~ ( bar / 2 ) ) : Math . max ( this . params . pixelRatio , this . params . barGap * this . params . pixelRatio ) ; const step = bar + gap ; const scale = length / this . width ; const first = start ; const last = end ; let i = first ; for ( i ; i < last ; i += step ) { const peak = peaks [ Math . floor ( i * scale * peakIndexScale ) ] || 0 ; const h = Math . round ( ( peak / absmax ) * halfH ) ; this . fillRect ( i + this . halfPixel , halfH - h + offsetY , bar + this . halfPixel , h * 2 ) ; } } ) ; }
Draw a waveform with bars
 @param {number[]|Number.<Array[]>} peaks Can also be an array of arrays
 for split channel rendering
 @param {number} channelIndex The index of the current channel.
Draw a waveform with bars @param { number [] |Number . <Array [] > } peaks Can also be an array of arrays for split channel rendering @param { number } channelIndex The index of the current channel .
// if drawBars was called within ws.empty we don't pass a start and // don't want anything to happen // Skip every other value if there are negatives.