react-native-audio-api 0.0.1 → 0.2.0
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/README.md +60 -1
- package/RNAudioAPI.podspec +46 -0
- package/android/CMakeLists.txt +74 -0
- package/android/build.gradle +194 -0
- package/android/gradle.properties +5 -0
- package/android/libs/fftw3/arm64-v8a/libfftw3.a +0 -0
- package/android/libs/fftw3/armeabi-v7a/libfftw3.a +0 -0
- package/android/libs/fftw3/x86/libfftw3.a +0 -0
- package/android/libs/fftw3/x86_64/libfftw3.a +0 -0
- package/android/libs/include/fftw3/fftw3.h +413 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/cpp/AudioAPIInstaller/AudioAPIInstaller.cpp +22 -0
- package/android/src/main/cpp/AudioAPIInstaller/AudioAPIInstaller.h +48 -0
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.cpp +66 -0
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.h +33 -0
- package/android/src/main/cpp/OnLoad.cpp +9 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt +14 -0
- package/android/src/main/java/com/swmansion/audioapi/module/AudioAPIInstaller.kt +21 -0
- package/android/src/main/java/com/swmansion/audioapi/nativemodules/AudioAPIModule.kt +25 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.cpp +52 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.h +45 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerWrapper.h +38 -0
- package/common/cpp/AudioAPIInstaller/android/AudioAPIInstallerWrapper.cpp +16 -0
- package/common/cpp/AudioAPIInstaller/ios/AudioAPIInstallerWrapper.cpp +12 -0
- package/common/cpp/HostObjects/AudioBufferHostObject.cpp +143 -0
- package/common/cpp/HostObjects/AudioBufferHostObject.h +33 -0
- package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.cpp +79 -0
- package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.h +37 -0
- package/common/cpp/HostObjects/AudioContextHostObject.cpp +54 -0
- package/common/cpp/HostObjects/AudioContextHostObject.h +36 -0
- package/common/cpp/HostObjects/AudioDestinationNodeHostObject.cpp +33 -0
- package/common/cpp/HostObjects/AudioDestinationNodeHostObject.h +31 -0
- package/common/cpp/HostObjects/AudioNodeHostObject.cpp +102 -0
- package/common/cpp/HostObjects/AudioNodeHostObject.h +29 -0
- package/common/cpp/HostObjects/AudioParamHostObject.cpp +115 -0
- package/common/cpp/HostObjects/AudioParamHostObject.h +34 -0
- package/common/cpp/HostObjects/AudioScheduledSourceNodeHostObject.cpp +73 -0
- package/common/cpp/HostObjects/AudioScheduledSourceNodeHostObject.h +31 -0
- package/common/cpp/HostObjects/BaseAudioContextHostObject.cpp +214 -0
- package/common/cpp/HostObjects/BaseAudioContextHostObject.h +39 -0
- package/common/cpp/HostObjects/BiquadFilterNodeHostObject.cpp +125 -0
- package/common/cpp/HostObjects/BiquadFilterNodeHostObject.h +42 -0
- package/common/cpp/HostObjects/Constants.h +22 -0
- package/common/cpp/HostObjects/GainNodeHostObject.cpp +41 -0
- package/common/cpp/HostObjects/GainNodeHostObject.h +32 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.cpp +88 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.h +41 -0
- package/common/cpp/HostObjects/PeriodicWaveHostObject.cpp +33 -0
- package/common/cpp/HostObjects/PeriodicWaveHostObject.h +33 -0
- package/common/cpp/HostObjects/StereoPannerNodeHostObject.cpp +41 -0
- package/common/cpp/HostObjects/StereoPannerNodeHostObject.h +36 -0
- package/common/cpp/core/AudioArray.cpp +103 -0
- package/common/cpp/core/AudioArray.h +42 -0
- package/common/cpp/core/AudioBuffer.cpp +55 -0
- package/common/cpp/core/AudioBuffer.h +40 -0
- package/common/cpp/core/AudioBufferSourceNode.cpp +135 -0
- package/common/cpp/core/AudioBufferSourceNode.h +30 -0
- package/common/cpp/core/AudioBus.cpp +357 -0
- package/common/cpp/core/AudioBus.h +63 -0
- package/common/cpp/core/AudioContext.cpp +24 -0
- package/common/cpp/core/AudioContext.h +16 -0
- package/common/cpp/core/AudioDestinationNode.cpp +45 -0
- package/common/cpp/core/AudioDestinationNode.h +32 -0
- package/common/cpp/core/AudioNode.cpp +222 -0
- package/common/cpp/core/AudioNode.h +74 -0
- package/common/cpp/core/AudioNodeManager.cpp +72 -0
- package/common/cpp/core/AudioNodeManager.h +35 -0
- package/common/cpp/core/AudioParam.cpp +133 -0
- package/common/cpp/core/AudioParam.h +50 -0
- package/common/cpp/core/AudioScheduledSourceNode.cpp +53 -0
- package/common/cpp/core/AudioScheduledSourceNode.h +34 -0
- package/common/cpp/core/BaseAudioContext.cpp +157 -0
- package/common/cpp/core/BaseAudioContext.h +80 -0
- package/common/cpp/core/BiquadFilterNode.cpp +385 -0
- package/common/cpp/core/BiquadFilterNode.h +124 -0
- package/common/cpp/core/GainNode.cpp +30 -0
- package/common/cpp/core/GainNode.h +25 -0
- package/common/cpp/core/OscillatorNode.cpp +75 -0
- package/common/cpp/core/OscillatorNode.h +72 -0
- package/common/cpp/core/ParamChange.cpp +46 -0
- package/common/cpp/core/ParamChange.h +34 -0
- package/common/cpp/core/PeriodicWave.cpp +362 -0
- package/common/cpp/core/PeriodicWave.h +119 -0
- package/common/cpp/core/StereoPannerNode.cpp +56 -0
- package/common/cpp/core/StereoPannerNode.h +26 -0
- package/common/cpp/types/BiquadFilterType.h +19 -0
- package/common/cpp/types/ChannelCountMode.h +10 -0
- package/common/cpp/types/ChannelInterpretation.h +10 -0
- package/common/cpp/types/ContextState.h +10 -0
- package/common/cpp/types/OscillatorType.h +11 -0
- package/common/cpp/utils/FFTFrame.h +63 -0
- package/common/cpp/utils/Locker.h +47 -0
- package/common/cpp/utils/VectorMath.cpp +678 -0
- package/common/cpp/utils/VectorMath.h +71 -0
- package/common/cpp/utils/android/FFTFrame.cpp +22 -0
- package/common/cpp/utils/ios/FFTFrame.cpp +24 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.cpp +45 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.h +26 -0
- package/common/cpp/wrappers/AudioBufferWrapper.cpp +46 -0
- package/common/cpp/wrappers/AudioBufferWrapper.h +30 -0
- package/common/cpp/wrappers/AudioContextWrapper.cpp +17 -0
- package/common/cpp/wrappers/AudioContextWrapper.h +19 -0
- package/common/cpp/wrappers/AudioDestinationNodeWrapper.h +16 -0
- package/common/cpp/wrappers/AudioNodeWrapper.cpp +37 -0
- package/common/cpp/wrappers/AudioNodeWrapper.h +25 -0
- package/common/cpp/wrappers/AudioParamWrapper.cpp +42 -0
- package/common/cpp/wrappers/AudioParamWrapper.h +25 -0
- package/common/cpp/wrappers/AudioScheduledSourceNodeWrapper.cpp +23 -0
- package/common/cpp/wrappers/AudioScheduledSourceNodeWrapper.h +23 -0
- package/common/cpp/wrappers/BaseAudioContextWrapper.cpp +76 -0
- package/common/cpp/wrappers/BaseAudioContextWrapper.h +49 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.cpp +60 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.h +37 -0
- package/common/cpp/wrappers/GainNodeWrapper.cpp +14 -0
- package/common/cpp/wrappers/GainNodeWrapper.h +20 -0
- package/common/cpp/wrappers/OscillatorNodeWrapper.cpp +44 -0
- package/common/cpp/wrappers/OscillatorNodeWrapper.h +31 -0
- package/common/cpp/wrappers/PeriodicWaveWrapper.h +17 -0
- package/common/cpp/wrappers/StereoPannerNodeWrapper.cpp +16 -0
- package/common/cpp/wrappers/StereoPannerNodeWrapper.h +21 -0
- package/ios/AudioAPIModule.h +24 -0
- package/ios/AudioAPIModule.mm +44 -0
- package/ios/AudioPlayer/AudioPlayer.h +28 -0
- package/ios/AudioPlayer/AudioPlayer.m +119 -0
- package/ios/AudioPlayer/IOSAudioPlayer.h +33 -0
- package/ios/AudioPlayer/IOSAudioPlayer.mm +57 -0
- package/lib/module/core/AudioBuffer.js +37 -0
- package/lib/module/core/AudioBuffer.js.map +1 -0
- package/lib/module/core/AudioBufferSourceNode.js +28 -0
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -0
- package/lib/module/core/AudioContext.js +10 -0
- package/lib/module/core/AudioContext.js.map +1 -0
- package/lib/module/core/AudioDestinationNode.js +7 -0
- package/lib/module/core/AudioDestinationNode.js.map +1 -0
- package/lib/module/core/AudioNode.js +22 -0
- package/lib/module/core/AudioNode.js.map +1 -0
- package/lib/module/core/AudioParam.js +35 -0
- package/lib/module/core/AudioParam.js.map +1 -0
- package/lib/module/core/AudioScheduledSourceNode.js +28 -0
- package/lib/module/core/AudioScheduledSourceNode.js.map +1 -0
- package/lib/module/core/BaseAudioContext.js +57 -0
- package/lib/module/core/BaseAudioContext.js.map +1 -0
- package/lib/module/core/BiquadFilterNode.js +25 -0
- package/lib/module/core/BiquadFilterNode.js.map +1 -0
- package/lib/module/core/GainNode.js +9 -0
- package/lib/module/core/GainNode.js.map +1 -0
- package/lib/module/core/OscillatorNode.js +24 -0
- package/lib/module/core/OscillatorNode.js.map +1 -0
- package/lib/module/core/PeriodicWave.js +8 -0
- package/lib/module/core/PeriodicWave.js.map +1 -0
- package/lib/module/core/StereoPannerNode.js +9 -0
- package/lib/module/core/StereoPannerNode.js.map +1 -0
- package/lib/module/core/types.js +2 -0
- package/lib/module/core/types.js.map +1 -0
- package/lib/module/errors/IndexSizeError.js +8 -0
- package/lib/module/errors/IndexSizeError.js.map +1 -0
- package/lib/module/errors/InvalidAccessError.js +8 -0
- package/lib/module/errors/InvalidAccessError.js.map +1 -0
- package/lib/module/errors/InvalidStateError.js +8 -0
- package/lib/module/errors/InvalidStateError.js.map +1 -0
- package/lib/module/errors/RangeError.js +8 -0
- package/lib/module/errors/RangeError.js.map +1 -0
- package/lib/module/errors/index.js +5 -0
- package/lib/module/errors/index.js.map +1 -0
- package/lib/module/index.js +18 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces.js +2 -0
- package/lib/module/interfaces.js.map +1 -0
- package/lib/module/modules/global.d.js +2 -0
- package/lib/module/modules/global.d.js.map +1 -0
- package/lib/module/utils/install.js +22 -0
- package/lib/module/utils/install.js.map +1 -0
- package/lib/typescript/core/AudioBuffer.d.ts +12 -0
- package/lib/typescript/core/AudioBuffer.d.ts.map +1 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts +12 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioContext.d.ts +6 -0
- package/lib/typescript/core/AudioContext.d.ts.map +1 -0
- package/lib/typescript/core/AudioDestinationNode.d.ts +7 -0
- package/lib/typescript/core/AudioDestinationNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioNode.d.ts +16 -0
- package/lib/typescript/core/AudioNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioParam.d.ts +14 -0
- package/lib/typescript/core/AudioParam.d.ts.map +1 -0
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts +10 -0
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -0
- package/lib/typescript/core/BaseAudioContext.d.ts +26 -0
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -0
- package/lib/typescript/core/BiquadFilterNode.d.ts +16 -0
- package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -0
- package/lib/typescript/core/GainNode.d.ts +9 -0
- package/lib/typescript/core/GainNode.d.ts.map +1 -0
- package/lib/typescript/core/OscillatorNode.d.ts +15 -0
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -0
- package/lib/typescript/core/PeriodicWave.d.ts +5 -0
- package/lib/typescript/core/PeriodicWave.d.ts.map +1 -0
- package/lib/typescript/core/StereoPannerNode.d.ts +9 -0
- package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -0
- package/lib/typescript/core/types.d.ts +9 -0
- package/lib/typescript/core/types.d.ts.map +1 -0
- package/lib/typescript/errors/IndexSizeError.d.ts +5 -0
- package/lib/typescript/errors/IndexSizeError.d.ts.map +1 -0
- package/lib/typescript/errors/InvalidAccessError.d.ts +5 -0
- package/lib/typescript/errors/InvalidAccessError.d.ts.map +1 -0
- package/lib/typescript/errors/InvalidStateError.d.ts +5 -0
- package/lib/typescript/errors/InvalidStateError.d.ts.map +1 -0
- package/lib/typescript/errors/RangeError.d.ts +5 -0
- package/lib/typescript/errors/RangeError.d.ts.map +1 -0
- package/lib/typescript/errors/index.d.ts +5 -0
- package/lib/typescript/errors/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/interfaces.d.ts +78 -0
- package/lib/typescript/interfaces.d.ts.map +1 -0
- package/lib/typescript/utils/install.d.ts +7 -0
- package/lib/typescript/utils/install.d.ts.map +1 -0
- package/package.json +104 -5
- package/src/core/AudioBuffer.ts +68 -0
- package/src/core/AudioBufferSourceNode.ts +35 -0
- package/src/core/AudioContext.ts +12 -0
- package/src/core/AudioDestinationNode.ts +9 -0
- package/src/core/AudioNode.ts +38 -0
- package/src/core/AudioParam.ts +55 -0
- package/src/core/AudioScheduledSourceNode.ts +43 -0
- package/src/core/BaseAudioContext.ts +97 -0
- package/src/core/BiquadFilterNode.ts +49 -0
- package/src/core/GainNode.ts +13 -0
- package/src/core/OscillatorNode.ts +37 -0
- package/src/core/PeriodicWave.ts +10 -0
- package/src/core/StereoPannerNode.ts +13 -0
- package/src/core/types.ts +26 -0
- package/src/errors/IndexSizeError.ts +8 -0
- package/src/errors/InvalidAccessError.ts +8 -0
- package/src/errors/InvalidStateError.ts +8 -0
- package/src/errors/RangeError.ts +8 -0
- package/src/errors/index.ts +4 -0
- package/src/index.ts +25 -0
- package/src/interfaces.ts +120 -0
- package/src/modules/global.d.ts +10 -0
- package/src/utils/install.ts +39 -0
- package/index.ts +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2010, Google Inc. All rights reserved.
|
|
3
|
+
* Copyright (C) 2020, Apple Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions
|
|
7
|
+
* are met:
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
*
|
|
14
|
+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
|
|
15
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
16
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
|
|
18
|
+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
// Defines the interface for several vector math functions whose implementation
|
|
29
|
+
// will ideally be optimized.
|
|
30
|
+
|
|
31
|
+
#include <cstddef>
|
|
32
|
+
|
|
33
|
+
namespace audioapi::VectorMath {
|
|
34
|
+
|
|
35
|
+
void multiplyByScalarThenAddToOutput(
|
|
36
|
+
const float *inputVector,
|
|
37
|
+
float scalar,
|
|
38
|
+
float *outputVector,
|
|
39
|
+
size_t numberOfElementsToProcess);
|
|
40
|
+
|
|
41
|
+
void multiplyByScalar(
|
|
42
|
+
const float *inputVector,
|
|
43
|
+
float scalar,
|
|
44
|
+
float *outputVector,
|
|
45
|
+
size_t numberOfElementsToProcess);
|
|
46
|
+
void addScalar(
|
|
47
|
+
const float *inputVector,
|
|
48
|
+
float scalar,
|
|
49
|
+
float *outputVector,
|
|
50
|
+
size_t numberOfElementsToProcess);
|
|
51
|
+
void add(
|
|
52
|
+
const float *inputVector1,
|
|
53
|
+
const float *inputVector2,
|
|
54
|
+
float *outputVector,
|
|
55
|
+
size_t numberOfElementsToProcess);
|
|
56
|
+
void subtract(
|
|
57
|
+
const float *inputVector1,
|
|
58
|
+
const float *inputVector2,
|
|
59
|
+
float *outputVector,
|
|
60
|
+
size_t numberOfElementsToProcess);
|
|
61
|
+
void multiply(
|
|
62
|
+
const float *inputVector1,
|
|
63
|
+
const float *inputVector2,
|
|
64
|
+
float *outputVector,
|
|
65
|
+
size_t numberOfElementsToProcess);
|
|
66
|
+
|
|
67
|
+
// Finds the maximum magnitude of a float vector.
|
|
68
|
+
float maximumMagnitude(
|
|
69
|
+
const float *inputVector,
|
|
70
|
+
size_t numberOfElementsToProcess);
|
|
71
|
+
} // namespace audioapi::VectorMath
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#if defined(ANDROID)
|
|
2
|
+
#include "FFTFrame.h"
|
|
3
|
+
#include <fftw3.h>
|
|
4
|
+
|
|
5
|
+
namespace audioapi {
|
|
6
|
+
void FFTFrame::inverse(float *timeDomainData) {
|
|
7
|
+
fftwf_complex *freqDomainData = fftwf_alloc_complex(size_ / 2);
|
|
8
|
+
for(int i = 0; i < size_ / 2; i++) {
|
|
9
|
+
freqDomainData[i][0] = realData_[i];
|
|
10
|
+
freqDomainData[i][1] = imaginaryData_[i];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
auto plan = fftwf_plan_dft_c2r_1d(size_, freqDomainData, timeDomainData, FFTW_ESTIMATE);
|
|
14
|
+
fftwf_execute(plan);
|
|
15
|
+
fftwf_destroy_plan(plan);
|
|
16
|
+
fftwf_free(freqDomainData);
|
|
17
|
+
|
|
18
|
+
VectorMath::multiplyByScalar(
|
|
19
|
+
timeDomainData, 1.0f / static_cast<float>(size_), timeDomainData, size_);
|
|
20
|
+
}
|
|
21
|
+
} // namespace audioapi
|
|
22
|
+
#endif
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#if defined(HAVE_ACCELERATE)
|
|
2
|
+
#include "FFTFrame.h"
|
|
3
|
+
#include "Accelerate/Accelerate.h"
|
|
4
|
+
|
|
5
|
+
namespace audioapi {
|
|
6
|
+
|
|
7
|
+
void FFTFrame::inverse(float *timeDomainData) {
|
|
8
|
+
FFTSetup fftSetup_ = vDSP_create_fftsetup(log2Size_, FFT_RADIX2);
|
|
9
|
+
DSPSplitComplex freqDomainData;
|
|
10
|
+
freqDomainData.realp = realData_;
|
|
11
|
+
freqDomainData.imagp = imaginaryData_;
|
|
12
|
+
|
|
13
|
+
vDSP_fft_zrip(fftSetup_, &freqDomainData, 1, log2Size_, FFT_INVERSE);
|
|
14
|
+
vDSP_ztoc(&freqDomainData, 1, reinterpret_cast<DSPComplex *>(timeDomainData), 2, size_ / 2);
|
|
15
|
+
|
|
16
|
+
// Scale the FFT data, beacuse of
|
|
17
|
+
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html#//apple_ref/doc/uid/TP40005147-CH3-15892
|
|
18
|
+
VectorMath::multiplyByScalar(
|
|
19
|
+
timeDomainData, 1.0f / static_cast<float>(size_), timeDomainData, size_);
|
|
20
|
+
|
|
21
|
+
vDSP_destroy_fftsetup(fftSetup_);
|
|
22
|
+
}
|
|
23
|
+
} // namespace audioapi
|
|
24
|
+
#endif
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#include "AudioBufferSourceNodeWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioBufferSourceNodeWrapper::AudioBufferSourceNodeWrapper(
|
|
6
|
+
const std::shared_ptr<AudioBufferSourceNode> &audioBufferSourceNode)
|
|
7
|
+
: AudioScheduledSourceNodeWrapper(audioBufferSourceNode) {}
|
|
8
|
+
|
|
9
|
+
std::shared_ptr<AudioBufferSourceNode>
|
|
10
|
+
AudioBufferSourceNodeWrapper::getAudioBufferSourceNodeFromAudioNode() {
|
|
11
|
+
return std::static_pointer_cast<AudioBufferSourceNode>(node_);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
bool AudioBufferSourceNodeWrapper::getLoop() {
|
|
15
|
+
auto audioBufferSourceNode = getAudioBufferSourceNodeFromAudioNode();
|
|
16
|
+
return audioBufferSourceNode->getLoop();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void AudioBufferSourceNodeWrapper::setLoop(bool loop) {
|
|
20
|
+
auto audioBufferSourceNode = getAudioBufferSourceNodeFromAudioNode();
|
|
21
|
+
audioBufferSourceNode->setLoop(loop);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::shared_ptr<AudioBufferWrapper> AudioBufferSourceNodeWrapper::getBuffer() {
|
|
25
|
+
auto audioBufferSourceNode = getAudioBufferSourceNodeFromAudioNode();
|
|
26
|
+
auto buffer = audioBufferSourceNode->getBuffer();
|
|
27
|
+
|
|
28
|
+
if (!buffer) {
|
|
29
|
+
return {nullptr};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return std::make_shared<AudioBufferWrapper>(buffer);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void AudioBufferSourceNodeWrapper::setBuffer(
|
|
36
|
+
const std::shared_ptr<AudioBufferWrapper> &buffer) {
|
|
37
|
+
auto audioBufferSourceNode = getAudioBufferSourceNodeFromAudioNode();
|
|
38
|
+
if (!buffer) {
|
|
39
|
+
audioBufferSourceNode->setBuffer(std::shared_ptr<AudioBuffer>(nullptr));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
audioBufferSourceNode->setBuffer(buffer->audioBuffer_);
|
|
44
|
+
}
|
|
45
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
|
|
6
|
+
#include "AudioBufferSourceNode.h"
|
|
7
|
+
#include "AudioBufferWrapper.h"
|
|
8
|
+
#include "AudioScheduledSourceNodeWrapper.h"
|
|
9
|
+
|
|
10
|
+
namespace audioapi {
|
|
11
|
+
|
|
12
|
+
class AudioBufferSourceNodeWrapper : public AudioScheduledSourceNodeWrapper {
|
|
13
|
+
public:
|
|
14
|
+
explicit AudioBufferSourceNodeWrapper(
|
|
15
|
+
const std::shared_ptr<AudioBufferSourceNode> &audioBufferSourceNode);
|
|
16
|
+
|
|
17
|
+
void setLoop(bool loop);
|
|
18
|
+
[[nodiscard]] bool getLoop();
|
|
19
|
+
[[nodiscard]] std::shared_ptr<AudioBufferWrapper> getBuffer();
|
|
20
|
+
void setBuffer(const std::shared_ptr<AudioBufferWrapper> &buffer);
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
std::shared_ptr<AudioBufferSourceNode>
|
|
24
|
+
getAudioBufferSourceNodeFromAudioNode();
|
|
25
|
+
};
|
|
26
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#include "AudioBufferWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioBufferWrapper::AudioBufferWrapper(
|
|
6
|
+
const std::shared_ptr<AudioBuffer> &audioBuffer)
|
|
7
|
+
: audioBuffer_(audioBuffer) {}
|
|
8
|
+
|
|
9
|
+
int AudioBufferWrapper::getSampleRate() const {
|
|
10
|
+
return audioBuffer_->getSampleRate();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
int AudioBufferWrapper::getLength() const {
|
|
14
|
+
return audioBuffer_->getLength();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
double AudioBufferWrapper::getDuration() const {
|
|
18
|
+
return audioBuffer_->getDuration();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int AudioBufferWrapper::getNumberOfChannels() const {
|
|
22
|
+
return audioBuffer_->getNumberOfChannels();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
float *AudioBufferWrapper::getChannelData(int channel) const {
|
|
26
|
+
return audioBuffer_->getChannelData(channel);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void AudioBufferWrapper::copyFromChannel(
|
|
30
|
+
float *destination,
|
|
31
|
+
int destinationLength,
|
|
32
|
+
int channelNumber,
|
|
33
|
+
int startInChannel) const {
|
|
34
|
+
audioBuffer_->copyFromChannel(
|
|
35
|
+
destination, destinationLength, channelNumber, startInChannel);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void AudioBufferWrapper::copyToChannel(
|
|
39
|
+
float *source,
|
|
40
|
+
int sourceLength,
|
|
41
|
+
int channelNumber,
|
|
42
|
+
int startInChannel) const {
|
|
43
|
+
audioBuffer_->copyToChannel(
|
|
44
|
+
source, sourceLength, channelNumber, startInChannel);
|
|
45
|
+
}
|
|
46
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "AudioBuffer.h"
|
|
6
|
+
|
|
7
|
+
namespace audioapi {
|
|
8
|
+
|
|
9
|
+
class AudioBufferWrapper {
|
|
10
|
+
public:
|
|
11
|
+
explicit AudioBufferWrapper(const std::shared_ptr<AudioBuffer> &audioBuffer);
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<AudioBuffer> audioBuffer_;
|
|
14
|
+
[[nodiscard]] int getNumberOfChannels() const;
|
|
15
|
+
[[nodiscard]] int getLength() const;
|
|
16
|
+
[[nodiscard]] double getDuration() const;
|
|
17
|
+
[[nodiscard]] int getSampleRate() const;
|
|
18
|
+
[[nodiscard]] float *getChannelData(int channel) const;
|
|
19
|
+
void copyFromChannel(
|
|
20
|
+
float *destination,
|
|
21
|
+
int destinationLength,
|
|
22
|
+
int channelNumber,
|
|
23
|
+
int startInChannel = 0) const;
|
|
24
|
+
void copyToChannel(
|
|
25
|
+
float *source,
|
|
26
|
+
int sourceLength,
|
|
27
|
+
int channelNumber,
|
|
28
|
+
int startInChannel = 0) const;
|
|
29
|
+
};
|
|
30
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include "AudioContextWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioContextWrapper::AudioContextWrapper(
|
|
6
|
+
const std::shared_ptr<AudioContext> &context)
|
|
7
|
+
: BaseAudioContextWrapper(context) {}
|
|
8
|
+
|
|
9
|
+
void AudioContextWrapper::close() {
|
|
10
|
+
getAudioContextFromBaseAudioContext()->close();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<AudioContext>
|
|
14
|
+
AudioContextWrapper::getAudioContextFromBaseAudioContext() {
|
|
15
|
+
return std::static_pointer_cast<AudioContext>(context_);
|
|
16
|
+
}
|
|
17
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "AudioContext.h"
|
|
6
|
+
#include "BaseAudioContextWrapper.h"
|
|
7
|
+
|
|
8
|
+
namespace audioapi {
|
|
9
|
+
|
|
10
|
+
class AudioContextWrapper : public BaseAudioContextWrapper {
|
|
11
|
+
public:
|
|
12
|
+
explicit AudioContextWrapper(const std::shared_ptr<AudioContext> &context);
|
|
13
|
+
|
|
14
|
+
void close();
|
|
15
|
+
|
|
16
|
+
private:
|
|
17
|
+
std::shared_ptr<AudioContext> getAudioContextFromBaseAudioContext();
|
|
18
|
+
};
|
|
19
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "AudioDestinationNode.h"
|
|
6
|
+
#include "AudioNodeWrapper.h"
|
|
7
|
+
|
|
8
|
+
namespace audioapi {
|
|
9
|
+
|
|
10
|
+
class AudioDestinationNodeWrapper : public AudioNodeWrapper {
|
|
11
|
+
public:
|
|
12
|
+
explicit AudioDestinationNodeWrapper(
|
|
13
|
+
const std::shared_ptr<AudioDestinationNode> &destinationNode)
|
|
14
|
+
: AudioNodeWrapper(destinationNode) {}
|
|
15
|
+
};
|
|
16
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "AudioNodeWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioNodeWrapper::AudioNodeWrapper(const std::shared_ptr<AudioNode> &node)
|
|
6
|
+
: node_(node) {}
|
|
7
|
+
|
|
8
|
+
int AudioNodeWrapper::getNumberOfInputs() const {
|
|
9
|
+
return node_->getNumberOfInputs();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
int AudioNodeWrapper::getNumberOfOutputs() const {
|
|
13
|
+
return node_->getNumberOfOutputs();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
int AudioNodeWrapper::getChannelCount() const {
|
|
17
|
+
return node_->getChannelCount();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
std::string AudioNodeWrapper::getChannelCountMode() const {
|
|
21
|
+
return node_->getChannelCountMode();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::string AudioNodeWrapper::getChannelInterpretation() const {
|
|
25
|
+
return node_->getChannelInterpretation();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void AudioNodeWrapper::connect(
|
|
29
|
+
const std::shared_ptr<AudioNodeWrapper> &node) const {
|
|
30
|
+
node_->connect(node->node_);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void AudioNodeWrapper::disconnect(
|
|
34
|
+
const std::shared_ptr<AudioNodeWrapper> &node) const {
|
|
35
|
+
node_->disconnect(node->node_);
|
|
36
|
+
}
|
|
37
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "AudioNode.h"
|
|
7
|
+
|
|
8
|
+
namespace audioapi {
|
|
9
|
+
|
|
10
|
+
class AudioNodeWrapper {
|
|
11
|
+
public:
|
|
12
|
+
explicit AudioNodeWrapper(const std::shared_ptr<AudioNode> &node);
|
|
13
|
+
|
|
14
|
+
[[nodiscard]] int getNumberOfInputs() const;
|
|
15
|
+
[[nodiscard]] int getNumberOfOutputs() const;
|
|
16
|
+
[[nodiscard]] int getChannelCount() const;
|
|
17
|
+
[[nodiscard]] std::string getChannelCountMode() const;
|
|
18
|
+
[[nodiscard]] std::string getChannelInterpretation() const;
|
|
19
|
+
void connect(const std::shared_ptr<AudioNodeWrapper> &node) const;
|
|
20
|
+
void disconnect(const std::shared_ptr<AudioNodeWrapper> &node) const;
|
|
21
|
+
|
|
22
|
+
protected:
|
|
23
|
+
std::shared_ptr<AudioNode> node_;
|
|
24
|
+
};
|
|
25
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#include "AudioParamWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioParamWrapper::AudioParamWrapper(const std::shared_ptr<AudioParam> ¶m)
|
|
6
|
+
: param_(param) {}
|
|
7
|
+
|
|
8
|
+
float AudioParamWrapper::getValue() const {
|
|
9
|
+
return param_->getValue();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
void AudioParamWrapper::setValue(float value) const {
|
|
13
|
+
param_->setValue(value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
float AudioParamWrapper::getDefaultValue() const {
|
|
17
|
+
return param_->getDefaultValue();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
float AudioParamWrapper::getMinValue() const {
|
|
21
|
+
return param_->getMinValue();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
float AudioParamWrapper::getMaxValue() const {
|
|
25
|
+
return param_->getMaxValue();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void AudioParamWrapper::setValueAtTime(float value, double startTime) const {
|
|
29
|
+
param_->setValueAtTime(value, startTime);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void AudioParamWrapper::linearRampToValueAtTime(float value, double endTime)
|
|
33
|
+
const {
|
|
34
|
+
param_->linearRampToValueAtTime(value, endTime);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void AudioParamWrapper::exponentialRampToValueAtTime(
|
|
38
|
+
float value,
|
|
39
|
+
double endTime) const {
|
|
40
|
+
param_->exponentialRampToValueAtTime(value, endTime);
|
|
41
|
+
}
|
|
42
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "AudioParam.h"
|
|
6
|
+
|
|
7
|
+
namespace audioapi {
|
|
8
|
+
|
|
9
|
+
class AudioParamWrapper {
|
|
10
|
+
public:
|
|
11
|
+
explicit AudioParamWrapper(const std::shared_ptr<AudioParam> ¶m);
|
|
12
|
+
|
|
13
|
+
[[nodiscard]] float getValue() const;
|
|
14
|
+
void setValue(float value) const;
|
|
15
|
+
[[nodiscard]] float getDefaultValue() const;
|
|
16
|
+
[[nodiscard]] float getMinValue() const;
|
|
17
|
+
[[nodiscard]] float getMaxValue() const;
|
|
18
|
+
void setValueAtTime(float value, double startTime) const;
|
|
19
|
+
void linearRampToValueAtTime(float value, double endTime) const;
|
|
20
|
+
void exponentialRampToValueAtTime(float value, double endTime) const;
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
std::shared_ptr<AudioParam> param_;
|
|
24
|
+
};
|
|
25
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include "AudioScheduledSourceNodeWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
AudioScheduledSourceNodeWrapper::AudioScheduledSourceNodeWrapper(
|
|
6
|
+
const std::shared_ptr<AudioScheduledSourceNode> &audioScheduledSourceNode)
|
|
7
|
+
: AudioNodeWrapper(audioScheduledSourceNode) {}
|
|
8
|
+
|
|
9
|
+
std::shared_ptr<AudioScheduledSourceNode>
|
|
10
|
+
AudioScheduledSourceNodeWrapper::getAudioScheduledSourceNodeFromAudioNode() {
|
|
11
|
+
return std::static_pointer_cast<AudioScheduledSourceNode>(node_);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void AudioScheduledSourceNodeWrapper::start(double time) {
|
|
15
|
+
auto audioScheduledSourceNode = getAudioScheduledSourceNodeFromAudioNode();
|
|
16
|
+
audioScheduledSourceNode->start(time);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void AudioScheduledSourceNodeWrapper::stop(double time) {
|
|
20
|
+
auto audioScheduledSourceNode = getAudioScheduledSourceNodeFromAudioNode();
|
|
21
|
+
audioScheduledSourceNode->stop(time);
|
|
22
|
+
}
|
|
23
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include "AudioNodeWrapper.h"
|
|
6
|
+
#include "AudioScheduledSourceNode.h"
|
|
7
|
+
|
|
8
|
+
namespace audioapi {
|
|
9
|
+
|
|
10
|
+
class AudioScheduledSourceNodeWrapper : public AudioNodeWrapper {
|
|
11
|
+
public:
|
|
12
|
+
explicit AudioScheduledSourceNodeWrapper(
|
|
13
|
+
const std::shared_ptr<AudioScheduledSourceNode>
|
|
14
|
+
&audioScheduledSourceNode);
|
|
15
|
+
|
|
16
|
+
void start(double time);
|
|
17
|
+
void stop(double time);
|
|
18
|
+
|
|
19
|
+
private:
|
|
20
|
+
std::shared_ptr<AudioScheduledSourceNode>
|
|
21
|
+
getAudioScheduledSourceNodeFromAudioNode();
|
|
22
|
+
};
|
|
23
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#include "BaseAudioContextWrapper.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
BaseAudioContextWrapper::BaseAudioContextWrapper(
|
|
6
|
+
const std::shared_ptr<BaseAudioContext> &context)
|
|
7
|
+
: context_(context) {
|
|
8
|
+
auto destination = context_->getDestination();
|
|
9
|
+
destination_ = std::make_shared<AudioDestinationNodeWrapper>(destination);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
std::shared_ptr<AudioDestinationNodeWrapper>
|
|
13
|
+
BaseAudioContextWrapper::getDestination() const {
|
|
14
|
+
return destination_;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
std::string BaseAudioContextWrapper::getState() const {
|
|
18
|
+
return context_->getState();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int BaseAudioContextWrapper::getSampleRate() const {
|
|
22
|
+
return context_->getSampleRate();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
double BaseAudioContextWrapper::getCurrentTime() const {
|
|
26
|
+
return context_->getCurrentTime();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
std::shared_ptr<OscillatorNodeWrapper>
|
|
30
|
+
BaseAudioContextWrapper::createOscillator() const {
|
|
31
|
+
auto oscillator = context_->createOscillator();
|
|
32
|
+
return std::make_shared<OscillatorNodeWrapper>(oscillator);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::shared_ptr<GainNodeWrapper> BaseAudioContextWrapper::createGain() const {
|
|
36
|
+
auto gain = context_->createGain();
|
|
37
|
+
return std::make_shared<GainNodeWrapper>(gain);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::shared_ptr<StereoPannerNodeWrapper>
|
|
41
|
+
BaseAudioContextWrapper::createStereoPanner() const {
|
|
42
|
+
auto panner = context_->createStereoPanner();
|
|
43
|
+
return std::make_shared<StereoPannerNodeWrapper>(panner);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::shared_ptr<BiquadFilterNodeWrapper>
|
|
47
|
+
BaseAudioContextWrapper::createBiquadFilter() const {
|
|
48
|
+
auto filter = context_->createBiquadFilter();
|
|
49
|
+
return std::make_shared<BiquadFilterNodeWrapper>(filter);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::shared_ptr<AudioBufferSourceNodeWrapper>
|
|
53
|
+
BaseAudioContextWrapper::createBufferSource() const {
|
|
54
|
+
auto bufferSource = context_->createBufferSource();
|
|
55
|
+
return std::make_shared<AudioBufferSourceNodeWrapper>(bufferSource);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
std::shared_ptr<AudioBufferWrapper> BaseAudioContextWrapper::createBuffer(
|
|
59
|
+
int numberOfChannels,
|
|
60
|
+
int length,
|
|
61
|
+
int sampleRate) const {
|
|
62
|
+
auto buffer = context_->createBuffer(numberOfChannels, length, sampleRate);
|
|
63
|
+
return std::make_shared<AudioBufferWrapper>(buffer);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
std::shared_ptr<PeriodicWaveWrapper>
|
|
67
|
+
BaseAudioContextWrapper::createPeriodicWave(
|
|
68
|
+
float *real,
|
|
69
|
+
float *imag,
|
|
70
|
+
bool disableNormalization,
|
|
71
|
+
int length) {
|
|
72
|
+
auto periodicWave =
|
|
73
|
+
context_->createPeriodicWave(real, imag, disableNormalization, length);
|
|
74
|
+
return std::make_shared<PeriodicWaveWrapper>(periodicWave);
|
|
75
|
+
}
|
|
76
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <utility>
|
|
6
|
+
|
|
7
|
+
#include "AudioBufferSourceNodeWrapper.h"
|
|
8
|
+
#include "AudioBufferWrapper.h"
|
|
9
|
+
#include "AudioDestinationNodeWrapper.h"
|
|
10
|
+
#include "BaseAudioContext.h"
|
|
11
|
+
#include "BiquadFilterNodeWrapper.h"
|
|
12
|
+
#include "GainNodeWrapper.h"
|
|
13
|
+
#include "OscillatorNodeWrapper.h"
|
|
14
|
+
#include "PeriodicWaveWrapper.h"
|
|
15
|
+
#include "StereoPannerNodeWrapper.h"
|
|
16
|
+
|
|
17
|
+
namespace audioapi {
|
|
18
|
+
|
|
19
|
+
class BaseAudioContextWrapper {
|
|
20
|
+
public:
|
|
21
|
+
explicit BaseAudioContextWrapper(
|
|
22
|
+
const std::shared_ptr<BaseAudioContext> &context);
|
|
23
|
+
|
|
24
|
+
[[nodiscard]] std::shared_ptr<AudioDestinationNodeWrapper> getDestination()
|
|
25
|
+
const;
|
|
26
|
+
[[nodiscard]] std::string getState() const;
|
|
27
|
+
[[nodiscard]] int getSampleRate() const;
|
|
28
|
+
[[nodiscard]] double getCurrentTime() const;
|
|
29
|
+
[[nodiscard]] std::shared_ptr<OscillatorNodeWrapper> createOscillator() const;
|
|
30
|
+
[[nodiscard]] std::shared_ptr<GainNodeWrapper> createGain() const;
|
|
31
|
+
[[nodiscard]] std::shared_ptr<StereoPannerNodeWrapper> createStereoPanner()
|
|
32
|
+
const;
|
|
33
|
+
[[nodiscard]] std::shared_ptr<BiquadFilterNodeWrapper> createBiquadFilter()
|
|
34
|
+
const;
|
|
35
|
+
[[nodiscard]] std::shared_ptr<AudioBufferSourceNodeWrapper>
|
|
36
|
+
createBufferSource() const;
|
|
37
|
+
[[nodiscard]] std::shared_ptr<AudioBufferWrapper>
|
|
38
|
+
createBuffer(int numberOfChannels, int length, int sampleRate) const;
|
|
39
|
+
[[nodiscard]] std::shared_ptr<PeriodicWaveWrapper> createPeriodicWave(
|
|
40
|
+
float *real,
|
|
41
|
+
float *imag,
|
|
42
|
+
bool disableNormalization,
|
|
43
|
+
int length);
|
|
44
|
+
|
|
45
|
+
protected:
|
|
46
|
+
std::shared_ptr<AudioDestinationNodeWrapper> destination_;
|
|
47
|
+
std::shared_ptr<BaseAudioContext> context_;
|
|
48
|
+
};
|
|
49
|
+
} // namespace audioapi
|