react-native-audio-api 0.12.0-nightly-37d6b7c-20260119 → 0.12.0-nightly-75589dc-20260121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +8 -5
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.cpp +7 -3
- package/android/src/main/cpp/audioapi/android/core/utils/FileOptions.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +4 -2
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +5 -4
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +2 -2
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +52 -49
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +2 -1
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +6 -0
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/utils/NodeOptions.h +111 -0
- package/common/cpp/audioapi/HostObjects/utils/NodeOptionsParser.h +262 -0
- package/common/cpp/audioapi/core/AudioNode.cpp +13 -6
- package/common/cpp/audioapi/core/AudioNode.h +2 -0
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +42 -44
- package/common/cpp/audioapi/core/BaseAudioContext.h +32 -21
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +8 -6
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +2 -1
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +7 -8
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +4 -1
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +5 -9
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +2 -2
- package/common/cpp/audioapi/core/effects/DelayNode.cpp +5 -4
- package/common/cpp/audioapi/core/effects/DelayNode.h +2 -1
- package/common/cpp/audioapi/core/effects/GainNode.cpp +4 -3
- package/common/cpp/audioapi/core/effects/GainNode.h +2 -1
- package/common/cpp/audioapi/core/effects/IIRFilterNode.cpp +6 -6
- package/common/cpp/audioapi/core/effects/IIRFilterNode.h +3 -2
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +3 -3
- package/common/cpp/audioapi/core/effects/StereoPannerNode.h +4 -1
- package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +4 -3
- package/common/cpp/audioapi/core/effects/WaveShaperNode.h +4 -1
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +1 -1
- package/common/cpp/audioapi/core/sources/AudioBuffer.cpp +3 -2
- package/common/cpp/audioapi/core/sources/AudioBuffer.h +2 -1
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +16 -22
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -1
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +9 -6
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -1
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +9 -7
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +4 -1
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +5 -8
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +4 -1
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +21 -16
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +4 -1
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +4 -2
- package/common/cpp/audioapi/core/sources/StreamerNode.h +11 -1
- package/common/cpp/test/src/ConstantSourceTest.cpp +3 -2
- package/common/cpp/test/src/DelayTest.cpp +12 -5
- package/common/cpp/test/src/GainTest.cpp +3 -2
- package/common/cpp/test/src/IIRFilterTest.cpp +3 -2
- package/common/cpp/test/src/OscillatorTest.cpp +2 -1
- package/common/cpp/test/src/StereoPannerTest.cpp +3 -2
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +10 -9
- package/common/cpp/test/src/core/effects/WaveShaperNodeTest.cpp +4 -3
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +1 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +5 -4
- package/ios/audioapi/ios/core/utils/FileOptions.h +3 -1
- package/ios/audioapi/ios/core/utils/FileOptions.mm +9 -3
- package/ios/audioapi/ios/core/utils/IOSFileWriter.h +2 -1
- package/ios/audioapi/ios/core/utils/IOSFileWriter.mm +5 -2
- package/lib/commonjs/api.js +11 -3
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +4 -10
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/core/AnalyserNode.js +11 -0
- package/lib/commonjs/core/AnalyserNode.js.map +1 -1
- package/lib/commonjs/core/AudioBuffer.js +20 -6
- package/lib/commonjs/core/AudioBuffer.js.map +1 -1
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js +9 -0
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferSourceNode.js +9 -0
- package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +3 -3
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +52 -65
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/BiquadFilterNode.js +7 -1
- package/lib/commonjs/core/BiquadFilterNode.js.map +1 -1
- package/lib/commonjs/core/ConstantSourceNode.js +7 -1
- package/lib/commonjs/core/ConstantSourceNode.js.map +1 -1
- package/lib/commonjs/core/ConvolverNode.js +9 -3
- package/lib/commonjs/core/ConvolverNode.js.map +1 -1
- package/lib/commonjs/core/DelayNode.js +7 -1
- package/lib/commonjs/core/DelayNode.js.map +1 -1
- package/lib/commonjs/core/GainNode.js +9 -3
- package/lib/commonjs/core/GainNode.js.map +1 -1
- package/lib/commonjs/core/IIRFilterNode.js +9 -0
- package/lib/commonjs/core/IIRFilterNode.js.map +1 -1
- package/lib/commonjs/core/OscillatorNode.js +10 -1
- package/lib/commonjs/core/OscillatorNode.js.map +1 -1
- package/lib/commonjs/core/PeriodicWave.js +30 -2
- package/lib/commonjs/core/PeriodicWave.js.map +1 -1
- package/lib/commonjs/core/RecorderAdapterNode.js +3 -0
- package/lib/commonjs/core/RecorderAdapterNode.js.map +1 -1
- package/lib/commonjs/core/StereoPannerNode.js +7 -1
- package/lib/commonjs/core/StereoPannerNode.js.map +1 -1
- package/lib/commonjs/core/StreamerNode.js +25 -1
- package/lib/commonjs/core/StreamerNode.js.map +1 -1
- package/lib/commonjs/core/WaveShaperNode.js +12 -0
- package/lib/commonjs/core/WaveShaperNode.js.map +1 -1
- package/lib/commonjs/core/WorkletNode.js +13 -1
- package/lib/commonjs/core/WorkletNode.js.map +1 -1
- package/lib/commonjs/core/WorkletProcessingNode.js +14 -1
- package/lib/commonjs/core/WorkletProcessingNode.js.map +1 -1
- package/lib/commonjs/core/WorkletSourceNode.js +13 -1
- package/lib/commonjs/core/WorkletSourceNode.js.map +1 -1
- package/lib/commonjs/defaults.js +78 -0
- package/lib/commonjs/defaults.js.map +1 -0
- package/lib/commonjs/options-validators.js +40 -0
- package/lib/commonjs/options-validators.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/web-core/AnalyserNode.js +2 -1
- package/lib/commonjs/web-core/AnalyserNode.js.map +1 -1
- package/lib/commonjs/web-core/AudioBuffer.js +14 -6
- package/lib/commonjs/web-core/AudioBuffer.js.map +1 -1
- package/lib/commonjs/web-core/AudioBufferSourceNode.js +276 -89
- package/lib/commonjs/web-core/AudioBufferSourceNode.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +33 -32
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/AudioNode.js +4 -0
- package/lib/commonjs/web-core/AudioNode.js.map +1 -1
- package/lib/commonjs/web-core/BiquadFilterNode.js +2 -1
- package/lib/commonjs/web-core/BiquadFilterNode.js.map +1 -1
- package/lib/commonjs/web-core/ConstantSourceNode.js +2 -1
- package/lib/commonjs/web-core/ConstantSourceNode.js.map +1 -1
- package/lib/commonjs/web-core/ConvolverNode.js +3 -5
- package/lib/commonjs/web-core/ConvolverNode.js.map +1 -1
- package/lib/commonjs/web-core/DelayNode.js +7 -1
- package/lib/commonjs/web-core/DelayNode.js.map +1 -1
- package/lib/commonjs/web-core/GainNode.js +2 -1
- package/lib/commonjs/web-core/GainNode.js.map +1 -1
- package/lib/commonjs/web-core/IIRFilterNode.js +12 -0
- package/lib/commonjs/web-core/IIRFilterNode.js.map +1 -1
- package/lib/commonjs/web-core/OfflineAudioContext.js +33 -32
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/web-core/OscillatorNode.js +2 -1
- package/lib/commonjs/web-core/OscillatorNode.js.map +1 -1
- package/lib/commonjs/web-core/PeriodicWave.js +6 -1
- package/lib/commonjs/web-core/PeriodicWave.js.map +1 -1
- package/lib/commonjs/web-core/StereoPannerNode.js +2 -1
- package/lib/commonjs/web-core/StereoPannerNode.js.map +1 -1
- package/lib/module/api.js +2 -1
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +2 -1
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/core/AnalyserNode.js +11 -0
- package/lib/module/core/AnalyserNode.js.map +1 -1
- package/lib/module/core/AudioBuffer.js +19 -6
- package/lib/module/core/AudioBuffer.js.map +1 -1
- package/lib/module/core/AudioBufferQueueSourceNode.js +9 -0
- package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferSourceNode.js +9 -0
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +3 -4
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +52 -65
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/BiquadFilterNode.js +7 -1
- package/lib/module/core/BiquadFilterNode.js.map +1 -1
- package/lib/module/core/ConstantSourceNode.js +7 -1
- package/lib/module/core/ConstantSourceNode.js.map +1 -1
- package/lib/module/core/ConvolverNode.js +9 -3
- package/lib/module/core/ConvolverNode.js.map +1 -1
- package/lib/module/core/DelayNode.js +7 -1
- package/lib/module/core/DelayNode.js.map +1 -1
- package/lib/module/core/GainNode.js +9 -3
- package/lib/module/core/GainNode.js.map +1 -1
- package/lib/module/core/IIRFilterNode.js +9 -0
- package/lib/module/core/IIRFilterNode.js.map +1 -1
- package/lib/module/core/OscillatorNode.js +10 -1
- package/lib/module/core/OscillatorNode.js.map +1 -1
- package/lib/module/core/PeriodicWave.js +29 -2
- package/lib/module/core/PeriodicWave.js.map +1 -1
- package/lib/module/core/RecorderAdapterNode.js +3 -0
- package/lib/module/core/RecorderAdapterNode.js.map +1 -1
- package/lib/module/core/StereoPannerNode.js +7 -1
- package/lib/module/core/StereoPannerNode.js.map +1 -1
- package/lib/module/core/StreamerNode.js +25 -1
- package/lib/module/core/StreamerNode.js.map +1 -1
- package/lib/module/core/WaveShaperNode.js +12 -0
- package/lib/module/core/WaveShaperNode.js.map +1 -1
- package/lib/module/core/WorkletNode.js +13 -1
- package/lib/module/core/WorkletNode.js.map +1 -1
- package/lib/module/core/WorkletProcessingNode.js +14 -1
- package/lib/module/core/WorkletProcessingNode.js.map +1 -1
- package/lib/module/core/WorkletSourceNode.js +13 -1
- package/lib/module/core/WorkletSourceNode.js.map +1 -1
- package/lib/module/defaults.js +74 -0
- package/lib/module/defaults.js.map +1 -0
- package/lib/module/options-validators.js +36 -0
- package/lib/module/options-validators.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/web-core/AnalyserNode.js +2 -1
- package/lib/module/web-core/AnalyserNode.js.map +1 -1
- package/lib/module/web-core/AudioBuffer.js +13 -6
- package/lib/module/web-core/AudioBuffer.js.map +1 -1
- package/lib/module/web-core/AudioBufferSourceNode.js +277 -90
- package/lib/module/web-core/AudioBufferSourceNode.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +33 -32
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/AudioNode.js +4 -0
- package/lib/module/web-core/AudioNode.js.map +1 -1
- package/lib/module/web-core/BiquadFilterNode.js +2 -1
- package/lib/module/web-core/BiquadFilterNode.js.map +1 -1
- package/lib/module/web-core/ConstantSourceNode.js +2 -1
- package/lib/module/web-core/ConstantSourceNode.js.map +1 -1
- package/lib/module/web-core/ConvolverNode.js +3 -5
- package/lib/module/web-core/ConvolverNode.js.map +1 -1
- package/lib/module/web-core/DelayNode.js +7 -1
- package/lib/module/web-core/DelayNode.js.map +1 -1
- package/lib/module/web-core/GainNode.js +2 -1
- package/lib/module/web-core/GainNode.js.map +1 -1
- package/lib/module/web-core/IIRFilterNode.js +12 -0
- package/lib/module/web-core/IIRFilterNode.js.map +1 -1
- package/lib/module/web-core/OfflineAudioContext.js +33 -32
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/web-core/OscillatorNode.js +2 -1
- package/lib/module/web-core/OscillatorNode.js.map +1 -1
- package/lib/module/web-core/PeriodicWave.js +6 -1
- package/lib/module/web-core/PeriodicWave.js.map +1 -1
- package/lib/module/web-core/StereoPannerNode.js +2 -1
- package/lib/module/web-core/StereoPannerNode.js.map +1 -1
- package/lib/typescript/api.d.ts +2 -1
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +2 -1
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/core/AnalyserNode.d.ts +3 -1
- package/lib/typescript/core/AnalyserNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioBuffer.d.ts +3 -0
- package/lib/typescript/core/AudioBuffer.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts +3 -0
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferSourceNode.d.ts +3 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +2 -2
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +10 -6
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/BiquadFilterNode.d.ts +2 -3
- package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -1
- package/lib/typescript/core/ConstantSourceNode.d.ts +2 -2
- package/lib/typescript/core/ConstantSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/ConvolverNode.d.ts +2 -2
- package/lib/typescript/core/ConvolverNode.d.ts.map +1 -1
- package/lib/typescript/core/DelayNode.d.ts +2 -2
- package/lib/typescript/core/DelayNode.d.ts.map +1 -1
- package/lib/typescript/core/GainNode.d.ts +2 -2
- package/lib/typescript/core/GainNode.d.ts.map +1 -1
- package/lib/typescript/core/IIRFilterNode.d.ts +3 -0
- package/lib/typescript/core/IIRFilterNode.d.ts.map +1 -1
- package/lib/typescript/core/OscillatorNode.d.ts +2 -3
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
- package/lib/typescript/core/PeriodicWave.d.ts +4 -1
- package/lib/typescript/core/PeriodicWave.d.ts.map +1 -1
- package/lib/typescript/core/RecorderAdapterNode.d.ts +2 -0
- package/lib/typescript/core/RecorderAdapterNode.d.ts.map +1 -1
- package/lib/typescript/core/StereoPannerNode.d.ts +2 -2
- package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -1
- package/lib/typescript/core/StreamerNode.d.ts +5 -0
- package/lib/typescript/core/StreamerNode.d.ts.map +1 -1
- package/lib/typescript/core/WaveShaperNode.d.ts +3 -0
- package/lib/typescript/core/WaveShaperNode.d.ts.map +1 -1
- package/lib/typescript/core/WorkletNode.d.ts +3 -0
- package/lib/typescript/core/WorkletNode.d.ts.map +1 -1
- package/lib/typescript/core/WorkletProcessingNode.d.ts +3 -0
- package/lib/typescript/core/WorkletProcessingNode.d.ts.map +1 -1
- package/lib/typescript/core/WorkletSourceNode.d.ts +3 -0
- package/lib/typescript/core/WorkletSourceNode.d.ts.map +1 -1
- package/lib/typescript/defaults.d.ts +16 -0
- package/lib/typescript/defaults.d.ts.map +1 -0
- package/lib/typescript/interfaces.d.ts +17 -16
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/options-validators.d.ts +6 -0
- package/lib/typescript/options-validators.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +83 -11
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/web-core/AnalyserNode.d.ts +2 -2
- package/lib/typescript/web-core/AnalyserNode.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioBuffer.d.ts +3 -0
- package/lib/typescript/web-core/AudioBuffer.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioBufferSourceNode.d.ts +24 -15
- package/lib/typescript/web-core/AudioBufferSourceNode.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +5 -6
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioNode.d.ts +2 -2
- package/lib/typescript/web-core/AudioNode.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +3 -3
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BiquadFilterNode.d.ts +2 -2
- package/lib/typescript/web-core/BiquadFilterNode.d.ts.map +1 -1
- package/lib/typescript/web-core/ConstantSourceNode.d.ts +2 -1
- package/lib/typescript/web-core/ConstantSourceNode.d.ts.map +1 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +2 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -1
- package/lib/typescript/web-core/DelayNode.d.ts +2 -1
- package/lib/typescript/web-core/DelayNode.d.ts.map +1 -1
- package/lib/typescript/web-core/GainNode.d.ts +2 -1
- package/lib/typescript/web-core/GainNode.d.ts.map +1 -1
- package/lib/typescript/web-core/IIRFilterNode.d.ts +3 -0
- package/lib/typescript/web-core/IIRFilterNode.d.ts.map +1 -1
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +5 -6
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/OscillatorNode.d.ts +2 -2
- package/lib/typescript/web-core/OscillatorNode.d.ts.map +1 -1
- package/lib/typescript/web-core/PeriodicWave.d.ts +3 -1
- package/lib/typescript/web-core/PeriodicWave.d.ts.map +1 -1
- package/lib/typescript/web-core/StereoPannerNode.d.ts +2 -1
- package/lib/typescript/web-core/StereoPannerNode.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +3 -1
- package/src/api.web.ts +1 -2
- package/src/core/AnalyserNode.ts +16 -1
- package/src/core/AudioBuffer.ts +26 -6
- package/src/core/AudioBufferQueueSourceNode.ts +15 -0
- package/src/core/AudioBufferSourceNode.ts +12 -0
- package/src/core/AudioRecorder.ts +4 -3
- package/src/core/BaseAudioContext.ts +48 -151
- package/src/core/BiquadFilterNode.ts +9 -2
- package/src/core/ConstantSourceNode.ts +9 -1
- package/src/core/ConvolverNode.ts +11 -3
- package/src/core/DelayNode.ts +5 -2
- package/src/core/GainNode.ts +10 -3
- package/src/core/IIRFilterNode.ts +12 -0
- package/src/core/OscillatorNode.ts +13 -2
- package/src/core/PeriodicWave.ts +36 -2
- package/src/core/RecorderAdapterNode.ts +5 -0
- package/src/core/StereoPannerNode.ts +9 -1
- package/src/core/StreamerNode.ts +29 -1
- package/src/core/WaveShaperNode.ts +17 -0
- package/src/core/WorkletNode.ts +30 -1
- package/src/core/WorkletProcessingNode.ts +39 -1
- package/src/core/WorkletSourceNode.ts +36 -1
- package/src/defaults.ts +100 -0
- package/src/interfaces.ts +38 -25
- package/src/options-validators.ts +66 -0
- package/src/types.ts +100 -12
- package/src/web-core/AnalyserNode.tsx +15 -6
- package/src/web-core/AudioBuffer.tsx +20 -6
- package/src/web-core/AudioBufferSourceNode.tsx +393 -148
- package/src/web-core/AudioContext.tsx +22 -72
- package/src/web-core/AudioNode.tsx +6 -2
- package/src/web-core/BaseAudioContext.tsx +3 -7
- package/src/web-core/BiquadFilterNode.tsx +6 -2
- package/src/web-core/ConstantSourceNode.tsx +3 -1
- package/src/web-core/ConvolverNode.tsx +8 -8
- package/src/web-core/DelayNode.tsx +5 -1
- package/src/web-core/GainNode.tsx +3 -1
- package/src/web-core/IIRFilterNode.tsx +15 -0
- package/src/web-core/OfflineAudioContext.tsx +19 -67
- package/src/web-core/OscillatorNode.tsx +3 -2
- package/src/web-core/PeriodicWave.tsx +11 -1
- package/src/web-core/StereoPannerNode.tsx +9 -1
|
@@ -3,10 +3,12 @@ import { InvalidStateError, RangeError } from '../errors';
|
|
|
3
3
|
import AudioParam from './AudioParam';
|
|
4
4
|
import AudioBuffer from './AudioBuffer';
|
|
5
5
|
import BaseAudioContext from './BaseAudioContext';
|
|
6
|
-
import
|
|
6
|
+
import AudioNode from './AudioNode';
|
|
7
7
|
|
|
8
8
|
import { clamp } from '../utils';
|
|
9
|
-
import {
|
|
9
|
+
import { TAudioBufferSourceOptions } from '../types';
|
|
10
|
+
import { AudioBufferSourceOptions } from '../defaults';
|
|
11
|
+
import { globalWasmPromise, globalTag } from './custom/LoadCustomWasm';
|
|
10
12
|
|
|
11
13
|
interface ScheduleOptions {
|
|
12
14
|
rate?: number;
|
|
@@ -173,8 +175,6 @@ class IStretcherNodeAudioParam implements globalThis.AudioParam {
|
|
|
173
175
|
|
|
174
176
|
type DefaultSource = globalThis.AudioBufferSourceNode;
|
|
175
177
|
|
|
176
|
-
type IAudioBufferSourceNode = DefaultSource | IStretcherNode;
|
|
177
|
-
|
|
178
178
|
declare global {
|
|
179
179
|
interface Window {
|
|
180
180
|
[globalTag]: (
|
|
@@ -183,10 +183,28 @@ declare global {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
interface IAudioAPIBufferSourceNodeWeb {
|
|
187
|
+
connect(destination: AudioNode | AudioParam): AudioNode | AudioParam;
|
|
188
|
+
disconnect(destination?: AudioNode | AudioParam): void;
|
|
189
|
+
start(when?: number, offset?: number, duration?: number): void;
|
|
190
|
+
stop(when: number): void;
|
|
191
|
+
setDetune(value: number, when?: number): void;
|
|
192
|
+
setPlaybackRate(value: number, when?: number): void;
|
|
193
|
+
get buffer(): AudioBuffer | null;
|
|
194
|
+
set buffer(buffer: AudioBuffer | null);
|
|
195
|
+
get loop(): boolean;
|
|
196
|
+
set loop(value: boolean);
|
|
197
|
+
get loopStart(): number;
|
|
198
|
+
set loopStart(value: number);
|
|
199
|
+
get loopEnd(): number;
|
|
200
|
+
set loopEnd(value: number);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
class AudioBufferSourceNodeStretcher implements IAudioAPIBufferSourceNodeWeb {
|
|
204
|
+
private stretcherPromise: Promise<IStretcherNode> | null = null;
|
|
205
|
+
private node: IStretcherNode | null = null;
|
|
206
|
+
private hasBeenStarted: boolean = false;
|
|
207
|
+
private context: BaseAudioContext;
|
|
190
208
|
readonly playbackRate: AudioParam;
|
|
191
209
|
readonly detune: AudioParam;
|
|
192
210
|
|
|
@@ -196,98 +214,218 @@ export default class AudioBufferSourceNode<
|
|
|
196
214
|
|
|
197
215
|
private _buffer: AudioBuffer | null = null;
|
|
198
216
|
|
|
199
|
-
constructor(context: BaseAudioContext
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
'a-rate',
|
|
210
|
-
-1200,
|
|
211
|
-
1200,
|
|
212
|
-
0
|
|
213
|
-
),
|
|
214
|
-
context
|
|
215
|
-
);
|
|
217
|
+
constructor(context: BaseAudioContext) {
|
|
218
|
+
const promise = async () => {
|
|
219
|
+
await globalWasmPromise;
|
|
220
|
+
return window[globalTag](new window.AudioContext());
|
|
221
|
+
};
|
|
222
|
+
this.context = context;
|
|
223
|
+
this.stretcherPromise = promise();
|
|
224
|
+
this.stretcherPromise.then((node) => {
|
|
225
|
+
this.node = node;
|
|
226
|
+
});
|
|
216
227
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
this.detune = new AudioParam(
|
|
229
|
+
new IStretcherNodeAudioParam(
|
|
230
|
+
0,
|
|
231
|
+
this.setDetune.bind(this),
|
|
232
|
+
'a-rate',
|
|
233
|
+
-1200,
|
|
234
|
+
1200,
|
|
235
|
+
0
|
|
236
|
+
),
|
|
237
|
+
context
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
this.playbackRate = new AudioParam(
|
|
241
|
+
new IStretcherNodeAudioParam(
|
|
242
|
+
1,
|
|
243
|
+
this.setPlaybackRate.bind(this),
|
|
244
|
+
'a-rate',
|
|
245
|
+
0,
|
|
246
|
+
Infinity,
|
|
247
|
+
1
|
|
248
|
+
),
|
|
249
|
+
context
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
connect(destination: AudioNode | AudioParam): AudioNode | AudioParam {
|
|
254
|
+
const action = (node: IStretcherNode) => {
|
|
255
|
+
if (destination instanceof AudioParam) {
|
|
256
|
+
node.connect(destination.param);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
node.connect(destination.node);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
if (!this.node) {
|
|
263
|
+
this.stretcherPromise!.then((node) => {
|
|
264
|
+
action(node);
|
|
265
|
+
});
|
|
228
266
|
} else {
|
|
229
|
-
this.
|
|
230
|
-
this.playbackRate = new AudioParam(
|
|
231
|
-
(node as DefaultSource).playbackRate,
|
|
232
|
-
context
|
|
233
|
-
);
|
|
267
|
+
action(this.node);
|
|
234
268
|
}
|
|
235
|
-
}
|
|
236
269
|
|
|
237
|
-
|
|
238
|
-
return this._pitchCorrection;
|
|
270
|
+
return destination;
|
|
239
271
|
}
|
|
240
272
|
|
|
241
|
-
|
|
242
|
-
|
|
273
|
+
disconnect(destination?: AudioNode | AudioParam): void {
|
|
274
|
+
const action = (node: IStretcherNode) => {
|
|
275
|
+
if (destination === undefined) {
|
|
276
|
+
node.disconnect();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (destination instanceof AudioParam) {
|
|
281
|
+
node.disconnect(destination.param);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
node.disconnect(destination.node);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
if (!this.node) {
|
|
288
|
+
this.stretcherPromise!.then((node) => {
|
|
289
|
+
action(node);
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
action(this.node);
|
|
293
|
+
}
|
|
243
294
|
}
|
|
244
295
|
|
|
245
|
-
|
|
246
|
-
|
|
296
|
+
start(when?: number, offset?: number, duration?: number): void {
|
|
297
|
+
if (when && when < 0) {
|
|
298
|
+
throw new RangeError(
|
|
299
|
+
`when must be a finite non-negative number: ${when}`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (offset && offset < 0) {
|
|
304
|
+
throw new RangeError(
|
|
305
|
+
`offset must be a finite non-negative number: ${offset}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (duration && duration < 0) {
|
|
310
|
+
throw new RangeError(
|
|
311
|
+
`duration must be a finite non-negative number: ${duration}`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (this.hasBeenStarted) {
|
|
316
|
+
throw new InvalidStateError('Cannot call start more than once');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
this.hasBeenStarted = true;
|
|
320
|
+
const startAt =
|
|
321
|
+
!when || when < this.context.currentTime
|
|
322
|
+
? this.context.currentTime
|
|
323
|
+
: when;
|
|
324
|
+
|
|
325
|
+
const scheduleAction = (node: IStretcherNode) => {
|
|
326
|
+
node.schedule({
|
|
327
|
+
loopStart: this._loopStart,
|
|
328
|
+
loopEnd: this._loopEnd,
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
if (this.loop && this._loopStart !== -1 && this._loopEnd !== -1) {
|
|
333
|
+
if (!this.node) {
|
|
334
|
+
this.stretcherPromise!.then((node) => {
|
|
335
|
+
scheduleAction(node);
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
scheduleAction(this.node);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const startAction = (node: IStretcherNode) => {
|
|
343
|
+
node.start(
|
|
344
|
+
startAt,
|
|
345
|
+
offset,
|
|
346
|
+
duration,
|
|
347
|
+
this.playbackRate.value,
|
|
348
|
+
Math.floor(clamp(this.detune.value / 100, -12, 12))
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
if (!this.node) {
|
|
352
|
+
this.stretcherPromise!.then((node) => {
|
|
353
|
+
startAction(node);
|
|
354
|
+
});
|
|
355
|
+
} else {
|
|
356
|
+
startAction(this.node);
|
|
357
|
+
}
|
|
247
358
|
}
|
|
248
359
|
|
|
249
|
-
|
|
250
|
-
if (
|
|
360
|
+
stop(when: number): void {
|
|
361
|
+
if (when < 0) {
|
|
362
|
+
throw new RangeError(
|
|
363
|
+
`when must be a finite non-negative number: ${when}`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
const action = (node: IStretcherNode) => {
|
|
367
|
+
node.stop(when);
|
|
368
|
+
};
|
|
369
|
+
if (!this.node) {
|
|
370
|
+
this.stretcherPromise!.then((node) => {
|
|
371
|
+
action(node);
|
|
372
|
+
});
|
|
251
373
|
return;
|
|
252
374
|
}
|
|
253
|
-
|
|
254
|
-
this.asStretcher().schedule({
|
|
255
|
-
semitones: Math.floor(clamp(value / 100, -12, 12)),
|
|
256
|
-
output: when,
|
|
257
|
-
});
|
|
375
|
+
action(this.node);
|
|
258
376
|
}
|
|
259
377
|
|
|
260
|
-
|
|
261
|
-
if (!this.
|
|
378
|
+
setDetune(value: number, when?: number): void {
|
|
379
|
+
if (!this.hasBeenStarted) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const action = (node: IStretcherNode) => {
|
|
383
|
+
node.schedule({
|
|
384
|
+
semitones: Math.floor(clamp(value / 100, -12, 12)),
|
|
385
|
+
output: when,
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
if (!this.node) {
|
|
390
|
+
this.stretcherPromise!.then((node) => {
|
|
391
|
+
action(node);
|
|
392
|
+
});
|
|
262
393
|
return;
|
|
263
394
|
}
|
|
264
395
|
|
|
265
|
-
this.
|
|
266
|
-
rate: value,
|
|
267
|
-
output: when,
|
|
268
|
-
});
|
|
396
|
+
action(this.node);
|
|
269
397
|
}
|
|
270
398
|
|
|
271
|
-
|
|
272
|
-
if (this.
|
|
273
|
-
return
|
|
399
|
+
setPlaybackRate(value: number, when?: number): void {
|
|
400
|
+
if (!this.hasBeenStarted) {
|
|
401
|
+
return;
|
|
274
402
|
}
|
|
403
|
+
const action = (node: IStretcherNode) => {
|
|
404
|
+
node.schedule({
|
|
405
|
+
rate: value,
|
|
406
|
+
output: when,
|
|
407
|
+
});
|
|
408
|
+
};
|
|
275
409
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
410
|
+
if (!this.node) {
|
|
411
|
+
this.stretcherPromise!.then((node) => {
|
|
412
|
+
action(node);
|
|
413
|
+
});
|
|
414
|
+
return;
|
|
280
415
|
}
|
|
281
416
|
|
|
282
|
-
|
|
417
|
+
action(this.node);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
get buffer(): AudioBuffer | null {
|
|
421
|
+
return this._buffer;
|
|
283
422
|
}
|
|
284
423
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
this._buffer = buffer;
|
|
424
|
+
set buffer(buffer: AudioBuffer | null) {
|
|
425
|
+
this._buffer = buffer;
|
|
288
426
|
|
|
289
|
-
|
|
290
|
-
|
|
427
|
+
const action = (node: IStretcherNode) => {
|
|
428
|
+
node.dropBuffers();
|
|
291
429
|
|
|
292
430
|
if (!buffer) {
|
|
293
431
|
return;
|
|
@@ -299,70 +437,56 @@ export default class AudioBufferSourceNode<
|
|
|
299
437
|
channelArrays.push(buffer.getChannelData(i));
|
|
300
438
|
}
|
|
301
439
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
440
|
+
node.addBuffers(channelArrays);
|
|
441
|
+
};
|
|
305
442
|
|
|
306
|
-
if (!
|
|
307
|
-
this.
|
|
443
|
+
if (!this.node) {
|
|
444
|
+
this.stretcherPromise!.then((node) => {
|
|
445
|
+
action(node);
|
|
446
|
+
});
|
|
308
447
|
return;
|
|
309
448
|
}
|
|
310
|
-
|
|
311
|
-
this.asBufferSource().buffer = buffer.buffer;
|
|
449
|
+
action(this.node);
|
|
312
450
|
}
|
|
313
451
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return this._loop;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return this.asBufferSource().loop;
|
|
452
|
+
get loop(): boolean {
|
|
453
|
+
return this._loop;
|
|
320
454
|
}
|
|
321
455
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
this._loop = value;
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
this.asBufferSource().loop = value;
|
|
456
|
+
set loop(value: boolean) {
|
|
457
|
+
this._loop = value;
|
|
329
458
|
}
|
|
330
459
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return this._loopStart;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return this.asBufferSource().loopStart;
|
|
460
|
+
get loopStart(): number {
|
|
461
|
+
return this._loopStart;
|
|
337
462
|
}
|
|
338
463
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
this._loopStart = value;
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
this.asBufferSource().loopStart = value;
|
|
464
|
+
set loopStart(value: number) {
|
|
465
|
+
this._loopStart = value;
|
|
346
466
|
}
|
|
347
467
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
468
|
+
get loopEnd(): number {
|
|
469
|
+
return this._loopEnd;
|
|
470
|
+
}
|
|
352
471
|
|
|
353
|
-
|
|
472
|
+
set loopEnd(value: number) {
|
|
473
|
+
this._loopEnd = value;
|
|
354
474
|
}
|
|
475
|
+
}
|
|
355
476
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
477
|
+
class AudioBufferSourceNodeWeb implements IAudioAPIBufferSourceNodeWeb {
|
|
478
|
+
private node: DefaultSource;
|
|
479
|
+
private hasBeenStarted: boolean = false;
|
|
480
|
+
readonly playbackRate: AudioParam;
|
|
481
|
+
readonly detune: AudioParam;
|
|
361
482
|
|
|
362
|
-
|
|
483
|
+
constructor(context: BaseAudioContext, options?: TAudioBufferSourceOptions) {
|
|
484
|
+
this.node = new globalThis.AudioBufferSourceNode(context.context, options);
|
|
485
|
+
this.detune = new AudioParam(this.node.detune, context);
|
|
486
|
+
this.playbackRate = new AudioParam(this.node.playbackRate, context);
|
|
363
487
|
}
|
|
364
488
|
|
|
365
|
-
|
|
489
|
+
start(when: number = 0, offset?: number, duration?: number): void {
|
|
366
490
|
if (when && when < 0) {
|
|
367
491
|
throw new RangeError(
|
|
368
492
|
`when must be a finite non-negative number: ${when}`
|
|
@@ -386,34 +510,10 @@ export default class AudioBufferSourceNode<
|
|
|
386
510
|
}
|
|
387
511
|
|
|
388
512
|
this.hasBeenStarted = true;
|
|
389
|
-
|
|
390
|
-
if (!this.isStretcherNode()) {
|
|
391
|
-
this.asBufferSource().start(when, offset, duration);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const startAt =
|
|
396
|
-
!when || when < this.context.currentTime
|
|
397
|
-
? this.context.currentTime
|
|
398
|
-
: when;
|
|
399
|
-
|
|
400
|
-
if (this.loop && this._loopStart !== -1 && this._loopEnd !== -1) {
|
|
401
|
-
this.asStretcher().schedule({
|
|
402
|
-
loopStart: this._loopStart,
|
|
403
|
-
loopEnd: this._loopEnd,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
this.asStretcher().start(
|
|
408
|
-
startAt,
|
|
409
|
-
offset,
|
|
410
|
-
duration,
|
|
411
|
-
this.playbackRate.value,
|
|
412
|
-
Math.floor(clamp(this.detune.value / 100, -12, 12))
|
|
413
|
-
);
|
|
513
|
+
this.node.start(when, offset, duration);
|
|
414
514
|
}
|
|
415
515
|
|
|
416
|
-
|
|
516
|
+
stop(when: number = 0): void {
|
|
417
517
|
if (when < 0) {
|
|
418
518
|
throw new RangeError(
|
|
419
519
|
`when must be a finite non-negative number: ${when}`
|
|
@@ -425,12 +525,157 @@ export default class AudioBufferSourceNode<
|
|
|
425
525
|
'Cannot call stop without calling start first'
|
|
426
526
|
);
|
|
427
527
|
}
|
|
528
|
+
this.node.stop(when);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
532
|
+
setDetune(value: number, when?: number): void {
|
|
533
|
+
console.warn('setDetune is not implemented for non-pitch-correction mode');
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
537
|
+
setPlaybackRate(value: number, when?: number): void {
|
|
538
|
+
console.warn(
|
|
539
|
+
'setPlaybackRate is not implemented for non-pitch-correction mode'
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
get buffer(): AudioBuffer | null {
|
|
544
|
+
const buffer = this.node.buffer;
|
|
545
|
+
if (!buffer) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return new AudioBuffer(buffer);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
set buffer(buffer: AudioBuffer | null) {
|
|
553
|
+
if (!buffer) {
|
|
554
|
+
this.node.buffer = null;
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
this.node.buffer = buffer.buffer;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
get loop(): boolean {
|
|
562
|
+
return this.node.loop;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
set loop(value: boolean) {
|
|
566
|
+
this.node.loop = value;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
get loopStart(): number {
|
|
570
|
+
return this.node.loopStart;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
set loopStart(value: number) {
|
|
574
|
+
this.node.loopStart = value;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
get loopEnd(): number {
|
|
578
|
+
return this.node.loopEnd;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
set loopEnd(value: number) {
|
|
582
|
+
this.node.loopEnd = value;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
connect(destination: AudioNode | AudioParam): AudioNode | AudioParam {
|
|
586
|
+
if (destination instanceof AudioParam) {
|
|
587
|
+
this.node.connect(destination.param);
|
|
588
|
+
} else {
|
|
589
|
+
this.node.connect(destination.node);
|
|
590
|
+
}
|
|
591
|
+
return destination;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
disconnect(destination?: AudioNode | AudioParam): void {
|
|
595
|
+
if (destination === undefined) {
|
|
596
|
+
this.node.disconnect();
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
428
599
|
|
|
429
|
-
if (
|
|
430
|
-
this.
|
|
600
|
+
if (destination instanceof AudioParam) {
|
|
601
|
+
this.node.disconnect(destination.param);
|
|
431
602
|
return;
|
|
432
603
|
}
|
|
604
|
+
this.node.disconnect(destination.node);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export default class AudioBufferSourceNode
|
|
609
|
+
implements IAudioAPIBufferSourceNodeWeb
|
|
610
|
+
{
|
|
611
|
+
private node: AudioBufferSourceNodeStretcher | AudioBufferSourceNodeWeb;
|
|
612
|
+
constructor(context: BaseAudioContext, options?: TAudioBufferSourceOptions) {
|
|
613
|
+
const finalOptions: TAudioBufferSourceOptions = {
|
|
614
|
+
...AudioBufferSourceOptions,
|
|
615
|
+
...options,
|
|
616
|
+
};
|
|
617
|
+
this.node = finalOptions.pitchCorrection
|
|
618
|
+
? new AudioBufferSourceNodeStretcher(context)
|
|
619
|
+
: new AudioBufferSourceNodeWeb(context, options);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
connect(destination: AudioNode | AudioParam): AudioNode | AudioParam {
|
|
623
|
+
return this.asAudioBufferSourceNodeWeb().connect(destination);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
disconnect(destination?: AudioNode | AudioParam): void {
|
|
627
|
+
this.asAudioBufferSourceNodeWeb().disconnect(destination);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
asAudioBufferSourceNodeWeb(): IAudioAPIBufferSourceNodeWeb {
|
|
631
|
+
return this.node as unknown as IAudioAPIBufferSourceNodeWeb;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
start(when: number = 0, offset?: number, duration?: number): void {
|
|
635
|
+
this.asAudioBufferSourceNodeWeb().start(when, offset, duration);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
stop(when: number = 0): void {
|
|
639
|
+
this.asAudioBufferSourceNodeWeb().stop(when);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
setDetune(value: number, when?: number): void {
|
|
643
|
+
this.asAudioBufferSourceNodeWeb().setDetune(value, when);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
setPlaybackRate(value: number, when?: number): void {
|
|
647
|
+
this.asAudioBufferSourceNodeWeb().setPlaybackRate(value, when);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
get buffer(): AudioBuffer | null {
|
|
651
|
+
return this.asAudioBufferSourceNodeWeb().buffer;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
set buffer(buffer: AudioBuffer | null) {
|
|
655
|
+
this.asAudioBufferSourceNodeWeb().buffer = buffer;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
get loop(): boolean {
|
|
659
|
+
return this.asAudioBufferSourceNodeWeb().loop;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
set loop(value: boolean) {
|
|
663
|
+
this.asAudioBufferSourceNodeWeb().loop = value;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
get loopStart(): number {
|
|
667
|
+
return this.asAudioBufferSourceNodeWeb().loopStart;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
set loopStart(value: number) {
|
|
671
|
+
this.asAudioBufferSourceNodeWeb().loopStart = value;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
get loopEnd(): number {
|
|
675
|
+
return this.asAudioBufferSourceNodeWeb().loopEnd;
|
|
676
|
+
}
|
|
433
677
|
|
|
434
|
-
|
|
678
|
+
set loopEnd(value: number) {
|
|
679
|
+
this.asAudioBufferSourceNodeWeb().loopEnd = value;
|
|
435
680
|
}
|
|
436
681
|
}
|