@k13engineering/rubberband 0.0.6 → 0.0.7
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/lib/index.d.ts +1 -0
- package/dist/lib/index.js +16 -0
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ declare const createRubberbandWrapper: ({ sampleRate, channelCount, maxBufferSiz
|
|
|
16
16
|
process: ({ audioData }: {
|
|
17
17
|
audioData: TRubberbandAudioData;
|
|
18
18
|
}) => void;
|
|
19
|
+
end: () => void;
|
|
19
20
|
available: () => number;
|
|
20
21
|
latencyInSamples: () => number;
|
|
21
22
|
retrieve: ({ sampleCount }: {
|
package/dist/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const rubberbandApi = await RubberBandInterface.initialize(wasm);
|
|
|
12
12
|
|
|
13
13
|
const OptionProcessRealTime = 1;
|
|
14
14
|
|
|
15
|
+
// eslint-disable-next-line max-statements
|
|
15
16
|
const createRubberbandWrapper = ({
|
|
16
17
|
sampleRate,
|
|
17
18
|
channelCount,
|
|
@@ -22,6 +23,8 @@ const createRubberbandWrapper = ({
|
|
|
22
23
|
maxBufferSizeInFrames: number;
|
|
23
24
|
}*/) => {
|
|
24
25
|
|
|
26
|
+
let ended = false;
|
|
27
|
+
|
|
25
28
|
const channelArrayPtr = rubberbandApi.malloc(channelCount * 4);
|
|
26
29
|
const channelDataPtrs/*: number[]*/ = [];
|
|
27
30
|
for (let channel = 0; channel < channelCount; channel += 1) {
|
|
@@ -45,6 +48,9 @@ const createRubberbandWrapper = ({
|
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
const process = ({ audioData }/*: { audioData: TRubberbandAudioData }*/) => {
|
|
51
|
+
if (ended) {
|
|
52
|
+
throw Error("already ended");
|
|
53
|
+
}
|
|
48
54
|
|
|
49
55
|
const firstPlane = audioData.planes[0];
|
|
50
56
|
const sampleCount = firstPlane.length;
|
|
@@ -66,6 +72,15 @@ const createRubberbandWrapper = ({
|
|
|
66
72
|
rubberbandApi.rubberband_process(rb, channelArrayPtr, sampleCount, 0);
|
|
67
73
|
};
|
|
68
74
|
|
|
75
|
+
const end = () => {
|
|
76
|
+
if (ended) {
|
|
77
|
+
throw Error("already ended");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ended = true;
|
|
81
|
+
rubberbandApi.rubberband_process(rb, channelArrayPtr, 0, 1);
|
|
82
|
+
};
|
|
83
|
+
|
|
69
84
|
const available = ()/*: number*/ => {
|
|
70
85
|
return rubberbandApi.rubberband_available(rb);
|
|
71
86
|
};
|
|
@@ -117,6 +132,7 @@ const createRubberbandWrapper = ({
|
|
|
117
132
|
requestTimeRatio,
|
|
118
133
|
samplesRequired,
|
|
119
134
|
process,
|
|
135
|
+
end,
|
|
120
136
|
available,
|
|
121
137
|
latencyInSamples,
|
|
122
138
|
retrieve
|
package/package.json
CHANGED