Refactor/buffer source nodes#986
Open
maciejmakowski2003 wants to merge 2 commits intorefactor/aligned-data-structures-integrationfrom
Open
Refactor/buffer source nodes#986maciejmakowski2003 wants to merge 2 commits intorefactor/aligned-data-structures-integrationfrom
maciejmakowski2003 wants to merge 2 commits intorefactor/aligned-data-structures-integrationfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the audio buffer/array infrastructure and updates the node pipeline to use DSP-aligned buffers/arrays, aiming to simplify and unify buffer source node implementations across platforms.
Changes:
- Replace legacy
AudioArray/AudioBuffer.h/.cppimplementations with header-only, alignment-aware.hppversions (AudioArray.hpp,AudioBuffer.hpp) and introduceDSPAudioArray/DSPAudioBufferaliases. - Replace
CircularAudioArraywith a templatedCircularArray(CircularArray.hpp) and update affected nodes/utilities. - Update core nodes, host objects, DSP utilities, and platform players/recorders to use
DSPAudioBufferin the processing/render path and adjust tests/docs/templates accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-audio-api/ios/audioapi/ios/core/utils/IOSRecorderCallback.mm | Update includes to new .hpp headers and circular array replacement. |
| packages/react-native-audio-api/ios/audioapi/ios/core/utils/IOSRecorderCallback.h | Switch to .hpp buffer include; remove obsolete forward decls/includes. |
| packages/react-native-audio-api/ios/audioapi/ios/core/IOSAudioRecorder.mm | Update includes to .hpp + CircularArray.hpp. |
| packages/react-native-audio-api/ios/audioapi/ios/core/IOSAudioPlayer.mm | Switch render path to DSPAudioBuffer. |
| packages/react-native-audio-api/ios/audioapi/ios/core/IOSAudioPlayer.h | Update API types to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/test/src/utils/AudioBufferTest.cpp | Update include to AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/test/src/utils/AudioArrayTest.cpp | Update include to AudioArray.hpp. |
| packages/react-native-audio-api/common/cpp/test/src/core/sources/ConstantSourceTest.cpp | Update tests to DSPAudioBuffer and new includes. |
| packages/react-native-audio-api/common/cpp/test/src/core/sources/AudioScheduledSourceTest.cpp | Update tests to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/test/src/core/effects/WaveShaperNodeTest.cpp | Update tests to DSPAudioBuffer and new includes. |
| packages/react-native-audio-api/common/cpp/test/src/core/effects/StereoPannerTest.cpp | Update tests to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/test/src/core/effects/GainTest.cpp | Update tests to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/test/src/core/effects/DelayTest.cpp | Update tests to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/CircularOverflowableAudioArray.h | Switch include to AudioArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/CircularAudioArray.h | Remove legacy circular array interface. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/CircularAudioArray.cpp | Remove legacy circular array implementation. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/CircularArray.hpp | Add templated circular array replacement + aliases. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioBuffer.hpp | Add new alignment-aware AudioBuffer/DSPAudioBuffer implementation. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioBuffer.h | Remove legacy AudioBuffer header. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioBuffer.cpp | Remove legacy AudioBuffer source. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioArrayBuffer.hpp | Refactor AudioArrayBuffer into alignment-aware version. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioArray.hpp | Add new alignment-aware AudioArray/DSPAudioArray implementation. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioArray.h | Remove legacy AudioArray header. |
| packages/react-native-audio-api/common/cpp/audioapi/utils/AudioArray.cpp | Remove legacy AudioArray source. |
| packages/react-native-audio-api/common/cpp/audioapi/types/NodeOptions.h | Update options includes/types; add onPositionChangedInterval; change WaveShaper curve type. |
| packages/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h | Update include to AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp | Update includes to new audio array header. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/r8brain/Resampler.hpp | Add header-only resampler (replacing .h/.cpp). |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/r8brain/Resampler.h | Remove legacy resampler header. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/r8brain/Resampler.cpp | Remove legacy resampler source. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/WaveShaper.h | Update processing to DSPAudioArray + new resampler header. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/WaveShaper.cpp | Update temp buffers/types and includes for new DSP arrays. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/FFT.h | Template FFT helpers over aligned audio arrays. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/Convolver.h | Update processing to DSPAudioArray and internal buffer types. |
| packages/react-native-audio-api/common/cpp/audioapi/dsp/Convolver.cpp | Update includes + switch processing signature to DSP arrays. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioStretcher.h | Include new AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioStretcher.cpp | Update includes to AudioArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioRecorderCallback.h | Update includes + swap to CircularArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioRecorderCallback.cpp | Update includes to CircularArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioGraphManager.h | Include new AudioBuffer.hpp and remove old forward decl. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioGraphManager.cpp | Remove old AudioBuffer.h include. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioDecoder.h | Include new AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/utils/AudioDecoder.cpp | Update includes to AudioArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/WorkletSourceNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.h | Switch processing signature to DSPAudioBuffer + resampler header change. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.cpp | Switch processing signature/allocations to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/RecorderAdapterNode.h | Switch node processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/RecorderAdapterNode.cpp | Mix AudioBuffer adapter output into DSPAudioBuffer processing buffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/OscillatorNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/OscillatorNode.cpp | Switch processing signature to DSPAudioBuffer; adjust allocations/includes. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/ConstantSourceNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h | Update playback info API to accept DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp | Update playback info API to accept DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h | Refactor to implement base hooks using DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp | Refactor setBuffer/process helpers for DSP buffer pipeline. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h | Refactor to implement base hooks using DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp | Refactor helper methods to use DSP processing buffer type. |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h | Centralize processing into base with DSP buffers + new hooks (isEmpty, interpolation hooks). |
| packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp | Implement unified base processing pipeline; add interval setup. |
| packages/react-native-audio-api/common/cpp/audioapi/core/inputs/AudioRecorder.h | Include AudioBuffer.hpp and drop old forward decls. |
| packages/react-native-audio-api/common/cpp/audioapi/core/inputs/AudioRecorder.cpp | Minor cleanup (remove stray leading blank line). |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletProcessingNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp | Switch processing signature + use double time variable. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WaveShaperNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/WaveShaperNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/StereoPannerNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/StereoPannerNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/PeriodicWave.h | Switch wavetable storage/types to DSP-aligned buffers/arrays. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/PeriodicWave.cpp | Allocate DSP-aligned wavetable buffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/IIRFilterNode.h | Switch processing signature to DSPAudioBuffer; update internal array types. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/IIRFilterNode.cpp | Update includes/signature to DSP processing buffer type. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/GainNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/GainNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/DelayNode.h | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/DelayNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/ConvolverNode.h | Switch internal buffers + processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/ConvolverNode.cpp | Switch processing signatures to DSP buffers; TODO about DSP buffer destruction. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/BiquadFilterNode.h | Switch processing signature to DSPAudioBuffer; use DSP arrays for delay samples. |
| packages/react-native-audio-api/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp | Switch processing signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/destinations/AudioDestinationNode.h | Switch render/process signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/destinations/AudioDestinationNode.cpp | Switch render signature to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/analysis/AnalyserNode.h | Switch internal buffers to DSP-aligned variants + CircularDSPAudioArray. |
| packages/react-native-audio-api/common/cpp/audioapi/core/analysis/AnalyserNode.cpp | Allocate DSP-aligned buffers + circular DSP array; minor numeric casting tweak. |
| packages/react-native-audio-api/common/cpp/audioapi/core/OfflineAudioContext.h | Store DSP render buffer as member; make length/channels const. |
| packages/react-native-audio-api/common/cpp/audioapi/core/OfflineAudioContext.cpp | Reuse a member DSPAudioBuffer during offline rendering. |
| packages/react-native-audio-api/common/cpp/audioapi/core/BaseAudioContext.h | Remove duplicate/obsolete forward declarations. |
| packages/react-native-audio-api/common/cpp/audioapi/core/BaseAudioContext.cpp | Update includes to new .hpp + circular array header. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioParam.h | Switch internal buffers to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioParam.cpp | Allocate/process modulation buffers as DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioNode.h | Switch audio processing pipeline to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioNode.cpp | Allocate node internal buffers as DSPAudioBuffer and update processing signature. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioContext.h | Update render callback type to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/core/AudioContext.cpp | Update render callback type to DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/utils/NodeOptionsParser.h | Update WaveShaper curve parsing to AudioArray. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h | Include new AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp | Remove playbackRateBuffer plumbing; allocate DSP processing buffer. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.h | Update include to AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.cpp | Remove legacy AudioBuffer.h include. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp | Track interval from options; initialize pitch correction buffers as DSP. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp | Update include to AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.cpp | Switch curve creation to AudioArray. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h | Include new AudioBuffer.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp | Allocate convolver internal buffers as DSPAudioBuffer. |
| packages/react-native-audio-api/common/cpp/audioapi/HostObjects/AudioParamHostObject.cpp | Update include to AudioArray.hpp. |
| packages/react-native-audio-api/common/cpp/audioapi/AudioAPIModuleInstaller.h | Fix createAudioBuffer installer naming typo. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h | Update includes to .hpp; remove old forward decls. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp | Update includes to .hpp + CircularArray.hpp. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AudioPlayer.h | Update render callback + internal buffer type to DSPAudioBuffer. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp | Allocate DSP processing buffer; update includes. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h | Update includes; remove old forward decls. |
| packages/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp | Update circular array include to CircularArray.hpp. |
| packages/custom-node-generator/templates/basic/shared/MyProcessorNode.h | Update template to DSP processing buffer type. |
| packages/custom-node-generator/templates/basic/shared/MyProcessorNode.cpp | Update template to DSP processing buffer type; remove old include. |
| packages/audiodocs/docs/guides/create-your-own-effect.mdx | Update guide snippets to new DSP buffer/array types and includes. |
| apps/fabric-example/ios/Podfile.lock | Update RNAudioAPI pod checksum. |
Comments suppressed due to low confidence (1)
packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp:64
AudioBufferSourceNode::setBuffer()no longer defers destruction of the previousDSPAudioBufferviaAudioGraphManager(TODO left in place). Releasing large buffers on the audio thread can cause realtime glitches; consider extendingAudioGraphManager/AudioDestructorto also handleDSPAudioBuffer(or otherwise defer deletion off the audio thread).
if (buffer_ != nullptr) {
graphManager->addAudioBufferForDestruction(std::move(buffer_));
}
// TODO move DSPAudioBuffers destruction to graph manager as well
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #
Introduced changes
Checklist