gravix-rtc-react-native 0.0.0-stage → 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/CHANGELOG.md +134 -0
- package/LICENSE +20 -0
- package/LICENSES/Apache-2.0.txt +175 -0
- package/NOTICE +68 -0
- package/README.md +313 -2
- package/android/build.gradle +137 -0
- package/android/consumer-rules.pro +29 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/cpp/CMakeLists.txt +48 -0
- package/android/src/main/cpp/gx_dfn_engine.c +332 -0
- package/android/src/main/cpp/gx_fx_jni.cpp +34 -0
- package/android/src/main/cpp/gx_ns_jni.c +162 -0
- package/android/src/main/cpp/third_party/onnxruntime/LICENSE +21 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_c_api.h +9227 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_ep_c_api.h +3315 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_error_code.h +98 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioHooks.kt +144 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioModule.kt +105 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixNativeAudio.kt +310 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtc.kt +134 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcModule.kt +176 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcPackage.kt +39 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioDeviceKind.java +44 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioManagerUtils.kt +120 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioSwitchManager.java +270 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioType.kt +50 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicCaptureRouter.kt +375 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicDecoder.kt +339 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicInterruptionWatcher.kt +82 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMicRelease.kt +117 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixKernel.kt +191 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixerEngine.kt +617 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/AudioRoutePolicy.kt +137 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GravixCaptureProcessing.kt +67 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureDump.kt +143 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureSwitcher.kt +196 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNoiseProcessor.kt +795 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsLogic.kt +180 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsNative.kt +83 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsStudio.kt +372 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecordStartGuard.kt +76 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecorderSeam.kt +434 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxSingerSource.kt +37 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxVoiceFx.kt +160 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/OtherAppAudioPolicy.kt +143 -0
- package/android/src/main/java/org/webrtc/audio/WebRtcAudioTrackHelper.kt +43 -0
- package/docs/ANDROID_NATIVE_HOOKS.md +102 -0
- package/docs/FEATURE_MATRIX.md +192 -0
- package/docs/IOS_NATIVE_HOOKS.md +190 -0
- package/gravix-rtc-react-native.podspec +49 -0
- package/ios/GravixRtc.h +7 -0
- package/ios/GravixRtc.mm +273 -0
- package/ios/GravixRtcSetup.h +29 -0
- package/ios/GravixRtcSetup.m +52 -0
- package/ios/audio/GravixRtcIosAudio.m +157 -0
- package/ios/audio/GxAudioDevice.h +62 -0
- package/ios/audio/GxAudioDevice.m +857 -0
- package/ios/audio/GxAudioSetup.h +34 -0
- package/ios/audio/GxAudioSetup.m +70 -0
- package/ios/audio/GxCompat.swift +53 -0
- package/ios/audio/GxIosAudio.swift +99 -0
- package/ios/audio/GxMusicController.swift +150 -0
- package/ios/audio/GxMusicPost.swift +362 -0
- package/ios/audio/GxNoiseProcessor.swift +718 -0
- package/ios/audio/GxNsDfn3CoreML.swift +195 -0
- package/ios/audio/GxNsStudioEngine.swift +237 -0
- package/ios/audio/GxNsStudioPack.swift +212 -0
- package/ios/audio/GxVoiceFx.swift +161 -0
- package/ios/audio/gx_adm_state.h +153 -0
- package/ios/gxcore/apple/gx_music_post.c +312 -0
- package/ios/gxcore/apple/gx_pcm.c +30 -0
- package/ios/gxcore/apple/gxns_build.h +19 -0
- package/ios/gxcore/apple/gxns_ios.c +17 -0
- package/ios/gxcore/apple/include/gx_fx.h +3 -0
- package/ios/gxcore/apple/include/gx_music_post.h +88 -0
- package/ios/gxcore/apple/include/gx_ns.h +3 -0
- package/ios/gxcore/apple/include/gx_pcm.h +33 -0
- package/ios/gxcore/apple/include/gxns_ios.h +18 -0
- package/ios/gxcore/apple/include/module.modulemap +10 -0
- package/ios/gxcore/apple/shim/rnnoise.h +2 -0
- package/ios/gxcore/apple/shim/speex_resampler.h +2 -0
- package/ios/gxcore/apple/units/gx_fx_forward.cpp +3 -0
- package/ios/gxcore/apple/units/gx_ns.c +7 -0
- package/ios/gxcore/apple/units/gx_ns_timer.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_celt_lpc.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_denoise.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_kiss_fft.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_pitch.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn_data.c +7 -0
- package/ios/gxcore/apple/units/speexdsp_resample.c +7 -0
- package/ios/resources/ns/DFN3-NOTICE.txt +10 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-APACHE +201 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-MIT +19 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/analytics/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/metadata.json +338 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/model.mil +927 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/weights/weight.bin +0 -0
- package/lib/module/android/bindings.js +49 -0
- package/lib/module/android/bindings.js.map +1 -0
- package/lib/module/android/index.js +13 -0
- package/lib/module/android/index.js.map +1 -0
- package/lib/module/android/micMute.js +341 -0
- package/lib/module/android/micMute.js.map +1 -0
- package/lib/module/android/nativeAudio.js +47 -0
- package/lib/module/android/nativeAudio.js.map +1 -0
- package/lib/module/android/noiseSuppression.js +170 -0
- package/lib/module/android/noiseSuppression.js.map +1 -0
- package/lib/module/android/roomMusic.js +142 -0
- package/lib/module/android/roomMusic.js.map +1 -0
- package/lib/module/android/singerMode.js +31 -0
- package/lib/module/android/singerMode.js.map +1 -0
- package/lib/module/android/voiceEffects.js +65 -0
- package/lib/module/android/voiceEffects.js.map +1 -0
- package/lib/module/audio/AudioManager.js +79 -0
- package/lib/module/audio/AudioManager.js.map +1 -0
- package/lib/module/audio/AudioSession.js +90 -0
- package/lib/module/audio/AudioSession.js.map +1 -0
- package/lib/module/audio/remoteVolume.js +54 -0
- package/lib/module/audio/remoteVolume.js.map +1 -0
- package/lib/module/components/VideoView.js +109 -0
- package/lib/module/components/VideoView.js.map +1 -0
- package/lib/module/features/audioScenario.js +53 -0
- package/lib/module/features/audioScenario.js.map +1 -0
- package/lib/module/features/beauty.js +828 -0
- package/lib/module/features/beauty.js.map +1 -0
- package/lib/module/features/micRelease.js +89 -0
- package/lib/module/features/micRelease.js.map +1 -0
- package/lib/module/features/noiseSuppression.js +213 -0
- package/lib/module/features/noiseSuppression.js.map +1 -0
- package/lib/module/features/roomMusic.js +90 -0
- package/lib/module/features/roomMusic.js.map +1 -0
- package/lib/module/features/roomMusicAndroid.js +294 -0
- package/lib/module/features/roomMusicAndroid.js.map +1 -0
- package/lib/module/features/roomMusicIos.js +250 -0
- package/lib/module/features/roomMusicIos.js.map +1 -0
- package/lib/module/features/roomMusicTypes.js +53 -0
- package/lib/module/features/roomMusicTypes.js.map +1 -0
- package/lib/module/features/screenShare.js +22 -0
- package/lib/module/features/screenShare.js.map +1 -0
- package/lib/module/features/singerMode.js +73 -0
- package/lib/module/features/singerMode.js.map +1 -0
- package/lib/module/features/voiceEffects.js +148 -0
- package/lib/module/features/voiceEffects.js.map +1 -0
- package/lib/module/hooks/context.js +34 -0
- package/lib/module/hooks/context.js.map +1 -0
- package/lib/module/hooks/hooks.js +145 -0
- package/lib/module/hooks/hooks.js.map +1 -0
- package/lib/module/hooks/types.js +4 -0
- package/lib/module/hooks/types.js.map +1 -0
- package/lib/module/hooks/useRoomEvents.js +30 -0
- package/lib/module/hooks/useRoomEvents.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/ios/autoAttach.js +14 -0
- package/lib/module/ios/autoAttach.js.map +1 -0
- package/lib/module/ios/iosAudio.js +149 -0
- package/lib/module/ios/iosAudio.js.map +1 -0
- package/lib/module/join/appStateLifecycle.js +54 -0
- package/lib/module/join/appStateLifecycle.js.map +1 -0
- package/lib/module/micPolicy.js +249 -0
- package/lib/module/micPolicy.js.map +1 -0
- package/lib/module/native/NativeGravixAudio.js +18 -0
- package/lib/module/native/NativeGravixAudio.js.map +1 -0
- package/lib/module/native/NativeGravixRtc.js +13 -0
- package/lib/module/native/NativeGravixRtc.js.map +1 -0
- package/lib/module/native/module.js +23 -0
- package/lib/module/native/module.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills/DOMException.js +22 -0
- package/lib/module/polyfills/DOMException.js.map +1 -0
- package/lib/module/polyfills/early.js +18 -0
- package/lib/module/polyfills/early.js.map +1 -0
- package/lib/module/polyfills/event.js +71 -0
- package/lib/module/polyfills/event.js.map +1 -0
- package/lib/module/polyfills/sha256.js +92 -0
- package/lib/module/polyfills/sha256.js.map +1 -0
- package/lib/module/polyfills/subtleHmac.js +91 -0
- package/lib/module/polyfills/subtleHmac.js.map +1 -0
- package/lib/module/polyfills/textCoding.js +164 -0
- package/lib/module/polyfills/textCoding.js.map +1 -0
- package/lib/module/registerGlobals.js +135 -0
- package/lib/module/registerGlobals.js.map +1 -0
- package/lib/module/unsupported.js +90 -0
- package/lib/module/unsupported.js.map +1 -0
- package/lib/module/version.js +7 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/android/bindings.d.ts +14 -0
- package/lib/typescript/src/android/bindings.d.ts.map +1 -0
- package/lib/typescript/src/android/index.d.ts +9 -0
- package/lib/typescript/src/android/index.d.ts.map +1 -0
- package/lib/typescript/src/android/micMute.d.ts +124 -0
- package/lib/typescript/src/android/micMute.d.ts.map +1 -0
- package/lib/typescript/src/android/nativeAudio.d.ts +40 -0
- package/lib/typescript/src/android/nativeAudio.d.ts.map +1 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts +48 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/android/roomMusic.d.ts +80 -0
- package/lib/typescript/src/android/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/android/singerMode.d.ts +27 -0
- package/lib/typescript/src/android/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/android/voiceEffects.d.ts +30 -0
- package/lib/typescript/src/android/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioManager.d.ts +32 -0
- package/lib/typescript/src/audio/AudioManager.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioSession.d.ts +70 -0
- package/lib/typescript/src/audio/AudioSession.d.ts.map +1 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts +8 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoView.d.ts +44 -0
- package/lib/typescript/src/components/VideoView.d.ts.map +1 -0
- package/lib/typescript/src/features/audioScenario.d.ts +24 -0
- package/lib/typescript/src/features/audioScenario.d.ts.map +1 -0
- package/lib/typescript/src/features/beauty.d.ts +377 -0
- package/lib/typescript/src/features/beauty.d.ts.map +1 -0
- package/lib/typescript/src/features/micRelease.d.ts +28 -0
- package/lib/typescript/src/features/micRelease.d.ts.map +1 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts +64 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusic.d.ts +41 -0
- package/lib/typescript/src/features/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts +60 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts +56 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts +76 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts.map +1 -0
- package/lib/typescript/src/features/screenShare.d.ts +12 -0
- package/lib/typescript/src/features/screenShare.d.ts.map +1 -0
- package/lib/typescript/src/features/singerMode.d.ts +20 -0
- package/lib/typescript/src/features/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/features/voiceEffects.d.ts +46 -0
- package/lib/typescript/src/features/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/hooks/context.d.ts +12 -0
- package/lib/typescript/src/hooks/context.d.ts.map +1 -0
- package/lib/typescript/src/hooks/hooks.d.ts +54 -0
- package/lib/typescript/src/hooks/hooks.d.ts.map +1 -0
- package/lib/typescript/src/hooks/types.d.ts +8 -0
- package/lib/typescript/src/hooks/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts +13 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +37 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ios/autoAttach.d.ts +2 -0
- package/lib/typescript/src/ios/autoAttach.d.ts.map +1 -0
- package/lib/typescript/src/ios/iosAudio.d.ts +96 -0
- package/lib/typescript/src/ios/iosAudio.d.ts.map +1 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts +14 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/micPolicy.d.ts +104 -0
- package/lib/typescript/src/micPolicy.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts +21 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts +31 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts.map +1 -0
- package/lib/typescript/src/native/module.d.ts +7 -0
- package/lib/typescript/src/native/module.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts +3 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/early.d.ts +2 -0
- package/lib/typescript/src/polyfills/early.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/event.d.ts +2 -0
- package/lib/typescript/src/polyfills/event.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/sha256.d.ts +3 -0
- package/lib/typescript/src/polyfills/sha256.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts +37 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts +36 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts.map +1 -0
- package/lib/typescript/src/registerGlobals.d.ts +42 -0
- package/lib/typescript/src/registerGlobals.d.ts.map +1 -0
- package/lib/typescript/src/unsupported.d.ts +42 -0
- package/lib/typescript/src/unsupported.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +3 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/metro/index.js +39 -0
- package/metro/noise-stub.js +10 -0
- package/native/gxfx/include/gx_fx.h +82 -0
- package/native/gxfx/src/gx_fx.cpp +527 -0
- package/native/gxfx/third_party/README.md +4 -0
- package/native/gxfx/third_party/signalsmith-linear/LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-linear/approx.h +191 -0
- package/native/gxfx/third_party/signalsmith-linear/fft.h +1386 -0
- package/native/gxfx/third_party/signalsmith-linear/linear.h +1129 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/approx-cmsisdsp.h +40 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/basic-fill-warnings.h +61 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-accelerate.h +340 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-cmsisdsp.h +307 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-ipp.h +532 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-linear.h +213 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft-double.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-accelerate.h +593 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-cmsisdsp.h +713 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd-dispatch.cpp +6 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd.h +818 -0
- package/native/gxfx/third_party/signalsmith-linear/stft.h +700 -0
- package/native/gxfx/third_party/signalsmith-stretch-LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-stretch.h +1060 -0
- package/native/gxns/CMakeLists.txt +67 -0
- package/native/gxns/include/gx_ns.h +285 -0
- package/native/gxns/src/gx_ns.c +1518 -0
- package/native/gxns/src/gx_ns_timer.c +84 -0
- package/native/gxns/src/gx_ns_timer.h +29 -0
- package/native/gxns/third_party/VENDOR.md +43 -0
- package/native/gxns/third_party/rnnoise/AUTHORS +1 -0
- package/native/gxns/third_party/rnnoise/COPYING +31 -0
- package/native/gxns/third_party/rnnoise/include/rnnoise.h +117 -0
- package/native/gxns/third_party/rnnoise/src/_kiss_fft_guts.h +182 -0
- package/native/gxns/third_party/rnnoise/src/arch.h +261 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.c +172 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.h +45 -0
- package/native/gxns/third_party/rnnoise/src/common.h +48 -0
- package/native/gxns/third_party/rnnoise/src/denoise.c +664 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.c +601 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.h +203 -0
- package/native/gxns/third_party/rnnoise/src/opus_types.h +159 -0
- package/native/gxns/third_party/rnnoise/src/pitch.c +523 -0
- package/native/gxns/third_party/rnnoise/src/pitch.h +149 -0
- package/native/gxns/third_party/rnnoise/src/rnn.c +178 -0
- package/native/gxns/third_party/rnnoise/src/rnn.h +65 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.c +11051 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.h +34 -0
- package/native/gxns/third_party/rnnoise/src/tansig_table.h +45 -0
- package/native/gxns/third_party/speexdsp/AUTHORS +18 -0
- package/native/gxns/third_party/speexdsp/COPYING +35 -0
- package/native/gxns/third_party/speexdsp/arch.h +232 -0
- package/native/gxns/third_party/speexdsp/resample.c +1239 -0
- package/native/gxns/third_party/speexdsp/resample_neon.h +339 -0
- package/native/gxns/third_party/speexdsp/resample_sse.h +128 -0
- package/native/gxns/third_party/speexdsp/speex_resampler.h +343 -0
- package/package.json +186 -4
- package/src/android/bindings.ts +61 -0
- package/src/android/index.ts +10 -0
- package/src/android/micMute.ts +422 -0
- package/src/android/nativeAudio.ts +94 -0
- package/src/android/noiseSuppression.ts +209 -0
- package/src/android/roomMusic.ts +193 -0
- package/src/android/singerMode.ts +53 -0
- package/src/android/voiceEffects.ts +126 -0
- package/src/audio/AudioManager.ts +111 -0
- package/src/audio/AudioSession.ts +190 -0
- package/src/audio/remoteVolume.ts +58 -0
- package/src/components/VideoView.tsx +152 -0
- package/src/features/audioScenario.ts +58 -0
- package/src/features/beauty.ts +1057 -0
- package/src/features/micRelease.ts +108 -0
- package/src/features/noiseSuppression.ts +251 -0
- package/src/features/roomMusic.ts +106 -0
- package/src/features/roomMusicAndroid.ts +310 -0
- package/src/features/roomMusicIos.ts +300 -0
- package/src/features/roomMusicTypes.ts +97 -0
- package/src/features/screenShare.ts +19 -0
- package/src/features/singerMode.ts +70 -0
- package/src/features/voiceEffects.ts +245 -0
- package/src/hooks/context.tsx +38 -0
- package/src/hooks/hooks.ts +247 -0
- package/src/hooks/types.ts +10 -0
- package/src/hooks/useRoomEvents.ts +35 -0
- package/src/index.tsx +134 -0
- package/src/ios/autoAttach.ts +11 -0
- package/src/ios/iosAudio.ts +202 -0
- package/src/join/appStateLifecycle.ts +55 -0
- package/src/micPolicy.ts +312 -0
- package/src/native/NativeGravixAudio.ts +30 -0
- package/src/native/NativeGravixRtc.ts +38 -0
- package/src/native/module.ts +22 -0
- package/src/polyfills/DOMException.ts +20 -0
- package/src/polyfills/early.ts +16 -0
- package/src/polyfills/event.ts +88 -0
- package/src/polyfills/sha256.ts +112 -0
- package/src/polyfills/subtleHmac.ts +124 -0
- package/src/polyfills/textCoding.ts +197 -0
- package/src/registerGlobals.ts +201 -0
- package/src/unsupported.ts +139 -0
- package/src/version.ts +4 -0
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
#ifndef SIGNALSMITH_AUDIO_LINEAR_H
|
|
2
|
+
#define SIGNALSMITH_AUDIO_LINEAR_H
|
|
3
|
+
|
|
4
|
+
#if defined(__FAST_MATH__) && (__apple_build_version__ >= 16000000) && (__apple_build_version__ <= 16000099) && !defined(SIGNALSMITH_IGNORE_BROKEN_APPLECLANG)
|
|
5
|
+
# error Apple Clang 16.0.0 generates incorrect SIMD for ARM. If you HAVE to use this version of Clang, turn off -ffast-math.
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#if defined(_MSC_VER)
|
|
9
|
+
// MSVC can misreport is_trivially_copyable for CRTP bases; approximate intent.
|
|
10
|
+
# define SIGNALSMITH_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copy_constructible<T>::value && std::is_trivially_destructible<T>::value)
|
|
11
|
+
#else
|
|
12
|
+
# define SIGNALSMITH_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#ifndef M_PI
|
|
16
|
+
# define M_PI 3.14159265358979323846
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#include <cmath>
|
|
20
|
+
#include <cassert>
|
|
21
|
+
#include <complex>
|
|
22
|
+
#include <array>
|
|
23
|
+
#include <vector>
|
|
24
|
+
#include <type_traits>
|
|
25
|
+
#include <functional>
|
|
26
|
+
#include <random>
|
|
27
|
+
|
|
28
|
+
#ifdef SIGNALSMITH_LOG_WARNINGS
|
|
29
|
+
# include <iostream>
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
namespace signalsmith { namespace linear {
|
|
33
|
+
|
|
34
|
+
template<typename V>
|
|
35
|
+
using ConstRealPointer = const V *;
|
|
36
|
+
template<typename V>
|
|
37
|
+
using RealPointer = V *;
|
|
38
|
+
|
|
39
|
+
template<typename V>
|
|
40
|
+
using ConstComplexPointer = const std::complex<V> *;
|
|
41
|
+
template<typename V>
|
|
42
|
+
using ComplexPointer = std::complex<V> *;
|
|
43
|
+
|
|
44
|
+
template<typename V>
|
|
45
|
+
struct ConstSplitPointer {
|
|
46
|
+
ConstRealPointer<V> real, imag;
|
|
47
|
+
ConstSplitPointer(ConstRealPointer<V> real, ConstRealPointer<V> imag) : real(real), imag(imag) {}
|
|
48
|
+
|
|
49
|
+
// Array-like access for convenience
|
|
50
|
+
const std::complex<V> operator[](std::ptrdiff_t i) const {
|
|
51
|
+
return {real[i], imag[i]};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
template<typename V>
|
|
56
|
+
struct SplitPointer {
|
|
57
|
+
using Complex = std::complex<V>;
|
|
58
|
+
|
|
59
|
+
RealPointer<V> real, imag;
|
|
60
|
+
SplitPointer(RealPointer<V> real, RealPointer<V> imag) : real(real), imag(imag) {}
|
|
61
|
+
operator ConstSplitPointer<V>() const {
|
|
62
|
+
return {real, imag};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Array-like access for convenience
|
|
66
|
+
const Complex operator[](std::ptrdiff_t i) const {
|
|
67
|
+
return {real[i], imag[i]};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Assignable (if not const) and converts to `std::complex<V>`
|
|
71
|
+
struct Value : public Complex {
|
|
72
|
+
Value(V &_real, V &_imag) : Complex(_real, _imag), _real(_real), _imag(_imag) {}
|
|
73
|
+
|
|
74
|
+
V real() const {
|
|
75
|
+
return _real;
|
|
76
|
+
}
|
|
77
|
+
void real(V v) {
|
|
78
|
+
_real = v;
|
|
79
|
+
Complex::real(v);
|
|
80
|
+
}
|
|
81
|
+
V imag() const {
|
|
82
|
+
return _imag;
|
|
83
|
+
}
|
|
84
|
+
void imag(V v) {
|
|
85
|
+
_imag = v;
|
|
86
|
+
Complex::imag(v);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#define LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(OP) \
|
|
90
|
+
Value & operator OP(const std::complex<V> &other) { \
|
|
91
|
+
std::complex<V>::operator OP(other); \
|
|
92
|
+
_real = Complex::real(); \
|
|
93
|
+
_imag = Complex::imag(); \
|
|
94
|
+
return *this; \
|
|
95
|
+
}
|
|
96
|
+
LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(=);
|
|
97
|
+
LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(+=);
|
|
98
|
+
LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(-=);
|
|
99
|
+
LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(*=);
|
|
100
|
+
LINEAR_SPLIT_POINTER_ASSIGNMENT_OP(/=);
|
|
101
|
+
#undef LINEAR_SPLIT_POINTER_ASSIGNMENT_OP
|
|
102
|
+
|
|
103
|
+
private:
|
|
104
|
+
V &_real;
|
|
105
|
+
V &_imag;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Value operator[](std::ptrdiff_t i) {
|
|
109
|
+
return {real[i], imag[i]};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
template<bool=true>
|
|
114
|
+
struct LinearImpl;
|
|
115
|
+
using Linear = LinearImpl<true>;
|
|
116
|
+
|
|
117
|
+
// Everything we deal with is actually one of these
|
|
118
|
+
template<class BaseExpr>
|
|
119
|
+
struct Expression;
|
|
120
|
+
template<class BaseExpr>
|
|
121
|
+
struct WritableExpression;
|
|
122
|
+
|
|
123
|
+
#define EXPRESSION_NAME(Class, nameExpr) \
|
|
124
|
+
static std::string name() {\
|
|
125
|
+
return nameExpr; \
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Expression templates, which always hold const pointers
|
|
129
|
+
namespace expression {
|
|
130
|
+
// All base Exprs inherit from this, so we can SFINAE-test for them
|
|
131
|
+
struct Base {};
|
|
132
|
+
inline void mustBeExpr(const Base &) {}
|
|
133
|
+
|
|
134
|
+
struct BaseUnary : public Base {};
|
|
135
|
+
struct BaseBinary : public Base {};
|
|
136
|
+
struct BasePointer : public Base {};
|
|
137
|
+
struct BaseConstant : public Base {};
|
|
138
|
+
|
|
139
|
+
template<typename V>
|
|
140
|
+
struct ConstantExpr : public BaseConstant {
|
|
141
|
+
EXPRESSION_NAME(Constant, "V");
|
|
142
|
+
using Unwrapped = ConstantExpr;
|
|
143
|
+
V value;
|
|
144
|
+
|
|
145
|
+
static_assert(SIGNALSMITH_IS_TRIVIALLY_COPYABLE(V), "ConstantExpr<V> values must be trivially copyable");
|
|
146
|
+
|
|
147
|
+
ConstantExpr(V value) : value(value) {}
|
|
148
|
+
|
|
149
|
+
const V get(std::ptrdiff_t) const {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
template<typename V>
|
|
155
|
+
using Arithmetic = decltype(std::declval<V>() + std::declval<V>());
|
|
156
|
+
|
|
157
|
+
// If the constant is one of our assignable complex proxies, use the basic one instead
|
|
158
|
+
template<>
|
|
159
|
+
struct ConstantExpr<typename SplitPointer<float>::Value> : public ConstantExpr<std::complex<float>> {
|
|
160
|
+
using ConstantExpr<std::complex<float>>::ConstantExpr;
|
|
161
|
+
};
|
|
162
|
+
template<>
|
|
163
|
+
struct ConstantExpr<typename SplitPointer<double>::Value> : public ConstantExpr<std::complex<double>> {
|
|
164
|
+
using ConstantExpr<std::complex<double>>::ConstantExpr;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
template<class V, typename=void>
|
|
168
|
+
struct ExprTest {
|
|
169
|
+
using ConstantE = ConstantExpr<Arithmetic<V>>;
|
|
170
|
+
|
|
171
|
+
static_assert(SIGNALSMITH_IS_TRIVIALLY_COPYABLE(ConstantE), "ConstantExpr<V> must be trivially copyable");
|
|
172
|
+
|
|
173
|
+
static ConstantE wrap(const V &v) {
|
|
174
|
+
return {v};
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
template<class Expr>
|
|
178
|
+
struct ExprTest<Expr, decltype(mustBeExpr(std::declval<Expr>()))> {
|
|
179
|
+
static Expr wrap(const Expr &expr) {
|
|
180
|
+
return expr;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
// Constant class, only defined for non-Expr types
|
|
184
|
+
template<class Expr>
|
|
185
|
+
using Constant = typename ExprTest<Expr>::ConstantE;
|
|
186
|
+
|
|
187
|
+
template<class Expr>
|
|
188
|
+
auto ensureExpr(const Expr &expr) -> decltype(ExprTest<Expr>::wrap(expr)) {
|
|
189
|
+
return ExprTest<Expr>::wrap(expr);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// Expressions that just read from a pointer
|
|
193
|
+
template<typename V>
|
|
194
|
+
struct ReadableReal : public BasePointer {
|
|
195
|
+
EXPRESSION_NAME(ReadableReal, "V*");
|
|
196
|
+
using Unwrapped = ReadableReal;
|
|
197
|
+
ConstRealPointer<V> pointer;
|
|
198
|
+
|
|
199
|
+
ReadableReal(ConstRealPointer<V> pointer) : pointer(pointer) {}
|
|
200
|
+
|
|
201
|
+
V get(std::ptrdiff_t i) const {
|
|
202
|
+
return pointer[i];
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
template<typename V>
|
|
206
|
+
struct ReadableComplex : public BasePointer {
|
|
207
|
+
EXPRESSION_NAME(ReadableComplex, "VC*");
|
|
208
|
+
using Unwrapped = ReadableComplex;
|
|
209
|
+
ConstComplexPointer<V> pointer;
|
|
210
|
+
|
|
211
|
+
ReadableComplex(ConstComplexPointer<V> pointer) : pointer(pointer) {}
|
|
212
|
+
|
|
213
|
+
std::complex<V> get(std::ptrdiff_t i) const {
|
|
214
|
+
return pointer[i];
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
template<typename V>
|
|
218
|
+
struct ReadableSplit : public BasePointer {
|
|
219
|
+
EXPRESSION_NAME(ReadableSplit, "VS*");
|
|
220
|
+
using Unwrapped = ReadableSplit;
|
|
221
|
+
ConstSplitPointer<V> pointer;
|
|
222
|
+
|
|
223
|
+
ReadableSplit(ConstSplitPointer<V> pointer) : pointer(pointer) {}
|
|
224
|
+
|
|
225
|
+
std::complex<V> get(std::ptrdiff_t i) const {
|
|
226
|
+
return {pointer.real[i], pointer.imag[i]};
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// Remove `Expression<>` or `WritableExpression<>` layers, and add const to pointers
|
|
231
|
+
template<class E>
|
|
232
|
+
typename E::Unwrapped unwrap(E e) {
|
|
233
|
+
return e;
|
|
234
|
+
}
|
|
235
|
+
template<class E>
|
|
236
|
+
typename E::Unwrapped unwrap(Expression<E> e) {
|
|
237
|
+
return e;
|
|
238
|
+
}
|
|
239
|
+
template<class E>
|
|
240
|
+
typename E::Unwrapped unwrap(WritableExpression<E> e) {
|
|
241
|
+
return e;
|
|
242
|
+
}
|
|
243
|
+
template<class E>
|
|
244
|
+
using Unwrap = decltype(unwrap(std::declval<E>()));
|
|
245
|
+
|
|
246
|
+
template<class Expr>
|
|
247
|
+
using ElementType = typename std::decay<decltype(std::declval<Expr>().get(0))>::type;
|
|
248
|
+
|
|
249
|
+
template<class T>
|
|
250
|
+
static constexpr bool isSplittable() {
|
|
251
|
+
return std::is_same<T, std::complex<float>>::value || std::is_same<T, std::complex<double>>::value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= <=>(since C++20) && || ++ -- , ->* -> ( ) [ ]
|
|
256
|
+
|
|
257
|
+
#define SIGNALSMITH_AUDIO_LINEAR_UNARY_PREFIX(Name, OP) \
|
|
258
|
+
namespace expression { \
|
|
259
|
+
template<class A> \
|
|
260
|
+
struct Name : public BaseUnary { \
|
|
261
|
+
EXPRESSION_NAME(Name, (#Name "<") + A::name() + ">"); \
|
|
262
|
+
using Unwrapped = Name<Unwrap<A>>; \
|
|
263
|
+
A a; \
|
|
264
|
+
Name(const A &a) : a(a) {} \
|
|
265
|
+
auto get(std::ptrdiff_t i) const -> decltype(OP a.get(i)) const { \
|
|
266
|
+
return OP a.get(i); \
|
|
267
|
+
} \
|
|
268
|
+
template<class T> \
|
|
269
|
+
using ReplaceWith = Name<T>;\
|
|
270
|
+
}; \
|
|
271
|
+
template<class A> \
|
|
272
|
+
Name<Unwrap<A>> make##Name(A a) { \
|
|
273
|
+
return {a}; \
|
|
274
|
+
} \
|
|
275
|
+
} \
|
|
276
|
+
template<class A> \
|
|
277
|
+
Expression<expression::Name<expression::Unwrap<A>>> operator OP(const Expression<A> &a) { \
|
|
278
|
+
return {a}; \
|
|
279
|
+
}
|
|
280
|
+
SIGNALSMITH_AUDIO_LINEAR_UNARY_PREFIX(Neg, -)
|
|
281
|
+
// Two negatives cancel out
|
|
282
|
+
template<class A>
|
|
283
|
+
Expression<A> operator-(const Expression<expression::Neg<A>> &expr) { \
|
|
284
|
+
return expr.a;
|
|
285
|
+
}
|
|
286
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_UNARY_PREFIX
|
|
287
|
+
|
|
288
|
+
#define SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX(Name, OP) \
|
|
289
|
+
namespace expression { \
|
|
290
|
+
template<class A, class B> \
|
|
291
|
+
struct Name : public BaseBinary { \
|
|
292
|
+
EXPRESSION_NAME(Name, (#Name "<") + A::name() + "," + B::name() + ">"); \
|
|
293
|
+
using Unwrapped = Name<Unwrap<A>, Unwrap<B>>; \
|
|
294
|
+
A a; \
|
|
295
|
+
B b; \
|
|
296
|
+
Name(const A &a, const B &b) : a(a), b(b) {} \
|
|
297
|
+
auto get(std::ptrdiff_t i) const -> decltype(a.get(i) OP b.get(i)) const { \
|
|
298
|
+
return a.get(i) OP b.get(i); \
|
|
299
|
+
} \
|
|
300
|
+
template<class T1, class T2> \
|
|
301
|
+
using ReplaceWith = Name<T1, T2>;\
|
|
302
|
+
template<class T> \
|
|
303
|
+
using ReplaceWithL = Name<T, B>;\
|
|
304
|
+
template<class T> \
|
|
305
|
+
using ReplaceWithR = Name<A, T>;\
|
|
306
|
+
}; \
|
|
307
|
+
template<class A, class B> \
|
|
308
|
+
Name<Unwrap<A>, Unwrap<B>> make##Name(A a, B b) { \
|
|
309
|
+
return {a, b}; \
|
|
310
|
+
} \
|
|
311
|
+
} \
|
|
312
|
+
template<class A, class B> \
|
|
313
|
+
const Expression<expression::Name<expression::Unwrap<A>, expression::Unwrap<B>>> operator OP(const Expression<A> &a, const Expression<B> &b) { \
|
|
314
|
+
return {a, b}; \
|
|
315
|
+
} \
|
|
316
|
+
template<class A, class B> \
|
|
317
|
+
const Expression<expression::Name<expression::Unwrap<A>, expression::Constant<B>>> operator OP(const Expression<A> &a, const B &b) { \
|
|
318
|
+
return {a, b}; \
|
|
319
|
+
} \
|
|
320
|
+
template<class A, class B> \
|
|
321
|
+
const Expression<expression::Name<expression::Constant<A>, expression::Unwrap<B>>> operator OP(const A &a, const Expression<B> &b) { \
|
|
322
|
+
return {a, b}; \
|
|
323
|
+
}
|
|
324
|
+
SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX(Add, +)
|
|
325
|
+
SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX(Mul, *)
|
|
326
|
+
SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX(Sub, -)
|
|
327
|
+
SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX(Div, /)
|
|
328
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_BINARY_INFIX
|
|
329
|
+
|
|
330
|
+
namespace expression {
|
|
331
|
+
#define SIGNALSMITH_AUDIO_LINEAR_FUNC1(Name, func) \
|
|
332
|
+
template<class A> \
|
|
333
|
+
struct Name; \
|
|
334
|
+
template<class A> \
|
|
335
|
+
Name<Unwrap<A>> make##Name(A a) { \
|
|
336
|
+
return {a}; \
|
|
337
|
+
} \
|
|
338
|
+
template<class A> \
|
|
339
|
+
struct Name : public BaseUnary { \
|
|
340
|
+
EXPRESSION_NAME(Name, (#Name "<") + A::name() + ">"); \
|
|
341
|
+
using Unwrapped = Name<Unwrap<A>>; \
|
|
342
|
+
A a; \
|
|
343
|
+
Name(const A &a) : a(a) {} \
|
|
344
|
+
auto get(std::ptrdiff_t i) const -> decltype(func(a.get(i))) { \
|
|
345
|
+
return func(a.get(i)); \
|
|
346
|
+
} \
|
|
347
|
+
template<class T> \
|
|
348
|
+
using ReplaceWith = Name<T>;\
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
template<class A>
|
|
352
|
+
A fastAbs(const A &a) {
|
|
353
|
+
return std::abs(a);
|
|
354
|
+
}
|
|
355
|
+
template<class A>
|
|
356
|
+
A fastAbs(const std::complex<A> &a) {
|
|
357
|
+
return std::hypot(a.real(), a.imag());
|
|
358
|
+
}
|
|
359
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Abs, fastAbs)
|
|
360
|
+
|
|
361
|
+
template<class A>
|
|
362
|
+
A fastNorm(const A &a) {
|
|
363
|
+
return a*a;
|
|
364
|
+
}
|
|
365
|
+
template<class A>
|
|
366
|
+
A fastNorm(const std::complex<A> &a) {
|
|
367
|
+
A real = a.real(), imag = a.imag();
|
|
368
|
+
return real*real + imag*imag;
|
|
369
|
+
}
|
|
370
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Norm, fastNorm)
|
|
371
|
+
|
|
372
|
+
// Single-argument functions
|
|
373
|
+
// Abs, Norm, Exp, Exp2, Log, Log2, Log10, Sqrt, Cbrt, Ceil, Floor, Trunc, Round, Conj, Real, Imag, Arg, Proj, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh, Asinh, Acosh, Atanh, Erf, Erfc, Tgamma, Lgamma
|
|
374
|
+
|
|
375
|
+
// .abs and .norm are handled above
|
|
376
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp, std::exp)
|
|
377
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp2, std::exp2)
|
|
378
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log, std::log)
|
|
379
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log2, std::log2)
|
|
380
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log10, std::log10)
|
|
381
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sqrt, std::sqrt)
|
|
382
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cbrt, std::cbrt)
|
|
383
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Ceil, std::ceil)
|
|
384
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Floor, std::floor)
|
|
385
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Trunc, std::trunc)
|
|
386
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Round, std::round)
|
|
387
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Conj, std::conj)
|
|
388
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Real, std::real)
|
|
389
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Imag, std::imag)
|
|
390
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Arg, std::arg)
|
|
391
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Proj, std::proj)
|
|
392
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sin, std::sin)
|
|
393
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cos, std::cos)
|
|
394
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tan, std::tan)
|
|
395
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asin, std::asin)
|
|
396
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acos, std::acos)
|
|
397
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atan, std::atan)
|
|
398
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sinh, std::sinh)
|
|
399
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cosh, std::cosh)
|
|
400
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tanh, std::tanh)
|
|
401
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asinh, std::asinh)
|
|
402
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acosh, std::acosh)
|
|
403
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atanh, std::atanh)
|
|
404
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erf, std::erf)
|
|
405
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erfc, std::erfc)
|
|
406
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tgamma, std::tgamma)
|
|
407
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Lgamma, std::lgamma)
|
|
408
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_FUNC1
|
|
409
|
+
|
|
410
|
+
#define SIGNALSMITH_AUDIO_LINEAR_FUNC2(Name, func) \
|
|
411
|
+
template<typename VA, typename VB> \
|
|
412
|
+
auto common##Name(VA a, VB b) -> decltype(func((decltype(a + b))a, (decltype(a + b))b)) { \
|
|
413
|
+
return func((decltype(a + b))a, (decltype(a + b))b); \
|
|
414
|
+
} \
|
|
415
|
+
template<class A, class B> \
|
|
416
|
+
struct Name : public BaseBinary { \
|
|
417
|
+
EXPRESSION_NAME(Name, (#Name "<") + A::name() + "," + B::name() + ">"); \
|
|
418
|
+
using Unwrapped = Name<Unwrap<A>, Unwrap<B>>; \
|
|
419
|
+
A a; \
|
|
420
|
+
B b; \
|
|
421
|
+
Name(const A &a, const B &b) : a(a), b(b) {} \
|
|
422
|
+
auto get(std::ptrdiff_t i) const -> decltype(common##Name(a.get(i), b.get(i))) const { \
|
|
423
|
+
return common##Name(a.get(i), b.get(i)); \
|
|
424
|
+
} \
|
|
425
|
+
template<class T1, class T2> \
|
|
426
|
+
using ReplaceWith = Name<T1, T2>;\
|
|
427
|
+
template<class T> \
|
|
428
|
+
using ReplaceWithL = Name<T, B>;\
|
|
429
|
+
template<class T> \
|
|
430
|
+
using ReplaceWithR = Name<A, T>;\
|
|
431
|
+
}; \
|
|
432
|
+
template<class A, class B> \
|
|
433
|
+
Name<Unwrap<A>, Unwrap<B>> make##Name(A a, B b) { \
|
|
434
|
+
return {a, b}; \
|
|
435
|
+
}
|
|
436
|
+
// Min, Max, Dim, Pow, Atan2, Hypot, Copysign, Polar
|
|
437
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Max, std::fmax)
|
|
438
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Min, std::fmin)
|
|
439
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Dim, std::fdim)
|
|
440
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Pow, std::pow)
|
|
441
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Atan2, std::atan2)
|
|
442
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Hypot, std::hypot)
|
|
443
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Copysign, std::copysign)
|
|
444
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Polar, std::polar)
|
|
445
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_FUNC2
|
|
446
|
+
|
|
447
|
+
} // expression::
|
|
448
|
+
|
|
449
|
+
template<class BaseExpr>
|
|
450
|
+
struct Expression : public BaseExpr {
|
|
451
|
+
template<class ...Args>
|
|
452
|
+
Expression(Args &&...args) : BaseExpr(std::forward<Args>(args)...) {
|
|
453
|
+
static_assert(SIGNALSMITH_IS_TRIVIALLY_COPYABLE(BaseExpr), "BaseExpr must be trivially copyable");
|
|
454
|
+
static_assert(SIGNALSMITH_IS_TRIVIALLY_COPYABLE(Expression), "Expression<> must be trivially copyable");
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
auto operator[](std::ptrdiff_t i) -> decltype(BaseExpr::get(i)) const {
|
|
458
|
+
return BaseExpr::get(i);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
#define SIGNALSMITH_AUDIO_LINEAR_FUNC1(ExprName, methodName) \
|
|
462
|
+
const Expression<expression::ExprName<expression::Unwrap<BaseExpr>>> methodName() const { \
|
|
463
|
+
return {*this}; \
|
|
464
|
+
}
|
|
465
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Abs, abs)
|
|
466
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Norm, norm)
|
|
467
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp, exp)
|
|
468
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp2, exp2)
|
|
469
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log, log)
|
|
470
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log2, log2)
|
|
471
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log10, log10)
|
|
472
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sqrt, sqrt)
|
|
473
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cbrt, cbrt)
|
|
474
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Ceil, ceil)
|
|
475
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Floor, floor)
|
|
476
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Trunc, trunc)
|
|
477
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Round, round)
|
|
478
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Conj, conj)
|
|
479
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Real, real)
|
|
480
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Imag, imag)
|
|
481
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Arg, arg)
|
|
482
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Proj, proj)
|
|
483
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sin, sin)
|
|
484
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cos, cos)
|
|
485
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tan, tan)
|
|
486
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asin, asin)
|
|
487
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acos, acos)
|
|
488
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atan, atan)
|
|
489
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sinh, sinh)
|
|
490
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cosh, cosh)
|
|
491
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tanh, tanh)
|
|
492
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asinh, asinh)
|
|
493
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acosh, acosh)
|
|
494
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atanh, atanh)
|
|
495
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erf, erf)
|
|
496
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erfc, erfc)
|
|
497
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tgamma, tgamma)
|
|
498
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Lgamma, lgamma)
|
|
499
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_FUNC1
|
|
500
|
+
};
|
|
501
|
+
template<class BaseExpr>
|
|
502
|
+
struct WritableExpression : public Expression<BaseExpr> {
|
|
503
|
+
using Expression<BaseExpr>::Expression;
|
|
504
|
+
|
|
505
|
+
WritableExpression(const WritableExpression &other) = default;
|
|
506
|
+
|
|
507
|
+
template<class Expr>
|
|
508
|
+
WritableExpression & operator=(const Expr &expr) {
|
|
509
|
+
this->linear.fill(this->pointer, expression::ensureExpr(expr), this->size);
|
|
510
|
+
return *this;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
WritableExpression & operator=(const WritableExpression &expr) {
|
|
514
|
+
this->linear.fill(this->pointer, expr, this->size);
|
|
515
|
+
return *this;
|
|
516
|
+
}
|
|
517
|
+
#define SIGNALSMITH_AUDIO_ASSIGNMENT_OP(assignOp, binaryOp) \
|
|
518
|
+
template<class E>\
|
|
519
|
+
WritableExpression & operator assignOp(const E &expr) { \
|
|
520
|
+
return *this = (*this) binaryOp expr; \
|
|
521
|
+
}
|
|
522
|
+
SIGNALSMITH_AUDIO_ASSIGNMENT_OP(+=, +)
|
|
523
|
+
SIGNALSMITH_AUDIO_ASSIGNMENT_OP(-=, -)
|
|
524
|
+
SIGNALSMITH_AUDIO_ASSIGNMENT_OP(*=, *)
|
|
525
|
+
SIGNALSMITH_AUDIO_ASSIGNMENT_OP(/=, /)
|
|
526
|
+
#undef SIGNALSMITH_AUDIO_ASSIGNMENT_OP
|
|
527
|
+
|
|
528
|
+
// Use the pointer's `operator[]` instead of the expression
|
|
529
|
+
auto operator[](std::ptrdiff_t i) -> decltype(this->pointer[i]) {
|
|
530
|
+
return this->pointer[i];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
auto operator[](std::ptrdiff_t i) const -> decltype(this->pointer[i]) {
|
|
534
|
+
return this->pointer[i];
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/// Helper class for temporary storage
|
|
539
|
+
template<typename V, bool allowAllocation, size_t alignBytes>
|
|
540
|
+
struct Temporary {
|
|
541
|
+
|
|
542
|
+
Temporary() {}
|
|
543
|
+
Temporary(const Temporary &other) = delete;
|
|
544
|
+
Temporary & operator=(const Temporary &other) = delete;
|
|
545
|
+
~Temporary() {
|
|
546
|
+
if (buffer) delete[] buffer;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
void reserve(size_t size) {
|
|
550
|
+
if (buffer) delete[] buffer;
|
|
551
|
+
buffer = new V[size];
|
|
552
|
+
alignedBuffer = nextAligned(buffer);
|
|
553
|
+
if (alignedBuffer != buffer) {
|
|
554
|
+
delete[] buffer;
|
|
555
|
+
buffer = new V[size + extraAlignmentItems];
|
|
556
|
+
alignedBuffer = nextAligned(buffer);
|
|
557
|
+
}
|
|
558
|
+
start = alignedBuffer;
|
|
559
|
+
end = alignedBuffer + size;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
void clear() {
|
|
563
|
+
start = alignedBuffer;
|
|
564
|
+
fallbacks.resize(0);
|
|
565
|
+
fallbacks.shrink_to_fit();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// You should have one of these every time you're using the temporary storage
|
|
569
|
+
struct Scoped {
|
|
570
|
+
Scoped(Temporary &temporary) : temporary(temporary), restoreStart(temporary.start), fallbackSize(temporary.fallbacks.size()) {}
|
|
571
|
+
|
|
572
|
+
~Scoped() {
|
|
573
|
+
temporary.start = restoreStart;
|
|
574
|
+
temporary.fallbacks.resize(fallbackSize);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
V * operator()(size_t size) {
|
|
578
|
+
return temporary.getChunk(size);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
private:
|
|
582
|
+
Temporary &temporary;
|
|
583
|
+
V *restoreStart;
|
|
584
|
+
size_t fallbackSize;
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
private:
|
|
588
|
+
static constexpr size_t extraAlignmentItems = alignBytes/sizeof(V);
|
|
589
|
+
static V * nextAligned(V *ptr) {
|
|
590
|
+
return (V*)((size_t(ptr) + (alignBytes - 1))&~(alignBytes - 1));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
size_t depth = 0;
|
|
594
|
+
V *start = nullptr, *end = nullptr;
|
|
595
|
+
V *buffer = nullptr, *alignedBuffer = nullptr;
|
|
596
|
+
|
|
597
|
+
std::vector<std::vector<V>> fallbacks;
|
|
598
|
+
|
|
599
|
+
/// Valid until the next call to .clear() or .reserve()
|
|
600
|
+
V * getChunk(size_t size) {
|
|
601
|
+
V *result = start;
|
|
602
|
+
V *newStart = start + size;
|
|
603
|
+
if (newStart > end) {
|
|
604
|
+
#ifdef SIGNALSMITH_LOG_WARNINGS
|
|
605
|
+
std::cerr << "Signalsmith Linear: insufficient temporary storage (" << (newStart > buffer) << "\n";
|
|
606
|
+
#endif
|
|
607
|
+
if (!allowAllocation) return nullptr;
|
|
608
|
+
// OK, actually we ran out of temporary space, so allocate
|
|
609
|
+
fallbacks.emplace_back(size + extraAlignmentItems);
|
|
610
|
+
result = nextAligned(fallbacks.back().data());
|
|
611
|
+
// but we're not happy about it. >:(
|
|
612
|
+
}
|
|
613
|
+
start = nextAligned(newStart);
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
template<class Linear, bool allowAllocation=true, size_t alignBytes=64>
|
|
619
|
+
struct CachedResults {
|
|
620
|
+
using TemporaryFloats = Temporary<float, allowAllocation, alignBytes>;
|
|
621
|
+
using TemporaryDoubles = Temporary<double, allowAllocation, alignBytes>;
|
|
622
|
+
|
|
623
|
+
template<typename V>
|
|
624
|
+
using WritableReal = typename Linear::template WritableReal<V>;
|
|
625
|
+
template<typename V>
|
|
626
|
+
using WritableComplex = typename Linear::template WritableComplex<V>;
|
|
627
|
+
template<typename V>
|
|
628
|
+
using WritableSplit = typename Linear::template WritableSplit<V>;
|
|
629
|
+
|
|
630
|
+
CachedResults(Linear &linear) : linear(linear) {}
|
|
631
|
+
|
|
632
|
+
struct ScopedFloat : public TemporaryFloats::Scoped {
|
|
633
|
+
ScopedFloat(Linear &linear, TemporaryFloats &temporary) : TemporaryFloats::Scoped(temporary), linear(linear) {}
|
|
634
|
+
|
|
635
|
+
template<class Expr>
|
|
636
|
+
ConstRealPointer<float> real(Expr expr, size_t size) {
|
|
637
|
+
auto chunk = (*this)(size);
|
|
638
|
+
linear.fill(chunk, expr, size);
|
|
639
|
+
return chunk;
|
|
640
|
+
}
|
|
641
|
+
ConstRealPointer<float> real(expression::ReadableReal<float> expr, size_t) {
|
|
642
|
+
return expr.pointer;
|
|
643
|
+
}
|
|
644
|
+
ConstRealPointer<float> real(WritableReal<float> expr, size_t) {
|
|
645
|
+
return expr.pointer;
|
|
646
|
+
}
|
|
647
|
+
template<class Expr>
|
|
648
|
+
ConstRealPointer<float> real(Expr expr, size_t size, RealPointer<float> canUse) {
|
|
649
|
+
linear.fill(canUse, expr, size);
|
|
650
|
+
return canUse;
|
|
651
|
+
}
|
|
652
|
+
ConstRealPointer<float> real(expression::ReadableReal<float> expr, size_t, RealPointer<float>) {
|
|
653
|
+
return expr.pointer;
|
|
654
|
+
}
|
|
655
|
+
ConstRealPointer<float> real(WritableReal<float> expr, size_t, RealPointer<float>) {
|
|
656
|
+
return expr.pointer;
|
|
657
|
+
}
|
|
658
|
+
template<class Expr>
|
|
659
|
+
ConstComplexPointer<float> complex(Expr expr, size_t size) {
|
|
660
|
+
auto chunk = (*this)(size*2);
|
|
661
|
+
linear.fill((ComplexPointer<float>)chunk, expr, size);
|
|
662
|
+
return reinterpret_cast<const std::complex<float> *>(chunk);
|
|
663
|
+
}
|
|
664
|
+
ConstComplexPointer<float> complex(expression::ReadableComplex<float> expr, size_t) {
|
|
665
|
+
return expr.pointer;
|
|
666
|
+
}
|
|
667
|
+
ConstComplexPointer<float> complex(WritableComplex<float> expr, size_t) {
|
|
668
|
+
return expr.pointer;
|
|
669
|
+
}
|
|
670
|
+
template<class Expr>
|
|
671
|
+
ConstComplexPointer<float> complex(Expr expr, size_t size, ComplexPointer<float> canUse) {
|
|
672
|
+
linear.fill(canUse, expr, size);
|
|
673
|
+
return canUse;
|
|
674
|
+
}
|
|
675
|
+
ConstComplexPointer<float> complex(expression::ReadableComplex<float> expr, size_t, ComplexPointer<float>) {
|
|
676
|
+
return expr.pointer;
|
|
677
|
+
}
|
|
678
|
+
ConstComplexPointer<float> complex(WritableComplex<float> expr, size_t, ComplexPointer<float>) {
|
|
679
|
+
return expr.pointer;
|
|
680
|
+
}
|
|
681
|
+
template<class Expr>
|
|
682
|
+
ConstSplitPointer<float> split(Expr expr, size_t size) {
|
|
683
|
+
SplitPointer<float> chunk{(*this)(size), (*this)(size)};
|
|
684
|
+
linear.fill(chunk, expr, size);
|
|
685
|
+
return chunk;
|
|
686
|
+
}
|
|
687
|
+
ConstSplitPointer<float> split(expression::ReadableSplit<float> expr, size_t) {
|
|
688
|
+
return expr.pointer;
|
|
689
|
+
}
|
|
690
|
+
ConstSplitPointer<float> split(WritableSplit<float> expr, size_t) {
|
|
691
|
+
return expr.pointer;
|
|
692
|
+
}
|
|
693
|
+
template<class Expr>
|
|
694
|
+
ConstSplitPointer<float> split(Expr expr, size_t size, SplitPointer<float> canUse) {
|
|
695
|
+
linear.fill(canUse, expr, size);
|
|
696
|
+
return canUse;
|
|
697
|
+
}
|
|
698
|
+
ConstSplitPointer<float> split(expression::ReadableSplit<float> expr, size_t, SplitPointer<float>) {
|
|
699
|
+
return expr.pointer;
|
|
700
|
+
}
|
|
701
|
+
ConstSplitPointer<float> split(WritableSplit<float> expr, size_t, SplitPointer<float>) {
|
|
702
|
+
return expr.pointer;
|
|
703
|
+
}
|
|
704
|
+
private:
|
|
705
|
+
Linear &linear;
|
|
706
|
+
};
|
|
707
|
+
ScopedFloat floatScope() {
|
|
708
|
+
return {linear, floats};
|
|
709
|
+
}
|
|
710
|
+
void reserveFloats(size_t size) {
|
|
711
|
+
floats.reserve(size);
|
|
712
|
+
}
|
|
713
|
+
template<class Fn>
|
|
714
|
+
void reserveFloats(size_t size, Fn &&allocationWarning) {
|
|
715
|
+
floats.reserve(size);
|
|
716
|
+
floats.allocationWarning = allocationWarning;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
struct ScopedDouble : public TemporaryDoubles::Scoped {
|
|
720
|
+
ScopedDouble(Linear &linear, TemporaryDoubles &temporary) : TemporaryDoubles::Scoped(temporary), linear(linear) {}
|
|
721
|
+
|
|
722
|
+
template<class Expr>
|
|
723
|
+
ConstRealPointer<double> real(Expr expr, size_t size) {
|
|
724
|
+
auto chunk = (*this)(size);
|
|
725
|
+
linear.fill(chunk, expr, size);
|
|
726
|
+
return chunk;
|
|
727
|
+
}
|
|
728
|
+
ConstRealPointer<double> real(expression::ReadableReal<double> expr, size_t) {
|
|
729
|
+
return expr.pointer;
|
|
730
|
+
}
|
|
731
|
+
ConstRealPointer<double> real(WritableReal<double> expr, size_t) {
|
|
732
|
+
return expr.pointer;
|
|
733
|
+
}
|
|
734
|
+
template<class Expr>
|
|
735
|
+
ConstRealPointer<double> real(Expr expr, size_t size, RealPointer<double> canUse) {
|
|
736
|
+
linear.fill(canUse, expr, size);
|
|
737
|
+
return canUse;
|
|
738
|
+
}
|
|
739
|
+
ConstRealPointer<double> real(expression::ReadableReal<double> expr, size_t, RealPointer<double>) {
|
|
740
|
+
return expr.pointer;
|
|
741
|
+
}
|
|
742
|
+
ConstRealPointer<double> real(WritableReal<double> expr, size_t, RealPointer<double>) {
|
|
743
|
+
return expr.pointer;
|
|
744
|
+
}
|
|
745
|
+
template<class Expr>
|
|
746
|
+
ConstComplexPointer<double> complex(Expr expr, size_t size) {
|
|
747
|
+
auto chunk = (*this)(size*2);
|
|
748
|
+
linear.fill((ComplexPointer<double>)chunk, expr, size);
|
|
749
|
+
return reinterpret_cast<const std::complex<double> *>(chunk);
|
|
750
|
+
}
|
|
751
|
+
ConstComplexPointer<double> complex(expression::ReadableComplex<double> expr, size_t) {
|
|
752
|
+
return expr.pointer;
|
|
753
|
+
}
|
|
754
|
+
ConstComplexPointer<double> complex(WritableComplex<double> expr, size_t) {
|
|
755
|
+
return expr.pointer;
|
|
756
|
+
}
|
|
757
|
+
template<class Expr>
|
|
758
|
+
ConstComplexPointer<double> complex(Expr expr, size_t size, ComplexPointer<double> canUse) {
|
|
759
|
+
linear.fill(canUse, expr, size);
|
|
760
|
+
return canUse;
|
|
761
|
+
}
|
|
762
|
+
ConstComplexPointer<double> complex(expression::ReadableComplex<double> expr, size_t, ComplexPointer<double>) {
|
|
763
|
+
return expr.pointer;
|
|
764
|
+
}
|
|
765
|
+
ConstComplexPointer<double> complex(WritableComplex<double> expr, size_t, ComplexPointer<double>) {
|
|
766
|
+
return expr.pointer;
|
|
767
|
+
}
|
|
768
|
+
template<class Expr>
|
|
769
|
+
ConstSplitPointer<double> split(Expr expr, size_t size) {
|
|
770
|
+
SplitPointer<double> chunk{(*this)(size), (*this)(size)};
|
|
771
|
+
linear.fill(chunk, expr, size);
|
|
772
|
+
return chunk;
|
|
773
|
+
}
|
|
774
|
+
ConstSplitPointer<double> split(expression::ReadableSplit<double> expr, size_t) {
|
|
775
|
+
return expr.pointer;
|
|
776
|
+
}
|
|
777
|
+
ConstSplitPointer<double> split(WritableSplit<double> expr, size_t) {
|
|
778
|
+
return expr.pointer;
|
|
779
|
+
}
|
|
780
|
+
template<class Expr>
|
|
781
|
+
ConstSplitPointer<double> split(Expr expr, size_t size, SplitPointer<double> canUse) {
|
|
782
|
+
linear.fill(canUse, expr, size);
|
|
783
|
+
return canUse;
|
|
784
|
+
}
|
|
785
|
+
ConstSplitPointer<double> split(expression::ReadableSplit<double> expr, size_t, SplitPointer<double>) {
|
|
786
|
+
return expr.pointer;
|
|
787
|
+
}
|
|
788
|
+
ConstSplitPointer<double> split(WritableSplit<double> expr, size_t, SplitPointer<double>) {
|
|
789
|
+
return expr.pointer;
|
|
790
|
+
}
|
|
791
|
+
private:
|
|
792
|
+
Linear &linear;
|
|
793
|
+
};
|
|
794
|
+
ScopedDouble doubleScope() {
|
|
795
|
+
return {linear, doubles};
|
|
796
|
+
}
|
|
797
|
+
void reserveDoubles(size_t size) {
|
|
798
|
+
doubles.reserve(size);
|
|
799
|
+
}
|
|
800
|
+
template<class Fn>
|
|
801
|
+
void reserveDoubles(size_t size, Fn &&allocationWarning) {
|
|
802
|
+
doubles.reserve(size);
|
|
803
|
+
doubles.allocationWarning = allocationWarning;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
private:
|
|
807
|
+
TemporaryFloats floats;
|
|
808
|
+
TemporaryDoubles doubles;
|
|
809
|
+
Linear &linear;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
template<bool useLinear=true>
|
|
813
|
+
struct LinearImplBase {
|
|
814
|
+
using Linear = LinearImpl<useLinear>;
|
|
815
|
+
|
|
816
|
+
template<class V>
|
|
817
|
+
void reserve(size_t) {}
|
|
818
|
+
|
|
819
|
+
template<typename V>
|
|
820
|
+
struct WritableReal {
|
|
821
|
+
EXPRESSION_NAME(WritableReal, "rw V*");
|
|
822
|
+
Linear &linear;
|
|
823
|
+
RealPointer<V> pointer;
|
|
824
|
+
size_t size;
|
|
825
|
+
WritableReal(Linear &linear, RealPointer<V> pointer, size_t size) : linear(linear), pointer(pointer), size(size) {
|
|
826
|
+
static_assert(SIGNALSMITH_IS_TRIVIALLY_COPYABLE(WritableReal), "must be trivially copyable");
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
using Unwrapped = expression::ReadableReal<V>;
|
|
830
|
+
operator Unwrapped() const {
|
|
831
|
+
return {pointer};
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
V get(std::ptrdiff_t i) const {
|
|
835
|
+
return pointer[i];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
V & operator[](std::ptrdiff_t i) {
|
|
839
|
+
return pointer[i];
|
|
840
|
+
}
|
|
841
|
+
const V & operator[](std::ptrdiff_t i) const {
|
|
842
|
+
return pointer[i];
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
template<typename V>
|
|
846
|
+
struct WritableComplex {
|
|
847
|
+
EXPRESSION_NAME(WritableComplex, "rw VC*");
|
|
848
|
+
Linear &linear;
|
|
849
|
+
ComplexPointer<V> pointer;
|
|
850
|
+
size_t size;
|
|
851
|
+
WritableComplex(Linear &linear, ComplexPointer<V> pointer, size_t size) : linear(linear), pointer(pointer), size(size) {}
|
|
852
|
+
|
|
853
|
+
using Unwrapped = expression::ReadableComplex<V>;
|
|
854
|
+
operator Unwrapped() const {
|
|
855
|
+
return {pointer};
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
std::complex<V> get(std::ptrdiff_t i) const {
|
|
859
|
+
return pointer[i];
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
std::complex<V> & operator[](std::ptrdiff_t i) {
|
|
863
|
+
return pointer[i];
|
|
864
|
+
}
|
|
865
|
+
const std::complex<V> & operator[](std::ptrdiff_t i) const {
|
|
866
|
+
return pointer[i];
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
template<typename V>
|
|
870
|
+
struct WritableSplit {
|
|
871
|
+
EXPRESSION_NAME(WritableSplit, "rw VS*");
|
|
872
|
+
Linear &linear;
|
|
873
|
+
SplitPointer<V> pointer;
|
|
874
|
+
size_t size;
|
|
875
|
+
WritableSplit(Linear &linear, SplitPointer<V> pointer, size_t size) : linear(linear), pointer(pointer), size(size) {}
|
|
876
|
+
|
|
877
|
+
using Unwrapped = expression::ReadableSplit<V>;
|
|
878
|
+
operator Unwrapped() const {
|
|
879
|
+
return ConstSplitPointer<V>{pointer.real, pointer.imag};
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
std::complex<V> get(std::ptrdiff_t i) const {
|
|
883
|
+
return {pointer.real[i], pointer.imag[i]};
|
|
884
|
+
}
|
|
885
|
+
auto operator[](std::ptrdiff_t i) -> decltype(pointer[i]) {
|
|
886
|
+
return pointer[i];
|
|
887
|
+
}
|
|
888
|
+
auto operator[](std::ptrdiff_t i) const -> decltype(pointer[i]) {
|
|
889
|
+
return pointer[i];
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
// Arithmetic values get turned into constants
|
|
894
|
+
template<typename V, typename=typename std::enable_if<std::is_arithmetic<V>::value, V>::type>
|
|
895
|
+
Expression<expression::Constant<V>> wrap(V v) {
|
|
896
|
+
return {v};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// Pass `Expression`s through
|
|
900
|
+
template<class V>
|
|
901
|
+
Expression<V> wrap(Expression<V> expr) {
|
|
902
|
+
return expr;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// Wrap a pointer as an expression
|
|
906
|
+
template<typename V>
|
|
907
|
+
Expression<expression::ReadableReal<V>> wrap(ConstRealPointer<V> pointer) {
|
|
908
|
+
return {pointer};
|
|
909
|
+
}
|
|
910
|
+
template<typename V>
|
|
911
|
+
Expression<expression::ReadableComplex<V>> wrap(ConstComplexPointer<V> pointer) {
|
|
912
|
+
return {pointer};
|
|
913
|
+
}
|
|
914
|
+
template<typename V>
|
|
915
|
+
Expression<expression::ReadableSplit<V>> wrap(ConstSplitPointer<V> pointer) {
|
|
916
|
+
return {pointer};
|
|
917
|
+
}
|
|
918
|
+
template<typename V>
|
|
919
|
+
Expression<expression::ReadableSplit<V>> wrap(ConstRealPointer<V> real, ConstRealPointer<V> imag) {
|
|
920
|
+
return {ConstSplitPointer<V>{real, imag}};
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// When a length is supplied, make it writable
|
|
924
|
+
template<typename V>
|
|
925
|
+
WritableExpression<WritableReal<V>> wrap(RealPointer<V> pointer, size_t size) {
|
|
926
|
+
return {self(), pointer, size};
|
|
927
|
+
}
|
|
928
|
+
template<typename V>
|
|
929
|
+
WritableExpression<WritableComplex<V>> wrap(ComplexPointer<V> pointer, size_t size) {
|
|
930
|
+
return {self(), pointer, size};
|
|
931
|
+
}
|
|
932
|
+
template<typename V>
|
|
933
|
+
WritableExpression<WritableSplit<V>> wrap(SplitPointer<V> pointer, size_t size) {
|
|
934
|
+
return {self(), pointer, size};
|
|
935
|
+
}
|
|
936
|
+
template<typename V>
|
|
937
|
+
WritableExpression<WritableSplit<V>> wrap(RealPointer<V> real, RealPointer<V> imag, size_t size) {
|
|
938
|
+
return {self(), SplitPointer<V>{real, imag}, size};
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// Wrap vectors (writable)
|
|
942
|
+
template<typename V, class A>
|
|
943
|
+
WritableExpression<WritableReal<V>> wrap(std::vector<V, A> &vector) {
|
|
944
|
+
return {self(), vector.data(), vector.size()};
|
|
945
|
+
}
|
|
946
|
+
template<typename V, class A>
|
|
947
|
+
WritableExpression<WritableComplex<V>> wrap(std::vector<std::complex<V>, A> &vector) {
|
|
948
|
+
return {self(), vector.data(), vector.size()};
|
|
949
|
+
}
|
|
950
|
+
template<typename V, class A1, class A2>
|
|
951
|
+
WritableExpression<WritableSplit<V>> wrap(std::vector<V, A1> &real, std::vector<V, A2> &imag) {
|
|
952
|
+
SplitPointer<V> pointer{real.data(), imag.data()};
|
|
953
|
+
size_t size = std::min<size_t>(real.size(), imag.size());
|
|
954
|
+
return {self(), pointer, size};
|
|
955
|
+
}
|
|
956
|
+
// and read-only
|
|
957
|
+
template<typename V, class A>
|
|
958
|
+
Expression<expression::ReadableReal<V>> wrap(const std::vector<V, A> &vector) {
|
|
959
|
+
return {vector.data()};
|
|
960
|
+
}
|
|
961
|
+
template<typename V, class A>
|
|
962
|
+
Expression<expression::ReadableComplex<V>> wrap(const std::vector<std::complex<V>, A> &vector) {
|
|
963
|
+
return {vector.data()};
|
|
964
|
+
}
|
|
965
|
+
template<typename V, class A1, class A2>
|
|
966
|
+
Expression<expression::ReadableSplit<V>> wrap(const std::vector<V, A1> &real, const std::vector<V, A2> &imag) {
|
|
967
|
+
ConstSplitPointer<V> pointer{real.data(), imag.data()};
|
|
968
|
+
return {pointer};
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
template<class ...Args>
|
|
972
|
+
auto operator()(Args &&...args) -> decltype(wrap(std::forward<Args>(args)...)) {
|
|
973
|
+
return wrap(std::forward<Args>(args)...);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
template<class Pointer, class Expr>
|
|
977
|
+
void fill(Pointer pointer, Expr expr, size_t size) {
|
|
978
|
+
for (size_t i = 0; i < size; ++i) {
|
|
979
|
+
pointer[i] = expr.get(i);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
template<class V, class Expr>
|
|
983
|
+
void fill(SplitPointer<V> pointer, Expr expr, size_t size) {
|
|
984
|
+
for (size_t i = 0; i < size; ++i) {
|
|
985
|
+
std::complex<V> v = expr.get(i);
|
|
986
|
+
pointer.real[i] = v.real();
|
|
987
|
+
pointer.imag[i] = v.imag();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// Remove the Expression<...> layer, so the simplification template-matching works
|
|
992
|
+
template<class Pointer, class Expr>
|
|
993
|
+
void fill(Pointer pointer, Expression<Expr> expr, size_t size) {
|
|
994
|
+
return self().fill(pointer, (Expr &)expr, size);
|
|
995
|
+
}
|
|
996
|
+
// Separate otherwise it's ambiguous between the two previous ones
|
|
997
|
+
template<class V, class Expr>
|
|
998
|
+
void fill(SplitPointer<V> pointer, Expression<Expr> expr, size_t size) {
|
|
999
|
+
return self().fill(pointer, (Expr &)expr, size);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
#define SIGNALSMITH_AUDIO_LINEAR_FUNC1(ExprName, methodName) \
|
|
1003
|
+
template<class A> \
|
|
1004
|
+
auto methodName(A &&a) -> Expression<decltype(expression::make##ExprName(wrap(std::forward<A>(a))))> { \
|
|
1005
|
+
return expression::make##ExprName(wrap(std::forward<A>(a))); \
|
|
1006
|
+
}
|
|
1007
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Abs, abs)
|
|
1008
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Norm, norm)
|
|
1009
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp, exp)
|
|
1010
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Exp2, exp2)
|
|
1011
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log, log)
|
|
1012
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log2, log2)
|
|
1013
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Log10, log10)
|
|
1014
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sqrt, sqrt)
|
|
1015
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cbrt, cbrt)
|
|
1016
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Ceil, ceil)
|
|
1017
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Floor, floor)
|
|
1018
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Trunc, trunc)
|
|
1019
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Round, round)
|
|
1020
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Conj, conj)
|
|
1021
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Real, real)
|
|
1022
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Imag, imag)
|
|
1023
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Arg, arg)
|
|
1024
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Proj, proj)
|
|
1025
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sin, sin)
|
|
1026
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cos, cos)
|
|
1027
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tan, tan)
|
|
1028
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asin, asin)
|
|
1029
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acos, acos)
|
|
1030
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atan, atan)
|
|
1031
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Sinh, sinh)
|
|
1032
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Cosh, cosh)
|
|
1033
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tanh, tanh)
|
|
1034
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Asinh, asinh)
|
|
1035
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Acosh, acosh)
|
|
1036
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Atanh, atanh)
|
|
1037
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erf, erf)
|
|
1038
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Erfc, erfc)
|
|
1039
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Tgamma, tgamma)
|
|
1040
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC1(Lgamma, lgamma)
|
|
1041
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_FUNC1
|
|
1042
|
+
|
|
1043
|
+
#define SIGNALSMITH_AUDIO_LINEAR_FUNC2(ExprName, methodName) \
|
|
1044
|
+
template<class A, class B> \
|
|
1045
|
+
auto methodName(A a, B b) -> Expression<decltype(expression::make##ExprName(wrap(a), wrap(b)))> { \
|
|
1046
|
+
return expression::make##ExprName(wrap(a), wrap(b)); \
|
|
1047
|
+
}
|
|
1048
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Max, max)
|
|
1049
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Min, min)
|
|
1050
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Dim, dim)
|
|
1051
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Pow, pow)
|
|
1052
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Atan2, atan2)
|
|
1053
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Hypot, hypot)
|
|
1054
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Copysign, copysign)
|
|
1055
|
+
SIGNALSMITH_AUDIO_LINEAR_FUNC2(Polar, polar)
|
|
1056
|
+
#undef SIGNALSMITH_AUDIO_LINEAR_FUNC2
|
|
1057
|
+
|
|
1058
|
+
protected:
|
|
1059
|
+
LinearImplBase(Linear *linearThis) {
|
|
1060
|
+
assert((LinearImplBase *)linearThis == this);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
Linear & self() {
|
|
1064
|
+
return *(Linear *)this;
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
#undef EXPRESSION_NAME
|
|
1068
|
+
|
|
1069
|
+
/* SFINAE template for checking that an expression naturally returns a particular item type
|
|
1070
|
+
|
|
1071
|
+
e.g.
|
|
1072
|
+
template<class A>
|
|
1073
|
+
ItemType<A, float, void> fill(...)
|
|
1074
|
+
*/
|
|
1075
|
+
template<class InputExpr, typename Item, class OutputExpr>
|
|
1076
|
+
using ItemType = typename std::enable_if<
|
|
1077
|
+
std::is_same<expression::ElementType<InputExpr>, Item>::value,
|
|
1078
|
+
OutputExpr
|
|
1079
|
+
>::type;
|
|
1080
|
+
|
|
1081
|
+
// Fallback implementation - this should be specialised (with useLinear=true) with faster methods where available
|
|
1082
|
+
template<bool useLinear>
|
|
1083
|
+
struct LinearImpl : public LinearImplBase<useLinear> {
|
|
1084
|
+
LinearImpl() : LinearImplBase<useLinear>(this), cached(*this) {}
|
|
1085
|
+
|
|
1086
|
+
using LinearImplBase<useLinear>::fill;
|
|
1087
|
+
|
|
1088
|
+
// Override .fill() for specific pointer/expressions which you can do quickly. Calling `cached.realFloat()` etc. will call back to .fill()
|
|
1089
|
+
template<class Expr>
|
|
1090
|
+
void fill(RealPointer<float> pointer, expression::Sqrt<expression::Norm<Expr>> expr, size_t size) {
|
|
1091
|
+
auto floats = cached.floatScope(); // temporary storage - usually not actually needed for specialisations
|
|
1092
|
+
|
|
1093
|
+
auto normExpr = expr.a;
|
|
1094
|
+
auto array = floats.real(normExpr, size); // fill the temporary storage with real values, return a pointer Expr
|
|
1095
|
+
|
|
1096
|
+
// The idea is to use an existing fast function, but this is an example
|
|
1097
|
+
for (size_t i = 0; i < size; ++i) {
|
|
1098
|
+
pointer[i] = std::sqrt(array[i]);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
template<typename V>
|
|
1103
|
+
void reserve(size_t size) {
|
|
1104
|
+
// Assume it's either float or double
|
|
1105
|
+
if (sizeof(V) == sizeof(double)) {
|
|
1106
|
+
cached.reserveDoubles(size);
|
|
1107
|
+
} else if (sizeof(V) == sizeof(float)) {
|
|
1108
|
+
cached.reserveFloats(size);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
private:
|
|
1112
|
+
CachedResults<LinearImpl, true, 16> cached;
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
}}; // namespace
|
|
1116
|
+
|
|
1117
|
+
#if defined(SIGNALSMITH_USE_ACCELERATE)
|
|
1118
|
+
# include "./platform/linear-accelerate.h"
|
|
1119
|
+
#elif defined(SIGNALSMITH_USE_XSIMD)
|
|
1120
|
+
# include "./platform/linear-xsimd.h"
|
|
1121
|
+
#elif defined(SIGNALSMITH_USE_CMSISDSP)
|
|
1122
|
+
# include "./platform/linear-cmsisdsp.h"
|
|
1123
|
+
//#elif defined(SIGNALSMITH_USE_IPP)
|
|
1124
|
+
//# include "./platform/linear-ipp.h"
|
|
1125
|
+
#endif
|
|
1126
|
+
|
|
1127
|
+
#undef SIGNALSMITH_IS_TRIVIALLY_COPYABLE
|
|
1128
|
+
|
|
1129
|
+
#endif // include guard
|