@remotion/media-utils 3.0.0-lambda.25 → 3.0.0-lambda.288
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.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AudioData } from './types';
|
|
2
|
+
declare type FnParameters = {
|
|
3
|
+
audioData: AudioData;
|
|
4
|
+
frame: number;
|
|
5
|
+
fps: number;
|
|
6
|
+
waveformDuration: number;
|
|
7
|
+
numberOfSamples: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const visualizeAudioWaveform: ({ smoothing, ...parameters }: FnParameters & {
|
|
10
|
+
smoothing?: boolean | undefined;
|
|
11
|
+
}) => number[];
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=visualize-audio-waveform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualize-audio-waveform.d.ts","sourceRoot":"","sources":["../src/visualize-audio-waveform.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAIlC,aAAK,YAAY,GAAG;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACxB,CAAC;AAuCF,eAAO,MAAM,sBAAsB;;cAalC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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, waveformDuration, }) => {
|
|
7
|
+
if (waveformDuration * audioData.sampleRate < numberOfSamples) {
|
|
8
|
+
throw new TypeError(waveformDuration +
|
|
9
|
+
's audiodata does not have ' +
|
|
10
|
+
numberOfSamples +
|
|
11
|
+
' bars. Increase waveformDuration or decrease numberOfSamples');
|
|
12
|
+
}
|
|
13
|
+
const cacheKey = audioData.resultId + frame + fps + numberOfSamples + 'waveform';
|
|
14
|
+
if (cache[cacheKey]) {
|
|
15
|
+
return cache[cacheKey];
|
|
16
|
+
}
|
|
17
|
+
const startTimeInSeconds = frame / fps < waveformDuration
|
|
18
|
+
? 0
|
|
19
|
+
: frame / fps + waveformDuration / 2 >= audioData.durationInSeconds
|
|
20
|
+
? audioData.durationInSeconds - waveformDuration
|
|
21
|
+
: frame / fps - waveformDuration / 2;
|
|
22
|
+
return (0, get_waveform_portion_1.getWaveformPortion)({
|
|
23
|
+
audioData,
|
|
24
|
+
startTimeInSeconds,
|
|
25
|
+
durationInSeconds: waveformDuration,
|
|
26
|
+
numberOfSamples,
|
|
27
|
+
normalize: false,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const visualizeAudioWaveform = ({ smoothing = true, ...parameters }) => {
|
|
31
|
+
if (smoothing) {
|
|
32
|
+
// TODO: Add bezier manipulation?
|
|
33
|
+
console.log('nice');
|
|
34
|
+
}
|
|
35
|
+
const data = visualizeAudioWaveformFrame(parameters);
|
|
36
|
+
return data.map((value) => value.amplitude);
|
|
37
|
+
};
|
|
38
|
+
exports.visualizeAudioWaveform = visualizeAudioWaveform;
|
|
39
|
+
//# sourceMappingURL=visualize-audio-waveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualize-audio-waveform.js","sourceRoot":"","sources":["../src/visualize-audio-waveform.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAG/D,MAAM,KAAK,GAA2B,EAAE,CAAC;AAUzC,MAAM,2BAA2B,GAAG,CAAC,EACpC,SAAS,EACT,KAAK,EACL,GAAG,EACH,eAAe,EACf,gBAAgB,GACF,EAAE,EAAE;IAClB,IAAI,gBAAgB,GAAG,SAAS,CAAC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|
|
3
|
-
"version": "3.0.0-lambda.
|
|
3
|
+
"version": "3.0.0-lambda.288+6ab6c681d",
|
|
4
4
|
"description": "Utility functions for audio and video",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/remotion-dev/remotion"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"remotion": "3.0.0-lambda.
|
|
18
|
+
"remotion": "3.0.0-lambda.288+6ab6c681d"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": "^17.0.1",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "6ab6c681d4f1d42b00b08ffd4dfb44c18c1cc6f1"
|
|
36
36
|
}
|