Skip to content

Refactor/buffer source nodes#986

Open
maciejmakowski2003 wants to merge 2 commits intorefactor/aligned-data-structures-integrationfrom
refactor/buffer-source-nodes
Open

Refactor/buffer source nodes#986
maciejmakowski2003 wants to merge 2 commits intorefactor/aligned-data-structures-integrationfrom
refactor/buffer-source-nodes

Conversation

@maciejmakowski2003
Copy link
Collaborator

Closes #

⚠️ Breaking changes ⚠️

Introduced changes

  • Simplified and unified some parts of buffer source nodes implementation.

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web
  • Updated old arch android spec file

@maciejmakowski2003 maciejmakowski2003 self-assigned this Mar 12, 2026
@maciejmakowski2003 maciejmakowski2003 changed the base branch from main to refactor/aligned-data-structures-integration March 12, 2026 13:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/.cpp implementations with header-only, alignment-aware .hpp versions (AudioArray.hpp, AudioBuffer.hpp) and introduce DSPAudioArray/DSPAudioBuffer aliases.
  • Replace CircularAudioArray with a templated CircularArray (CircularArray.hpp) and update affected nodes/utilities.
  • Update core nodes, host objects, DSP utilities, and platform players/recorders to use DSPAudioBuffer in 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 previous DSPAudioBuffer via AudioGraphManager (TODO left in place). Releasing large buffers on the audio thread can cause realtime glitches; consider extending AudioGraphManager/AudioDestructor to also handle DSPAudioBuffer (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants