@remotion/media-utils 3.0.0-lambda.99 → 3.0.0-pnpm.18
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-buffer/audio-buffer-to-wav.d.ts +7 -0
- package/dist/audio-buffer/audio-buffer-to-wav.d.ts.map +1 -0
- package/dist/audio-buffer/audio-buffer-to-wav.js +96 -0
- package/dist/audio-buffer/audio-buffer-to-wav.js.map +1 -0
- package/dist/audio-buffer/audio-url-helpers.d.ts +2 -0
- package/dist/audio-buffer/audio-url-helpers.d.ts.map +1 -0
- package/dist/audio-buffer/audio-url-helpers.js +18 -0
- package/dist/audio-buffer/audio-url-helpers.js.map +1 -0
- package/dist/create-smooth-svg-path.d.ts +5 -0
- package/dist/create-smooth-svg-path.d.ts.map +1 -0
- package/dist/create-smooth-svg-path.js +30 -0
- package/dist/create-smooth-svg-path.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/smooth-path.d.ts +5 -0
- package/dist/smooth-path.d.ts.map +1 -0
- package/dist/smooth-path.js +30 -0
- package/dist/smooth-path.js.map +1 -0
- package/dist/visualize-audio-waveform.d.ts +2 -4
- package/dist/visualize-audio-waveform.d.ts.map +1 -1
- package/dist/visualize-audio-waveform.js +11 -16
- package/dist/visualize-audio-waveform.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from https://github.com/Jam3/audiobuffer-to-wav/commit/2272eb09bd46a05e50a6d684d908aa6f13c58f63#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346
|
|
3
|
+
*/
|
|
4
|
+
export declare function audioBufferToWav(buffer: AudioBuffer, opt: {
|
|
5
|
+
float32: boolean;
|
|
6
|
+
}): ArrayBuffer;
|
|
7
|
+
//# sourceMappingURL=audio-buffer-to-wav.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-buffer-to-wav.d.ts","sourceRoot":"","sources":["../../src/audio-buffer/audio-buffer-to-wav.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE;IACJ,OAAO,EAAE,OAAO,CAAC;CACjB,eAqBD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inlined from https://github.com/Jam3/audiobuffer-to-wav/commit/2272eb09bd46a05e50a6d684d908aa6f13c58f63#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.audioBufferToWav = void 0;
|
|
7
|
+
function audioBufferToWav(buffer, opt) {
|
|
8
|
+
const numChannels = buffer.numberOfChannels;
|
|
9
|
+
const { sampleRate } = buffer;
|
|
10
|
+
const format = opt.float32 ? 3 : 1;
|
|
11
|
+
const bitDepth = format === 3 ? 32 : 16;
|
|
12
|
+
let result;
|
|
13
|
+
if (numChannels === 2) {
|
|
14
|
+
result = interleave(buffer.getChannelData(0), buffer.getChannelData(1));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result = buffer.getChannelData(0);
|
|
18
|
+
}
|
|
19
|
+
return encodeWAV({
|
|
20
|
+
samples: result,
|
|
21
|
+
format,
|
|
22
|
+
sampleRate,
|
|
23
|
+
numChannels,
|
|
24
|
+
bitDepth,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.audioBufferToWav = audioBufferToWav;
|
|
28
|
+
function encodeWAV({ samples, format, sampleRate, numChannels, bitDepth, }) {
|
|
29
|
+
const bytesPerSample = bitDepth / 8;
|
|
30
|
+
const blockAlign = numChannels * bytesPerSample;
|
|
31
|
+
const buffer = new ArrayBuffer(44 + samples.length * bytesPerSample);
|
|
32
|
+
const view = new DataView(buffer);
|
|
33
|
+
/* RIFF identifier */
|
|
34
|
+
writeString(view, 0, 'RIFF');
|
|
35
|
+
/* RIFF chunk length */
|
|
36
|
+
view.setUint32(4, 36 + samples.length * bytesPerSample, true);
|
|
37
|
+
/* RIFF type */
|
|
38
|
+
writeString(view, 8, 'WAVE');
|
|
39
|
+
/* format chunk identifier */
|
|
40
|
+
writeString(view, 12, 'fmt ');
|
|
41
|
+
/* format chunk length */
|
|
42
|
+
view.setUint32(16, 16, true);
|
|
43
|
+
/* sample format (raw) */
|
|
44
|
+
view.setUint16(20, format, true);
|
|
45
|
+
/* channel count */
|
|
46
|
+
view.setUint16(22, numChannels, true);
|
|
47
|
+
/* sample rate */
|
|
48
|
+
view.setUint32(24, sampleRate, true);
|
|
49
|
+
/* byte rate (sample rate * block align) */
|
|
50
|
+
view.setUint32(28, sampleRate * blockAlign, true);
|
|
51
|
+
/* block align (channel count * bytes per sample) */
|
|
52
|
+
view.setUint16(32, blockAlign, true);
|
|
53
|
+
/* bits per sample */
|
|
54
|
+
view.setUint16(34, bitDepth, true);
|
|
55
|
+
/* data chunk identifier */
|
|
56
|
+
writeString(view, 36, 'data');
|
|
57
|
+
/* data chunk length */
|
|
58
|
+
view.setUint32(40, samples.length * bytesPerSample, true);
|
|
59
|
+
if (format === 1) {
|
|
60
|
+
// Raw PCM
|
|
61
|
+
floatTo16BitPCM(view, 44, samples);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
writeFloat32(view, 44, samples);
|
|
65
|
+
}
|
|
66
|
+
return buffer;
|
|
67
|
+
}
|
|
68
|
+
function interleave(inputL, inputR) {
|
|
69
|
+
const length = inputL.length + inputR.length;
|
|
70
|
+
const result = new Float32Array(length);
|
|
71
|
+
let index = 0;
|
|
72
|
+
let inputIndex = 0;
|
|
73
|
+
while (index < length) {
|
|
74
|
+
result[index++] = inputL[inputIndex];
|
|
75
|
+
result[index++] = inputR[inputIndex];
|
|
76
|
+
inputIndex++;
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function writeFloat32(output, offset, input) {
|
|
81
|
+
for (let i = 0; i < input.length; i++, offset += 4) {
|
|
82
|
+
output.setFloat32(offset, input[i], true);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function floatTo16BitPCM(output, offset, input) {
|
|
86
|
+
for (let i = 0; i < input.length; i++, offset += 2) {
|
|
87
|
+
const s = Math.max(-1, Math.min(1, input[i]));
|
|
88
|
+
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function writeString(view, offset, string) {
|
|
92
|
+
for (let i = 0; i < string.length; i++) {
|
|
93
|
+
view.setUint8(offset + i, string.charCodeAt(i));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=audio-buffer-to-wav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-buffer-to-wav.js","sourceRoot":"","sources":["../../src/audio-buffer/audio-buffer-to-wav.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,SAAgB,gBAAgB,CAC/B,MAAmB,EACnB,GAEC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC5C,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,CAAC;IAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAExC,IAAI,MAAM,CAAC;IACX,IAAI,WAAW,KAAK,CAAC,EAAE;QACtB,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,CAA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@@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.audioBufferToDataUrl = void 0;
|
|
4
|
+
const audio_buffer_to_wav_1 = require("./audio-buffer-to-wav");
|
|
5
|
+
const audioBufferToDataUrl = (buffer) => {
|
|
6
|
+
const wavAsArrayBuffer = (0, audio_buffer_to_wav_1.audioBufferToWav)(buffer, {
|
|
7
|
+
float32: true,
|
|
8
|
+
});
|
|
9
|
+
let binary = '';
|
|
10
|
+
const bytes = new Uint8Array(wavAsArrayBuffer);
|
|
11
|
+
const len = bytes.byteLength;
|
|
12
|
+
for (let i = 0; i < len; i++) {
|
|
13
|
+
binary += String.fromCharCode(bytes[i]);
|
|
14
|
+
}
|
|
15
|
+
return 'data:audio/wav;base64,' + window.btoa(binary);
|
|
16
|
+
};
|
|
17
|
+
exports.audioBufferToDataUrl = audioBufferToDataUrl;
|
|
18
|
+
//# sourceMappingURL=audio-url-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-url-helpers.js","sourceRoot":"","sources":["../../src/audio-buffer/audio-url-helpers.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AAEhD,MAAM,oBAAoB,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC3D,MAAM,gBAAgB,GAAG,IAAA,sCAAgB,EAAC,MAAM,EAAE;QACjD,OAAO,EAAE,IAAI;KACb,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC7B,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;IAED,OAAO,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-smooth-svg-path.d.ts","sourceRoot":"","sources":["../src/create-smooth-svg-path.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAY;IAAC,MAAM;IAAE,MAAM;CAAC,EAAE,kBA6B7D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
|
30
|
+
//# sourceMappingURL=create-smooth-svg-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-smooth-svg-path.js","sourceRoot":"","sources":["../src/create-smooth-svg-path.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,MAA0B,EAAE,EAAE;IACjE,OAAO,MAAM,CAAC,MAAM,CACnB,CAAC,GAAkB,EAAE,KAAuB,EAAE,CAAS,EAAE,CAAC,EAAE,EAAE;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE;YACZ,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SACnC;QAED,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACjG;QAED,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;IACnE,CAAC,EACD,EAAE,CACF,CAAC;AACH,CAAC,CAAC;AA7BW,QAAA,mBAAmB,uBA6B9B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * from './types';
|
|
|
6
6
|
export type { AudioData, VideoMetadata as VideoData } from './types';
|
|
7
7
|
export { useAudioData } from './use-audio-metadata';
|
|
8
8
|
export { visualizeAudio } from './visualize-audio';
|
|
9
|
+
export { audioBufferToDataUrl } from './audio-buffer/audio-url-helpers';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,cAAc,SAAS,CAAC;AACxB,YAAY,EAAC,SAAS,EAAE,aAAa,IAAI,SAAS,EAAC,MAAM,SAAS,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,cAAc,SAAS,CAAC;AACxB,YAAY,EAAC,SAAS,EAAE,aAAa,IAAI,SAAS,EAAC,MAAM,SAAS,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.visualizeAudio = exports.useAudioData = exports.getWaveformPortion = exports.getVideoMetadata = exports.getAudioDuration = exports.getAudioData = void 0;
|
|
13
|
+
exports.audioBufferToDataUrl = exports.visualizeAudio = exports.useAudioData = exports.getWaveformPortion = exports.getVideoMetadata = exports.getAudioDuration = exports.getAudioData = void 0;
|
|
14
14
|
var get_audio_data_1 = require("./get-audio-data");
|
|
15
15
|
Object.defineProperty(exports, "getAudioData", { enumerable: true, get: function () { return get_audio_data_1.getAudioData; } });
|
|
16
16
|
var get_audio_duration_1 = require("./get-audio-duration");
|
|
@@ -24,4 +24,6 @@ var use_audio_metadata_1 = require("./use-audio-metadata");
|
|
|
24
24
|
Object.defineProperty(exports, "useAudioData", { enumerable: true, get: function () { return use_audio_metadata_1.useAudioData; } });
|
|
25
25
|
var visualize_audio_1 = require("./visualize-audio");
|
|
26
26
|
Object.defineProperty(exports, "visualizeAudio", { enumerable: true, get: function () { return visualize_audio_1.visualizeAudio; } });
|
|
27
|
+
var audio_url_helpers_1 = require("./audio-buffer/audio-url-helpers");
|
|
28
|
+
Object.defineProperty(exports, "audioBufferToDataUrl", { enumerable: true, get: function () { return audio_url_helpers_1.audioBufferToDataUrl; } });
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA8C;AAAtC,8GAAA,YAAY,OAAA;AACpB,2DAAsD;AAA9C,sHAAA,gBAAgB,OAAA;AACxB,2DAAsD;AAA9C,sHAAA,gBAAgB,OAAA;AACxB,+DAA0D;AAAlD,0HAAA,kBAAkB,OAAA;AAC1B,0CAAwB;AAExB,2DAAkD;AAA1C,kHAAA,YAAY,OAAA;AACpB,qDAAiD;AAAzC,iHAAA,cAAc,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA8C;AAAtC,8GAAA,YAAY,OAAA;AACpB,2DAAsD;AAA9C,sHAAA,gBAAgB,OAAA;AACxB,2DAAsD;AAA9C,sHAAA,gBAAgB,OAAA;AACxB,+DAA0D;AAAlD,0HAAA,kBAAkB,OAAA;AAC1B,0CAAwB;AAExB,2DAAkD;AAA1C,kHAAA,YAAY,OAAA;AACpB,qDAAiD;AAAzC,iHAAA,cAAc,OAAA;AACtB,sEAAsE;AAA9D,yHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth-path.d.ts","sourceRoot":"","sources":["../src/smooth-path.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAY;IAAC,MAAM;IAAE,MAAM;CAAC,EAAE,kBA6B7D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
|
30
|
+
//# sourceMappingURL=smooth-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth-path.js","sourceRoot":"","sources":["../src/smooth-path.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,MAA0B,EAAE,EAAE;IACjE,OAAO,MAAM,CAAC,MAAM,CACnB,CAAC,GAAkB,EAAE,KAAuB,EAAE,CAAS,EAAE,CAAC,EAAE,EAAE;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE;YACZ,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SACnC;QAED,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACjG;QAED,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;IACnE,CAAC,EACD,EAAE,CACF,CAAC;AACH,CAAC,CAAC;AA7BW,QAAA,mBAAmB,uBA6B9B"}
|
|
@@ -3,11 +3,9 @@ declare type FnParameters = {
|
|
|
3
3
|
audioData: AudioData;
|
|
4
4
|
frame: number;
|
|
5
5
|
fps: number;
|
|
6
|
-
|
|
6
|
+
windowInSeconds: number;
|
|
7
7
|
numberOfSamples: number;
|
|
8
8
|
};
|
|
9
|
-
export declare const visualizeAudioWaveform: ({
|
|
10
|
-
smoothing?: boolean | undefined;
|
|
11
|
-
}) => number[];
|
|
9
|
+
export declare const visualizeAudioWaveform: ({ ...parameters }: FnParameters) => number[];
|
|
12
10
|
export {};
|
|
13
11
|
//# sourceMappingURL=visualize-audio-waveform.d.ts.map
|
|
@@ -1 +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,
|
|
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,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACxB,CAAC;AA2CF,eAAO,MAAM,sBAAsB,sBAAqB,YAAY,aAGnE,CAAC"}
|
|
@@ -3,35 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.visualizeAudioWaveform = void 0;
|
|
4
4
|
const get_waveform_portion_1 = require("./get-waveform-portion");
|
|
5
5
|
const cache = {};
|
|
6
|
-
const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples,
|
|
7
|
-
if (
|
|
8
|
-
throw new TypeError(
|
|
6
|
+
const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples, windowInSeconds, }) => {
|
|
7
|
+
if (windowInSeconds * audioData.sampleRate < numberOfSamples) {
|
|
8
|
+
throw new TypeError(windowInSeconds +
|
|
9
9
|
's audiodata does not have ' +
|
|
10
10
|
numberOfSamples +
|
|
11
|
-
' bars. Increase
|
|
11
|
+
' bars. Increase windowInSeconds or decrease numberOfSamples');
|
|
12
12
|
}
|
|
13
13
|
const cacheKey = audioData.resultId + frame + fps + numberOfSamples + 'waveform';
|
|
14
14
|
if (cache[cacheKey]) {
|
|
15
15
|
return cache[cacheKey];
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: frame / fps - waveformDuration / 2;
|
|
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));
|
|
22
21
|
return (0, get_waveform_portion_1.getWaveformPortion)({
|
|
23
22
|
audioData,
|
|
24
23
|
startTimeInSeconds,
|
|
25
|
-
durationInSeconds:
|
|
24
|
+
durationInSeconds: windowInSeconds,
|
|
26
25
|
numberOfSamples,
|
|
27
|
-
normalize:
|
|
26
|
+
normalize: true,
|
|
28
27
|
});
|
|
29
28
|
};
|
|
30
|
-
const visualizeAudioWaveform = ({
|
|
31
|
-
if (smoothing) {
|
|
32
|
-
// TODO: Add bezier manipulation?
|
|
33
|
-
console.log('nice');
|
|
34
|
-
}
|
|
29
|
+
const visualizeAudioWaveform = ({ ...parameters }) => {
|
|
35
30
|
const data = visualizeAudioWaveformFrame(parameters);
|
|
36
31
|
return data.map((value) => value.amplitude);
|
|
37
32
|
};
|
|
@@ -1 +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,
|
|
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,e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|
|
3
|
+
"version": "3.0.0-pnpm.18+af042d076",
|
|
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": "
|
|
18
|
+
"remotion": "3.0.0-pnpm.18+af042d076"
|
|
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": "af042d07642fd844cb5169601b7ec7b20282888b"
|
|
36
36
|
}
|