react-native-audio-api 0.10.0-nightly-c815c40-20251027 → 0.11.0-alpha.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/RNAudioAPI.podspec +5 -9
- package/android/build.gradle +3 -33
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +94 -28
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +28 -14
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +33 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +431 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +112 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +237 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +46 -0
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
- package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +2 -30
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +80 -18
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +15 -6
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +102 -49
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +46 -28
- package/common/cpp/audioapi/core/utils/Constants.h +1 -2
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
- package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +44 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +1 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +3 -2
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
- package/common/cpp/test/CMakeLists.txt +0 -3
- package/ios/audioapi/ios/AudioAPIModule.h +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +35 -0
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +135 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +38 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +187 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +18 -10
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +70 -28
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +2 -6
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +5 -73
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
- package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
- package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
- package/lib/commonjs/api.js +76 -134
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +157 -12
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +25 -16
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/types.js +50 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/bitEnums.js +33 -0
- package/lib/commonjs/utils/bitEnums.js.map +1 -0
- package/lib/commonjs/utils/index.js +21 -19
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/api.js +15 -15
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/AudioContext.js +2 -2
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +157 -12
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +26 -17
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/types.js +46 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/bitEnums.js +27 -0
- package/lib/module/utils/bitEnums.js.map +1 -0
- package/lib/module/utils/index.js +2 -15
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/api.d.ts +17 -18
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +58 -6
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +16 -0
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +39 -3
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +75 -4
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/bitEnums.d.ts +4 -0
- package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/package.json +4 -7
- package/src/api.ts +18 -44
- package/src/core/AudioContext.ts +2 -3
- package/src/core/AudioRecorder.ts +190 -20
- package/src/core/BaseAudioContext.ts +60 -44
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +18 -0
- package/src/interfaces.ts +47 -4
- package/src/types.ts +86 -4
- package/src/utils/bitEnums.ts +51 -0
- package/src/utils/index.ts +2 -22
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
- package/scripts/download-prebuilt-binaries.sh +0 -52
- package/scripts/rnaa_utils.rb +0 -8
- package/scripts/validate-worklets-version.js +0 -28
|
Binary file
|
|
Binary file
|
|
@@ -16,16 +16,13 @@
|
|
|
16
16
|
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
17
17
|
|
|
18
18
|
#include <memory>
|
|
19
|
-
#include <
|
|
19
|
+
#include <string>
|
|
20
20
|
|
|
21
21
|
namespace audioapi {
|
|
22
22
|
|
|
23
23
|
using namespace facebook;
|
|
24
24
|
|
|
25
25
|
class AudioAPIModuleInstaller {
|
|
26
|
-
private:
|
|
27
|
-
inline static std::vector<std::weak_ptr<AudioContext>> contexts_ = {};
|
|
28
|
-
|
|
29
26
|
public:
|
|
30
27
|
static void injectJSIBindings(
|
|
31
28
|
jsi::Runtime *jsiRuntime,
|
|
@@ -65,19 +62,6 @@ class AudioAPIModuleInstaller {
|
|
|
65
62
|
*jsiRuntime, audioEventHandlerRegistryHostObject));
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
static void closeAllContexts() {
|
|
69
|
-
for (auto it = contexts_.begin(); it != contexts_.end(); ++it) {
|
|
70
|
-
auto weakContext = *it;
|
|
71
|
-
|
|
72
|
-
if (auto context = weakContext.lock()) {
|
|
73
|
-
context->close();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
it = contexts_.erase(it);
|
|
77
|
-
--it;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
65
|
private:
|
|
82
66
|
static jsi::Function getCreateAudioContextFunction(
|
|
83
67
|
jsi::Runtime *jsiRuntime,
|
|
@@ -112,8 +96,6 @@ class AudioAPIModuleInstaller {
|
|
|
112
96
|
initSuspended,
|
|
113
97
|
audioEventHandlerRegistry,
|
|
114
98
|
runtimeRegistry);
|
|
115
|
-
AudioAPIModuleInstaller::contexts_.push_back(audioContext);
|
|
116
|
-
|
|
117
99
|
auto audioContextHostObject =
|
|
118
100
|
std::make_shared<AudioContextHostObject>(
|
|
119
101
|
audioContext, &runtime, jsCallInvoker);
|
|
@@ -157,7 +139,6 @@ class AudioAPIModuleInstaller {
|
|
|
157
139
|
sampleRate,
|
|
158
140
|
audioEventHandlerRegistry,
|
|
159
141
|
runtimeRegistry);
|
|
160
|
-
|
|
161
142
|
auto audioContextHostObject =
|
|
162
143
|
std::make_shared<OfflineAudioContextHostObject>(
|
|
163
144
|
offlineAudioContext, &runtime, jsCallInvoker);
|
|
@@ -180,17 +161,8 @@ class AudioAPIModuleInstaller {
|
|
|
180
161
|
const jsi::Value &thisValue,
|
|
181
162
|
const jsi::Value *args,
|
|
182
163
|
size_t count) -> jsi::Value {
|
|
183
|
-
auto options = args[0].getObject(runtime);
|
|
184
|
-
|
|
185
|
-
auto sampleRate = static_cast<float>(
|
|
186
|
-
options.getProperty(runtime, "sampleRate").getNumber());
|
|
187
|
-
auto bufferLength = static_cast<int>(
|
|
188
|
-
options.getProperty(runtime, "bufferLengthInSamples")
|
|
189
|
-
.getNumber());
|
|
190
|
-
|
|
191
164
|
auto audioRecorderHostObject =
|
|
192
|
-
std::make_shared<AudioRecorderHostObject>(
|
|
193
|
-
audioEventHandlerRegistry, sampleRate, bufferLength);
|
|
165
|
+
std::make_shared<AudioRecorderHostObject>(audioEventHandlerRegistry);
|
|
194
166
|
|
|
195
167
|
return jsi::Object::createFromHostObject(
|
|
196
168
|
runtime, audioRecorderHostObject);
|
|
@@ -67,7 +67,7 @@ JSI_HOST_FUNCTION_IMPL(BiquadFilterNodeHostObject, getFrequencyResponse) {
|
|
|
67
67
|
.getArrayBuffer(runtime);
|
|
68
68
|
auto frequencyArray =
|
|
69
69
|
reinterpret_cast<float *>(arrayBufferFrequency.data(runtime));
|
|
70
|
-
auto length = static_cast<
|
|
70
|
+
auto length = static_cast<int>(arrayBufferFrequency.size(runtime));
|
|
71
71
|
|
|
72
72
|
auto arrayBufferMag = args[1]
|
|
73
73
|
.getObject(runtime)
|
|
@@ -14,35 +14,86 @@
|
|
|
14
14
|
namespace audioapi {
|
|
15
15
|
|
|
16
16
|
AudioRecorderHostObject::AudioRecorderHostObject(
|
|
17
|
-
const std::shared_ptr<AudioEventHandlerRegistry>
|
|
18
|
-
|
|
19
|
-
int bufferLength) {
|
|
17
|
+
const std::shared_ptr<AudioEventHandlerRegistry>
|
|
18
|
+
&audioEventHandlerRegistry) {
|
|
20
19
|
#ifdef ANDROID
|
|
21
|
-
audioRecorder_ =
|
|
22
|
-
|
|
20
|
+
audioRecorder_ =
|
|
21
|
+
std::make_shared<AndroidAudioRecorder>(audioEventHandlerRegistry);
|
|
23
22
|
#else
|
|
24
|
-
audioRecorder_ =
|
|
25
|
-
|
|
23
|
+
audioRecorder_ =
|
|
24
|
+
std::make_shared<IOSAudioRecorder>(audioEventHandlerRegistry);
|
|
26
25
|
#endif
|
|
27
26
|
|
|
28
|
-
addSetters(JSI_EXPORT_PROPERTY_SETTER(AudioRecorderHostObject, onAudioReady));
|
|
29
|
-
|
|
30
27
|
addFunctions(
|
|
31
28
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, start),
|
|
32
29
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, stop),
|
|
30
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, isRecording),
|
|
31
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, enableFileOutput),
|
|
32
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disableFileOutput),
|
|
33
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, pause),
|
|
34
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, resume),
|
|
33
35
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, connect),
|
|
34
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect)
|
|
36
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect),
|
|
37
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, setOnAudioReady),
|
|
38
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, clearOnAudioReady));
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
audioRecorder_->
|
|
39
|
-
|
|
41
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, start) {
|
|
42
|
+
audioRecorder_->start();
|
|
43
|
+
|
|
44
|
+
return jsi::Value::undefined();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, stop) {
|
|
48
|
+
std::string filePath = audioRecorder_->stop();
|
|
49
|
+
|
|
50
|
+
return jsi::Value(runtime, jsi::String::createFromUtf8(runtime, filePath));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, isRecording) {
|
|
54
|
+
return jsi::Value(audioRecorder_->isRecording());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, enableFileOutput) {
|
|
58
|
+
auto options = args[0].getObject(runtime);
|
|
59
|
+
|
|
60
|
+
auto sampleRate = static_cast<float>(
|
|
61
|
+
options.getProperty(runtime, "sampleRate").getNumber());
|
|
62
|
+
auto channelCount =
|
|
63
|
+
static_cast<size_t>(options.getProperty(runtime, "channels").getNumber());
|
|
64
|
+
auto bitRate =
|
|
65
|
+
static_cast<size_t>(options.getProperty(runtime, "bitRate").getNumber());
|
|
66
|
+
auto iosFlags =
|
|
67
|
+
static_cast<size_t>(options.getProperty(runtime, "ios").getNumber());
|
|
68
|
+
auto androidFlags =
|
|
69
|
+
static_cast<size_t>(options.getProperty(runtime, "android").getNumber());
|
|
70
|
+
|
|
71
|
+
audioRecorder_->enableFileOutput(
|
|
72
|
+
sampleRate, channelCount, bitRate, iosFlags, androidFlags);
|
|
73
|
+
return jsi::Value::undefined();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disableFileOutput) {
|
|
77
|
+
audioRecorder_->disableFileOutput();
|
|
78
|
+
return jsi::Value::undefined();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, pause) {
|
|
82
|
+
audioRecorder_->pause();
|
|
83
|
+
|
|
84
|
+
return jsi::Value::undefined();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, resume) {
|
|
88
|
+
audioRecorder_->resume();
|
|
89
|
+
return jsi::Value::undefined();
|
|
40
90
|
}
|
|
41
91
|
|
|
42
92
|
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
|
|
43
93
|
auto adapterNodeHostObject =
|
|
44
94
|
args[0].getObject(runtime).getHostObject<RecorderAdapterNodeHostObject>(
|
|
45
95
|
runtime);
|
|
96
|
+
|
|
46
97
|
audioRecorder_->connect(
|
|
47
98
|
std::static_pointer_cast<RecorderAdapterNode>(
|
|
48
99
|
adapterNodeHostObject->node_));
|
|
@@ -51,18 +102,29 @@ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
|
|
|
51
102
|
|
|
52
103
|
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disconnect) {
|
|
53
104
|
audioRecorder_->disconnect();
|
|
105
|
+
|
|
54
106
|
return jsi::Value::undefined();
|
|
55
107
|
}
|
|
56
108
|
|
|
57
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject,
|
|
58
|
-
|
|
109
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, setOnAudioReady) {
|
|
110
|
+
auto options = args[0].getObject(runtime);
|
|
111
|
+
|
|
112
|
+
auto sampleRate = static_cast<float>(
|
|
113
|
+
options.getProperty(runtime, "sampleRate").getNumber());
|
|
114
|
+
auto bufferLength = static_cast<size_t>(
|
|
115
|
+
options.getProperty(runtime, "bufferLength").getNumber());
|
|
116
|
+
auto channelCount = static_cast<size_t>(
|
|
117
|
+
options.getProperty(runtime, "channelCount").getNumber());
|
|
118
|
+
auto callbackId = static_cast<uint64_t>(
|
|
119
|
+
options.getProperty(runtime, "callbackId").getNumber());
|
|
59
120
|
|
|
121
|
+
audioRecorder_->setOnAudioReadyCallback(
|
|
122
|
+
sampleRate, bufferLength, channelCount, callbackId);
|
|
60
123
|
return jsi::Value::undefined();
|
|
61
124
|
}
|
|
62
125
|
|
|
63
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject,
|
|
64
|
-
audioRecorder_->
|
|
65
|
-
|
|
126
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, clearOnAudioReady) {
|
|
127
|
+
audioRecorder_->clearOnAudioReadyCallback();
|
|
66
128
|
return jsi::Value::undefined();
|
|
67
129
|
}
|
|
68
130
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include <utility>
|
|
7
7
|
#include <vector>
|
|
8
8
|
#include <cstdio>
|
|
9
|
+
#include <string>
|
|
9
10
|
|
|
10
11
|
namespace audioapi {
|
|
11
12
|
using namespace facebook;
|
|
@@ -16,18 +17,26 @@ class AudioEventHandlerRegistry;
|
|
|
16
17
|
class AudioRecorderHostObject : public JsiHostObject {
|
|
17
18
|
public:
|
|
18
19
|
explicit AudioRecorderHostObject(
|
|
19
|
-
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry
|
|
20
|
-
float sampleRate,
|
|
21
|
-
int bufferLength);
|
|
20
|
+
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
JSI_HOST_FUNCTION_DECL(start);
|
|
23
|
+
JSI_HOST_FUNCTION_DECL(stop);
|
|
24
|
+
JSI_HOST_FUNCTION_DECL(isRecording);
|
|
25
|
+
|
|
26
|
+
JSI_HOST_FUNCTION_DECL(enableFileOutput);
|
|
27
|
+
JSI_HOST_FUNCTION_DECL(disableFileOutput);
|
|
28
|
+
|
|
29
|
+
JSI_HOST_FUNCTION_DECL(pause);
|
|
30
|
+
JSI_HOST_FUNCTION_DECL(resume);
|
|
24
31
|
|
|
25
32
|
JSI_HOST_FUNCTION_DECL(connect);
|
|
26
33
|
JSI_HOST_FUNCTION_DECL(disconnect);
|
|
27
|
-
|
|
28
|
-
JSI_HOST_FUNCTION_DECL(
|
|
34
|
+
|
|
35
|
+
JSI_HOST_FUNCTION_DECL(setOnAudioReady);
|
|
36
|
+
JSI_HOST_FUNCTION_DECL(clearOnAudioReady);
|
|
29
37
|
|
|
30
38
|
private:
|
|
31
39
|
std::shared_ptr<AudioRecorder> audioRecorder_;
|
|
32
40
|
};
|
|
41
|
+
|
|
33
42
|
} // namespace audioapi
|
|
@@ -56,7 +56,7 @@ float AudioParam::getValueAtTime(double time) {
|
|
|
56
56
|
void AudioParam::setValueAtTime(float value, double startTime) {
|
|
57
57
|
auto event = [value, startTime](AudioParam ¶m) {
|
|
58
58
|
// Ignore events scheduled before the end of existing automation
|
|
59
|
-
if (startTime
|
|
59
|
+
if (startTime <= param.getQueueEndTime()) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -87,7 +87,7 @@ void AudioParam::setValueAtTime(float value, double startTime) {
|
|
|
87
87
|
void AudioParam::linearRampToValueAtTime(float value, double endTime) {
|
|
88
88
|
auto event = [value, endTime](AudioParam ¶m) {
|
|
89
89
|
// Ignore events scheduled before the end of existing automation
|
|
90
|
-
if (endTime
|
|
90
|
+
if (endTime <= param.getQueueEndTime()) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2010 Google Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Redistribution and use in source and binary forms, with or without
|
|
5
|
-
* modification, are permitted provided that the following conditions
|
|
6
|
-
* are met:
|
|
7
|
-
*
|
|
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
|
-
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
14
|
-
* its contributors may be used to endorse or promote products derived
|
|
15
|
-
* from this software without specific prior written permission.
|
|
16
|
-
*
|
|
17
|
-
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
|
18
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
-
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
21
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
24
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
-
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
1
|
#include <audioapi/core/BaseAudioContext.h>
|
|
30
2
|
#include <audioapi/core/effects/BiquadFilterNode.h>
|
|
31
3
|
#include <audioapi/utils/AudioArray.h>
|
|
@@ -41,14 +13,14 @@ BiquadFilterNode::BiquadFilterNode(BaseAudioContext *context)
|
|
|
41
13
|
frequencyParam_ = std::make_shared<AudioParam>(
|
|
42
14
|
350.0, 0.0f, context->getNyquistFrequency(), context);
|
|
43
15
|
detuneParam_ = std::make_shared<AudioParam>(
|
|
44
|
-
0.
|
|
16
|
+
0.0,
|
|
45
17
|
-1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
|
|
46
18
|
1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
|
|
47
19
|
context);
|
|
48
20
|
QParam_ = std::make_shared<AudioParam>(
|
|
49
|
-
1.
|
|
21
|
+
1.0, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
|
|
50
22
|
gainParam_ = std::make_shared<AudioParam>(
|
|
51
|
-
0.
|
|
23
|
+
0.0,
|
|
52
24
|
MOST_NEGATIVE_SINGLE_FLOAT,
|
|
53
25
|
40 * LOG10_MOST_POSITIVE_SINGLE_FLOAT,
|
|
54
26
|
context);
|
|
@@ -104,35 +76,27 @@ void BiquadFilterNode::getFrequencyResponse(
|
|
|
104
76
|
const float *frequencyArray,
|
|
105
77
|
float *magResponseOutput,
|
|
106
78
|
float *phaseResponseOutput,
|
|
107
|
-
const
|
|
108
|
-
#ifndef AUDIO_API_TEST_SUITE
|
|
79
|
+
const int length) {
|
|
109
80
|
applyFilter();
|
|
110
|
-
#endif
|
|
111
|
-
|
|
112
|
-
// Use double precision for later calculations
|
|
113
|
-
double b0 = static_cast<double>(b0_);
|
|
114
|
-
double b1 = static_cast<double>(b1_);
|
|
115
|
-
double b2 = static_cast<double>(b2_);
|
|
116
|
-
double a1 = static_cast<double>(a1_);
|
|
117
|
-
double a2 = static_cast<double>(a2_);
|
|
118
81
|
|
|
119
|
-
|
|
82
|
+
// Local copies for micro-optimization
|
|
83
|
+
float b0 = b0_;
|
|
84
|
+
float b1 = b1_;
|
|
85
|
+
float b2 = b2_;
|
|
86
|
+
float a1 = a1_;
|
|
87
|
+
float a2 = a2_;
|
|
120
88
|
|
|
121
89
|
for (size_t i = 0; i < length; i++) {
|
|
122
|
-
|
|
123
|
-
float normalizedFreq = frequencyArray[i] / nyquist;
|
|
124
|
-
|
|
125
|
-
if (normalizedFreq < 0.0f || normalizedFreq > 1.0f) {
|
|
126
|
-
// Out-of-bounds frequencies should return NaN.
|
|
90
|
+
if (frequencyArray[i] < 0.0 || frequencyArray[i] > 1.0) {
|
|
127
91
|
magResponseOutput[i] = std::nanf("");
|
|
128
92
|
phaseResponseOutput[i] = std::nanf("");
|
|
129
93
|
continue;
|
|
130
94
|
}
|
|
131
95
|
|
|
132
|
-
|
|
133
|
-
auto z = std::complex<
|
|
96
|
+
auto omega = -PI * frequencyArray[i] / context_->getNyquistFrequency();
|
|
97
|
+
auto z = std::complex<float>(cos(omega), sin(omega));
|
|
134
98
|
auto response = (b0 + (b1 + b2 * z) * z) /
|
|
135
|
-
(std::complex<
|
|
99
|
+
(std::complex<float>(1, 0) + (a1 + a2 * z) * z);
|
|
136
100
|
magResponseOutput[i] = static_cast<float>(std::abs(response));
|
|
137
101
|
phaseResponseOutput[i] =
|
|
138
102
|
static_cast<float>(atan2(imag(response), real(response)));
|
|
@@ -156,16 +120,17 @@ void BiquadFilterNode::setNormalizedCoefficients(
|
|
|
156
120
|
|
|
157
121
|
void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
|
|
158
122
|
// Limit frequency to [0, 1] range
|
|
159
|
-
if (frequency >= 1.
|
|
123
|
+
if (frequency >= 1.0) {
|
|
160
124
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
161
125
|
return;
|
|
162
126
|
}
|
|
163
127
|
|
|
164
|
-
if (frequency <= 0.
|
|
128
|
+
if (frequency <= 0.0) {
|
|
165
129
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
166
130
|
return;
|
|
167
131
|
}
|
|
168
132
|
|
|
133
|
+
Q = std::max(0.0f, Q);
|
|
169
134
|
float g = std::pow(10.0f, 0.05f * Q);
|
|
170
135
|
|
|
171
136
|
float theta = PI * frequency;
|
|
@@ -178,15 +143,16 @@ void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
|
|
|
178
143
|
}
|
|
179
144
|
|
|
180
145
|
void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
|
|
181
|
-
if (frequency >= 1.
|
|
146
|
+
if (frequency >= 1.0) {
|
|
182
147
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
183
148
|
return;
|
|
184
149
|
}
|
|
185
|
-
if (frequency <= 0.
|
|
150
|
+
if (frequency <= 0.0) {
|
|
186
151
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
187
152
|
return;
|
|
188
153
|
}
|
|
189
154
|
|
|
155
|
+
Q = std::max(0.0f, Q);
|
|
190
156
|
float g = std::pow(10.0f, 0.05f * Q);
|
|
191
157
|
|
|
192
158
|
float theta = PI * frequency;
|
|
@@ -200,13 +166,13 @@ void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
|
|
|
200
166
|
|
|
201
167
|
void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
|
|
202
168
|
// Limit frequency to [0, 1] range
|
|
203
|
-
if (frequency <= 0.
|
|
169
|
+
if (frequency <= 0.0 || frequency >= 1.0) {
|
|
204
170
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
205
171
|
return;
|
|
206
172
|
}
|
|
207
173
|
|
|
208
174
|
// Limit Q to positive values
|
|
209
|
-
if (Q <= 0.
|
|
175
|
+
if (Q <= 0.0) {
|
|
210
176
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
211
177
|
return;
|
|
212
178
|
}
|
|
@@ -222,12 +188,12 @@ void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
|
|
|
222
188
|
void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
|
|
223
189
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
224
190
|
|
|
225
|
-
if (frequency >= 1.
|
|
191
|
+
if (frequency >= 1.0) {
|
|
226
192
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
227
193
|
return;
|
|
228
194
|
}
|
|
229
195
|
|
|
230
|
-
if (frequency <= 0.
|
|
196
|
+
if (frequency <= 0.0) {
|
|
231
197
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
232
198
|
return;
|
|
233
199
|
}
|
|
@@ -249,12 +215,12 @@ void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
|
|
|
249
215
|
void BiquadFilterNode::setHighshelfCoefficients(float frequency, float gain) {
|
|
250
216
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
251
217
|
|
|
252
|
-
if (frequency >= 1.
|
|
218
|
+
if (frequency >= 1.0) {
|
|
253
219
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
254
220
|
return;
|
|
255
221
|
}
|
|
256
222
|
|
|
257
|
-
if (frequency <= 0.
|
|
223
|
+
if (frequency <= 0.0) {
|
|
258
224
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
259
225
|
return;
|
|
260
226
|
}
|
|
@@ -281,12 +247,12 @@ void BiquadFilterNode::setPeakingCoefficients(
|
|
|
281
247
|
float gain) {
|
|
282
248
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
283
249
|
|
|
284
|
-
if (frequency <= 0.
|
|
250
|
+
if (frequency <= 0.0 || frequency >= 1.0) {
|
|
285
251
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
286
252
|
return;
|
|
287
253
|
}
|
|
288
254
|
|
|
289
|
-
if (Q <= 0.
|
|
255
|
+
if (Q <= 0.0) {
|
|
290
256
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
291
257
|
return;
|
|
292
258
|
}
|
|
@@ -305,12 +271,12 @@ void BiquadFilterNode::setPeakingCoefficients(
|
|
|
305
271
|
}
|
|
306
272
|
|
|
307
273
|
void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
|
|
308
|
-
if (frequency <= 0.
|
|
274
|
+
if (frequency <= 0.0 || frequency >= 1.0) {
|
|
309
275
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
310
276
|
return;
|
|
311
277
|
}
|
|
312
278
|
|
|
313
|
-
if (Q <= 0.
|
|
279
|
+
if (Q <= 0.0) {
|
|
314
280
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
315
281
|
return;
|
|
316
282
|
}
|
|
@@ -324,12 +290,12 @@ void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
|
|
|
324
290
|
}
|
|
325
291
|
|
|
326
292
|
void BiquadFilterNode::setAllpassCoefficients(float frequency, float Q) {
|
|
327
|
-
if (frequency <= 0.
|
|
293
|
+
if (frequency <= 0.0 || frequency >= 1.0) {
|
|
328
294
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
329
295
|
return;
|
|
330
296
|
}
|
|
331
297
|
|
|
332
|
-
if (Q <= 0.
|
|
298
|
+
if (Q <= 0.0) {
|
|
333
299
|
setNormalizedCoefficients(-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
334
300
|
return;
|
|
335
301
|
}
|
|
@@ -352,9 +318,6 @@ void BiquadFilterNode::applyFilter() {
|
|
|
352
318
|
auto Q = QParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
|
|
353
319
|
auto gain = gainParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
|
|
354
320
|
|
|
355
|
-
// NyquistFrequency is half of the sample rate.
|
|
356
|
-
// Normalized frequency is therefore:
|
|
357
|
-
// frequency / (sampleRate / 2) = (2 * frequency) / sampleRate
|
|
358
321
|
float normalizedFrequency = frequency / context_->getNyquistFrequency();
|
|
359
322
|
if (detune != 0.0f) {
|
|
360
323
|
normalizedFrequency *= std::pow(2.0f, detune / 1200.0f);
|
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2010 Google Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Redistribution and use in source and binary forms, with or without
|
|
5
|
-
* modification, are permitted provided that the following conditions
|
|
6
|
-
* are met:
|
|
7
|
-
*
|
|
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
|
-
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
14
|
-
* its contributors may be used to endorse or promote products derived
|
|
15
|
-
* from this software without specific prior written permission.
|
|
16
|
-
*
|
|
17
|
-
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
|
18
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
-
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
21
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
24
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
-
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
1
|
#pragma once
|
|
30
2
|
|
|
31
3
|
#include <audioapi/core/AudioNode.h>
|
|
32
4
|
#include <audioapi/core/AudioParam.h>
|
|
33
5
|
#include <audioapi/core/types/BiquadFilterType.h>
|
|
34
|
-
#ifdef AUDIO_API_TEST_SUITE
|
|
35
|
-
#include <gtest/gtest_prod.h>
|
|
36
|
-
#endif
|
|
37
6
|
|
|
38
7
|
#include <algorithm>
|
|
39
8
|
#include <cmath>
|
|
@@ -48,11 +17,6 @@ namespace audioapi {
|
|
|
48
17
|
class AudioBus;
|
|
49
18
|
|
|
50
19
|
class BiquadFilterNode : public AudioNode {
|
|
51
|
-
#ifdef AUDIO_API_TEST_SUITE
|
|
52
|
-
friend class BiquadFilterTest;
|
|
53
|
-
FRIEND_TEST(BiquadFilterTest, GetFrequencyResponse);
|
|
54
|
-
#endif
|
|
55
|
-
|
|
56
20
|
public:
|
|
57
21
|
explicit BiquadFilterNode(BaseAudioContext *context);
|
|
58
22
|
|
|
@@ -66,7 +30,7 @@ class BiquadFilterNode : public AudioNode {
|
|
|
66
30
|
const float *frequencyArray,
|
|
67
31
|
float *magResponseOutput,
|
|
68
32
|
float *phaseResponseOutput,
|
|
69
|
-
|
|
33
|
+
int length);
|
|
70
34
|
|
|
71
35
|
protected:
|
|
72
36
|
std::shared_ptr<AudioBus> processNode(
|