Skip to content

Commit

Permalink
Merge branch 'main' into refactor/ts-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Makowski committed Oct 25, 2024
2 parents f11ead0 + c916700 commit 925b6f3
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 60 deletions.
156 changes: 156 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Bug report
description: Report an issue with React Native Audio API here.
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
Before you proceed:
- Make sure to check whether there are similar issues in the repository
- Make sure to clean cache in your project. Depending on your setup this could be done by:
- `yarn start --reset-cache` or
- `npm start -- --reset-cache` or
- `expo start --clear`
- type: markdown
attributes:
value: |
## Required information
- type: textarea
id: description
attributes:
label: Description
description: Please provide a clear, concise and descriptive explanation of what the bug is. Include screenshots or a video if needed. Tell us what were you expecting to happen instead of what is happening now.
validations:
required: true

- type: textarea
id: steps-to-reproduce
attributes:
label: Steps to reproduce
description: Provide a detailed list of steps that reproduce the issue.
placeholder: |
1.
2.
3.
validations:
required: true

- type: input
id: repro
attributes:
label: Snack or a link to a repository
description: |
Please provide a Snack (https://snack.expo.io/) or a link to a repository on GitHub under your username that reproduces the issue.
Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve.
Issues without a reproduction are likely to stale.
placeholder: Link to a Snack or a GitHub repository
validations:
required: true

- type: input
id: react-native-audio-api-version
attributes:
label: React Native Audio API version
description: What version of react-native-audio-api are you using?
placeholder: 0.1.0
validations:
required: true

- type: input
id: react-native-version
attributes:
label: React Native version
description: What version of react-native are you using?
placeholder: 0.75.3
validations:
required: true

- type: dropdown
id: platforms
attributes:
label: Platforms
description: On what platform your application is running on?
multiple: true
options:
- Android
- iOS
validations:
required: true

- type: markdown
attributes:
value: |
## Additonal information
Providing as much information as possible greatly helps us with reproducting the issues.
- type: dropdown
id: runtime
attributes:
label: JavaScript runtime
description: What runtime is your application using?
options:
- JSC
- Hermes
- V8

- type: dropdown
id: workflow
attributes:
label: Workflow
description: How is your application managed?
options:
- React Native
- Expo Go
- Expo Dev Client

- type: dropdown
id: architecture
attributes:
label: Architecture
description: What React Native architecture your application is running on? Currently, the default architecture on React Native is Paper so if you haven't changed it in your application select this option.
options:
- Paper (Old Architecture)
- Fabric (New Architecture)

- type: dropdown
id: build-type
attributes:
label: Build type
description: What is the build configuration/variant of your native app and JavaScript bundle mode?
options:
- Debug app & dev bundle
- Release app & production bundle
- Debug app & production bundle
- Release app & dev bundle
- Other (please specify)

- type: dropdown
id: emulator
attributes:
label: Device
description: How are you running your application?
options:
- iOS simulator
- Android emulator
- Real device

- type: input
id: device-model
attributes:
label: Device model
description: What device you are experiencing this problem on? Specify full device name along with the version of the operating system it's running.
placeholder: ex. Samsung Galaxy A22 (Android 12)

- type: dropdown
id: acknowledgements
attributes:
label: Acknowledgements
description: I searched for similar issues in the repository.
options:
- 'Yes'
validations:
required: true
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Feature request
description: Suggest a feature
body:
- type: textarea
id: Suggestion
attributes:
label: Feature Request
description: Describe the feature(s) you would like to be added.
validations:
required: true
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Reference any GitHub issues resolved by this PR -->

Closes #

## Introduced changes

<!-- A brief description of the changes -->

-

## Checklist

<!-- Make sure all of these are complete -->

- [ ] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added/Conducted relevant tests
- [ ] Performed self-review of the code
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Clap implements SoundEngine {
output[i] = Math.random() * 2 - 1;
}

buffer.setChannelData(0, output);
buffer.copyToChannel(output, 0, 0);

return buffer;
}
Expand Down
36 changes: 9 additions & 27 deletions docs/web-audio-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@ 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 (**5** out of 33)
## ✅ Completed (**6** out of 33)

<details>
<summary><b>AudioScheduledSourceNode</b></summary>
<summary><b>AudioBuffer</b></summary>
</details>
<details>
<summary><b>AudioDestinationNode</b></summary>
</details>
<details>
<summary><b>GainNode</b></summary>
<summary><b>AudioNode</b></summary>
</details>
<details>
<summary><b>StereoPannerNode</b></summary>
<summary><b>AudioScheduledSourceNode</b></summary>
</details>
<details>
<summary><b>AudioNode</b></summary>
<summary><b>GainNode</b></summary>
</details>
<details>
<summary><b>StereoPannerNode</b></summary>
</details>

## 🚧 In Progress (**7** out of 33)
## 🚧 In Progress (**6** out of 33)

<details>
<summary><b>AudioContext</b></summary>
Expand All @@ -49,27 +52,6 @@ Some of the noticeable implementation details that are still in progress or not

</details>

<details>
<summary><b>AudioBuffer</b></summary>

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

| Property 🔹/ Method 🔘 | state |
| ---------------------- | ----- |
| 🔹 sampleRate ||
| 🔹 length ||
| 🔹 duration ||
| 🔹 numberOfChannels ||
| 🔘 getChannelData ||
| 🔘 getChannelData ||
| 🔘 setChannelData ||
| 🔘 copyFromChannel ||
| 🔘 copyToChannel ||

</div>

</details>

<details>
<summary><b>AudioBufferSourceNode</b></summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ std::vector<jsi::PropNameID> AudioBufferHostObject::getPropertyNames(
propertyNames.push_back(
jsi::PropNameID::forAscii(runtime, "numberOfChannels"));
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "getChannelData"));
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "setChannelData"));
propertyNames.push_back(
jsi::PropNameID::forAscii(runtime, "copyFromChannel"));
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "copyToChannel"));
return propertyNames;
}

Expand Down Expand Up @@ -64,26 +66,63 @@ jsi::Value AudioBufferHostObject::get(
});
}

if (propName == "setChannelData") {
if (propName == "copyFromChannel") {
return jsi::Function::createFromHostFunction(
runtime,
propNameId,
2,
3,
[this](
jsi::Runtime &rt,
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count) -> jsi::Value {
int channel = static_cast<int>(args[0].getNumber());
auto array = args[1].getObject(rt).asArray(rt);
auto *channelData = new float[wrapper_->getLength()];
auto destination = args[0].getObject(rt).asArray(rt);
auto destinationLength = static_cast<int>(
destination.getProperty(rt, "length").asNumber());
auto channelNumber = static_cast<int>(args[1].getNumber());
auto startInChannel = static_cast<int>(args[2].getNumber());

auto *destinationData = new float[destinationLength];

wrapper_->copyFromChannel(
destinationData,
destinationLength,
channelNumber,
startInChannel);

for (int i = 0; i < destinationLength; i++) {
destination.setValueAtIndex(rt, i, jsi::Value(destinationData[i]));
}

for (int i = 0; i < wrapper_->getLength(); i++) {
channelData[i] =
static_cast<float>(array.getValueAtIndex(rt, i).getNumber());
return jsi::Value::undefined();
});
}

if (propName == "copyToChannel") {
return jsi::Function::createFromHostFunction(
runtime,
propNameId,
3,
[this](
jsi::Runtime &rt,
const jsi::Value &thisVal,
const jsi::Value *args,
size_t count) -> jsi::Value {
auto source = args[0].getObject(rt).asArray(rt);
auto sourceLength =
static_cast<int>(source.getProperty(rt, "length").asNumber());
auto channelNumber = static_cast<int>(args[1].getNumber());
auto startInChannel = static_cast<int>(args[2].getNumber());

auto *sourceData = new float[sourceLength];

for (int i = 0; i < sourceLength; i++) {
sourceData[i] =
static_cast<float>(source.getValueAtIndex(rt, i).getNumber());
}

wrapper_->setChannelData(channel, channelData, wrapper_->getLength());
wrapper_->copyToChannel(
sourceData, sourceLength, channelNumber, startInChannel);

return jsi::Value::undefined();
});
Expand Down
Loading

0 comments on commit 925b6f3

Please sign in to comment.