refactor: implemented aligned audio array implementation#980
Open
maciejmakowski2003 wants to merge 6 commits intomainfrom
Open
refactor: implemented aligned audio array implementation#980maciejmakowski2003 wants to merge 6 commits intomainfrom
maciejmakowski2003 wants to merge 6 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors AudioArray and AudioBuffer from traditional .h/.cpp class pairs into C++ template header-only (.hpp) implementations, introducing configurable memory alignment via the AlignedAudioArray<Alignment> and AlignedAudioBuffer<Alignment> template classes. Type aliases preserve backward compatibility (AudioArray, AudioBuffer) while adding new DSPAudioArray and DSPAudioBuffer types with 64-byte alignment for SIMD optimization.
Changes:
- Replaced
AudioArray.h/.cppandAudioBuffer.h/.cppwith template header-onlyAudioArray.hppandAudioBuffer.hpp, parameterized on memory alignment. - Updated all
#includedirectives and removed now-unnecessary forward declarations (class AudioBuffer;,class AudioArray;) across ~50 files. - Fixed a typo in
AudioAPIModuleInstaller.hrenaminggetCrateAudioBufferFunctiontogetCreateAudioBufferFunction.
Reviewed changes
Copilot reviewed 102 out of 103 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
AudioArray.hpp |
New template header replacing AudioArray.h/.cpp with alignment-parameterized AlignedAudioArray<Alignment> |
AudioBuffer.hpp |
New template header replacing AudioBuffer.h/.cpp with alignment-parameterized AlignedAudioBuffer<Alignment> |
AudioArrayBuffer.hpp |
Updated to use templatized AlignedAudioArrayBuffer<Alignment> inheriting from AlignedAudioArray |
AudioArray.h/.cpp |
Deleted (replaced by .hpp) |
AudioBuffer.h/.cpp |
Deleted (replaced by .hpp) |
AudioAPIModuleInstaller.h |
Fixed function name typo (getCrate... → getCreate...) |
~40 other .h/.cpp/.mm files |
Updated includes from .h to .hpp and removed stale forward declarations |
create-your-own-effect.mdx |
Updated documentation with new include paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-native-audio-api/common/cpp/audioapi/utils/AudioArray.hpp
Outdated
Show resolved
Hide resolved
packages/react-native-audio-api/common/cpp/audioapi/AudioAPIModuleInstaller.h
Outdated
Show resolved
Hide resolved
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of RNAA-425
Introduced changes
AlignedAudioArraythat allows to specify alignment used to allocate it's data. There are two default template instantiations:AudioArrayaligned toalignof(std::max_align_t)- in common 16 bytes,DSPAudioArrayaligned to 64 bytes in order to avoid false sharing and boost SIMD.AlignedAudioBufferthat is a wrapper around a vector of AlignedAudioArray.Checklist