@remotion/timeline-utils 4.0.479 → 4.0.481
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio-waveform/audio-waveform-worker-types.d.ts +2 -1
- package/dist/audio-waveform/draw-peaks.d.ts +2 -1
- package/dist/audio-waveform/draw-peaks.js +16 -3
- package/dist/esm/audio-waveform-worker.mjs +19 -3
- package/dist/esm/index.mjs +19 -3
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TimelineLoopDisplay } from '../loop-display';
|
|
2
|
+
import type { WaveformVolume } from './draw-peaks';
|
|
2
3
|
export type AudioWaveformWorkerInitMessage = {
|
|
3
4
|
readonly type: 'init';
|
|
4
5
|
readonly canvas: OffscreenCanvas;
|
|
@@ -9,7 +10,7 @@ export type AudioWaveformWorkerRenderMessage = {
|
|
|
9
10
|
readonly src: string;
|
|
10
11
|
readonly width: number;
|
|
11
12
|
readonly height: number;
|
|
12
|
-
readonly volume:
|
|
13
|
+
readonly volume: WaveformVolume;
|
|
13
14
|
readonly startFrom: number;
|
|
14
15
|
readonly durationInFrames: number;
|
|
15
16
|
readonly fps: number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export type WaveformVolume = number | readonly number[];
|
|
1
2
|
export declare const drawBars: ({ canvas, color, peaks, volume, width, }: {
|
|
2
3
|
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
3
4
|
readonly peaks: Float32Array<ArrayBufferLike>;
|
|
4
5
|
readonly color: string;
|
|
5
|
-
readonly volume:
|
|
6
|
+
readonly volume: WaveformVolume;
|
|
6
7
|
readonly width: number;
|
|
7
8
|
}) => void;
|
|
@@ -3,6 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.drawBars = void 0;
|
|
4
4
|
const parse_color_1 = require("./parse-color");
|
|
5
5
|
const CLIPPING_COLOR = '#FF7F50';
|
|
6
|
+
const getVolumeAtBar = ({ barIndex, numBars, volume, }) => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (typeof volume === 'number') {
|
|
9
|
+
return volume;
|
|
10
|
+
}
|
|
11
|
+
if (volume.length === 0) {
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
if (volume.length === 1 || numBars <= 1) {
|
|
15
|
+
return volume[0];
|
|
16
|
+
}
|
|
17
|
+
const volumeIndex = Math.round((barIndex / (numBars - 1)) * (volume.length - 1));
|
|
18
|
+
return (_a = volume[volumeIndex]) !== null && _a !== void 0 ? _a : 1;
|
|
19
|
+
};
|
|
6
20
|
const drawBars = ({ canvas, color, peaks, volume, width, }) => {
|
|
7
21
|
const ctx = canvas.getContext('2d');
|
|
8
22
|
if (!ctx) {
|
|
@@ -18,8 +32,6 @@ const drawBars = ({ canvas, color, peaks, volume, width, }) => {
|
|
|
18
32
|
return;
|
|
19
33
|
}
|
|
20
34
|
ctx.clearRect(0, 0, w, height);
|
|
21
|
-
if (volume === 0)
|
|
22
|
-
return;
|
|
23
35
|
const [r, g, b, a] = (0, parse_color_1.parseColor)(color);
|
|
24
36
|
const [cr, cg, cb, ca] = (0, parse_color_1.parseColor)(CLIPPING_COLOR);
|
|
25
37
|
const imageData = ctx.createImageData(w, height);
|
|
@@ -31,7 +43,8 @@ const drawBars = ({ canvas, color, peaks, volume, width, }) => {
|
|
|
31
43
|
break;
|
|
32
44
|
const peakIndex = Math.floor((barIndex / numBars) * peaks.length);
|
|
33
45
|
const peak = peaks[peakIndex] || 0;
|
|
34
|
-
const
|
|
46
|
+
const barVolume = getVolumeAtBar({ barIndex, numBars, volume });
|
|
47
|
+
const scaledPeak = peak * barVolume;
|
|
35
48
|
const halfBar = Math.max(0, Math.min(height / 2, (scaledPeak * height) / 2));
|
|
36
49
|
if (halfBar === 0)
|
|
37
50
|
continue;
|
|
@@ -15,6 +15,23 @@ var parseColor = (color) => {
|
|
|
15
15
|
|
|
16
16
|
// src/audio-waveform/draw-peaks.ts
|
|
17
17
|
var CLIPPING_COLOR = "#FF7F50";
|
|
18
|
+
var getVolumeAtBar = ({
|
|
19
|
+
barIndex,
|
|
20
|
+
numBars,
|
|
21
|
+
volume
|
|
22
|
+
}) => {
|
|
23
|
+
if (typeof volume === "number") {
|
|
24
|
+
return volume;
|
|
25
|
+
}
|
|
26
|
+
if (volume.length === 0) {
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
if (volume.length === 1 || numBars <= 1) {
|
|
30
|
+
return volume[0];
|
|
31
|
+
}
|
|
32
|
+
const volumeIndex = Math.round(barIndex / (numBars - 1) * (volume.length - 1));
|
|
33
|
+
return volume[volumeIndex] ?? 1;
|
|
34
|
+
};
|
|
18
35
|
var drawBars = ({
|
|
19
36
|
canvas,
|
|
20
37
|
color,
|
|
@@ -32,8 +49,6 @@ var drawBars = ({
|
|
|
32
49
|
return;
|
|
33
50
|
}
|
|
34
51
|
ctx.clearRect(0, 0, w, height);
|
|
35
|
-
if (volume === 0)
|
|
36
|
-
return;
|
|
37
52
|
const [r, g, b, a] = parseColor(color);
|
|
38
53
|
const [cr, cg, cb, ca] = parseColor(CLIPPING_COLOR);
|
|
39
54
|
const imageData = ctx.createImageData(w, height);
|
|
@@ -45,7 +60,8 @@ var drawBars = ({
|
|
|
45
60
|
break;
|
|
46
61
|
const peakIndex = Math.floor(barIndex / numBars * peaks.length);
|
|
47
62
|
const peak = peaks[peakIndex] || 0;
|
|
48
|
-
const
|
|
63
|
+
const barVolume = getVolumeAtBar({ barIndex, numBars, volume });
|
|
64
|
+
const scaledPeak = peak * barVolume;
|
|
49
65
|
const halfBar = Math.max(0, Math.min(height / 2, scaledPeak * height / 2));
|
|
50
66
|
if (halfBar === 0)
|
|
51
67
|
continue;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -17,6 +17,23 @@ var parseColor = (color) => {
|
|
|
17
17
|
|
|
18
18
|
// src/audio-waveform/draw-peaks.ts
|
|
19
19
|
var CLIPPING_COLOR = "#FF7F50";
|
|
20
|
+
var getVolumeAtBar = ({
|
|
21
|
+
barIndex,
|
|
22
|
+
numBars,
|
|
23
|
+
volume
|
|
24
|
+
}) => {
|
|
25
|
+
if (typeof volume === "number") {
|
|
26
|
+
return volume;
|
|
27
|
+
}
|
|
28
|
+
if (volume.length === 0) {
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
if (volume.length === 1 || numBars <= 1) {
|
|
32
|
+
return volume[0];
|
|
33
|
+
}
|
|
34
|
+
const volumeIndex = Math.round(barIndex / (numBars - 1) * (volume.length - 1));
|
|
35
|
+
return volume[volumeIndex] ?? 1;
|
|
36
|
+
};
|
|
20
37
|
var drawBars = ({
|
|
21
38
|
canvas,
|
|
22
39
|
color,
|
|
@@ -34,8 +51,6 @@ var drawBars = ({
|
|
|
34
51
|
return;
|
|
35
52
|
}
|
|
36
53
|
ctx.clearRect(0, 0, w, height);
|
|
37
|
-
if (volume === 0)
|
|
38
|
-
return;
|
|
39
54
|
const [r, g, b, a] = parseColor(color);
|
|
40
55
|
const [cr, cg, cb, ca] = parseColor(CLIPPING_COLOR);
|
|
41
56
|
const imageData = ctx.createImageData(w, height);
|
|
@@ -47,7 +62,8 @@ var drawBars = ({
|
|
|
47
62
|
break;
|
|
48
63
|
const peakIndex = Math.floor(barIndex / numBars * peaks.length);
|
|
49
64
|
const peak = peaks[peakIndex] || 0;
|
|
50
|
-
const
|
|
65
|
+
const barVolume = getVolumeAtBar({ barIndex, numBars, volume });
|
|
66
|
+
const scaledPeak = peak * barVolume;
|
|
51
67
|
const halfBar = Math.max(0, Math.min(height / 2, scaledPeak * height / 2));
|
|
52
68
|
if (halfBar === 0)
|
|
53
69
|
continue;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { AudioWaveformWorkerIncomingMessage, AudioWaveformWorkerOutgoingMessage, AudioWaveformWorkerRenderMessage, } from './audio-waveform/audio-waveform-worker-types';
|
|
2
2
|
export { TARGET_SAMPLE_RATE } from './audio-waveform/constants';
|
|
3
|
-
export { drawBars } from './audio-waveform/draw-peaks';
|
|
3
|
+
export { drawBars, type WaveformVolume } from './audio-waveform/draw-peaks';
|
|
4
4
|
export { loadWaveformPeaks } from './audio-waveform/load-waveform-peaks';
|
|
5
5
|
export { makeAudioWaveformWorker } from './audio-waveform/make-audio-waveform-worker';
|
|
6
6
|
export { sliceWaveformPeaks } from './audio-waveform/slice-waveform-peaks';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/timeline-utils"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/timeline-utils",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.481",
|
|
7
7
|
"description": "Internal utilities for rendering Remotion timelines",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@mediabunny/server": "1.47.0",
|
|
28
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
28
|
+
"@remotion/eslint-config-internal": "4.0.481",
|
|
29
29
|
"eslint": "9.19.0",
|
|
30
30
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
31
31
|
},
|