@remotion/media-utils 3.0.10 → 3.0.11
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/create-smooth-svg-path.d.ts +1 -0
- package/dist/create-smooth-svg-path.js +29 -0
- package/dist/fft/fft-freq.d.ts +1 -4
- package/dist/fft/fft.d.ts +1 -4
- package/dist/fft/mag.d.ts +1 -4
- package/dist/visualize-audio-waveform.d.ts +10 -0
- package/dist/visualize-audio-waveform.js +33 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createSmoothSvgPath: (points: [number, number][]) => string | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSmoothSvgPath = void 0;
|
|
4
|
+
const createSmoothSvgPath = (points) => {
|
|
5
|
+
return points.reduce((acc, point, i, a) => {
|
|
6
|
+
if (i === 0) {
|
|
7
|
+
return `M ${point[0]},${point[1]}`;
|
|
8
|
+
}
|
|
9
|
+
const p0 = a[i - 2] || a[i - 1];
|
|
10
|
+
const x0 = p0[0];
|
|
11
|
+
const y0 = p0[1];
|
|
12
|
+
const p1 = a[i - 1];
|
|
13
|
+
const x1 = p1[0];
|
|
14
|
+
const y1 = p1[1];
|
|
15
|
+
const x = point[0];
|
|
16
|
+
const y = point[1];
|
|
17
|
+
const cp1x = (2 * x0 + x1) / 3;
|
|
18
|
+
const cp1y = (2 * y0 + y1) / 3;
|
|
19
|
+
const cp2x = (x0 + 2 * x1) / 3;
|
|
20
|
+
const cp2y = (y0 + 2 * y1) / 3;
|
|
21
|
+
const cp3x = (x0 + 4 * x1 + x) / 6;
|
|
22
|
+
const cp3y = (y0 + 4 * y1 + y) / 6;
|
|
23
|
+
if (i === a.length - 1) {
|
|
24
|
+
return `${acc} C ${cp1x},${cp1y} ${cp2x},${cp2y} ${cp3x},${cp3y} C${x},${y} ${x},${y} ${x},${y}`;
|
|
25
|
+
}
|
|
26
|
+
return `${acc} C ${cp1x},${cp1y} ${cp2x},${cp2y} ${cp3x},${cp3y}`;
|
|
27
|
+
}, '');
|
|
28
|
+
};
|
|
29
|
+
exports.createSmoothSvgPath = createSmoothSvgPath;
|
package/dist/fft/fft-freq.d.ts
CHANGED
package/dist/fft/fft.d.ts
CHANGED
package/dist/fft/mag.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AudioData } from './types';
|
|
2
|
+
declare type FnParameters = {
|
|
3
|
+
audioData: AudioData;
|
|
4
|
+
frame: number;
|
|
5
|
+
fps: number;
|
|
6
|
+
windowInSeconds: number;
|
|
7
|
+
numberOfSamples: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const visualizeAudioWaveform: ({ ...parameters }: FnParameters) => number[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visualizeAudioWaveform = void 0;
|
|
4
|
+
const get_waveform_portion_1 = require("./get-waveform-portion");
|
|
5
|
+
const cache = {};
|
|
6
|
+
const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples, windowInSeconds, }) => {
|
|
7
|
+
if (windowInSeconds * audioData.sampleRate < numberOfSamples) {
|
|
8
|
+
throw new TypeError(windowInSeconds +
|
|
9
|
+
's audiodata does not have ' +
|
|
10
|
+
numberOfSamples +
|
|
11
|
+
' bars. Increase windowInSeconds or decrease numberOfSamples');
|
|
12
|
+
}
|
|
13
|
+
const cacheKey = audioData.resultId + frame + fps + numberOfSamples + 'waveform';
|
|
14
|
+
if (cache[cacheKey]) {
|
|
15
|
+
return cache[cacheKey];
|
|
16
|
+
}
|
|
17
|
+
const time = frame / fps;
|
|
18
|
+
const max = audioData.durationInSeconds - windowInSeconds / 2;
|
|
19
|
+
const min = windowInSeconds / 2;
|
|
20
|
+
const startTimeInSeconds = Math.min(max, Math.max(min, time - windowInSeconds / 2));
|
|
21
|
+
return (0, get_waveform_portion_1.getWaveformPortion)({
|
|
22
|
+
audioData,
|
|
23
|
+
startTimeInSeconds,
|
|
24
|
+
durationInSeconds: windowInSeconds,
|
|
25
|
+
numberOfSamples,
|
|
26
|
+
outputRange: 'minus-one-to-one',
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const visualizeAudioWaveform = ({ ...parameters }) => {
|
|
30
|
+
const data = visualizeAudioWaveformFrame(parameters);
|
|
31
|
+
return data.map((value) => value.amplitude);
|
|
32
|
+
};
|
|
33
|
+
exports.visualizeAudioWaveform = visualizeAudioWaveform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media-utils",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Utility functions for audio and video",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"remotion": "3.0.
|
|
21
|
+
"remotion": "3.0.11"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=16.8.0",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "7bdd2de3305f669cefecfdbda7f555df1480d9c9"
|
|
48
48
|
}
|