Skip to content

Commit 125696f

Browse files
authored
feat: audio param performance improvement (#639)
* feat: simple performant ring buff impl * chore: ring buff neatpicks * feat: optimized param change event type * chore: minor changes * feat: param events queue impl * feat: enchanced audio param impl * chore: neatpicks * chore: neatpicks * chore: minor opts * fix: fixed tests * fix: comments * fix: minor fixes * fix: neatpicks
1 parent 2c9c6a6 commit 125696f

File tree

10 files changed

+748
-329
lines changed

10 files changed

+748
-329
lines changed

apps/common-app/src/examples/DrumMachine/DrumMachine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const DrumMachine: React.FC = () => {
134134
label="BPM"
135135
step={1}
136136
min={24}
137-
max={1000}
137+
max={1500}
138138
value={bpm}
139139
onValueChange={setBpm}
140140
/>

packages/react-native-audio-api/common/cpp/audioapi/HostObjects/AudioParamHostObject.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <audioapi/core/AudioParam.h>
55

66
#include <jsi/jsi.h>
7+
#include <utility>
78
#include <memory>
89
#include <vector>
910
#include <cstddef>
@@ -81,12 +82,13 @@ class AudioParamHostObject : public JsiHostObject {
8182

8283
JSI_HOST_FUNCTION(setValueCurveAtTime) {
8384
auto arrayBuffer = args[0].getObject(runtime).getPropertyAsObject(runtime, "buffer").getArrayBuffer(runtime);
84-
auto values = reinterpret_cast<float *>(arrayBuffer.data(runtime));
85+
auto rawValues = reinterpret_cast<float *>(arrayBuffer.data(runtime));
8586
auto length = static_cast<int>(arrayBuffer.size(runtime));
87+
auto values = std::make_unique<std::vector<float>>(rawValues, rawValues + length);
8688

8789
double startTime = args[1].getNumber();
8890
double duration = args[2].getNumber();
89-
param_->setValueCurveAtTime(values, length, startTime, duration);
91+
param_->setValueCurveAtTime(std::move(values), length, startTime, duration);
9092
return jsi::Value::undefined();
9193
}
9294

0 commit comments

Comments
 (0)