-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#201] [Core] AudioBus - support for multiple node connections and mi…
…xed amount of channels (#206) * feat: working on new buffer structure * feat: more work * feat: channel mixer * feat: add some comments * fix: spellchecker howling * fix: linter howling * fix: linter howling part 1.27 * fix: politely obey to false-positive linter check * feat: working on AudioPlayer implementation using AudioBus * feat: processNode implementations * feat: self-abuse * feat: migrate gain node * feat: audio bus & audio array range operators * feat: audio buffer source node - rewrite to use audio bus and complicate the matter * fix: some memory alloc fixes * fix: get back to previous scheduling impl * fix: cleanup logs * feat: update translations * fix: uncomment all oscilator example params * fix: more fixes * feat: locker + audio node manager wip * fix: remove silencer + add post and preproc * feat: working on decontruction * feat: something is working * fix: hi-hat sound * feat: proper deconstruction * fix: unused variable, android player pointer usage * fix: linter * fix: linter2 - the return of the explicit? * Update packages/react-native-audio-api/common/cpp/core/AudioBus.cpp * Update packages/react-native-audio-api/common/cpp/core/AudioBus.cpp * fix: cleanup * fix: redundant HAVE_ACCELERATE directive
- Loading branch information
Showing
43 changed files
with
1,484 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ rnaa | |
|
||
tada | ||
vec | ||
rnaa | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apps/fabric-example/ios/FabricExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/react-native-audio-api/common/cpp/core/AudioArray.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#include <algorithm> | ||
|
||
#include "AudioArray.h" | ||
#include "VectorMath.h" | ||
|
||
namespace audioapi { | ||
|
||
AudioArray::AudioArray(int size) : size_(size), data_(0) { | ||
resize(size); | ||
} | ||
|
||
AudioArray::~AudioArray() { | ||
if (data_) { | ||
delete[] data_; | ||
data_ = 0; | ||
} | ||
} | ||
|
||
int AudioArray::getSize() const { | ||
return size_; | ||
} | ||
|
||
float* AudioArray::getData() const { | ||
return data_; | ||
} | ||
|
||
float& AudioArray::operator[](int index) { | ||
return data_[index]; | ||
} | ||
|
||
const float& AudioArray::operator[](int index) const { | ||
return data_[index]; | ||
} | ||
|
||
void AudioArray::normalize() { | ||
float maxAbsValue = getMaxAbsValue(); | ||
|
||
if (maxAbsValue == 0.0f || maxAbsValue == 1.0f) { | ||
return; | ||
} | ||
|
||
VectorMath::multiplyByScalar(data_, 1.0f / maxAbsValue, data_, size_); | ||
} | ||
|
||
void AudioArray::resize(int size) { | ||
if (size == size_) { | ||
if (!data_) { | ||
data_ = new float[size]; | ||
} | ||
|
||
zero(0, size); | ||
return; | ||
} | ||
|
||
delete[] data_; | ||
size_ = size; | ||
data_ = new float[size_]; | ||
|
||
zero(0, size_); | ||
} | ||
|
||
void AudioArray::scale(float value) { | ||
VectorMath::multiplyByScalar(data_, value, data_, size_); | ||
} | ||
|
||
float AudioArray::getMaxAbsValue() const { | ||
return VectorMath::maximumMagnitude(data_, size_); | ||
} | ||
|
||
void AudioArray::zero() { | ||
zero(0, size_); | ||
} | ||
|
||
void AudioArray::zero(int start, int length) { | ||
memset(data_ + start, 0, length * sizeof(float)); | ||
} | ||
|
||
void AudioArray::sum(const AudioArray* source) { | ||
sum(source, 0, 0, size_); | ||
} | ||
|
||
void AudioArray::sum(const AudioArray* source, int start, int length) { | ||
sum(source, start, start, length); | ||
} | ||
|
||
void AudioArray::sum(const AudioArray* source, int sourceStart, int destinationStart, int length) { | ||
VectorMath::add(data_ + destinationStart, source->getData() + sourceStart, data_ + destinationStart, length); | ||
} | ||
|
||
void AudioArray::copy(const AudioArray* source) { | ||
copy(source, 0, size_); | ||
} | ||
|
||
void AudioArray::copy(const AudioArray* source, int start, int length) { | ||
copy(source, start, start, length); | ||
} | ||
|
||
void AudioArray::copy(const AudioArray* source, int sourceStart, int destinationStart, int length) { | ||
memcpy(data_ + destinationStart, source->getData() + sourceStart, length * sizeof(float)); | ||
} | ||
|
||
} // namespace audioapi | ||
|
42 changes: 42 additions & 0 deletions
42
packages/react-native-audio-api/common/cpp/core/AudioArray.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <algorithm> | ||
|
||
namespace audioapi { | ||
|
||
class AudioArray { | ||
public: | ||
explicit AudioArray(int size); | ||
~AudioArray(); | ||
|
||
[[nodiscard]] int getSize() const; | ||
float* getData() const; | ||
|
||
|
||
float& operator[](int index); | ||
const float& operator[](int index) const; | ||
|
||
void normalize(); | ||
void resize(int size); | ||
void scale(float value); | ||
float getMaxAbsValue() const; | ||
|
||
void zero(); | ||
void zero(int start, int length); | ||
|
||
void sum(const AudioArray* source); | ||
void sum(const AudioArray* source, int start, int length); | ||
void sum(const AudioArray* source, int sourceStart, int destinationStart, int length); | ||
|
||
void copy(const AudioArray* source); | ||
void copy(const AudioArray* source, int start, int length); | ||
void copy(const AudioArray* source, int sourceStart, int destinationStart, int length); | ||
|
||
|
||
private: | ||
float *data_; | ||
int size_; | ||
}; | ||
|
||
} // namespace audioapi |
Oops, something went wrong.