mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
tweak waveform
This commit is contained in:
@@ -84,6 +84,7 @@ class RecordPlugin extends BasePlugin<RecordPluginEvents, RecordPluginOptions> {
|
|||||||
const dataArray = new Uint8Array(bufferLength);
|
const dataArray = new Uint8Array(bufferLength);
|
||||||
|
|
||||||
let animationId: number, previousTimeStamp: number;
|
let animationId: number, previousTimeStamp: number;
|
||||||
|
const MULTIPLIER = 1.2;
|
||||||
const DATA_SIZE = 128.0;
|
const DATA_SIZE = 128.0;
|
||||||
const BUFFER_SIZE = 2 ** 8;
|
const BUFFER_SIZE = 2 ** 8;
|
||||||
const dataBuffer = new Array(BUFFER_SIZE).fill(DATA_SIZE);
|
const dataBuffer = new Array(BUFFER_SIZE).fill(DATA_SIZE);
|
||||||
@@ -109,15 +110,19 @@ class RecordPlugin extends BasePlugin<RecordPluginEvents, RecordPluginOptions> {
|
|||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
const sliceWidth = canvas.width / dataBuffer.length;
|
const sliceWidth = canvas.width / dataBuffer.length;
|
||||||
let x = 0;
|
let xPos = 0;
|
||||||
|
|
||||||
for (let i = 0; i < dataBuffer.length; i++) {
|
for (let i = 0; i < dataBuffer.length; i++) {
|
||||||
const y = (canvas.height * dataBuffer[i]) / (2 * DATA_SIZE);
|
const y =
|
||||||
|
dataBuffer[i] + 2 > DATA_SIZE
|
||||||
|
? dataBuffer[i]
|
||||||
|
: dataBuffer[i] / MULTIPLIER;
|
||||||
|
const yPos = (canvas.height * y) / (2 * DATA_SIZE);
|
||||||
const sliceHeight =
|
const sliceHeight =
|
||||||
((1 - canvas.height) * dataBuffer[i]) / DATA_SIZE + canvas.height;
|
((1 - canvas.height) * y) / DATA_SIZE + canvas.height;
|
||||||
|
|
||||||
canvasCtx.fillRect(x, y, (sliceWidth * 2) / 3, sliceHeight);
|
canvasCtx.fillRect(xPos, yPos, (sliceWidth * 2) / 3, sliceHeight);
|
||||||
x += sliceWidth;
|
xPos += sliceWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
animationId = requestAnimationFrame(drawWaveform);
|
animationId = requestAnimationFrame(drawWaveform);
|
||||||
|
|||||||
Reference in New Issue
Block a user