Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/audio param methods #238

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ PODS:
- React-logger (= 0.76.0)
- React-perflogger (= 0.76.0)
- React-utils (= 0.76.0)
- RNAudioAPI (0.3.0-rc2):
- RNAudioAPI (0.3.1):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -2152,7 +2152,7 @@ SPEC CHECKSUMS:
React-utils: d9624101245ebaab39c9f1bd786132da0b4f27ff
ReactCodegen: dbfef1fef26f42c900bb1884fa149d49d501d64d
ReactCommon: 429ca28cd813c31359c73ffac6dc24f93347d522
RNAudioAPI: 837e19b456700c09bfd3d3c0068b82d2a11c68d0
RNAudioAPI: e7c191e81df9b2a725b8409767130b0af869f9bc
RNGestureHandler: 0e5ae8d72ef4afb855e98dcdbe60f27d938abe13
RNReanimated: 006a5d3961bf09c1e96d62ed436e02b2e43b89bb
RNScreens: e389d6a6a66a4f0d3662924ecae803073ccce8ec
Expand Down
34 changes: 6 additions & 28 deletions docs/web-audio-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Some of the noticeable implementation details that are still in progress or not
- Support of different number of channels (current approach in most of the audio-graph nodes assumes working with two channel audio)
- Multi-input for each node and input mixing (Although specification suggests that most of the nodes can cave only one input or output, common use-cases proves otherwise). Only node that mixes multiple inputs is `DestinationNode`.

## ✅ Completed (**9** out of 33)
## ✅ Completed (**10** out of 32)

<details>
<summary><b>AudioBuffer</b></summary>
Expand Down Expand Up @@ -36,8 +36,11 @@ Some of the noticeable implementation details that are still in progress or not
<details>
<summary><b>StereoPannerNode</b></summary>
</details>
<details>
<summary><b>AudioParam</b></summary>
</details>

## 🚧 In Progress (**4** out of 33)
## 🚧 In Progress (**3** out of 32)

<details>
<summary><b>AudioContext</b></summary>
Expand Down Expand Up @@ -80,28 +83,6 @@ Some of the noticeable implementation details that are still in progress or not

</details>

<details>
<summary><b>AudioParam</b></summary>

<div style="padding: 16px; padding-left: 42px;">

| Property 🔹/ Method 🔘 | state |
| -------------------------- | ----- |
| 🔹 value | ✅ |
| 🔹 defaultValue | ✅ |
| 🔹 minValue | ✅ |
| 🔹 maxValue | ✅ |
| 🔘 setValueAtTime | ✅ |
| 🔘 linearRampToValueAtTime | ✅ |
| 🔘 setTargetAtTime | ❌ |
| 🔘 setValueCurveAtTime | ❌ |
| 🔘 cancelScheduledValues | ❌ |
| 🔘 cancelAndHoldAtTime | ❌ |

</div>

</details>

<details>
<summary><b>BaseAudioContext</b></summary>

Expand Down Expand Up @@ -138,7 +119,7 @@ Some of the noticeable implementation details that are still in progress or not

</details>

## ❌ Not yet available (**20** out of 33)
## ❌ Not yet available (**19** out of 32)

<details>
<summary><b>AudioParamMap</b></summary>
Expand Down Expand Up @@ -197,6 +178,3 @@ Some of the noticeable implementation details that are still in progress or not
<details>
<summary><b>OfflineAudioContext</b></summary>
</details>
<details>
<summary><b>AudioParamMap</b></summary>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class AudioParamHostObject : public JsiHostObject {
addFunctions(
JSI_EXPORT_FUNCTION(AudioParamHostObject, setValueAtTime),
JSI_EXPORT_FUNCTION(AudioParamHostObject, linearRampToValueAtTime),
JSI_EXPORT_FUNCTION(
AudioParamHostObject, exponentialRampToValueAtTime));
JSI_EXPORT_FUNCTION(AudioParamHostObject, exponentialRampToValueAtTime),
JSI_EXPORT_FUNCTION(AudioParamHostObject, setTargetAtTime),
JSI_EXPORT_FUNCTION(AudioParamHostObject, setValueCurveAtTime),
JSI_EXPORT_FUNCTION(AudioParamHostObject, cancelScheduledValues),
JSI_EXPORT_FUNCTION(AudioParamHostObject, cancelAndHoldAtTime));

addSetters(JSI_EXPORT_PROPERTY_SETTER(AudioParamHostObject, value));
}
Expand Down Expand Up @@ -66,6 +69,40 @@ class AudioParamHostObject : public JsiHostObject {
return jsi::Value::undefined();
}

JSI_HOST_FUNCTION(setTargetAtTime) {
auto target = static_cast<float>(args[0].getNumber());
double startTime = args[1].getNumber();
double timeConstant = args[2].getNumber();
param_->setTargetAtTime(target, startTime, timeConstant);
return jsi::Value::undefined();
}

JSI_HOST_FUNCTION(setValueCurveAtTime) {
auto values = args[0].getObject(runtime).asArray(runtime);
auto length = static_cast<int>(values.length(runtime));
auto valuesData = new float[length];
for (size_t i = 0; i < values.length(runtime); i++) {
valuesData[i] =
static_cast<float>(values.getValueAtIndex(runtime, i).getNumber());
}
double startTime = args[1].getNumber();
double duration = args[2].getNumber();
param_->setValueCurveAtTime(valuesData, length, startTime, duration);
return jsi::Value::undefined();
}

JSI_HOST_FUNCTION(cancelScheduledValues) {
double cancelTime = args[0].getNumber();
param_->cancelScheduledValues(cancelTime);
return jsi::Value::undefined();
}

JSI_HOST_FUNCTION(cancelAndHoldAtTime) {
double cancelTime = args[0].getNumber();
param_->cancelAndHoldAtTime(cancelTime);
return jsi::Value::undefined();
}

JSI_PROPERTY_SETTER(value) {
param_->setValue(static_cast<float>(value.getNumber()));
}
Expand Down
Loading
Loading