Skip to content

Commit 9c21686

Browse files
committed
Render channels with gap in between
1 parent c5038bb commit 9c21686

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

chrome/player/ui/audio/AudioChannelMixer.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class AudioChannelMixer extends AbstractAudioModule {
198198
const canvas = els.volumeMeter;
199199
const ctx = els.volumeMeterCtx;
200200

201-
const width = canvas.clientWidth * window.devicePixelRatio;
201+
const width = canvas.clientWidth * window.devicePixelRatio * 2;
202202
const height = canvas.clientHeight * window.devicePixelRatio;
203203
if (width === 0 || height === 0) return;
204204

@@ -216,7 +216,7 @@ export class AudioChannelMixer extends AbstractAudioModule {
216216
const minDb = outputMeter.minDecibels;
217217
const maxDb = outputMeter.maxDecibels;
218218
const now = Date.now();
219-
const channelWidth = width / data.length;
219+
const channelWidthDivided = (width + 1) / data.length;
220220

221221
data.forEach((channelData, i) => {
222222
const cache = this.outputMeterCache[i];
@@ -237,7 +237,9 @@ export class AudioChannelMixer extends AbstractAudioModule {
237237
cache.peakTime = now;
238238
}
239239

240-
const xStart = i * channelWidth;
240+
const xStart = Math.round(i * channelWidthDivided);
241+
const xEnd = Math.round((i + 1) * channelWidthDivided);
242+
const channelWidth = xEnd - xStart - (i === data.length - 1 ? 0 : 1); // 1px gap except last channel
241243
for (let i = 0; i < rectCount; i++) {
242244
const y = height - (i + 1) * rectHeight;
243245

0 commit comments

Comments
 (0)