├── SwiftRNBO_Example_multiplatfrom_SwiftUI ├── SwiftRNBO_Example_multiplatfrom_SwiftUI │ ├── RNBO │ │ ├── Export │ │ │ ├── rnbo │ │ │ │ ├── .gitignore │ │ │ │ ├── adapters │ │ │ │ │ ├── juce │ │ │ │ │ │ ├── staticplugin │ │ │ │ │ │ │ ├── PkgInfo │ │ │ │ │ │ │ ├── unity.cpp │ │ │ │ │ │ │ ├── au.cpp │ │ │ │ │ │ │ ├── common.cpp │ │ │ │ │ │ │ ├── vst3.cpp │ │ │ │ │ │ │ ├── VST3Info.plist.in │ │ │ │ │ │ │ ├── UnityInfo.plist.in │ │ │ │ │ │ │ └── AUInfo.plist.in │ │ │ │ │ │ ├── .github │ │ │ │ │ │ │ └── workflows │ │ │ │ │ │ │ │ └── project.yml │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ ├── RNBO_JuceAudioProcessorEditor.h │ │ │ │ │ │ ├── RNBO_JuceAudioProcessorUtils.h │ │ │ │ │ │ └── RNBO_JuceAudioProcessorUtils.cpp │ │ │ │ │ ├── max │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ ├── .github │ │ │ │ │ │ │ └── workflows │ │ │ │ │ │ │ │ └── project.yml │ │ │ │ │ │ ├── RNBO_MaxPresetAdapter.h │ │ │ │ │ │ ├── rnbo_data_loader.h │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ └── rnbo_bufferref.h │ │ │ │ │ └── wasm │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ └── LICENSE │ │ │ │ ├── common │ │ │ │ │ ├── RNBO_Version.h │ │ │ │ │ ├── RNBO_ProbingInterface.h │ │ │ │ │ ├── RNBO_ExternalBase.h │ │ │ │ │ ├── RNBO_PatcherInterfaceImpl.h │ │ │ │ │ ├── RNBO_EventTarget.h │ │ │ │ │ ├── RNBO_ProcessInterface.h │ │ │ │ │ ├── RNBO_EngineLink.h │ │ │ │ │ ├── RNBO_Common.h │ │ │ │ │ ├── RNBO_ListHelpers.h │ │ │ │ │ ├── RNBO_PatcherFactory.h │ │ │ │ │ ├── RNBO_Debug.h │ │ │ │ │ ├── RNBO_ExternalPtr.h │ │ │ │ │ ├── RNBO_BaseInterface.h │ │ │ │ │ ├── RNBO_ParameterInterface.h │ │ │ │ │ ├── RNBO_PatcherEventTarget.h │ │ │ │ │ ├── RNBO_CompilerMacros.h │ │ │ │ │ ├── RNBO_Array.h │ │ │ │ │ ├── RNBO_EngineInterface.h │ │ │ │ │ ├── RNBO_MIDIHelper.h │ │ │ │ │ ├── RNBO_Logger.h │ │ │ │ │ ├── RNBO_PatcherInterface.h │ │ │ │ │ └── RNBO_UniquePtr.h │ │ │ │ ├── cmake │ │ │ │ │ ├── CCache.cmake │ │ │ │ │ ├── SCCache.cmake │ │ │ │ │ ├── RNBOConan.cmake │ │ │ │ │ ├── rnbo_description.h.in │ │ │ │ │ ├── RNBOJuce.cmake │ │ │ │ │ ├── MinGWSTDThreads.cmake │ │ │ │ │ └── RNBODescriptionHeader.cmake │ │ │ │ ├── version.cmake │ │ │ │ ├── src │ │ │ │ │ ├── RNBO_PlatformInterfaceImpl.cpp │ │ │ │ │ ├── RNBO_PatcherFactory.cpp │ │ │ │ │ ├── 3rdparty │ │ │ │ │ │ ├── concurrentqueue │ │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ │ ├── LICENSE.md │ │ │ │ │ │ │ └── internal │ │ │ │ │ │ │ │ └── concurrentqueue_internal_debug.h │ │ │ │ │ │ └── readerwriterqueue │ │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ │ └── LICENSE.md │ │ │ │ │ ├── RNBO_DataBuffer.cpp │ │ │ │ │ ├── RNBO_PresetList.h │ │ │ │ │ ├── RNBO_MaxClang.h │ │ │ │ │ ├── RNBO_List.cpp │ │ │ │ │ ├── RNBO_UnitTests.h │ │ │ │ │ ├── RNBO_ParameterEventQueue.h │ │ │ │ │ ├── platforms │ │ │ │ │ │ ├── nostdlib │ │ │ │ │ │ │ └── RNBO_LoggerNoStdLib.cpp │ │ │ │ │ │ └── stdlib │ │ │ │ │ │ │ └── RNBO_PlatformInterfaceStdLib.h │ │ │ │ │ ├── RNBO_Logger.cpp │ │ │ │ │ ├── RNBO_ParamNameHash.h │ │ │ │ │ ├── RNBO_EmptyEvent.h │ │ │ │ │ ├── RNBO_FileChangeWatcher.cpp │ │ │ │ │ ├── RNBO_FileChangeWatcher.h │ │ │ │ │ ├── RNBO_DataRefList.cpp │ │ │ │ │ ├── RNBO_BinaryData.h │ │ │ │ │ ├── RNBO_PresetList.cpp │ │ │ │ │ ├── RNBO_ServiceNotification.h │ │ │ │ │ ├── RNBO_ParameterInterfaceAsync.h │ │ │ │ │ ├── RNBO_Utils.h │ │ │ │ │ ├── RNBO_Config.h │ │ │ │ │ ├── RNBO_TempoEvent.h │ │ │ │ │ ├── RNBO_DynamicSymbolRegistry.h │ │ │ │ │ ├── RNBO_TransportEvent.h │ │ │ │ │ ├── RNBO_DataRefList.h │ │ │ │ │ ├── RNBO_OutletEvent.h │ │ │ │ │ ├── RNBO_DataRefEvent.h │ │ │ │ │ ├── RNBO_StartupEvent.h │ │ │ │ │ ├── RNBO_BeatTimeEvent.h │ │ │ │ │ ├── RNBO_DataBuffer.h │ │ │ │ │ ├── RNBO_TimeSignatureEvent.h │ │ │ │ │ ├── RNBO_UniversalEvent.h │ │ │ │ │ ├── RNBO_DynamicPatcherFactory.h │ │ │ │ │ ├── RNBO_ParameterInterfaceSync.h │ │ │ │ │ ├── RNBO_EventSender.h │ │ │ │ │ ├── RNBO_EventQueue.h │ │ │ │ │ ├── RNBO_PatcherStateDummy.h │ │ │ │ │ ├── RNBO_ClockEvent.h │ │ │ │ │ ├── RNBO_ParameterInterfaceAsync.cpp │ │ │ │ │ ├── RNBO_ParameterEvent.h │ │ │ │ │ └── RNBO_MidiEvent.h │ │ │ │ ├── test │ │ │ │ │ └── main.cpp │ │ │ │ ├── RNBO.h │ │ │ │ ├── RNBO.cpp │ │ │ │ └── LICENSE │ │ │ ├── dependencies.json │ │ │ ├── media │ │ │ │ └── cherokee.aif │ │ │ └── presets.json │ │ ├── Bindings │ │ │ ├── .DS_Store │ │ │ ├── RNBO-Bridging-Header.h │ │ │ ├── RNBOList.h │ │ │ ├── RNBOList.mm │ │ │ ├── RNBOEventHandler.hpp │ │ │ ├── RNBOAudioUnit.h │ │ │ └── RNBOEventHandlerProtocol.h │ │ └── Interface │ │ │ ├── Synth.aif │ │ │ ├── MIDIHelpers.swift │ │ │ ├── RNBOParameter.swift │ │ │ ├── RNBODescription.swift │ │ │ └── RNBOEventHandler.swift │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Preview Content │ │ └── Preview Assets.xcassets │ │ │ └── Contents.json │ ├── SwiftRNBO_Example_multiplatfrom_SwiftUI.entitlements │ ├── SwiftRNBO_Example_multiplatfrom_SwiftUIApp.swift │ ├── ContentView.swift │ ├── SliderView.swift │ ├── Sliders.swift │ ├── AudioKitKeyboard.swift │ └── Buttons.swift ├── SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── swiftpm │ │ │ └── Package.resolved │ ├── xcuserdata │ │ ├── eldarsadykov.xcuserdatad │ │ │ ├── xcdebugger │ │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ │ └── xcschememanagement.plist │ │ └── alex.xcuserdatad │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── SwiftRNBO_Example_multiplatfrom_SwiftUI.xcscheme └── SwiftRNBO-Example-multiplatfrom-SwiftUI-Info.plist ├── .gitignore ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── LICENSE /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | docs 3 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/PkgInfo: -------------------------------------------------------------------------------- 1 | BNDL???? -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | RNBO/.DS_Store 3 | RNBO/Bindings/.DS_Store 4 | RNBO/Export/.DS_Store 5 | .DS_Store 6 | *.xcuserstate 7 | SwiftRNBO_Example_multiplatfrom_SwiftUI/.DS_Store 8 | **/*.DS_Store 9 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/dependencies.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "rnbuff1", 4 | "file": "media/cherokee.aif" 5 | } 6 | ] -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceammc/SwiftRNBO/HEAD/SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/.DS_Store -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/Synth.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceammc/SwiftRNBO/HEAD/SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/Synth.aif -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/media/cherokee.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceammc/SwiftRNBO/HEAD/SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/media/cherokee.aif -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_Version.h: -------------------------------------------------------------------------------- 1 | //automatically generated 2 | #ifndef _RNBO_Version_H_ 3 | #define _RNBO_Version_H_ 4 | namespace RNBO { 5 | const char * version = "1.2.2"; 6 | } 7 | #endif 8 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBO-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Rnbo-Bridging-Header.h 3 | // JSR 4 | // 5 | // Created by Alex on 12.02.2023. 6 | // 7 | 8 | #import "RNBOAudioUnit.h" 9 | #import "RNBOList.h" 10 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/CCache.cmake: -------------------------------------------------------------------------------- 1 | include_guard(GLOBAL) 2 | 3 | find_program(CCACHE_PROGRAM ccache) 4 | if (CCACHE_PROGRAM) 5 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") 6 | endif() 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/SCCache.cmake: -------------------------------------------------------------------------------- 1 | include_guard(GLOBAL) 2 | 3 | find_program(SCCACHE_PROGRAM sccache) 4 | if (SCCACHE_PROGRAM) 5 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${SCCACHE_PROGRAM}") 6 | endif() 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/version.cmake: -------------------------------------------------------------------------------- 1 | #automatically generated 2 | SET(RNBO_VERSION_MAJOR 1) 3 | SET(RNBO_VERSION_MINOR 2) 4 | SET(RNBO_VERSION_PATCH 2) 5 | SET(RNBO_VERSION_PRERELEASE "null") 6 | SET(RNBO_VERSION "1.2.2") 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/xcuserdata/eldarsadykov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO-Example-multiplatfrom-SwiftUI-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIBackgroundModes 6 | 7 | audio 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.device.audio-input 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_PlatformInterfaceImpl.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // PlatformInterfaceImpl.cpp 3 | // 4 | // Created by Rob Sussman on May 20, 2016 5 | // 6 | // 7 | 8 | #include "platforms/stdlib//RNBO_PlatformInterfaceStdLib.h" 9 | 10 | namespace RNBO { 11 | static PlatformInterfaceStdLib platformInstance; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_PatcherFactory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_PatcherFactory.cpp 3 | // 4 | // Created by DDZ on 11/08/15. 5 | // 6 | // 7 | 8 | #ifndef USE_DYNAMIC_COMPILATION 9 | 10 | #ifdef RNBO_TEST_FILE 11 | // this includes the test file directly when we are not using dynamic compilation 12 | 13 | #include RNBO_TEST_FILE 14 | 15 | #endif 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBOList.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBOList.h 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Эльдар Садыков on 22.02.2023. 6 | // 7 | 8 | #import 9 | 10 | 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface RNBOList : NSObject 15 | 16 | - (void)fromArrayOfNumbers:(NSArray *)array; 17 | - (NSArray *)toArrayOfNumbers; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/wasm/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "RNBO_UnitTests.h" 3 | #include "RNBO.h" 4 | #include "RNBO_MidiStreamParser.h" 5 | 6 | int main (int /*argc*/, char** /*argv*/) 7 | { 8 | RNBO::UnitTestRunner runner; 9 | runner.runAllTests(); 10 | for (auto i = 0; i < runner.getNumResults(); i++) { 11 | auto res = runner.getResult(i); 12 | if (res == nullptr || res->failures > 0) { 13 | return -1; 14 | } 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/3rdparty/concurrentqueue/.gitignore: -------------------------------------------------------------------------------- 1 | *.ipch 2 | *.suo 3 | *.user 4 | *.sdf 5 | *.opensdf 6 | *.exe 7 | *.pdb 8 | build/bin/ 9 | build/*.log 10 | build/msvc12/*.log 11 | build/msvc12/obj/ 12 | build/msvc11/*.log 13 | build/msvc11/obj/ 14 | tests/fuzztests/fuzztests.log 15 | benchmarks/benchmarks.log 16 | tests/CDSChecker/*.o 17 | tests/CDSChecker/*.log 18 | tests/CDSChecker/model-checker/ 19 | tests/relacy/freelist.exe 20 | tests/relacy/spmchash.exe 21 | tests/relacy/log.txt 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/xcuserdata/alex.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftRNBO_Example_multiplatfrom_SwiftUI.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ProbingInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_PROBINGINTERFACE_H_ 2 | #define _RNBO_PROBINGINTERFACE_H_ 3 | 4 | #include "RNBO_Types.h" 5 | 6 | namespace RNBO { 7 | 8 | /** 9 | * @private 10 | */ 11 | class ProbingInterface { 12 | 13 | protected: 14 | 15 | ~ProbingInterface() { } 16 | 17 | public: 18 | 19 | virtual ParameterIndex getProbingChannels(MessageTag outletId) const = 0; 20 | }; 21 | 22 | } // namespace RNBO 23 | 24 | #endif // #ifndef _RNBO_PROBINGINTERFACE_H_ 25 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/unity.cpp: -------------------------------------------------------------------------------- 1 | #define UNITY_INTERFACE_EXPORT __attribute__ ((visibility("default"))) 2 | #define UNITY_INTERFACE_API 3 | 4 | //forward decl 5 | extern "C" int UNITY_INTERFACE_API JuceStatic_UnityGetAudioEffectDefinitions (void*** definitionsPtr); 6 | 7 | //entrypoint trampoline to JUCE 8 | extern "C" UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API UnityGetAudioEffectDefinitions (void*** definitionsPtr) 9 | { 10 | return JuceStatic_UnityGetAudioEffectDefinitions(definitionsPtr); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ExternalBase.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_ExternalBase_h_ 2 | #define _RNBO_ExternalBase_h_ 3 | 4 | #include "RNBO_ProcessInterface.h" 5 | #include "RNBO_EngineLink.h" 6 | #include "RNBO_EventTarget.h" 7 | 8 | namespace RNBO { 9 | 10 | /** 11 | * @private 12 | */ 13 | class ExternalBase : public ProcessInterface, public EngineLink, public EventTarget { 14 | 15 | public: 16 | 17 | virtual ~ExternalBase() { } 18 | 19 | }; 20 | 21 | } // namespace RNBO 22 | 23 | #endif // #ifndef _RNBO_ExternalBase_h_ 24 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/RNBO.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO.h 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_H_ 9 | #define _RNBO_H_ 10 | 11 | #include "src/RNBO_Config.h" 12 | #include "common/RNBO_Types.h" 13 | #include "common/RNBO_ParameterInterface.h" 14 | #include "common/RNBO_BaseInterface.h" 15 | #include "common/RNBO_PatcherFactory.h" 16 | #include "src/RNBO_ParameterEvent.h" 17 | #include "src/RNBO_MidiEvent.h" 18 | #include "src/RNBO_DynamicSymbolRegistry.h" 19 | #include "src/RNBO_CoreObject.h" 20 | 21 | #endif // #ifndef _RNBO_H_ 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/presets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "untitled", 4 | "preset": { 5 | "__sps": { 6 | "filters": {} 7 | }, 8 | "cutoff": { 9 | "value": 0 10 | }, 11 | "freq1": { 12 | "value": 220 13 | }, 14 | "freq2": { 15 | "value": 220 16 | }, 17 | "play": { 18 | "value": 1 19 | }, 20 | "resonance": { 21 | "value": 0.5 22 | }, 23 | "vol1": { 24 | "value": 0 25 | }, 26 | "vol2": { 27 | "value": 0 28 | } 29 | } 30 | } 31 | ] -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/.github/workflows/project.yml: -------------------------------------------------------------------------------- 1 | name: Add Issues and PRs to RNBO Project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | pull_request: 8 | types: 9 | - opened 10 | 11 | jobs: 12 | add-to-project: 13 | name: Add to RNBO Project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/add-to-project@v0.3.0 17 | with: 18 | project-url: https://github.com/orgs/Cycling74/projects/${{ secrets.RNBO_PROJECT_NUMBER }} 19 | github-token: ${{ secrets.RNBO_PROJECT_PAT }} 20 | 21 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/.github/workflows/project.yml: -------------------------------------------------------------------------------- 1 | name: Add Issues and PRs to RNBO Project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | pull_request: 8 | types: 9 | - opened 10 | 11 | jobs: 12 | add-to-project: 13 | name: Add to RNBO Project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/add-to-project@v0.3.0 17 | with: 18 | project-url: https://github.com/orgs/Cycling74/projects/${{ secrets.RNBO_PROJECT_NUMBER }} 19 | github-token: ${{ secrets.RNBO_PROJECT_PAT }} 20 | 21 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/RNBOConan.cmake: -------------------------------------------------------------------------------- 1 | #setup conan, include the module paths, setup the remote 2 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR}) 3 | list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | include_guard(GLOBAL) 6 | 7 | #cloud compiler might have already included conan 8 | if (NOT COMMAND conan_check) 9 | include(${CMAKE_CURRENT_LIST_DIR}/conan.cmake) 10 | endif() 11 | 12 | conan_check(VERSION 1.29.0 REQUIRED) 13 | conan_add_remote( 14 | NAME cycling-public 15 | INDEX 1 16 | URL https://conan-public.cycling74.com 17 | VERIFY_SSL True 18 | ) 19 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUIApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftRNBO_Example_multiplatfrom_SwiftUIApp.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Эльдар Садыков on 19.02.2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct SwiftRNBO_Example_multiplatfrom_SwiftUIApp: App { 12 | @ObservedObject var rnbo = RNBOAudioUnitHostModel() 13 | var body: some Scene { 14 | WindowGroup { 15 | ContentView() 16 | .onAppear { rnbo.connectEventHandler() } 17 | .environmentObject(rnbo) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_PatcherInterfaceImpl.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RNBO_PatcherInterfaceImpl_H_ 3 | // 4 | // Created by Rob Sussman on 1/11/18. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_PatcherInterfaceImpl_H_ 9 | #define _RNBO_PatcherInterfaceImpl_H_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_PatcherInterface.h" 13 | 14 | namespace RNBO { 15 | 16 | class PatcherInterfaceImpl : public PatcherInterface 17 | { 18 | public: 19 | 20 | void destroy() override 21 | { 22 | delete this; 23 | } 24 | 25 | }; 26 | 27 | } // namespace RNBO 28 | 29 | 30 | #endif // #ifndef _RNBO_PatcherInterfaceImpl_H_ 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/RNBO_MaxPresetAdapter.h: -------------------------------------------------------------------------------- 1 | //forward decl 2 | struct _dictionary; 3 | typedef _dictionary t_dictionary; 4 | 5 | namespace RNBO { 6 | class PatcherState; 7 | class CoreObject; 8 | using Preset = PatcherState; 9 | } 10 | 11 | namespace MaxPresetAdapter { 12 | void toDict(const RNBO::Preset& preset, t_dictionary* presetDict); 13 | void fromDict(t_dictionary* presetDict, RNBO::Preset& preset); 14 | //XXX Note, this will block while waiting for the preset 15 | void getObjectPreset(RNBO::CoreObject& o, t_dictionary *presetDict, bool dspIsOn); 16 | void setObjectPreset(RNBO::CoreObject& o, t_dictionary *presetDict); 17 | } 18 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/rnbo_description.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef RNBO_DESCRIPTION_AS_STRING 4 | 5 | namespace RNBO { 6 | const std::string patcher_description( 7 | @PATCHER_DESCRIPTION_JSON@ 8 | ); 9 | 10 | const std::string patcher_presets( 11 | @PATCHER_PRESETS_JSON@ 12 | ); 13 | } 14 | 15 | #else 16 | 17 | #include 18 | 19 | namespace RNBO { 20 | const nlohmann::json patcher_description = nlohmann::json::parse( 21 | std::string( 22 | @PATCHER_DESCRIPTION_JSON@ 23 | ) 24 | ); 25 | 26 | const nlohmann::json patcher_presets = nlohmann::json::parse( 27 | std::string( 28 | @PATCHER_PRESETS_JSON@ 29 | ) 30 | ); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Эльдар Садыков on 19.02.2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | @EnvironmentObject var rnbo: RNBOAudioUnitHostModel 12 | 13 | var body: some View { 14 | VStack(spacing: 0) { 15 | Buttons() 16 | #if !os(tvOS) 17 | if rnbo.showDescription { 18 | DescriptionView() 19 | } else { 20 | Sliders() 21 | AudioKitKeyboard() 22 | } 23 | #endif 24 | } 25 | .padding() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/au.cpp: -------------------------------------------------------------------------------- 1 | //Audio Units entrypoint/factory 2 | //defines pulled from JUCE 3 | 4 | #ifndef AUSDK_EXPORT 5 | #if __GNUC__ 6 | #define AUSDK_EXPORT __attribute__((visibility("default"))) // NOLINT 7 | #else 8 | #warning export? 9 | #endif 10 | #endif 11 | 12 | #define JUCE_AU_ENTRY_POINT_NAME RNBO_Plugin_AUFactory 13 | 14 | //forward decl 15 | extern "C" void* StaticAUExportFactory(const void * desc); 16 | extern "C" void* JUCE_AU_ENTRY_POINT_NAME (const /*AudioComponentDescription*/ void* inDesc); 17 | 18 | AUSDK_EXPORT extern "C" void* JUCE_AU_ENTRY_POINT_NAME (const /*AudioComponentDescription*/ void* inDesc) 19 | { 20 | return StaticAUExportFactory(inDesc); 21 | } 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "keyboard", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/AudioKit/Keyboard.git", 7 | "state" : { 8 | "revision" : "fb589acbbb0854da0fa571ad83c4f1230c2cd280", 9 | "version" : "1.3.6" 10 | } 11 | }, 12 | { 13 | "identity" : "tonic", 14 | "kind" : "remoteSourceControl", 15 | "location" : "https://github.com/AudioKit/Tonic.git", 16 | "state" : { 17 | "revision" : "bd73003b0e6caa90fb1d71b57329b0d609b097ee", 18 | "version" : "1.0.10" 19 | } 20 | } 21 | ], 22 | "version" : 2 23 | } 24 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/RNBOJuce.cmake: -------------------------------------------------------------------------------- 1 | include_guard(GLOBAL) 2 | 3 | set(RNBO_JUCE_VERSION 7.0.3) 4 | 5 | if (RNBO_JUCE_USE_CONAN) 6 | include(${CMAKE_CURRENT_LIST_DIR}/RNBOConan.cmake) 7 | 8 | conan_cmake_configure( 9 | REQUIRES "JUCE/${RNBO_JUCE_VERSION}@c74/testing" 10 | GENERATORS cmake_paths 11 | ) 12 | conan_cmake_autodetect(settings) 13 | conan_cmake_install( 14 | PATH_OR_REFERENCE . 15 | BUILD missing 16 | SETTINGS ${settings} 17 | REMOTE cycling-public 18 | ) 19 | include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake) 20 | find_package(JUCE ${RNBO_JUCE_VERSION} CONFIG REQUIRED) 21 | else() 22 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../../thirdparty/juce ${CMAKE_BINARY_DIR}/juce) 23 | endif() 24 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBOList.mm: -------------------------------------------------------------------------------- 1 | // 2 | // RNBOList.m 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Эльдар Садыков on 22.02.2023. 6 | // 7 | 8 | #include "RNBO.h" 9 | #import "RNBOList.h" 10 | 11 | @implementation RNBOList{ 12 | std::shared_ptr _obj; 13 | } 14 | 15 | - (void)fromArrayOfNumbers:(NSArray *)array { 16 | } 17 | 18 | - (NSArray *)toArrayOfNumbers { 19 | return @[]; 20 | } 21 | 22 | @end 23 | 24 | #pragma mark - 25 | 26 | @interface RNBOList (CxxCounterpart) 27 | - (void)setCxxList:(std::shared_ptr)list; 28 | @end 29 | 30 | @implementation RNBOList (CxxCounterpart) 31 | - (void)setCxxList:(std::shared_ptr)list { 32 | self->_obj = list; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_EventTarget.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_EventTarget.h 3 | // 4 | // Created by Rob Sussman on 1/14/16. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_EventTarget_h_ 9 | #define _RNBO_EventTarget_h_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_EngineLink.h" 13 | 14 | namespace RNBO { 15 | 16 | /** 17 | * @private 18 | */ 19 | class EventTarget { 20 | 21 | public: 22 | 23 | virtual void processMidiEvent(MillisecondTime time, int port, ConstByteArray data, Index length) = 0; 24 | virtual void processClockEvent(MillisecondTime time, ClockId index, bool hasValue, ParameterValue value) = 0; 25 | 26 | protected: 27 | 28 | ~EventTarget() { } 29 | 30 | }; 31 | 32 | } // namespace RNBO 33 | 34 | #endif // #ifndef _RNBO_EventTarget_h_ 35 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DataBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DataBuffer.cpp 3 | // RNBOApp 4 | // 5 | // Created by Rob Sussman on 12/21/15. 6 | // 7 | // 8 | 9 | #include "RNBO_DataBuffer.h" 10 | 11 | namespace RNBO { 12 | 13 | DataBuffer::DataBuffer(size_t size) 14 | : _data(size) 15 | { 16 | 17 | } 18 | 19 | DataBuffer::DataBuffer(const char* dataToCopy, size_t sizeOfDataToCopy) 20 | : _data(sizeOfDataToCopy) 21 | { 22 | memcpy(_data.data(), dataToCopy, _data.size()); 23 | } 24 | 25 | DataBuffer::DataBuffer(const char* stringToCopy) 26 | : _data(strlen(stringToCopy)+1) 27 | { 28 | memcpy(_data.data(), stringToCopy, _data.size()); 29 | } 30 | 31 | void DataBuffer::resize(size_t size) 32 | { 33 | _data.resize(size); 34 | } 35 | 36 | 37 | } // namespace RNBO 38 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/MinGWSTDThreads.cmake: -------------------------------------------------------------------------------- 1 | include_guard(GLOBAL) 2 | 3 | #use mingw_stdthreads for windows cross compiling to work around need for pthreads otherwise 4 | if (CMAKE_SYSTEM_NAME STREQUAL Windows AND CMAKE_CROSSCOMPILING) 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/RNBOConan.cmake) 7 | 8 | #TODO what if we're using clang? 9 | set(BUILD_SYSTEM_IS_MINGW On) 10 | conan_cmake_configure( 11 | REQUIRES mingw_stdthreads/1.0.0-prelatch@c74/testing 12 | GENERATORS cmake_paths 13 | ) 14 | conan_cmake_install( 15 | PATH_OR_REFERENCE . 16 | BUILD missing 17 | ) 18 | include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake) 19 | option(MINGW_STDTHREADS_GENERATE_STDHEADERS "" ON) 20 | add_subdirectory(${CONAN_MINGW_STDTHREADS_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/mingw_stdthreads) 21 | endif() 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ProcessInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_PROCESSINTERFACE_H_ 2 | #define _RNBO_PROCESSINTERFACE_H_ 3 | 4 | #include "RNBO_Types.h" 5 | #include "RNBO_BaseInterface.h" 6 | 7 | namespace RNBO { 8 | 9 | /** 10 | * @brief An interface for signal-rate data processing 11 | */ 12 | class ProcessInterface : public BaseInterface { 13 | 14 | protected: 15 | 16 | ~ProcessInterface() {} 17 | 18 | public: 19 | 20 | virtual void prepareToProcess(number sampleRate, Index maxBlockSize, bool force = false) = 0; 21 | 22 | virtual void process(const SampleValue* const* audioInputs, Index numInputs, 23 | SampleValue* const* audioOutputs, Index numOutputs, 24 | Index sampleFrames) = 0; 25 | 26 | }; 27 | 28 | } // namespace RNBO 29 | 30 | #endif // #ifndef _RNBO_PROCESSINTERFACE_H_ 31 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/3rdparty/readerwriterqueue/.gitignore: -------------------------------------------------------------------------------- 1 | *.ipch 2 | *.suo 3 | *.user 4 | *.sdf 5 | *.opensdf 6 | *.exe 7 | tests/stabtest/msvc10/Debug/ 8 | tests/stabtest/msvc10/Release/ 9 | tests/stabtest/msvc10/obj/ 10 | tests/stabtest/msvc10/log.txt 11 | tests/stabtest/msvc12/Debug/ 12 | tests/stabtest/msvc12/Release/ 13 | tests/stabtest/msvc12/obj/ 14 | tests/stabtest/msvc12/log.txt 15 | tests/stabtest/log.txt 16 | tests/unittests/msvc10/Debug/ 17 | tests/unittests/msvc10/Release/ 18 | tests/unittests/msvc10/obj/ 19 | tests/unittests/msvc12/Debug/ 20 | tests/unittests/msvc12/Release/ 21 | tests/unittests/msvc12/obj/ 22 | tests/CDSChecker/model-checker/ 23 | benchmarks/msvc10/Debug/ 24 | benchmarks/msvc10/Release/ 25 | benchmarks/msvc10/obj/ 26 | benchmarks/msvc12/Debug/ 27 | benchmarks/msvc12/Release/ 28 | benchmarks/msvc12/obj/ 29 | test/ 30 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/common.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | const char * JuceStatic_Plugin_Name() { 5 | return PLUGIN_NAME; 6 | } 7 | uint32_t JuceStatic_Plugin_Code() { 8 | return PLUGIN_CODE_HEX; 9 | } 10 | uint32_t JuceStatic_Plugin_VersionCode() { 11 | return PLUGIN_VERSION_NUM; 12 | } 13 | const char * JuceStatic_Plugin_VersionString() { 14 | return PLUGIN_VERSION; 15 | } 16 | 17 | const char * JuceStatic_Plugin_Manufacturer() { 18 | return PLUGIN_MANUFACTURER_NAME; 19 | } 20 | const char * JuceStatic_Plugin_ManufacturerWebsite() { 21 | return PLUGIN_MANUFACTURER_WEBSITE; 22 | } 23 | const char * JuceStatic_Plugin_ManufacturerEmail() { 24 | return PLUGIN_MANUFACTURER_EMAIL; 25 | } 26 | uint32_t JuceStatic_Plugin_ManufacturerCode() { 27 | return PLUGIN_MANUFACTURER_CODE_HEX; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_PresetList.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_PresetList.h 3 | // RNBO 4 | // 5 | // Created by Samuel Tarakajian on 11/9/20. 6 | // 7 | 8 | #ifndef RNBO_PresetList_h 9 | #define RNBO_PresetList_h 10 | 11 | #include "RNBO_Presets.h" 12 | 13 | #if !(defined(RNBO_NOPRESETS) || defined(RNBO_NOJSONPRESETS)) 14 | 15 | 16 | namespace RNBO { 17 | class PresetList { 18 | public: 19 | PresetList(std::string jsonString); 20 | ~PresetList(); 21 | 22 | size_t size(); 23 | 24 | UniquePresetPtr presetAtIndex(size_t index); 25 | 26 | std::string presetNameAtIndex(size_t index); 27 | 28 | UniquePresetPtr presetWithName(std::string name); 29 | 30 | private: 31 | std::vector> _parsedPresets; 32 | }; 33 | } 34 | 35 | #endif /* RNBO_NOPRESETS */ 36 | 37 | #endif /* RNBO_PresetList_h */ 38 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_EngineLink.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_EngineLink_h_ 2 | #define _RNBO_EngineLink_h_ 3 | 4 | 5 | namespace RNBO { 6 | 7 | class EngineInterface; 8 | class PatcherEventTarget; 9 | 10 | /** 11 | * @private 12 | */ 13 | class EngineLink { 14 | 15 | public: 16 | 17 | void setEngineAndPatcher(EngineInterface *engineInterface, PatcherEventTarget* parentPatcher) { 18 | _engineInterface = engineInterface; 19 | _parentPatcher = parentPatcher; 20 | } 21 | 22 | virtual EngineInterface *getEngine() const { 23 | return _engineInterface; 24 | } 25 | 26 | PatcherEventTarget* getPatcherEventTarget() const { 27 | return _parentPatcher; 28 | } 29 | 30 | protected: 31 | 32 | ~EngineLink() { } 33 | 34 | EngineInterface* _engineInterface = nullptr; 35 | PatcherEventTarget* _parentPatcher = nullptr; 36 | }; 37 | 38 | } // namespace RNBO 39 | 40 | #endif // #ifndef _RNBO_EngineLink_h_ 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/RNBO.cpp: -------------------------------------------------------------------------------- 1 | // rnbo_lib.cpp includes all the source files for RNBO 2 | // making it easy to include RNBO as source into a project. 3 | // Simply add this one file to your compilation. 4 | 5 | #include "RNBO.h" 6 | 7 | #include "src/RNBO_PlatformInterfaceImpl.cpp" // comes first to ensure that platform is available 8 | #include "src/RNBO_CoreObject.cpp" 9 | #include "src/RNBO_DataBuffer.cpp" 10 | #include "src/RNBO_DataRefList.cpp" 11 | #include "src/RNBO_DynamicPatcherFactory.cpp" 12 | #include "src/RNBO_Engine.cpp" 13 | #include "src/RNBO_ExternalLoader.cpp" 14 | #include "src/RNBO_FileChangeWatcher.cpp" 15 | #include "src/RNBO_Logger.cpp" 16 | #include "src/RNBO_MaxClang.cpp" 17 | #include "src/RNBO_ParameterInterfaceAsync.cpp" 18 | #include "src/RNBO_ParameterInterfaceSync.cpp" 19 | #include "src/RNBO_PatcherFactory.cpp" 20 | #include "src/RNBO_PatcherState.cpp" 21 | #include "src/RNBO_PresetList.cpp" 22 | #include "src/RNBO_List.cpp" 23 | #include "src/RNBO_UnitTests.cpp" 24 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_MaxClang.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_MAXCLANG_H_ 2 | #define _RNBO_MAXCLANG_H_ 3 | 4 | #if defined(USE_DYNAMIC_COMPILATION) 5 | 6 | #include "RNBO_ClangInterface.h" 7 | #include "ext.h" 8 | 9 | namespace RNBO { 10 | 11 | class MaxClang : public ClangInterface 12 | { 13 | public: 14 | 15 | MaxClang(); 16 | ~MaxClang(); 17 | 18 | void addPreprocessorDefinition(std::string definition) override; 19 | void addIncludePath(std::string path) override; 20 | void addSymbol(std::string name, void* address) override; 21 | void setOptimizationLevel(OLevel level) override; 22 | bool compile(std::string name, const std::string& source) override; 23 | void getLastErrors(t_dictionary **lastErrors) override; 24 | 25 | void* getFunctionAddress(std::string name) override; 26 | 27 | private: 28 | t_object* _maxclang; 29 | 30 | }; 31 | 32 | } // namespace RNBO 33 | 34 | #endif // #if defined(USE_DYNAMIC_COMPILATION) 35 | 36 | #endif // #ifndef _RNBO_MAXCLANG_H_ 37 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_List.cpp: -------------------------------------------------------------------------------- 1 | #include "RNBO_List.h" 2 | 3 | #ifdef C74_UNIT_TESTS 4 | #include 5 | #include 6 | 7 | namespace ListTests { 8 | using namespace RNBO; 9 | class Tests : public UnitTest { 10 | public: 11 | Tests() 12 | : UnitTest("List Tests") 13 | {} 14 | void runTest() override { 15 | beginTest("listbase bounds"); 16 | listbase l = { 1.0 }; 17 | expectDoesNotThrow(l[0]); 18 | expectThrowsType(l[1], std::out_of_range); 19 | expectThrowsType(l[1] = 20.0, std::out_of_range); 20 | expectThrowsType(l[100], std::out_of_range); 21 | 22 | //shift 23 | expectEquals(l.shift(), 1.0); 24 | expectThrowsType(l.shift(), std::out_of_range); 25 | 26 | //pop 27 | l.push(20.0); 28 | l.push(10.0); 29 | expectEquals(l.pop(), 10.0); 30 | expectEquals(l.pop(), 20.0); 31 | expectEquals(l.pop(), 0.0); 32 | expectEquals(l.pop(), 0.0); 33 | } 34 | }; 35 | Tests tests; 36 | } 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_UnitTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_UnitTests.h 3 | // binding 4 | // 5 | // Created by Stefan Brunner on 27.08.15. 6 | // 7 | // 8 | 9 | #ifndef binding_RNBO_UnitTests_h 10 | #define binding_RNBO_UnitTests_h 11 | 12 | // for now we only want to compile unit tests in the debug version 13 | // the general idea is, that if you want unit tests, you inlcude this file BEFORE including 14 | // RNBO.h, this will define C74_UNIT_TESTS and therefore comoile the unit tests 15 | 16 | // generally running unit tests needs Juce for now, so be aware that your project has to be prepared to use Juce 17 | 18 | #if defined(DEBUG) && !defined(C74_UNIT_TESTS) 19 | #define C74_UNIT_TESTS 20 | #endif 21 | 22 | #ifdef C74_UNIT_TESTS 23 | 24 | #include "JuceHeader.h" 25 | 26 | namespace RNBO { 27 | 28 | class UnitTestRunner : public juce::UnitTestRunner 29 | { 30 | // no modifications needed for now 31 | }; 32 | 33 | } 34 | 35 | #endif // C74_UNIT_TESTS 36 | 37 | 38 | #endif // binding_RNBO_UnitTests_h 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 CEAMMC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/rnbo_data_loader.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_DATA_LOADER_H 2 | #define _RNBO_DATA_LOADER_H 3 | 4 | //RNBO.h seems to have to come first in visual studio or std::numeric_limits<_>::max() breaks.. 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "commonsyms.h" 13 | 14 | extern "C" { 15 | typedef struct _rnbo_data_loader t_rnbo_data_loader; 16 | 17 | void rnbo_data_loader_register(); 18 | 19 | //path or url, it handles it 20 | void rnbo_data_loader_load(t_rnbo_data_loader *x, const char *pathorurl); 21 | t_symbol *rnbo_data_loader_get_last_requested(t_rnbo_data_loader *x); 22 | 23 | bool rnbo_path_is_url(const char *pathOrURL); 24 | } 25 | 26 | namespace RNBO { 27 | void DataLoaderHandoffData( 28 | ExternalDataIndex dataRefIndex, 29 | const ExternalDataRef* ref, 30 | t_rnbo_data_loader *loader, 31 | UpdateRefCallback updateDataRef, 32 | ReleaseRefCallback releaseDataRef 33 | ); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParameterEventQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ParameterEventQueue.h 3 | // Created by Timothy Place on 11.08.15. 4 | // 5 | 6 | #ifndef _RNBO_ParameterEventQueue_h 7 | #define _RNBO_ParameterEventQueue_h 8 | 9 | #include "RNBO_EventQueue.h" 10 | #include "RNBO_ServiceNotification.h" 11 | 12 | namespace RNBO { 13 | 14 | using ParameterEventQueue = EventQueue>; 15 | using ParameterEventQueuePtr = std::unique_ptr>; 16 | #if RNBO_MULTIPRODUCER_QUEUE_SUPPORTED 17 | using SafeParameterEventQueue = EventQueue>; 18 | #else 19 | using SafeParameterEventQueue = ParameterEventQueue; // hack, TODO fix this! 20 | #endif 21 | using ServiceNotificationQueue = EventQueue>; 22 | 23 | using MidiEventQueue = EventQueue>; 24 | 25 | } // namespace RNBO 26 | 27 | #endif // _RNBO_ParameterEventQueue_h 28 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/platforms/nostdlib/RNBO_LoggerNoStdLib.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_LoggerNoStdLib.cpp 3 | // Created: 12 July 2016 2:42:32pm 4 | // Author: jb 5 | // 6 | // 7 | 8 | #include "RNBO_Common.h" 9 | 10 | namespace RNBO { 11 | 12 | Logger consoleInstance; 13 | LoggerInterface* console = &consoleInstance; 14 | 15 | Logger::Logger() 16 | : _outputCallback(&Logger::defaultLogOutputFunction) 17 | { 18 | } 19 | 20 | Logger::~Logger() 21 | { 22 | } 23 | 24 | void Logger::setLoggerOutputCallback(OutputCallback* callback) 25 | { 26 | _outputCallback = callback ? callback : defaultLogOutputFunction; 27 | } 28 | 29 | void Logger::defaultLogOutputFunction(LogLevel level, const char* message) 30 | { 31 | const static char* levelStr[] = { "[INFO]", "[WARNING]", "[ERROR]" }; 32 | String formattedMessage = levelStr[level]; 33 | formattedMessage += "\t"; 34 | formattedMessage += message; 35 | formattedMessage += "\n"; 36 | platform->printMessage(formattedMessage.c_str()); 37 | } 38 | 39 | Logger& Logger::getInstance() 40 | { 41 | return consoleInstance; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/MIDIHelpers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MIDIHelpers.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 19.11.2023. 6 | // 7 | 8 | import Foundation 9 | 10 | enum MidiCommand: UInt8 { 11 | case noteOff = 0x80 12 | case noteOn = 0x90 13 | case polyphonicKeyPressure = 0xA0 14 | case controlChange = 0xB0 15 | case programChange = 0xC0 16 | case channelPressure = 0xD0 17 | case pitchBend = 0xE0 18 | 19 | init?(statusByte: UInt8) { 20 | switch statusByte & 0xF0 { 21 | case MidiCommand.noteOff.rawValue: self = .noteOff 22 | case MidiCommand.noteOn.rawValue: self = .noteOn 23 | case MidiCommand.polyphonicKeyPressure.rawValue: self = .polyphonicKeyPressure 24 | case MidiCommand.controlChange.rawValue: self = .controlChange 25 | case MidiCommand.programChange.rawValue: self = .programChange 26 | case MidiCommand.channelPressure.rawValue: self = .channelPressure 27 | case MidiCommand.pitchBend.rawValue: self = .pitchBend 28 | default: return nil 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_Common.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_Common.h 3 | // 4 | // Created by Rob Sussman on 11/11/15. 5 | // 6 | // 7 | 8 | // This file is included by the generated RNBO code 9 | // and is intended to have the minimal amount necessary to get 10 | // the generated code to build with the goal of speeding up 11 | // dynamic compilation via clang/llvm as much as possible. 12 | 13 | #ifndef _RNBO_Common_h 14 | #define _RNBO_Common_h 15 | 16 | #include "RNBO_PlatformInterface.h" 17 | #include "RNBO_Types.h" 18 | #include "RNBO_List.h" 19 | #include "RNBO_ListHelpers.h" 20 | #include "RNBO_Array.h" 21 | #include "RNBO_String.h" 22 | #include "RNBO_Logger.h" 23 | #include "RNBO_DataRef.h" 24 | #include "RNBO_BaseInterface.h" 25 | #include "RNBO_UniquePtr.h" 26 | #include "RNBO_ExternalPtr.h" 27 | #include "RNBO_EngineInterface.h" 28 | #include "RNBO_EventTarget.h" 29 | #include "RNBO_PatcherStateInterface.h" 30 | #include "RNBO_PatcherInterface.h" 31 | #include "RNBO_PatcherInterfaceImpl.h" 32 | #include "RNBO_PatcherFactory.h" 33 | #include "RNBO_MIDIHelper.h" 34 | #include "RNBO_TimeConverter.h" 35 | 36 | #endif // #ifndef _RNBO_Common_h 37 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 Cycling '74 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Cycling '74 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/vst3.cpp: -------------------------------------------------------------------------------- 1 | //grabed/edited from the VST3 SDK 2 | //https://github.com/steinbergmedia/vst3_pluginterfaces/blob/b8566ef3b2a0cba60a96e3ef2001224c865c8b36/base/fplatform.h 3 | #if defined (_WIN32) 4 | #define PLUGIN_API __stdcall 5 | #define SMTG_EXPORT_SYMBOL __declspec (dllexport) 6 | #elif __gnu_linux__ || __linux__ 7 | #define PLUGIN_API 8 | #define SMTG_EXPORT_SYMBOL __attribute__ ((visibility ("default"))) 9 | #elif __APPLE__ 10 | #define PLUGIN_API 11 | #define SMTG_EXPORT_SYMBOL __attribute__ ((visibility ("default"))) 12 | #else 13 | #pragma error unknown platform 14 | #endif 15 | 16 | //forward decl 17 | class IPluginFactory; 18 | extern "C" IPluginFactory* PLUGIN_API JuceStatic_GetPluginFactory(); 19 | 20 | //VST3 entrypoint 21 | extern "C" SMTG_EXPORT_SYMBOL IPluginFactory* PLUGIN_API GetPluginFactory() 22 | { 23 | return JuceStatic_GetPluginFactory(); 24 | } 25 | 26 | #include 27 | extern "C" { 28 | uint32_t JuceStatic_Plugin_VSTNumMidiInputs() { 29 | return PLUGIN_NUM_MIDI_INPUTS; 30 | } 31 | uint32_t JuceStatic_Plugin_VSTNumMidiOutputs() { 32 | return PLUGIN_NUM_MIDI_OUTPUTS; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Cycling '74 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/wasm/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Cycling '74 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/VST3Info.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CFBundleExecutable 7 | ${MACOSX_BUNDLE_BUNDLE_NAME} 8 | CFBundleIconFile 9 | 10 | CFBundleIdentifier 11 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 12 | CFBundleName 13 | ${MACOSX_BUNDLE_BUNDLE_NAME} 14 | CFBundleDisplayName 15 | ${MACOSX_BUNDLE_BUNDLE_NAME} 16 | CFBundlePackageType 17 | BNDL 18 | CFBundleSignature 19 | ???? 20 | CFBundleShortVersionString 21 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 22 | CFBundleVersion 23 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 24 | NSHumanReadableCopyright 25 | ${MACOSX_BUNDLE_COPYRIGHT} 26 | NSHighResolutionCapable 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/UnityInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CFBundleExecutable 7 | ${MACOSX_BUNDLE_BUNDLE_NAME} 8 | CFBundleIconFile 9 | 10 | CFBundleIdentifier 11 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 12 | CFBundleName 13 | ${MACOSX_BUNDLE_BUNDLE_NAME} 14 | CFBundleDisplayName 15 | ${MACOSX_BUNDLE_BUNDLE_NAME} 16 | CFBundlePackageType 17 | BNDL 18 | CFBundleSignature 19 | ???? 20 | CFBundleShortVersionString 21 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 22 | CFBundleVersion 23 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 24 | NSHumanReadableCopyright 25 | ${MACOSX_BUNDLE_COPYRIGHT} 26 | NSHighResolutionCapable 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ListHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_LISTHELPERS_H_ 2 | #define _RNBO_LISTHELPERS_H_ 3 | 4 | // RNBO_LISTHELPERS.h -- list utilities used by generated code 5 | 6 | #include "RNBO_Std.h" 7 | 8 | namespace RNBO { 9 | 10 | ATTRIBUTE_UNUSED 11 | static list createListCopy(const list& l) 12 | { 13 | list tmp = l; 14 | return tmp; 15 | } 16 | 17 | /* 18 | * assume this statement: 19 | * 20 | * list newlist = oldlist; 21 | * 22 | * in C++ this will make a list copy, in JS this won't, so we need the below function (a NOOP in C++) 23 | */ 24 | ATTRIBUTE_UNUSED 25 | static const list& jsCreateListCopy(const list& l) 26 | { 27 | return l; 28 | } 29 | 30 | template list serializeArrayToList(T *array, size_t size) { 31 | list result; 32 | result.reserve(size); 33 | for (size_t i = 0; i < size; i++) { 34 | result.push((number)(array[i])); 35 | } 36 | return result; 37 | } 38 | 39 | template void deserializeArrayFromList(const list& l, T* result, size_t size) { 40 | for (size_t i = 0; i < size && i < l.length; i++) { 41 | result[i] = (T)(l[i]); 42 | } 43 | } 44 | 45 | } // namespace RNBO 46 | 47 | #endif // #ifndef _RNBO_LISTHELPERS_H_ 48 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/xcuserdata/eldarsadykov.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Keyboard (Playground) 1.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 2 13 | 14 | Keyboard (Playground) 2.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 3 20 | 21 | Keyboard (Playground).xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 0 27 | 28 | SwiftRNBO_Example_multiplatfrom_SwiftUI.xcscheme_^#shared#^_ 29 | 30 | orderHint 31 | 1 32 | 33 | 34 | SuppressBuildableAutocreation 35 | 36 | AFF2B41929A2090200068DD0 37 | 38 | primary 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/SliderView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParameterView.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 18.11.2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct SliderView: View { 11 | @EnvironmentObject var rnbo: RNBOAudioUnitHostModel 12 | @Binding var parameter: RNBOParameter 13 | var body: some View { 14 | HStack { 15 | // let displayName = parameter.displayName != "" ? parameter.displayName : parameter.name.capitalizedSentence 16 | let displayName = parameter.info.paramId 17 | #if os(iOS) 18 | SliderNameLabel(name: displayName) 19 | #endif 20 | Slider(value: $parameter.valueNormalized) { 21 | SliderNameLabel(name: displayName) 22 | } minimumValueLabel: { 23 | SliderValueLabel(value: parameter.info.minimum) 24 | } maximumValueLabel: { 25 | SliderValueLabel(value: parameter.info.maximum) 26 | } 27 | .onChange(of: parameter.valueNormalized) { rnbo.setParameterValueNormalized(to: $0, at: parameter.info.index) } 28 | SliderValueLabel(value: parameter.value) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Sliders.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sliders.swift 3 | // SwiftUI_RNBO_FromScratch_Test 4 | // 5 | // Created by Эльдар Садыков on 13.02.2023. 6 | // 7 | 8 | #if !os(tvOS) 9 | import SwiftUI 10 | 11 | struct Sliders: View { 12 | @EnvironmentObject var rnbo: RNBOAudioUnitHostModel 13 | 14 | var body: some View { 15 | ScrollView { 16 | VStack { 17 | ForEach($rnbo.parameters) { $parameter in 18 | SliderView(parameter: $parameter) 19 | } 20 | } 21 | .padding() 22 | .background() 23 | .padding(.bottom) 24 | } 25 | .frame(minHeight: 100) 26 | .padding(.bottom) 27 | } 28 | } 29 | 30 | struct SliderValueLabel: View { 31 | let value: Double 32 | var body: some View { 33 | Text(String(format: "%.2f", value)) 34 | .frame(minWidth: 50) 35 | } 36 | } 37 | 38 | struct SliderNameLabel: View { 39 | let name: String 40 | var body: some View { 41 | Text(name) 42 | .frame(minWidth: 100) 43 | } 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_PatcherFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_PatcherFactory.h 3 | // 4 | // Created by DDZ on 11/08/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_PatcherFactory_h 9 | #define _RNBO_PatcherFactory_h 10 | 11 | namespace RNBO { 12 | 13 | class PlatformInterface; 14 | class PatcherInterface; 15 | 16 | /** The patcher factory is just a function pointer to a function that 17 | allocates a PatcherInterface derived object and returns the PatcherInterface pointer 18 | Note, PatcherInterface should be freed via the PatcherInterface destroy() method. 19 | */ 20 | using PatcherFactoryFunctionPtr = PatcherInterface*(*)(); 21 | 22 | /** the patcher factory can be obtained via a staticaly linked in function named GetPatcherFactoryFunction 23 | or a DLL can export the function named GetPatcherFactoryFunction in which case the function 24 | should have the following signature. 25 | */ 26 | using GetPatcherFactoryFunctionPtr = PatcherFactoryFunctionPtr(*)(PlatformInterface*); 27 | 28 | } // namespace RNBO 29 | 30 | #ifndef RNBO_NO_PATCHERFACTORY 31 | extern "C" RNBO::PatcherFactoryFunctionPtr GetPatcherFactoryFunction(RNBO::PlatformInterface*); 32 | #endif 33 | 34 | #endif // ifndef _RNBO_PatcherFactory_h 35 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_Debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_DEBUG_H_ 2 | #define _RNBO_DEBUG_H_ 3 | 4 | #include "RNBO_Logger.h" 5 | 6 | // See https://github.com/scottt/debugbreak/blob/master/debugbreak.h for inspiration 7 | 8 | namespace RNBO { 9 | 10 | #ifndef RNBO_ASSERT 11 | 12 | # if defined(__APPLE__) 13 | 14 | #if defined(__thumb__) 15 | #define RNBODebugBreak __asm__ volatile(".inst 0xde01") 16 | #elif defined(__arm__) 17 | #define RNBODebugBreak __asm__ volatile(".inst 0xe7f001f0") 18 | #elif defined(__aarch64__) 19 | #define RNBODebugBreak __builtin_trap() 20 | #else 21 | #define RNBODebugBreak asm("int3") 22 | #endif 23 | 24 | #elif defined(_MSC_VER) 25 | #define RNBODebugBreak __debugbreak() 26 | #else 27 | #define RNBODebugBreak (0) 28 | #endif 29 | 30 | #define RNBO_STR_HELPER(x) #x 31 | #define RNBO_STR(x) RNBO_STR_HELPER(x) 32 | 33 | #if defined(_DEBUG) || defined(DEBUG) 34 | 35 | #define RNBO_ASSERT(condition) \ 36 | if (!(condition)) { console->log("ASSERTION - failed condition: %s\n", RNBO_STR(condition)); RNBODebugBreak; } 37 | 38 | #define RNBO_DEBUG 1 39 | 40 | #else 41 | #define RNBO_ASSERT(condition) 42 | #endif 43 | 44 | #endif // #ifndef RNBO_ASSERT 45 | 46 | } // namespace RNBO 47 | 48 | #endif // #ifndef _RNBO_DEBUG_H_ 49 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_Logger.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_Logger.cpp 3 | // Created: 25 Jan 2016 4:07:31pm 4 | // Author: stb 5 | // 6 | // 7 | 8 | #include "RNBO_Logger.h" 9 | #include "RNBO_DynamicSymbolRegistry.h" 10 | 11 | namespace RNBO { 12 | 13 | static Logger s_logger_instance; 14 | LoggerInterface* console = &s_logger_instance; 15 | static DynamicSymbolRegistrar ConsoleRegisteredSymbol("console" , reinterpret_cast(&console)); 16 | 17 | Logger::Logger() 18 | : _outputCallback(&Logger::defaultLogOutputFunction) 19 | { 20 | } 21 | 22 | Logger::~Logger() 23 | { 24 | } 25 | 26 | void Logger::setLoggerOutputCallback(OutputCallback* callback) 27 | { 28 | _outputCallback = callback ? callback : defaultLogOutputFunction; 29 | } 30 | 31 | void Logger::defaultLogOutputFunction(LogLevel level, const char* message) 32 | { 33 | const static char* levelStr[] = { "[INFO]", "[WARNING]", "[ERROR]" }; 34 | String formattedMessage = levelStr[level]; 35 | formattedMessage += "\t"; 36 | formattedMessage += message; 37 | formattedMessage += "\n"; 38 | Platform::get()->printMessage(formattedMessage.c_str()); 39 | } 40 | 41 | Logger& Logger::getInstance() 42 | { 43 | return s_logger_instance; 44 | } 45 | 46 | } // namespace RNBO 47 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParamNameHash.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ParamNameHash.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_ParamNameHash_H_ 7 | #define _RNBO_ParamNameHash_H_ 8 | 9 | #include "RNBO_Types.h" 10 | 11 | #ifndef RNBO_NOSTDLIB 12 | #include 13 | #include 14 | #endif 15 | 16 | namespace RNBO { 17 | 18 | class ParamNameHash { 19 | public: 20 | void update(const PatcherInterface *patcher) { 21 | #ifndef RNBO_NOSTDLIB 22 | _paramNames.clear(); 23 | for (ParameterIndex i = 0; i < patcher->getNumParameters(); i++) { 24 | const char* paramid = patcher->getParameterId(i); 25 | _paramNames.emplace(std::make_pair(paramid, i)); 26 | } 27 | #endif 28 | } 29 | 30 | ParameterIndex get(const char* paramid) const { 31 | #ifdef RNBO_NOSTDLIB 32 | // not supported without standard library 33 | RNBO_ASSERT(false); 34 | return INVALID_INDEX; 35 | #else 36 | auto match = _paramNames.find(paramid); 37 | if (match != _paramNames.end()) { 38 | return match->second; 39 | } 40 | 41 | return INVALID_INDEX; 42 | #endif 43 | } 44 | 45 | private: 46 | #ifndef RNBO_NOSTDLIB 47 | std::map _paramNames; 48 | #endif 49 | }; 50 | 51 | } // namespace RNBO 52 | 53 | 54 | #endif // #ifndef _RNBO_ParamNameHash_H_ 55 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/AudioKitKeyboard.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AudioKitKeyboard.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 17.11.2023. 6 | // 7 | 8 | #if !os(tvOS) 9 | import Keyboard 10 | import SwiftUI 11 | 12 | struct AudioKitKeyboard: View { 13 | @EnvironmentObject var rnbo: RNBOAudioUnitHostModel 14 | @State private var latch = false 15 | var body: some View { 16 | VStack { 17 | HStack { 18 | Toggle(isOn: $latch) { 19 | Text("Latch keys") 20 | } 21 | Spacer() 22 | } 23 | Keyboard(latching: latch) { pitch, point in 24 | let pitch = UInt8(pitch.midiNoteNumber) 25 | let velocity = latch ? 60 : UInt8(point.y * 127) 26 | rnbo.sendNoteOn(pitch, velocity: velocity) 27 | } noteOff: { pitch in 28 | let pitch = UInt8(pitch.midiNoteNumber) 29 | rnbo.sendNoteOff(pitch) 30 | } 31 | .frame(height: 100) 32 | .frame(minWidth: 600) 33 | } 34 | } 35 | } 36 | 37 | #Preview { 38 | AudioKitKeyboard() 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_EmptyEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_EmptyEvent.h 3 | // 4 | // Created by Rob Sussman on 9/18/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_EmptyEvent_h 9 | #define _RNBO_EmptyEvent_h 10 | 11 | namespace RNBO { 12 | 13 | /** 14 | * The EmptyEvent allows us to make an EventVariant that does not yet have an event. 15 | * 16 | * Useful, for example, to support calling a function that takes a reference to an EventVariant 17 | * and then fills in said EventVariant. 18 | */ 19 | class EmptyEvent { 20 | 21 | public: 22 | EmptyEvent() 23 | : _eventTarget(nullptr) 24 | { } 25 | 26 | bool operator==(const EmptyEvent& rhs) const 27 | { 28 | RNBO_UNUSED(rhs); 29 | return true; 30 | } 31 | 32 | // need a getTime() method for GetTimeVisitor to work. 33 | MillisecondTime getTime() const { return 0; } 34 | EventTarget* getEventTarget() const { return _eventTarget; } 35 | 36 | // debugging 37 | void dumpEvent() const { /* fprintf(stdout, "EmptyEvent\n"); */ } 38 | 39 | private: 40 | 41 | friend class EventVariant; 42 | 43 | void setTime(MillisecondTime eventTime) 44 | { 45 | RNBO_UNUSED(eventTime); 46 | } 47 | 48 | EventTarget *_eventTarget; 49 | 50 | }; 51 | 52 | } // namespace RNBO 53 | 54 | 55 | #endif // #ifndef _RNBO_EmptyEvent_h 56 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "1x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "2x", 16 | "size" : "16x16" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "1x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "2x", 26 | "size" : "32x32" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "2x", 36 | "size" : "128x128" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "1x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "2x", 46 | "size" : "256x256" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "1x", 51 | "size" : "512x512" 52 | }, 53 | { 54 | "idiom" : "mac", 55 | "scale" : "2x", 56 | "size" : "512x512" 57 | } 58 | ], 59 | "info" : { 60 | "author" : "xcode", 61 | "version" : 1 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_FileChangeWatcher.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_FileChangeWatcher.cpp 3 | // RNBOApp 4 | // 5 | // Created by Rob Sussman on 12/11/15. 6 | // 7 | // 8 | 9 | #include "RNBO_FileChangeWatcher.h" 10 | 11 | #if defined(USE_DYNAMIC_COMPILATION) && !defined(RNBO_NO_JUCE) 12 | 13 | namespace RNBO { 14 | 15 | FileChangeWatcher::FileChangeWatcher(const char* fullPathToFile, 16 | std::function callback) 17 | : _fileToWatch(File(fullPathToFile)) 18 | , _callback(callback) 19 | { 20 | // init _lastModificationTime to avoid an initial notification 21 | _lastModificationTime = _fileToWatch.getLastModificationTime(); 22 | startTimer(1000); 23 | } 24 | 25 | FileChangeWatcher::~FileChangeWatcher() 26 | { 27 | 28 | } 29 | 30 | bool FileChangeWatcher::fileExists() const 31 | { 32 | return _fileToWatch.exists(); 33 | } 34 | 35 | const char* FileChangeWatcher::getFullPathToWatchedFile() const 36 | { 37 | return _fileToWatch.getFullPathName().toRawUTF8(); 38 | } 39 | 40 | void FileChangeWatcher::timerCallback() 41 | { 42 | Time modtime = _fileToWatch.getLastModificationTime(); 43 | if (_lastModificationTime != modtime) { 44 | _lastModificationTime = modtime; 45 | _callback(this); 46 | } 47 | } 48 | 49 | } // namespace RNBO 50 | 51 | #endif // #ifdef USE_DYNAMIC_COMPILATION 52 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBOEventHandler.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBOEventHandler.h 3 | // 4 | // 5 | // Created by Alex on 21.02.2023. 6 | // 7 | 8 | #pragma once 9 | 10 | #import "RNBOEventHandlerProtocol.h" 11 | 12 | #include "RNBO.h" 13 | 14 | #import 15 | 16 | class RNBOEventHandler: public RNBO::EventHandler { 17 | NSObject *_obj; 18 | 19 | public: 20 | RNBOEventHandler(NSObject *handler = nil); 21 | 22 | inline void setEventHandler(NSObject *obj) { 23 | _obj = obj; 24 | } 25 | 26 | virtual void eventsAvailable() override final; 27 | 28 | virtual void handleParameterEvent(const RNBO::ParameterEvent& event) override final; 29 | virtual void handleMidiEvent(const RNBO::MidiEvent& event) override final; 30 | virtual void handleMessageEvent(const RNBO::MessageEvent& event) override final; 31 | virtual void handlePresetEvent(const RNBO::PresetEvent& event) override final; 32 | virtual void handleTempoEvent(const RNBO::TempoEvent& event) override final; 33 | virtual void handleTransportEvent(const RNBO::TransportEvent& event) override final; 34 | virtual void handleBeatTimeEvent(const RNBO::BeatTimeEvent& event) override final; 35 | virtual void handleTimeSignatureEvent(const RNBO::TimeSignatureEvent& event) override final; 36 | virtual void handleStartupEvent(const RNBO::StartupEvent& event) override final; 37 | }; 38 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ExternalPtr.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ExternalPtr.h 3 | // Created: 10 Feb 2016 2:46:28pm 4 | // Author: Stefan Brunner 5 | // 6 | // 7 | 8 | #ifndef _RNBO_EXTERNALPTR_H_ 9 | #define _RNBO_EXTERNALPTR_H_ 10 | 11 | #include "RNBO_UniquePtr.h" 12 | #include "RNBO_ExternalBase.h" 13 | 14 | namespace RNBO { 15 | 16 | /** 17 | * @private 18 | */ 19 | template 20 | class HolderPtr 21 | { 22 | public: 23 | HolderPtr() 24 | : _ptr(nullptr) 25 | {} 26 | 27 | HolderPtr(T* ptr) { 28 | _ptr.reset(ptr); 29 | } 30 | 31 | UniquePtr& operator->() { 32 | return _ptr; 33 | } 34 | 35 | const UniquePtr& operator->() const { 36 | return _ptr; 37 | } 38 | 39 | bool operator!() 40 | { 41 | return !_ptr; 42 | } 43 | 44 | T* get() const 45 | { 46 | return _ptr.get(); 47 | } 48 | 49 | explicit operator const T*() const { return _ptr.get(); } 50 | 51 | private: 52 | UniquePtr _ptr; 53 | }; 54 | 55 | template 56 | inline bool operator==(const T1* lhs, const HolderPtr& rhs) 57 | { 58 | return lhs == static_cast(rhs.get()); 59 | } 60 | 61 | template 62 | inline bool operator==(const HolderPtr& lhs, const T2* rhs) 63 | { 64 | return static_cast(lhs.get()) == rhs; 65 | } 66 | 67 | using ExternalPtr = HolderPtr; 68 | 69 | } 70 | 71 | #endif // #ifndef _RNBO_EXTERNALPTR_H_ 72 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_BaseInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_BASEINTERFACE_H_ 2 | #define _RNBO_BASEINTERFACE_H_ 3 | 4 | #include "RNBO_Types.h" 5 | #include "RNBO_ParameterInterface.h" 6 | 7 | namespace RNBO { 8 | 9 | /** 10 | * Base class for objects which, like CoreObject, expose an interface to exported RNBO code. 11 | */ 12 | class BaseInterface : public ParameterInterface { 13 | 14 | public: 15 | 16 | /** 17 | * Initialize data after construction of the BaseInterface 18 | */ 19 | virtual void initialize() {} 20 | 21 | virtual Index getNumMidiInputPorts() const = 0; 22 | virtual Index getNumMidiOutputPorts() const = 0; 23 | 24 | virtual Index getNumInputChannels() const = 0; 25 | virtual Index getNumOutputChannels() const = 0; 26 | 27 | // methods from ParameterInterface, they are here for documentation only 28 | ParameterIndex getNumParameters() const override = 0; 29 | ConstCharPointer getParameterName(ParameterIndex index) const override = 0; 30 | ConstCharPointer getParameterId(ParameterIndex index) const override = 0; 31 | void getParameterInfo(ParameterIndex index, ParameterInfo* info) const override = 0; 32 | 33 | ParameterValue getParameterValue(ParameterIndex index) override = 0; 34 | void setParameterValue(ParameterIndex index, ParameterValue value, MillisecondTime time = RNBOTimeNow) override = 0; 35 | 36 | protected: 37 | 38 | ~BaseInterface() { } 39 | 40 | }; 41 | 42 | } // namespace RNBO 43 | 44 | #endif // #ifndef _RNBO_BASEINTERFACE_H_ 45 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_FileChangeWatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_FileChangeWatcher.h 3 | // 4 | // Created by Rob Sussman on 12/11/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_FileChangeWatcher_H_ 9 | #define _RNBO_FileChangeWatcher_H_ 10 | 11 | #include "RNBO_Config.h" 12 | 13 | #ifdef USE_DYNAMIC_COMPILATION 14 | 15 | #include 16 | 17 | #ifndef RNBO_NO_JUCE 18 | #include "JuceHeader.h" 19 | #endif 20 | 21 | namespace RNBO { 22 | 23 | #ifdef RNBO_NO_JUCE 24 | class FileChangeWatcher 25 | { 26 | public: 27 | FileChangeWatcher(const char* fullPathToFile, 28 | std::function callback) 29 | { 30 | // dummy implementation 31 | } 32 | }; 33 | #else 34 | class FileChangeWatcher : public Timer 35 | { 36 | public: 37 | 38 | /** FileChangeWatcher will call the callback when the file changes. 39 | Passes in a pointer to the watcher so you can query the path. 40 | */ 41 | FileChangeWatcher(const char* fullPathToFile, 42 | std::function callback); 43 | ~FileChangeWatcher(); 44 | 45 | bool fileExists() const; 46 | const char* getFullPathToWatchedFile() const; 47 | 48 | void timerCallback() override; 49 | 50 | private: 51 | File _fileToWatch; 52 | Time _lastModificationTime; 53 | std::function _callback; 54 | }; 55 | #endif // #ifdef RNBO_NO_JUCE 56 | 57 | } // namespace RNBO 58 | 59 | #endif // #ifdef USE_DYNAMIC_COMPILATION 60 | 61 | #endif // #ifndef _RNBO_FileChangeWatcher_H_ 62 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_ParameterInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef RNBO_ParameterInterface_h 2 | #define RNBO_ParameterInterface_h 3 | 4 | #include "RNBO_Types.h" 5 | #include "RNBO_Math.h" 6 | 7 | namespace RNBO { 8 | 9 | class ParameterInterface { 10 | 11 | protected: 12 | ~ParameterInterface() { } 13 | 14 | public: 15 | virtual ParameterIndex getNumParameters() const = 0; 16 | virtual ConstCharPointer getParameterName(ParameterIndex index) const = 0; 17 | virtual ConstCharPointer getParameterId(ParameterIndex index) const = 0; 18 | virtual void getParameterInfo(ParameterIndex index, ParameterInfo* info) const = 0; 19 | 20 | virtual ParameterValue getParameterValue(ParameterIndex index) = 0; 21 | virtual void setParameterValue(ParameterIndex index, ParameterValue value, MillisecondTime time = RNBOTimeNow) = 0; 22 | 23 | virtual ParameterValue getParameterNormalized(ParameterIndex index) { 24 | return convertToNormalizedParameterValue(index, getParameterValue(index)); 25 | } 26 | 27 | virtual void setParameterValueNormalized(ParameterIndex index, ParameterValue normalizedValue, MillisecondTime time = RNBOTimeNow) { 28 | setParameterValue(index, convertFromNormalizedParameterValue(index, normalizedValue), time); 29 | } 30 | 31 | virtual ParameterValue convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const = 0; 32 | virtual ParameterValue convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue normalizedValue) const = 0; 33 | virtual ParameterValue constrainParameterValue(ParameterIndex, ParameterValue value) const { return value; } 34 | }; 35 | 36 | } // namespace RNBO 37 | 38 | #endif // RNBO_ParameterInterface_h 39 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DataRefList.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DataRefList.cpp 3 | // RNBO 4 | // 5 | // Created by Sam Tarakajian on 2/10/20. 6 | // 7 | 8 | #include "RNBO_DataRefList.h" 9 | 10 | #ifndef RNBO_NOSTDLIB 11 | 12 | RNBO_PUSH_DISABLE_WARNINGS 13 | #include "3rdparty/json/json.hpp" 14 | RNBO_POP_DISABLE_WARNINGS 15 | 16 | using Json = nlohmann::json; 17 | 18 | namespace RNBO { 19 | 20 | DataRefList::DataRefList(std::string jsonString) 21 | { 22 | Json json = Json::parse(jsonString); 23 | for (Json::iterator it = json.begin(); it != json.end(); it++) { 24 | if (it->is_object()) { 25 | Json& j = *it; 26 | 27 | if (j.contains("id") && (j.contains("file") || j.contains("url"))) { 28 | std::string rid = j["id"]; 29 | std::string location = j.contains("file") ? j["file"] : j["url"]; 30 | auto type = j.contains("file") ? DataRefType::File : DataRefType::URL; 31 | 32 | _ids.push_back(rid); 33 | _locations.push_back(location); 34 | _types.push_back(type); 35 | } 36 | } 37 | } 38 | } 39 | 40 | DataRefList::~DataRefList() {} 41 | 42 | size_t DataRefList::size() 43 | { 44 | return _ids.size(); 45 | } 46 | 47 | std::string DataRefList::datarefIdAtIndex(size_t index) 48 | { 49 | if (index > this->size()) return ""; 50 | return _ids[index]; 51 | } 52 | 53 | std::string DataRefList::datarefLocationAtIndex(size_t index) 54 | { 55 | if (index > this->size()) return ""; 56 | return _locations[index]; 57 | } 58 | 59 | DataRefType DataRefList::datarefTypeAtIndex(size_t index) 60 | { 61 | if (index > this->size()) return DataRefType::File; 62 | return _types[index]; 63 | } 64 | 65 | } 66 | 67 | #endif /* RNBO_NOPRESETS */ 68 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/3rdparty/readerwriterqueue/LICENSE.md: -------------------------------------------------------------------------------- 1 | This license applies to all the code in this repository except that written by third 2 | parties, namely the files in benchmarks/ext, which have their own licenses, and Jeff 3 | Preshing's semaphore implementation (used in the blocking queue) which has a zlib 4 | license (embedded in atomicops.h). 5 | 6 | Simplified BSD License: 7 | 8 | Copyright (c) 2013-2015, Cameron Desrochers 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without modification, 12 | are permitted provided that the following conditions are met: 13 | 14 | - Redistributions of source code must retain the above copyright notice, this list of 15 | conditions and the following disclaimer. 16 | - Redistributions in binary form must reproduce the above copyright notice, this list of 17 | conditions and the following disclaimer in the documentation and/or other materials 18 | provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 25 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_BinaryData.h: -------------------------------------------------------------------------------- 1 | #ifndef RNBO_BINARYDATA_H 2 | #define RNBO_BINARYDATA_H 3 | 4 | #include 5 | #include 6 | 7 | namespace RNBO { 8 | class BinaryDataEntry { 9 | public: 10 | BinaryDataEntry() {} 11 | BinaryDataEntry(const std::string filename, const uint8_t * data, size_t length) : mFileName(filename), mData(data), mLength(length) {} 12 | BinaryDataEntry(const BinaryDataEntry&) = default; 13 | 14 | BinaryDataEntry & operator=(const BinaryDataEntry & other) { 15 | mFileName = other.mFileName; 16 | mData = other.mData; 17 | mLength = other.mLength; 18 | return *this; 19 | } 20 | 21 | const std::string& filename() const { 22 | return mFileName; 23 | } 24 | 25 | const uint8_t * data() const { 26 | return mData; 27 | } 28 | 29 | size_t length() const { 30 | return mLength; 31 | } 32 | private: 33 | std::string mFileName; 34 | const uint8_t * mData = nullptr; 35 | size_t mLength = 0; 36 | }; 37 | 38 | class BinaryData { 39 | public: 40 | //TODO discover keys? 41 | virtual bool get(const std::string& key, BinaryDataEntry& out) const = 0; 42 | }; 43 | 44 | class BinaryDataImpl : public BinaryData { 45 | public: 46 | using Storage = std::unordered_map; 47 | BinaryDataImpl(Storage storage) : BinaryData(), mStorage(storage) {} 48 | BinaryDataImpl() : BinaryData() {} //empty 49 | 50 | bool get(const std::string& key, BinaryDataEntry& out) const override { 51 | auto it = mStorage.find(key); 52 | if (it != mStorage.end()) { 53 | out = it->second; 54 | return true; 55 | } 56 | return false; 57 | } 58 | 59 | private: 60 | Storage mStorage; 61 | }; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_PresetList.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_PresetList.cpp 3 | // RNBO 4 | // 5 | // Created by Samuel Tarakajian on 11/9/20. 6 | // 7 | 8 | #if !(defined(RNBO_NOPRESETS) || defined(RNBO_NOJSONPRESETS)) 9 | 10 | #include "RNBO_PresetList.h" 11 | 12 | namespace RNBO { 13 | 14 | PresetList::PresetList(std::string jsonString): 15 | _parsedPresets() 16 | { 17 | convertJSONArrayToPresetList(jsonString, _parsedPresets); 18 | } 19 | PresetList::~PresetList() {} 20 | 21 | size_t PresetList::size() 22 | { 23 | return _parsedPresets.size(); 24 | } 25 | 26 | UniquePresetPtr PresetList::presetAtIndex(size_t index) 27 | { 28 | if (index > this->size()) return nullptr; 29 | UniquePresetPtr preset = make_unique(); 30 | PresetPtr srcPreset = _parsedPresets[index]->preset; 31 | copyPreset(*srcPreset, *preset); 32 | return preset; 33 | } 34 | 35 | std::string PresetList::presetNameAtIndex(size_t index) 36 | { 37 | if (index > this->size()) return ""; 38 | std::string name = _parsedPresets[index]->name; 39 | return name; 40 | } 41 | 42 | UniquePresetPtr PresetList::presetWithName(std::string name) 43 | { 44 | for (size_t i = 0; i < _parsedPresets.size(); i++) { 45 | std::shared_ptr entry = _parsedPresets[i]; 46 | if (entry->name == name) { 47 | UniquePresetPtr preset = make_unique(); 48 | PresetPtr srcPreset = entry->preset; 49 | copyPreset(*srcPreset, *preset); 50 | return preset; 51 | } 52 | } 53 | 54 | return nullptr; 55 | } 56 | } 57 | 58 | #endif /* RNBO_NOPRESETS */ 59 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ServiceNotification.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ServiceEvent.h 3 | // 4 | // Created by Stefan Brunner on 9/21/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_ServiceEvent_H_ 9 | #define _RNBO_ServiceEvent_H_ 10 | 11 | #include "RNBO_Types.h" 12 | 13 | namespace RNBO { 14 | 15 | // an event representing service message on our dedicated serive queue, note that it does NOT impement getTime() 16 | // so it cannot be used inside an EventVariant 17 | using ServiceNotificationPayload = void*; 18 | 19 | /** 20 | * @private 21 | */ 22 | class ServiceNotification { 23 | public: 24 | 25 | enum ServiceNotificationType 26 | { 27 | ServiceNotificationUndefined, 28 | ParameterInterfaceCreated, 29 | ParameterInterfaceDeleted 30 | }; 31 | 32 | ServiceNotification(const ServiceNotification& other) = default; 33 | ServiceNotification& operator = (const ServiceNotification& other) = default; 34 | 35 | ServiceNotification() 36 | : _type(ServiceNotificationUndefined) 37 | , _payload(nullptr) 38 | { 39 | } 40 | 41 | ServiceNotification(ServiceNotificationType serviceType, ServiceNotificationPayload payload) 42 | : _type(serviceType) 43 | , _payload(payload) 44 | { 45 | } 46 | 47 | bool operator==(const ServiceNotification& rhs) const 48 | { 49 | return rhs.getType() == getType() 50 | && rhs.getPayload() == getPayload(); 51 | } 52 | 53 | ServiceNotificationType getType() const { return _type; } 54 | ServiceNotificationPayload getPayload() const { return _payload; } 55 | 56 | // debugging 57 | void dumpEvent() const { fprintf(stdout, "ServiceNotification: type=%d payload=%payload\n", _type, _payload); } 58 | 59 | private: 60 | 61 | ServiceNotificationType _type; 62 | ServiceNotificationPayload _payload; 63 | 64 | }; 65 | 66 | } // namespace RNBO 67 | 68 | #endif // #ifndef _RNBO_ServiceEvent_H_ 69 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_PatcherEventTarget.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RNBO_PatcherInterface_H_ 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_PatcherEventTarget_H_ 9 | #define _RNBO_PatcherEventTarget_H_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_EventTarget.h" 13 | #include "RNBO_List.h" 14 | 15 | namespace RNBO { 16 | 17 | /** 18 | * @private 19 | */ 20 | class PatcherEventTarget : public EventTarget { 21 | 22 | public: 23 | 24 | virtual void processNormalizedParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) = 0; 25 | virtual void processParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) = 0; 26 | virtual void processOutletEvent(EngineLink* sender, OutletIndex index, ParameterValue value, MillisecondTime time) = 0; 27 | virtual void processOutletAtCurrentTime(EngineLink* sender, OutletIndex index, ParameterValue value) = 0; 28 | virtual void processDataViewUpdate(DataRefIndex index, MillisecondTime time) = 0; 29 | virtual void processNumMessage(MessageTag tag, MessageTag objectId, MillisecondTime time, number payload) = 0; 30 | virtual void processListMessage(MessageTag tag, MessageTag objectId, MillisecondTime time, const list& payload) = 0; 31 | virtual void processBangMessage(MessageTag tag, MessageTag objectId, MillisecondTime time) = 0; 32 | virtual void processTempoEvent(MillisecondTime time, Tempo tempo) = 0; 33 | virtual void processTransportEvent(MillisecondTime time, TransportState state) = 0; 34 | virtual void processBeatTimeEvent(MillisecondTime time, BeatTime beatTime) = 0; 35 | virtual void processTimeSignatureEvent(MillisecondTime time, int numerator, int denominator) = 0; 36 | 37 | protected: 38 | 39 | ~PatcherEventTarget() { } 40 | 41 | }; 42 | 43 | } // namespace RNBO 44 | 45 | 46 | #endif // #ifndef _RNBO_PatcherEventTarget_H_ 47 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/3rdparty/concurrentqueue/LICENSE.md: -------------------------------------------------------------------------------- 1 | This license applies to everything in this repository except that which 2 | is explicitly annotated as being written by other authors, i.e. the Boost 3 | queue (included in the benchmarks for comparison), Intel's TBB library (ditto), 4 | the CDSChecker tool (used for verification), the Relacy model checker (ditto), 5 | and Jeff Preshing's semaphore implementation (used in the blocking queue) which 6 | has a zlib license (embedded in blockingconcurrentqueue.h). 7 | 8 | 9 | Simplified BSD License: 10 | 11 | Copyright (c) 2013-2015, Cameron Desrochers. 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without modification, 15 | are permitted provided that the following conditions are met: 16 | 17 | - Redistributions of source code must retain the above copyright notice, this list of 18 | conditions and the following disclaimer. 19 | - Redistributions in binary form must reproduce the above copyright notice, this list of 20 | conditions and the following disclaimer in the documentation and/or other materials 21 | provided with the distribution. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 24 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 26 | THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParameterInterfaceAsync.h: -------------------------------------------------------------------------------- 1 | // 2 | // ParameterInterface.h 3 | // 4 | // Created by Stefan Brunner on 12.08.15. 5 | // 6 | // 7 | 8 | #ifndef RNBOPlugin_ParameterInterfaceAsync_h 9 | #define RNBOPlugin_ParameterInterfaceAsync_h 10 | 11 | #include "RNBO_EventVariant.h" 12 | #include "RNBO_EventList.h" 13 | #include "RNBO_ParameterEventInterface.h" 14 | 15 | namespace RNBO { 16 | 17 | class Engine; 18 | using ParameterEventInterfaceImplPtr = std::shared_ptr; 19 | 20 | /** 21 | * @private 22 | */ 23 | class ParameterInterfaceAsync : public ParameterEventInterface 24 | { 25 | public: 26 | 27 | // DO NOT construct a parameter interface directly - use Engine::createParameterInterface instead 28 | ParameterInterfaceAsync(Engine& engine, EventHandler* handler, ParameterEventInterface::Type type); 29 | ~ParameterInterfaceAsync() override; 30 | 31 | ParameterIndex getNumParameters() const override; 32 | void getParameterInfo(ParameterIndex index, ParameterInfo* info) const override; 33 | ConstCharPointer getParameterName(ParameterIndex index) const override; 34 | ConstCharPointer getParameterId(ParameterIndex index) const override; 35 | 36 | ParameterValue getParameterValue(ParameterIndex index) override; 37 | void setParameterValue(ParameterIndex index, ParameterValue value, MillisecondTime time = RNBOTimeNow) override; 38 | 39 | ParameterValue convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const override; 40 | ParameterValue convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue normalizedValue) const override; 41 | ParameterValue constrainParameterValue(ParameterIndex index, ParameterValue value) const override; 42 | 43 | void scheduleEvent(EventVariant event) override; 44 | 45 | void drainEvents() override; 46 | 47 | private: 48 | 49 | ParameterEventInterfaceImplPtr _impl; 50 | }; 51 | } // namespace RNBO 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/Buttons.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Buttons.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 17.11.2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct Buttons: View { 11 | @EnvironmentObject var rnbo: RNBOAudioUnitHostModel 12 | @State private var enableMic: Bool = false 13 | var body: some View { 14 | HStack { 15 | Button("Test MIDI") { 16 | print("CC") 17 | rnbo.sendContinuousController(11, value: 60) 18 | print("PitchBend") 19 | rnbo.sendPitchBend(8192) 20 | print("Patch") 21 | rnbo.sendPatchChange(1) 22 | print("Pressure") 23 | rnbo.sendChannelPressure(60) 24 | print("Aftertouch") 25 | rnbo.sendAftertouch(60, pressure: 50) 26 | } 27 | Button("Randomize") { 28 | randomize() 29 | } 30 | Button("Send message") { 31 | let message: [Double] = [220, 330, 0.2, 0.3, 0.5] 32 | rnbo.sendMessage(message) 33 | } 34 | Button("Play Input") { 35 | rnbo.playAudioFile() 36 | } 37 | Button("Pause Input") { 38 | rnbo.pauseAudioFile() 39 | } 40 | Toggle(isOn: $rnbo.showDescription) { 41 | Text("Show description") 42 | } 43 | Toggle(isOn: $enableMic) { 44 | Text("Mic") 45 | } 46 | .onChange(of: enableMic) { newValue in 47 | rnbo.toggleMic(newValue) 48 | } 49 | } 50 | .padding(.bottom) 51 | } 52 | 53 | fileprivate func randomize() { 54 | for i in rnbo.parameters.indices { 55 | rnbo.setParameterValueNormalizedHot(to: Double.random(in: 0 ... 1), at: i) 56 | } 57 | } 58 | } 59 | 60 | #Preview { 61 | Buttons() 62 | } 63 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_Utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_Utils.h 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_Utils_H_ 9 | #define _RNBO_Utils_H_ 10 | 11 | #include 12 | 13 | namespace RNBO { 14 | 15 | // implementation of make_unique() 16 | // taken from: https://isocpp.org/files/papers/N3656.txt 17 | // linked to from: http://stackoverflow.com/questions/7038357/make-unique-and-perfect-forwarding 18 | 19 | /** 20 | * @private 21 | */ 22 | template struct _Unique_if { 23 | typedef std::unique_ptr _Single_object; 24 | }; 25 | 26 | /** 27 | * @private 28 | */ 29 | template struct _Unique_if { 30 | typedef std::unique_ptr _Unknown_bound; 31 | }; 32 | 33 | /** 34 | * @private 35 | */ 36 | template struct _Unique_if { 37 | typedef void _Known_bound; 38 | }; 39 | 40 | /** 41 | * @private 42 | */ 43 | template 44 | typename _Unique_if::_Single_object 45 | make_unique(Args&&... args) { 46 | return std::unique_ptr(new T(std::forward(args)...)); 47 | } 48 | 49 | /** 50 | * @private 51 | */ 52 | template 53 | typename _Unique_if::_Unknown_bound 54 | make_unique(size_t n) { 55 | typedef typename std::remove_extent::type U; 56 | return std::unique_ptr(new U[n]()); 57 | } 58 | 59 | template 60 | typename _Unique_if::_Known_bound 61 | make_unique(Args&&...) = delete; 62 | 63 | 64 | // helper template prevents single-argument universal-reference constructor from acting like the copy constructor 65 | // see: http://ericniebler.com/2013/08/07/universal-references-and-the-copy-constructo/ 66 | template 67 | using disable_if_same_or_derived = 68 | typename std::enable_if::type>::value>::type; 69 | 70 | 71 | } // namespace RNBO 72 | 73 | 74 | #endif // #ifndef _RNBO_Utils_H_ 75 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_Config.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_Config.h 3 | // 4 | // Created by Rob Sussman on 1/12/16. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_Config_h_ 9 | #define _RNBO_Config_h_ 10 | 11 | // include your own RNBO_LocalConfig.h before including "RNBO.h" 12 | // if you want to override the settings in this file 13 | 14 | ////////////////////////////////////////////////////////////////////////////////// 15 | 16 | // dynamic compilation watches the patcher source file and 17 | // uses clang/llvm to recompile dynamically when it changes 18 | // can enable or disable here for local testing, but primary configuration should be via project file 19 | // #define USE_DYNAMIC_COMPILATION 20 | // #undef USE_DYNAMIC_COMPILATION 21 | 22 | // determines if we should init the file watcher that checks for changes in the 23 | // default test file and triggers re-compilation 24 | // #define USE_TEST_FILEWATCHER 25 | // #undef USE_TEST_FILEWATCHER 26 | 27 | ////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #if defined(USE_DYNAMIC_COMPILATION) && defined(RNBO_NO_CLANG) 30 | 31 | // disable clang/llvm for projects that don't need/support it 32 | #undef USE_DYNAMIC_COMPILATION 33 | 34 | #endif // defined(USE_DYNAMIC_COMPILATION) && defined(RNBO_NO_CLANG) 35 | 36 | ////////////////////////////////////////////////////////////////////////////////// 37 | 38 | // Default place to write output cpp code 39 | #ifdef RNBO_DEFAULT_TEST_FILE 40 | #define RNBO_TEST_FILE RNBO_QUOTE(RNBO_DEFAULT_TEST_FILE) 41 | #endif 42 | 43 | // Default place to write output js code 44 | #ifdef RNBO_DEFAULT_WEB_FILE 45 | #define RNBO_WEB_FILE RNBO_QUOTE(RNBO_DEFAULT_WEB_FILE) 46 | #endif 47 | 48 | // Switch off the default Patcher Interface creation, necessary when you want to 49 | // use multiple CoreObjects in one Project 50 | //#define RNBO_NO_PATCHERFACTORY 51 | 52 | ////////////////////////////////////////////////////////////////////////////////// 53 | 54 | #endif // #ifndef _RNBO_Config_h_ 55 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_TempoEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_TempoEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_TempoEvent_H_ 7 | #define _RNBO_TempoEvent_H_ 8 | 9 | #include "RNBO_Types.h" 10 | 11 | namespace RNBO { 12 | 13 | class PatcherEventTarget; 14 | 15 | /** 16 | * A tempo event 17 | */ 18 | class TempoEvent { 19 | 20 | public: 21 | 22 | TempoEvent() 23 | : _eventTime(0) 24 | , _tempo(-1) 25 | { 26 | } 27 | 28 | ~TempoEvent() 29 | { 30 | } 31 | 32 | TempoEvent( 33 | MillisecondTime eventTime, 34 | Tempo tempo 35 | ) 36 | : _eventTime(eventTime) 37 | , _tempo(tempo) 38 | { 39 | } 40 | 41 | TempoEvent(const TempoEvent& other) 42 | : _eventTime(other._eventTime) 43 | { 44 | _tempo = other._tempo; 45 | } 46 | 47 | TempoEvent(TempoEvent&& other) 48 | : _eventTime(other._eventTime) 49 | { 50 | _tempo = other._tempo; 51 | } 52 | 53 | TempoEvent& operator = (const TempoEvent& other) 54 | { 55 | _eventTime = other._eventTime; 56 | _tempo = other._tempo; 57 | 58 | return *this; 59 | } 60 | 61 | bool operator==(const TempoEvent& rhs) const 62 | { 63 | return rhs.getTime() == getTime() && rhs.getTempo() == getTempo(); 64 | } 65 | 66 | MillisecondTime getTime() const { return _eventTime; } 67 | Tempo getTempo() const { return _tempo; } 68 | 69 | // we will always use the default event target (the top level patcher) 70 | PatcherEventTarget* getEventTarget() const { return nullptr; } 71 | 72 | // debugging 73 | void dumpEvent() const { 74 | // disabling for now to avoid requiring fprintf support in generated code 75 | // fprintf(stdout, "TempoEvent: time=%.3f tempo=%d", _eventTime, _tempo); 76 | } 77 | 78 | protected: 79 | 80 | MillisecondTime _eventTime; 81 | Tempo _tempo; 82 | 83 | friend class EventVariant; 84 | 85 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 86 | }; 87 | 88 | } // namespace RNBO 89 | 90 | #endif // #ifndef _RNBO_TempoEvent_H_ 91 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/staticplugin/AUInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CFBundleExecutable 7 | ${MACOSX_BUNDLE_BUNDLE_NAME} 8 | CFBundleIconFile 9 | 10 | CFBundleIdentifier 11 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 12 | CFBundleName 13 | ${MACOSX_BUNDLE_BUNDLE_NAME} 14 | CFBundleDisplayName 15 | ${MACOSX_BUNDLE_BUNDLE_NAME} 16 | CFBundlePackageType 17 | BNDL 18 | CFBundleSignature 19 | ???? 20 | CFBundleShortVersionString 21 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 22 | CFBundleVersion 23 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 24 | NSHumanReadableCopyright 25 | ${MACOSX_BUNDLE_COPYRIGHT} 26 | NSHighResolutionCapable 27 | 28 | AudioComponents 29 | 30 | 31 | name 32 | ${PLUGIN_MANUFACTURER_NAME}: ${PLUGIN_NAME} 33 | description 34 | ${PLUGIN_NAME} 35 | factoryFunction 36 | RNBO_Plugin_AUFactory 37 | manufacturer 38 | ${PLUGIN_MANUFACTURER_CODE} 39 | type 40 | ${AU_PLUGIN_TYPE} 41 | subtype 42 | ${PLUGIN_CODE} 43 | version 44 | 1 45 | resourceUsage 46 | 47 | network.client 48 | 49 | temporary-exception.files.all.read-write 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DynamicSymbolRegistry.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_DYNAMICSYMBOLREGISTRY_H_ 2 | #define _RNBO_DYNAMICSYMBOLREGISTRY_H_ 3 | 4 | #ifndef RNBO_DISABLE_CODEGEN 5 | 6 | #include 7 | 8 | namespace RNBO { 9 | 10 | /** 11 | * @private 12 | */ 13 | class DynamicSymbolRegistry { 14 | 15 | public: 16 | 17 | /** 18 | * @private 19 | */ 20 | struct DynamicSymbol { 21 | char _name[256]; 22 | void *_location; 23 | }; 24 | 25 | using DynamicSymbolList = std::vector; 26 | 27 | static DynamicSymbolList& getRegisteredSymbols() { 28 | static DynamicSymbolList dynamicSymbolRegistry; 29 | return dynamicSymbolRegistry; 30 | } 31 | 32 | static void registerSymbol(const char *name, void *location) { 33 | DynamicSymbol sym; 34 | char *n = sym._name; 35 | 36 | while ((*n++ = *name++) != 0) ; 37 | sym._location = location; 38 | 39 | getRegisteredSymbols().push_back(sym); 40 | } 41 | 42 | }; 43 | 44 | /** 45 | * @private 46 | */ 47 | class DynamicSymbolRegistrar { 48 | 49 | public: 50 | 51 | DynamicSymbolRegistrar(const char *name, void *location) { 52 | DynamicSymbolRegistry::registerSymbol(name, location); 53 | } 54 | 55 | }; 56 | 57 | } // RNBO 58 | 59 | # define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__) 60 | # define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__ 61 | 62 | # define REGISTER_RNBO_EXTERNAL(ExternalName) extern "C" RNBO::ExternalBase * CAT(ExternalName, Factory) () \ 63 | { return new ExternalName (); } \ 64 | static RNBO::DynamicSymbolRegistrar ExternalName ## RegisteredSymbol( #ExternalName "Factory" , (void *) CAT(ExternalName, Factory) ); 65 | 66 | #else // RNBO_DISABLE_CODEGEN 67 | 68 | namespace RNBO { 69 | 70 | class DynamicSymbolRegistry { 71 | 72 | }; 73 | 74 | class DynamicSymbolRegistrar { 75 | 76 | public: 77 | 78 | DynamicSymbolRegistrar(const char *name, void *location) {} 79 | 80 | }; 81 | 82 | } // RNBO 83 | 84 | # define REGISTER_RNBO_EXTERNAL(ExternalName) 85 | 86 | #endif // RNBO_DISABLE_CODEGEN 87 | 88 | #endif // _RNBO_DYNAMICSYMBOLREGISTRY_H_ 89 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_TransportEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_TransportEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_TransportEvent_H_ 7 | #define _RNBO_TransportEvent_H_ 8 | 9 | #include "RNBO_Types.h" 10 | 11 | namespace RNBO { 12 | 13 | class PatcherEventTarget; 14 | 15 | /** 16 | * An event representing stopping or starting the transport 17 | */ 18 | class TransportEvent { 19 | 20 | public: 21 | 22 | TransportEvent() 23 | : _eventTime(0) 24 | , _state(STOPPED) 25 | { 26 | } 27 | 28 | ~TransportEvent() 29 | { 30 | } 31 | 32 | TransportEvent( 33 | MillisecondTime eventTime, 34 | TransportState state 35 | ) 36 | : _eventTime(eventTime) 37 | , _state(state) 38 | { 39 | } 40 | 41 | TransportEvent(const TransportEvent& other) 42 | : _eventTime(other._eventTime) 43 | { 44 | _state = other._state; 45 | } 46 | 47 | TransportEvent(TransportEvent&& other) 48 | : _eventTime(other._eventTime) 49 | { 50 | _state = other._state; 51 | } 52 | 53 | TransportEvent& operator = (const TransportEvent& other) 54 | { 55 | _eventTime = other._eventTime; 56 | _state = other._state; 57 | 58 | return *this; 59 | } 60 | 61 | bool operator==(const TransportEvent& rhs) const 62 | { 63 | return rhs.getTime() == getTime() && rhs.getState() == getState(); 64 | } 65 | 66 | MillisecondTime getTime() const { return _eventTime; } 67 | TransportState getState() const { return _state; } 68 | 69 | // we will always use the default event target (the top level patcher) 70 | PatcherEventTarget* getEventTarget() const { return nullptr; } 71 | 72 | // debugging 73 | void dumpEvent() const { 74 | // disabling for now to avoid requiring fprintf support in generated code 75 | // fprintf(stdout, "TransportEvent: time=%.3f state=%d", _eventTime, _state); 76 | } 77 | 78 | protected: 79 | 80 | MillisecondTime _eventTime; 81 | TransportState _state; 82 | 83 | friend class EventVariant; 84 | 85 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 86 | }; 87 | 88 | } // namespace RNBO 89 | 90 | #endif // #ifndef _RNBO_TransportEvent_H_ 91 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DataRefList.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DataRefList.h 3 | // RNBO 4 | // 5 | // Created by Sam Tarakajian on 2/10/20. 6 | // 7 | 8 | #ifndef RNBO_DataRefList_h 9 | #define RNBO_DataRefList_h 10 | 11 | #include "RNBO_Utils.h" 12 | #include 13 | 14 | #ifndef RNBO_NOSTDLIB 15 | namespace RNBO { 16 | enum class DataRefType { 17 | File, 18 | URL 19 | }; 20 | 21 | /** 22 | * Wrapper class for exported RNBO dependencies. After reading a 23 | * dependencies.json file as a string, use this class to retrieve data ref 24 | * description information. 25 | * 26 | * @code{.cpp} 27 | * #include 28 | * #include 29 | * 30 | * // Read in the dependencies.json file as a std::string 31 | * std::ifstream t("../dependencies.json"); 32 | * std::stringstream buffer; 33 | * buffer << t.rdbuf(); 34 | * 35 | * // Parse dependencies into a RNBO DataRefList 36 | * DataRefList list(buffer.str()); 37 | * @endcode 38 | */ 39 | class DataRefList { 40 | public: 41 | 42 | DataRefList(std::string jsonString); 43 | ~DataRefList(); 44 | 45 | /** 46 | * Number of data refs in the list. 47 | */ 48 | size_t size(); 49 | 50 | /** 51 | * Get the ID of the data ref at the given index. 52 | * @code{.cpp} 53 | * std::string idstr = list.datarefIdAtIndex(i); 54 | * @endcode 55 | */ 56 | std::string datarefIdAtIndex(size_t index); 57 | 58 | /** 59 | * Get the path of the data ref at the given index. Can be a URL or a 60 | * file path. 61 | * @code{.cpp} 62 | * std::string location = list.datarefLocationAtIndex(i); 63 | * @endcode 64 | */ 65 | std::string datarefLocationAtIndex(size_t index); 66 | 67 | /** 68 | * Get the RNBO::DataRefType of the data ref at the given index. 69 | * @code{.cpp} 70 | * DataRefType type = list.datarefTypeAtIndex(i); 71 | * @endcode 72 | */ 73 | DataRefType datarefTypeAtIndex(size_t index); 74 | 75 | private: 76 | std::vector _ids; 77 | std::vector _locations; 78 | std::vector _types; 79 | }; 80 | } 81 | #endif /* RNBO_NOSTDLIB */ 82 | 83 | #endif /* RNBO_DataRefList_h */ 84 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_OutletEvent.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _RNBO_OutletEvent_H_ 3 | #define _RNBO_OutletEvent_H_ 4 | 5 | #include "RNBO_Types.h" 6 | #include "RNBO_PatcherInterface.h" 7 | 8 | namespace RNBO { 9 | 10 | /** 11 | * An event representing a message sent through an outlet of an external 12 | */ 13 | class OutletEvent { 14 | public: 15 | 16 | OutletEvent(const OutletEvent& other) = default; 17 | OutletEvent& operator = (const OutletEvent& other) = default; 18 | 19 | OutletEvent() 20 | : _eventTime(0) 21 | , _sender(nullptr) 22 | , _index(INVALID_INDEX) 23 | , _value(0) 24 | , _eventTarget(nullptr) 25 | { 26 | } 27 | 28 | OutletEvent(MillisecondTime eventTime, EngineLink* sender, OutletIndex index, ParameterValue value, PatcherEventTarget* eventTarget = nullptr) 29 | : _eventTime(eventTime) 30 | , _sender(sender) 31 | , _index(index) 32 | , _value(value) 33 | , _eventTarget(eventTarget) 34 | { 35 | } 36 | 37 | bool operator==(const OutletEvent& rhs) const 38 | { 39 | return rhs.getTime() == getTime() 40 | && rhs.getSender() == getSender() 41 | && rhs.getIndex() == getIndex() 42 | && rhs.getValue() == getValue() 43 | && rhs._eventTarget == _eventTarget; 44 | } 45 | 46 | EngineLink* getSender() const { return _sender; } 47 | OutletIndex getIndex() const { return _index; } 48 | ParameterValue getValue() const { return _value; } 49 | 50 | MillisecondTime getTime() const { return _eventTime; } 51 | PatcherEventTarget* getEventTarget() const { return _eventTarget; } 52 | 53 | // debugging 54 | void dumpEvent() const { 55 | // fprintf(stdout, "OutletEvent: time: %.4f sender: %p index: %d value: %.4f eventTarget: %p\n", _eventTime, _sender, _index, _value, _eventTarget); 56 | } 57 | 58 | private: 59 | 60 | MillisecondTime _eventTime; 61 | EngineLink* _sender; 62 | OutletIndex _index; 63 | ParameterValue _value; 64 | 65 | friend class EventVariant; 66 | 67 | PatcherEventTarget* _eventTarget; 68 | 69 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 70 | 71 | }; 72 | 73 | } // namespace RNBO 74 | 75 | #endif // #ifndef _RNBO_OutletEvent_H_ 76 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/RNBOParameter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Parameter.swift 3 | // RNBO_AVAudioEngine 4 | // 5 | // Created by Eldar Sadykov on 13.02.2023. 6 | // 7 | 8 | import Foundation 9 | 10 | struct RNBOParameter { 11 | var value: Double 12 | let info: ParameterInfo 13 | 14 | var valueNormalized: Double { 15 | get { 16 | value.toNormalised(minValue: info.minimum, maxValue: info.maximum, factor: info.exponent) 17 | } 18 | set { 19 | value = newValue.fromNormalised(minValue: info.minimum, maxValue: info.maximum, factor: info.exponent) 20 | } 21 | } 22 | 23 | init(_ info: ParameterInfo) { 24 | value = info.initialValue.clip(from: info.minimum, to: info.maximum) 25 | self.info = info 26 | } 27 | } 28 | 29 | extension RNBOParameter: Equatable { 30 | static func == (lhs: RNBOParameter, rhs: RNBOParameter) -> Bool { 31 | (lhs.value == rhs.value) && (lhs.id == rhs.id) 32 | } 33 | } 34 | 35 | extension RNBOParameter: Identifiable { 36 | var id: String { info.paramId } 37 | } 38 | 39 | extension RNBODescription { 40 | func getParametersArray() -> [RNBOParameter] { 41 | var parameters: [RNBOParameter] = [] 42 | for i in 0 ..< numParameters { 43 | let parameter = self.parameters[i] 44 | parameters.append(RNBOParameter(parameter)) 45 | } 46 | return parameters 47 | } 48 | } 49 | 50 | extension Double { 51 | func clip(from minValue: Double, to maxValue: Double) -> Double { 52 | min(maxValue, max(self, minValue)) 53 | } 54 | 55 | func fromNormalised(minValue: Double, maxValue: Double, factor: Double) -> Double { 56 | let exponentiatedValue = pow(self, factor) 57 | let scaledValue = minValue + (maxValue - minValue) * exponentiatedValue 58 | return scaledValue 59 | } 60 | 61 | func toNormalised(minValue: Double, maxValue: Double, factor: Double) -> Double { 62 | let normalizedValue = (self - minValue) / (maxValue - minValue) 63 | let inverseScaledValue = pow(normalizedValue, 1 / factor) 64 | return inverseScaledValue 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/3rdparty/concurrentqueue/internal/concurrentqueue_internal_debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#define MCDBGQ_TRACKMEM 1 4 | //#define MCDBGQ_NOLOCKFREE_FREELIST 1 5 | //#define MCDBGQ_USEDEBUGFREELIST 1 6 | //#define MCDBGQ_NOLOCKFREE_IMPLICITPRODBLOCKINDEX 1 7 | //#define MCDBGQ_NOLOCKFREE_IMPLICITPRODHASH 1 8 | 9 | #if defined(_WIN32) || defined(__WINDOWS__) || defined(__WIN32__) 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | namespace moodycamel { namespace debug { 13 | struct DebugMutex { 14 | DebugMutex() { InitializeCriticalSectionAndSpinCount(&cs, 0x400); } 15 | ~DebugMutex() { DeleteCriticalSection(&cs); } 16 | 17 | void lock() { EnterCriticalSection(&cs); } 18 | void unlock() { LeaveCriticalSection(&cs); } 19 | 20 | private: 21 | CRITICAL_SECTION cs; 22 | }; 23 | } } 24 | #else 25 | #include 26 | namespace moodycamel { namespace debug { 27 | struct DebugMutex { 28 | void lock() { m.lock(); } 29 | void unlock() { m.unlock(); } 30 | 31 | private: 32 | std::mutex m; 33 | }; 34 | } } 35 | #define 36 | #endif 37 | 38 | namespace moodycamel { namespace debug { 39 | struct DebugLock { 40 | explicit DebugLock(DebugMutex& mutex) 41 | : mutex(mutex) 42 | { 43 | mutex.lock(); 44 | } 45 | 46 | ~DebugLock() 47 | { 48 | mutex.unlock(); 49 | } 50 | 51 | private: 52 | DebugMutex& mutex; 53 | }; 54 | 55 | 56 | template 57 | struct DebugFreeList { 58 | DebugFreeList() : head(nullptr) { } 59 | DebugFreeList(DebugFreeList&& other) : head(other.head) { other.head = nullptr; } 60 | void swap(DebugFreeList& other) { std::swap(head, other.head); } 61 | 62 | inline void add(N* node) 63 | { 64 | DebugLock lock(mutex); 65 | node->freeListNext = head; 66 | head = node; 67 | } 68 | 69 | inline N* try_get() 70 | { 71 | DebugLock lock(mutex); 72 | if (head == nullptr) { 73 | return nullptr; 74 | } 75 | 76 | auto prevHead = head; 77 | head = head->freeListNext; 78 | return prevHead; 79 | } 80 | 81 | N* head_unsafe() const { return head; } 82 | 83 | private: 84 | N* head; 85 | DebugMutex mutex; 86 | }; 87 | } } 88 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/max/rnbo_bufferref.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_BUFFERREF_H 2 | #define _RNBO_BUFFERREF_H 3 | 4 | //RNBO.h seems to have to come first in visual studio or std::numeric_limits<_>::max() breaks.. 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | extern "C" { 13 | // the dataref object which is used for managing all references 14 | // to internal Max buffers that are used by RNBO 15 | typedef struct _rnbo_bufferref { 16 | t_object obj; 17 | t_buffer_ref *r_buffer_ref; 18 | t_symbol *r_name; 19 | float *r_lastKnownAddress; // To determine if memory changed 20 | float *r_staleAddress; // Stale address after a deferred call to set_external_ptr 21 | char r_islocked; 22 | char r_pending; 23 | } t_rnbo_bufferref; 24 | 25 | void rnbo_bufferref_register(); 26 | t_rnbo_bufferref *rnbo_bufferref_new(t_symbol *buffername); 27 | void rnbo_bufferref_free(t_rnbo_bufferref *x); 28 | t_max_err rnbo_bufferref_notify(t_rnbo_bufferref *x, t_symbol *s, t_symbol *msg, void *sender, void *data); 29 | float *rnbo_bufferref_lock(t_rnbo_bufferref *x); 30 | char rnbo_bufferref_islocked(t_rnbo_bufferref *x); 31 | void rnbo_bufferref_unlock(t_rnbo_bufferref *x); 32 | void rnbo_bufferref_setdirty(t_rnbo_bufferref *x); 33 | void rnbo_bufferref_setname(t_rnbo_bufferref *x, t_symbol * name); 34 | t_symbol * rnbo_bufferref_getname(t_rnbo_bufferref *x); 35 | void rnbo_bufferref_setlastaddress(t_rnbo_bufferref *x, float *lastAddress); 36 | float *rnbo_bufferref_getlastaddress(t_rnbo_bufferref *x); 37 | bool rnbo_bufferref_buffer_exists(t_rnbo_bufferref *x); 38 | void rnbo_bufferref_make_pending(t_rnbo_bufferref *x, float *fromaddr); 39 | bool rnbo_bufferref_ispending(t_rnbo_bufferref *x); 40 | } 41 | 42 | namespace RNBO { 43 | void DataRefBindMaxBuffer( 44 | ExternalDataIndex dataRefIndex, 45 | const ExternalDataRef* ref, 46 | t_rnbo_bufferref *dataref, 47 | UpdateRefCallback updateDataRef, 48 | ReleaseRefCallback releaseDataRef 49 | ); 50 | void DataRefUnbindMaxBuffer( 51 | const ExternalDataRef* externalRef, 52 | t_rnbo_bufferref *dataref 53 | ); 54 | }; 55 | #endif 56 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/cmake/RNBODescriptionHeader.cmake: -------------------------------------------------------------------------------- 1 | #break up long string into shorter strings to work around MSVC string length constraints: 2 | #https://learn.microsoft.com/en-us/cpp/c-language/maximum-string-length?redirectedfrom=MSDN&view=msvc-170 3 | 4 | function(_chunkup INSTR OUTSTR) 5 | set (index 0) 6 | set (chunklen 500) 7 | 8 | string(LENGTH ${INSTR} len) 9 | set(chunked "") 10 | 11 | string(SUBSTRING ${INSTR} ${index} ${chunklen} chunk) 12 | string(APPEND chunked "R\"RNBOLIT(${chunk})RNBOLIT\"") 13 | math(EXPR index "${chunklen} + ${index}") 14 | while (index LESS ${len}) 15 | string(SUBSTRING ${INSTR} ${index} ${chunklen} chunk) 16 | string(APPEND chunked "\nR\"RNBOLIT(${chunk})RNBOLIT\"") 17 | math(EXPR index "${chunklen} + ${index}") 18 | endwhile() 19 | 20 | set(${OUTSTR} ${chunked} PARENT_SCOPE) 21 | endfunction() 22 | 23 | function(rnbo_write_description_header DESCRIPTION_JSON OUTPUT_DIR) 24 | set(PRESETS_JSON "{}") 25 | 26 | #check for optional args 27 | set (optional_args ${ARGN}) 28 | list(LENGTH optional_args optional_count) 29 | 30 | if (${optional_count} GREATER 0) 31 | list(GET optional_args 0 PRESETS_JSON) 32 | endif () 33 | 34 | _chunkup(${DESCRIPTION_JSON} PATCHER_DESCRIPTION_JSON) 35 | _chunkup(${PRESETS_JSON} PATCHER_PRESETS_JSON) 36 | 37 | configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/rnbo_description.h.in ${OUTPUT_DIR}/rnbo_description.h) 38 | endfunction() 39 | 40 | function(rnbo_write_description_header_if_exists RNBO_DESCRIPTION_FILE DESCRIPTION_INCLUDE_DIR) 41 | 42 | if (EXISTS ${RNBO_DESCRIPTION_FILE}) 43 | file(READ ${RNBO_DESCRIPTION_FILE} DESCRIPTION_JSON) 44 | 45 | #check for optional args 46 | set (optional_args ${ARGN}) 47 | list(LENGTH optional_args optional_count) 48 | 49 | set(PRESETS_JSON "{}") 50 | if (${optional_count} GREATER 0) 51 | list(GET optional_args 0 PRESETS_JSON_FILE) 52 | if (EXISTS ${PRESETS_JSON_FILE}) 53 | file(READ ${PRESETS_JSON_FILE} PRESETS_JSON) 54 | endif() 55 | endif () 56 | 57 | rnbo_write_description_header("${DESCRIPTION_JSON}" ${DESCRIPTION_INCLUDE_DIR} "${PRESETS_JSON}") 58 | add_definitions(-DRNBO_INCLUDE_DESCRIPTION_FILE) 59 | endif() 60 | endfunction() 61 | 62 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_CompilerMacros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __has_builtin 4 | # define __has_builtin(x) 0 5 | #endif 6 | 7 | #ifndef __has_attribute 8 | # define __has_attribute(x) 0 9 | #endif 10 | 11 | #if !defined(GNUC_PREREQ) 12 | #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 13 | #define GNUC_PREREQ(maj, min, patch) \ 14 | ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \ 15 | ((maj) << 20) + ((min) << 10) + (patch)) 16 | #elif defined(__GNUC__) && defined(__GNUC_MINOR__) 17 | #define GNUC_PREREQ(maj, min, patch) \ 18 | ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10)) 19 | #else 20 | #define GNUC_PREREQ(maj, min, patch) 0 21 | #endif 22 | #endif 23 | 24 | #if defined(__clang__) 25 | # if defined(__APPLE__) 26 | # define APPLE_CLANG_VERSION __clang_major__ 27 | # define CLANG_VERSION 0 28 | # else 29 | # define APPLE_CLANG_VERSION 0 30 | # define CLANG_VERSION __clang_major__ 31 | # endif 32 | #else 33 | # define APPLE_CLANG_VERSION 0 34 | # define CLANG_VERSION 0 35 | #endif 36 | 37 | // NB: clang/llvm on Windows will define _MSC_VER so be careful 38 | #if defined(_MSC_VER) 39 | #define MSVC_VERSION _MSC_VER 40 | #else 41 | #define MSVC_VERSION 0 42 | #endif 43 | 44 | #if __has_attribute(noinline) || GNUC_PREREQ(3, 4, 0) 45 | #define ATTRIBUTE_NOINLINE __attribute__((noinline)) 46 | #elif defined(_MSC_VER) 47 | #define ATTRIBUTE_NOINLINE __declspec(noinline) 48 | #else 49 | #define ATTRIBUTE_NOINLINE 50 | #endif 51 | 52 | #if __has_attribute(always_inline) || GNUC_PREREQ(4, 0, 0) 53 | #define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) 54 | #elif defined(_MSC_VER) 55 | #define ATTRIBUTE_ALWAYS_INLINE __forceinline 56 | #else 57 | #define ATTRIBUTE_ALWAYS_INLINE 58 | #endif 59 | 60 | #if __has_attribute(unused) || GNUC_PREREQ(4, 0, 0) 61 | #define ATTRIBUTE_UNUSED __attribute__((unused)) 62 | #elif defined(_MSC_VER) 63 | #define ATTRIBUTE_UNUSED // to suppress warning, wrap code with #pragma warning(disable/default:4505) 64 | #else 65 | #define ATTRIBUTE_UNUSED 66 | #endif 67 | 68 | #undef CLANG_VERSION 69 | #undef MSVC_VERSION 70 | #undef GNUC_PREREQ 71 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DataRefEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DataRefEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_DataRefEvent_H_ 7 | #define _RNBO_DataRefEvent_H_ 8 | 9 | #include "RNBO_PatcherInterface.h" 10 | 11 | namespace RNBO { 12 | 13 | /** 14 | * An event for updating a Data Reference. Used internally. 15 | */ 16 | class DataRefEvent { 17 | 18 | public: 19 | 20 | enum 21 | { 22 | InvalidDataRefIndex = -1 23 | }; 24 | 25 | enum DataRefAction { 26 | NoAction, 27 | UpdateDataRef 28 | }; 29 | 30 | DataRefEvent() 31 | : _dataRefIndex(InvalidDataRefIndex) 32 | , _eventTime(0) 33 | , _action(NoAction) 34 | , _eventTarget(nullptr) 35 | { 36 | } 37 | 38 | DataRefEvent(const DataRefEvent& other) = default; 39 | DataRefEvent& operator = (const DataRefEvent& other) = default; 40 | 41 | DataRefEvent(DataRefIndex dataRefIndex, MillisecondTime eventTime, DataRefAction action, PatcherEventTarget* eventTarget = nullptr) 42 | : _dataRefIndex(dataRefIndex) 43 | , _eventTime(eventTime) 44 | , _action(action) 45 | , _eventTarget(eventTarget) 46 | { 47 | } 48 | 49 | bool operator==(const DataRefEvent& rhs) const 50 | { 51 | return rhs.getDataRefIndex() == getDataRefIndex() 52 | && rhs.getTime() == getTime() 53 | && getAction() == rhs.getAction() 54 | && rhs._eventTarget == _eventTarget; 55 | } 56 | 57 | DataRefIndex getDataRefIndex() const { return _dataRefIndex; } 58 | DataRefAction getAction() const { return _action; } 59 | 60 | MillisecondTime getTime() const { return _eventTime; } 61 | PatcherEventTarget* getEventTarget() const { return _eventTarget; } 62 | 63 | // debugging 64 | void dumpEvent() const 65 | { 66 | // disabling for now to avoid requiring fprintf support in generated code 67 | // fprintf(stdout, "DataRefEvent: DataRefIndex=%d time=%.3f action=%.4f\n", _dataRefIndex, _eventTime, _action); 68 | } 69 | 70 | private: 71 | 72 | DataRefIndex _dataRefIndex; 73 | MillisecondTime _eventTime; 74 | DataRefAction _action; 75 | 76 | friend class EventVariant; 77 | 78 | PatcherEventTarget* _eventTarget; 79 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 80 | 81 | }; 82 | 83 | } // namespace RNBO 84 | 85 | #endif // #ifndef _RNBO_DataRefEvent_H_ 86 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_Array.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_TUPLE_H_ 2 | #define _RNBO_TUPLE_H_ 3 | 4 | #include "RNBO_List.h" 5 | 6 | namespace RNBO { 7 | 8 | /** 9 | * Fixed-size array. Drop-in replacement for std::array, if you're compiling RNBO without stdlib. 10 | */ 11 | template class array { 12 | public: 13 | 14 | array() { 15 | Platform::get()->memset(_values, 0, sizeof(T) * N); 16 | } 17 | 18 | template array(Ts ... args) 19 | { 20 | // since allocating an array of 0 length is invalid, we always allocate at least length 1 21 | T values[sizeof...(args) + 1] = {static_cast(args)...}; 22 | for (size_t i = 0; i < sizeof...(args) && i < N; i++) { 23 | _values[i] = values[i]; 24 | } 25 | } 26 | 27 | array(const listbase& l) { 28 | for (size_t i = 0; i < N && i < l.length; i++) { 29 | _values[i] = l[i]; 30 | } 31 | } 32 | 33 | // copy constructor 34 | array(const array& a) 35 | { 36 | for (size_t i = 0; i < N; i++) { 37 | _values[i] = a._values[i]; 38 | } 39 | } 40 | 41 | array& operator=(const array& a) 42 | { 43 | if (&a != this) { 44 | for (size_t i = 0; i < N; i++) { 45 | _values[i] = a._values[i]; 46 | } 47 | } 48 | return *this; 49 | } 50 | 51 | constexpr size_t size() const { return N; } 52 | constexpr bool empty() const { return size() == 0; } 53 | 54 | T& operator[](size_t n) { 55 | if (n >= N) { 56 | Platform::get()->errorOrDefault(RuntimeError::OutOfRange, "array index out of range", false /*unused*/); 57 | _dummy = static_cast(0); 58 | return _dummy; 59 | } 60 | return _values[n]; 61 | } 62 | const T& operator[](size_t n) const { 63 | if (n >= N) { 64 | Platform::get()->errorOrDefault(RuntimeError::OutOfRange, "array index out of range", false /*unused*/); 65 | return _dummy; 66 | } 67 | return _values[n]; 68 | } 69 | 70 | operator listbase() const { 71 | listbase tmp; 72 | tmp.reserve(N); 73 | for (size_t i = 0; i < N; i++) { 74 | tmp.push(_values[i]); 75 | } 76 | 77 | return tmp; 78 | } 79 | 80 | private: 81 | T _values[N ? N : 1]; 82 | T _dummy = static_cast(0); 83 | }; 84 | 85 | } // namespace RNBO 86 | 87 | #endif // #ifndef _RNBO_TUPLE_H_ 88 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_StartupEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_StartupEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_StartupEvent_H_ 7 | #define _RNBO_StartupEvent_H_ 8 | 9 | #include 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_List.h" 13 | #include "RNBO_PlatformInterface.h" 14 | #include "RNBO_Logger.h" 15 | #include "RNBO_Debug.h" 16 | #include "RNBO_Presets.h" 17 | 18 | namespace RNBO { 19 | 20 | class PatcherEventTarget; 21 | 22 | /** 23 | * An event representing startup 24 | */ 25 | class StartupEvent { 26 | 27 | public: 28 | 29 | enum Type { 30 | Invalid = -1, 31 | Begin = 0, 32 | End, 33 | Max_Type 34 | }; 35 | 36 | 37 | StartupEvent() 38 | : _eventTime(0) 39 | , _type(Invalid) 40 | { 41 | } 42 | 43 | ~StartupEvent() 44 | { 45 | } 46 | 47 | StartupEvent(MillisecondTime eventTime, StartupEvent::Type type) 48 | : _eventTime(eventTime) 49 | , _type(type) 50 | { 51 | } 52 | 53 | StartupEvent(const StartupEvent& other) 54 | : _eventTime(other._eventTime) 55 | { 56 | _type = other._type; 57 | } 58 | 59 | StartupEvent(StartupEvent&& other) 60 | : _eventTime(other._eventTime) 61 | { 62 | _type = other._type; 63 | } 64 | 65 | StartupEvent& operator = (const StartupEvent& other) 66 | { 67 | _eventTime = other._eventTime; 68 | _type = other._type; 69 | 70 | return *this; 71 | } 72 | 73 | bool operator==(const StartupEvent& rhs) const 74 | { 75 | return rhs.getTime() == getTime() 76 | && rhs.getType() == getType(); 77 | } 78 | 79 | StartupEvent::Type getType() const { return _type; } 80 | MillisecondTime getTime() const { return _eventTime; } 81 | 82 | // we will always use the default event target (the top level patcher) 83 | PatcherEventTarget* getEventTarget() const { return nullptr; } 84 | 85 | // debugging 86 | void dumpEvent() const { 87 | // disabling for now to avoid requiring fprintf support in generated code 88 | // fprintf(stdout, "StartupEvent: time=%.3f type=%d", _eventTime, _type); 89 | } 90 | 91 | protected: 92 | 93 | MillisecondTime _eventTime; 94 | StartupEvent::Type _type = Invalid; 95 | 96 | friend class EventVariant; 97 | 98 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 99 | }; 100 | 101 | } // namespace RNBO 102 | 103 | 104 | #endif // #ifndef _RNBO_StartupEvent_H_ 105 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_BeatTimeEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_BeatTimeEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_BeatTimeEvent_H_ 7 | #define _RNBO_BeatTimeEvent_H_ 8 | 9 | #include "RNBO_Types.h" 10 | 11 | namespace RNBO { 12 | 13 | class PatcherEventTarget; 14 | 15 | /** 16 | * An event for setting the current transport time. Depending on the host, 17 | * setting the beat time may simply update the internal transport, or else 18 | * it may generate an event that causes the host to change its beat time. 19 | * @see RNBO::BeatTime represents time in quater notes, as used by (for 20 | * example) Ableton Link. @see RNBO::Millisecond time is of course the time 21 | * in milliseconds. 22 | */ 23 | class BeatTimeEvent { 24 | 25 | public: 26 | 27 | BeatTimeEvent() 28 | : _eventTime(0) 29 | , _beatTime(-1) 30 | { 31 | } 32 | 33 | ~BeatTimeEvent() 34 | { 35 | } 36 | 37 | BeatTimeEvent( 38 | MillisecondTime eventTime, 39 | BeatTime beatTime 40 | ) 41 | : _eventTime(eventTime) 42 | , _beatTime(beatTime) 43 | { 44 | } 45 | 46 | BeatTimeEvent(const BeatTimeEvent& other) 47 | : _eventTime(other._eventTime) 48 | { 49 | _beatTime = other._beatTime; 50 | } 51 | 52 | BeatTimeEvent(BeatTimeEvent&& other) 53 | : _eventTime(other._eventTime) 54 | { 55 | _beatTime = other._beatTime; 56 | } 57 | 58 | BeatTimeEvent& operator = (const BeatTimeEvent& other) 59 | { 60 | _eventTime = other._eventTime; 61 | _beatTime = other._beatTime; 62 | 63 | return *this; 64 | } 65 | 66 | bool operator==(const BeatTimeEvent& rhs) const 67 | { 68 | return rhs.getTime() == getTime() && rhs.getBeatTime() == getBeatTime(); 69 | } 70 | 71 | MillisecondTime getTime() const { return _eventTime; } 72 | BeatTime getBeatTime() const { return _beatTime; } 73 | 74 | // we will always use the default event target (the top level patcher) 75 | PatcherEventTarget* getEventTarget() const { return nullptr; } 76 | 77 | // debugging 78 | void dumpEvent() const { 79 | // disabling for now to avoid requiring fprintf support in generated code 80 | // fprintf(stdout, "BeatTimeEvent: time=%.3f beatTime=%d", _eventTime, _beatTime); 81 | } 82 | 83 | protected: 84 | 85 | MillisecondTime _eventTime; 86 | BeatTime _beatTime; 87 | 88 | friend class EventVariant; 89 | 90 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 91 | }; 92 | 93 | } // namespace RNBO 94 | 95 | #endif // #ifndef _RNBO_BeatTimeEvent_H_ 96 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/RNBO_JuceAudioProcessorEditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | RNBO_JuceAudioProcessorEditor.h 5 | Created: 21 Sep 2015 11:50:17am 6 | Author: stb 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef RNBO_JUCEAUDIOPROCESSOREDITOR_H_INCLUDED 12 | #define RNBO_JUCEAUDIOPROCESSOREDITOR_H_INCLUDED 13 | 14 | #include "RNBO.h" 15 | #include "RNBO_JuceAudioProcessor.h" 16 | #include 17 | 18 | namespace RNBO { 19 | //forward decl 20 | class DataRefPropertyComp; 21 | 22 | //============================================================================== 23 | /** 24 | 25 | this is mostly a copy of a Juce GenericAudioProcessorEditor, with the important 26 | difference that it can be refreshed via a ParameterInterfacHandle 27 | 28 | */ 29 | class RNBOAudioProcessorEditor : public juce::AudioProcessorEditor, public juce::AsyncUpdater, public RNBO::EventHandler, public juce::MessageListener 30 | { 31 | public: 32 | //============================================================================== 33 | RNBOAudioProcessorEditor (JuceAudioProcessor* owner, CoreObject& rnboObject); 34 | ~RNBOAudioProcessorEditor() override; 35 | 36 | //============================================================================== 37 | void paint (juce::Graphics&) override; 38 | void resized() override; 39 | 40 | void handleAsyncUpdate() override; 41 | 42 | void eventsAvailable() override; 43 | void handleParameterEvent(const RNBO::ParameterEvent& event) override; 44 | void handlePresetEvent(const RNBO::PresetEvent& event) override; 45 | 46 | void chooseFileForDataRef(const juce::String refName); 47 | JuceAudioProcessor * owner() const { return _owner; } 48 | 49 | void handleMessage(const juce::Message& message) override; 50 | 51 | private: 52 | 53 | void updateAllParams(); 54 | 55 | //============================================================================== 56 | JuceAudioProcessor* _owner; 57 | juce::PropertyPanel _panel; 58 | CoreObject& _rnboObject; 59 | ParameterEventInterfaceUniquePtr _parameterInterface; 60 | 61 | juce::Array _params; 62 | std::unique_ptr _dataRefChooser; 63 | std::unordered_map _dataRefPropertyMap; 64 | }; 65 | 66 | } // namespace RNBO 67 | 68 | #endif // RNBO_JUCEAUDIOPROCESSOREDITOR_H_INCLUDED 69 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DataBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DataBuffer.h 3 | // 4 | // Created by Rob Sussman on 12/21/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_DataBuffer_H_ 9 | #define _RNBO_DataBuffer_H_ 10 | 11 | #include 12 | #include 13 | 14 | namespace RNBO { 15 | 16 | /** 17 | * DataBuffer holds an arbitrary block of data. 18 | * 19 | * It is designed to be owned and used from one thread at a time and has no protections/locks on any of its methods. 20 | * It is also designed to minimize memory allocation, so shrinking the buffer size will not cause reallocations. 21 | */ 22 | class DataBuffer 23 | { 24 | public: 25 | 26 | /** 27 | * @brief Initialize a DataBuffer with zeros 28 | * 29 | * @param size the buffer size in bytes 30 | */ 31 | DataBuffer(size_t size); 32 | 33 | /** 34 | * @brief Initialize a DataBuffer with a block of memory 35 | * 36 | * @param dataToCopy source data to copy 37 | * @param sizeOfDataToCopy the number of bytes to copy from the source data 38 | */ 39 | DataBuffer(const char* dataToCopy, size_t sizeOfDataToCopy); 40 | 41 | /** 42 | * @brief Initialize a DataBuffer with a null-terminated string 43 | * 44 | * The string's contents are copied to a newly allocated block of memory. 45 | * 46 | * @param stringToCopy the null-terminated string to initialize the DataBuffer with 47 | */ 48 | DataBuffer(const char* stringToCopy); 49 | 50 | /** 51 | * @brief Resize the DataBuffer, attempting to preserve contents 52 | * 53 | * When expanding, the extra space is filled with zeros. 54 | * 55 | * @param size the new size of the DataBuffer 56 | */ 57 | void resize(size_t size); 58 | 59 | /** 60 | * @brief Get the current buffer size 61 | * 62 | * @return the size of the DataBuffer in bytes 63 | */ 64 | size_t size() const { return _data.size(); } 65 | 66 | /** 67 | * @brief Get a pointer to the raw data 68 | * 69 | * This can be used to modify the data in the buffer 70 | * 71 | * @return a pointer to the first byte of raw data in the DataBuffer 72 | */ 73 | char* data() { return _data.data(); } 74 | 75 | /** 76 | * @brief Get a const pointer to the raw data 77 | * 78 | * @return a const pointer to the first byte of raw data in the DataBuffer 79 | */ 80 | const char* data() const { return _data.data(); } 81 | 82 | private: 83 | std::vector _data; 84 | }; 85 | 86 | using DataBufferRef = std::shared_ptr; 87 | 88 | } // namespace RNBO 89 | 90 | #endif // #ifndef _RNBO_DataBuffer_H_ 91 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_TimeSignatureEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_TimeSignatureEvent.h 3 | // 4 | // 5 | 6 | #ifndef _RNBO_TimeSignatureEvent_H_ 7 | #define _RNBO_TimeSignatureEvent_H_ 8 | 9 | #include "RNBO_Types.h" 10 | 11 | namespace RNBO { 12 | 13 | class PatcherEventTarget; 14 | 15 | /** 16 | * An event representing changing the time signature 17 | */ 18 | class TimeSignatureEvent { 19 | 20 | public: 21 | 22 | TimeSignatureEvent() 23 | : _eventTime(0) 24 | , _numerator(-1) 25 | , _denominator(-1) 26 | { 27 | } 28 | 29 | ~TimeSignatureEvent() 30 | { 31 | } 32 | 33 | TimeSignatureEvent(MillisecondTime eventTime, int numerator, int denominator) 34 | : _eventTime(eventTime) 35 | , _numerator(numerator) 36 | , _denominator(denominator) 37 | { 38 | } 39 | 40 | TimeSignatureEvent(const TimeSignatureEvent& other) 41 | : _eventTime(other._eventTime) 42 | { 43 | _numerator = other._numerator; 44 | _denominator = other._denominator; 45 | } 46 | 47 | TimeSignatureEvent(TimeSignatureEvent&& other) 48 | : _eventTime(other._eventTime) 49 | { 50 | _numerator = other._numerator; 51 | _denominator = other._denominator; 52 | } 53 | 54 | TimeSignatureEvent& operator = (const TimeSignatureEvent& other) 55 | { 56 | _eventTime = other._eventTime; 57 | _numerator = other._numerator; 58 | _denominator = other._denominator; 59 | 60 | return *this; 61 | } 62 | 63 | bool operator==(const TimeSignatureEvent& rhs) const 64 | { 65 | return rhs.getTime() == getTime() 66 | && rhs.getNumerator() == getNumerator() 67 | && rhs.getDenominator() == getDenominator(); 68 | } 69 | 70 | MillisecondTime getTime() const { return _eventTime; } 71 | int getNumerator() const { return _numerator; } 72 | int getDenominator() const { return _denominator; } 73 | 74 | // we will always use the default event target (the top level patcher) 75 | PatcherEventTarget* getEventTarget() const { return nullptr; } 76 | 77 | // debugging 78 | void dumpEvent() const { 79 | // disabling for now to avoid requiring fprintf support in generated code 80 | // fprintf(stdout, "TimeSignatureEvent: time=%.3f numerator=%d denominator=%d", _eventTime, _numerator, _denominator); 81 | } 82 | 83 | protected: 84 | 85 | MillisecondTime _eventTime; 86 | int _numerator; 87 | int _denominator; 88 | 89 | friend class EventVariant; 90 | 91 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 92 | }; 93 | 94 | } // namespace RNBO 95 | 96 | #endif // #ifndef _RNBO_TimeSignatureEvent_H_ 97 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_UniversalEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_UniversalEvent.h 3 | // 4 | 5 | #ifndef _RNBO_UniversalEvent_H_ 6 | #define _RNBO_UniversalEvent_H_ 7 | 8 | #include "RNBO_EventTarget.h" 9 | #include "RNBO_HardwareDevice.h" 10 | 11 | namespace RNBO { 12 | 13 | // Note that this is not derived from anything, it just declares getTime() and can therefore be used inside an event 14 | // list. 15 | 16 | // assuming a single linear floating-point value from 0-1 as the value for the time being 17 | // we could add boolean, integer, enum, blob types later on 18 | 19 | /** 20 | * An event that can hold a timestamped external event (external controller, OSC, etc.) 21 | */ 22 | class UniversalEvent { 23 | public: 24 | UniversalEvent() 25 | : _eventTime(0) 26 | , _id(INVALID_INDEX) 27 | , _value(0) 28 | , _eventTarget(nullptr) 29 | {} 30 | 31 | UniversalEvent(MillisecondTime eventTime, Index deviceId, ParameterValue value, EventTarget* eventTarget = nullptr) 32 | : _eventTime(eventTime) 33 | , _id(deviceId) 34 | , _value(value) 35 | , _eventTarget(eventTarget) 36 | {} 37 | 38 | 39 | UniversalEvent(MillisecondTime eventTime, String deviceName, ParameterValue value, EventTarget* eventTarget = nullptr) 40 | : _eventTime(eventTime) 41 | , _id(INVALID_INDEX) 42 | , _value(value) 43 | , _eventTarget(eventTarget) 44 | { 45 | Index sourceId = UniversalEventSource::getIdForName(deviceName); 46 | if (sourceId >= 0) { 47 | _id = sourceId; 48 | } 49 | } 50 | 51 | bool operator==(const UniversalEvent& rhs) const 52 | { 53 | return rhs.getTime() == getTime() 54 | && rhs.getId() == getId() 55 | && rhs.getValue() == getValue(); 56 | } 57 | 58 | Index getId() const { return _id; } 59 | ParameterValue getValue() const { return _value; } 60 | 61 | MillisecondTime getTime() const { return _eventTime; } 62 | EventTarget* getEventTarget() const { return _eventTarget; } 63 | 64 | // debugging 65 | void dumpEvent() const { 66 | // TODO: would be good to have logging that doesn't depend on fprintf 67 | // fprintf(stdout, "MidiEvent: time=%.3f port=%d length=%d b1=%d b2=%d b3=%d\n", _eventTime, _portIndex, _length, _midiData[0], _midiData[1], _midiData[2]); 68 | } 69 | 70 | private: 71 | 72 | MillisecondTime _eventTime; 73 | Index _id; 74 | ParameterValue _value; 75 | 76 | friend class EventVariant; 77 | 78 | EventTarget* _eventTarget; 79 | 80 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 81 | 82 | }; 83 | 84 | } // namespace RNBO 85 | 86 | #endif // _RNBO_UniversalEvent_H_ 87 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_DynamicPatcherFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_DynamicPatcherFactory.h 3 | // 4 | // Created by Rob Sussman on 12/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_DynamicPatcherFactory_H_ 9 | #define _RNBO_DynamicPatcherFactory_H_ 10 | 11 | #ifdef USE_DYNAMIC_COMPILATION 12 | 13 | #include "RNBO_Types.h" 14 | #include "RNBO_ClangInterface.h" 15 | #include "RNBO_String.h" 16 | #include "RNBO_PatcherFactory.h" 17 | #include "RNBO_DynamicPatcherFactory.h" 18 | 19 | namespace RNBO { 20 | 21 | class DynamicPatcherFactory 22 | { 23 | public: 24 | 25 | /** DynamicPatcherFactory creates patcher instances by using clang/llvm to 26 | "dynamically" compile the given source. If the source changes nothing happens. 27 | If you want to recompile when the source changes make a new DynamicPatcherFactory() instance. 28 | 29 | Compilation happens synchronously in the constructor. 30 | You can pass in a listener to receive compilation diagnostic messages. 31 | Otherwise, messages are dropped. 32 | 33 | Can check on compilation success via didCompileSuccesfully() method. 34 | */ 35 | DynamicPatcherFactory(const char* fullPathToCppSource, 36 | const char* fullPathToRNBOHeaders); 37 | 38 | /** pass in a name and source code directly, rather than using a file on disk 39 | */ 40 | DynamicPatcherFactory(const char* name, 41 | const char* source, 42 | const char* fullPathToRNBOHeaders, 43 | ClangInterface::OLevel oLevel); 44 | 45 | /** call to determine if compilation (done in constructor) was successful 46 | when not successful createInstance() is expected to return nullptr 47 | */ 48 | bool didCompileSucceed() { return _didCompileSucceed; } 49 | void getLastErrors(_dictionary **lastErrors); 50 | 51 | const char* getFullPathToCppSource(); 52 | UniquePtr createInstance(); 53 | 54 | // TODO: fix debugging 55 | // void SetNotifyDebuggerCallback(RNBOClang::NotifyDebuggerCallback callback); 56 | 57 | private: 58 | PatcherFactoryFunctionPtr getPatcherFactoryFunction(); 59 | 60 | void initWithNameAndSource(const char* name, 61 | const char* source, 62 | const char* fullPathToRNBOHeaders, 63 | ClangInterface::OLevel oLevel); 64 | static String defaultFullPathToCppSource(); 65 | 66 | String _fullPathToCppSource; 67 | std::shared_ptr _clanger; 68 | bool _didCompileSucceed; 69 | }; 70 | 71 | } // namespace RNBO 72 | 73 | #endif // #ifdef USE_DYNAMIC_COMPILATION 74 | 75 | #endif // #ifndef _RNBO_DynamicPatcherFactory_H_ 76 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParameterInterfaceSync.h: -------------------------------------------------------------------------------- 1 | #ifndef RNBO_ParameterInterfaceSync_h 2 | #define RNBO_ParameterInterfaceSync_h 3 | 4 | #include "RNBO_ParameterEventInterface.h" 5 | 6 | #ifdef USE_STD_VECTOR 7 | #include 8 | #else 9 | #include "RNBO_Vector.h" 10 | #endif 11 | 12 | namespace RNBO { 13 | 14 | class EngineCore; 15 | 16 | /** 17 | * @private 18 | */ 19 | class ParameterInterfaceSync : public ParameterEventInterfaceImpl 20 | { 21 | public: 22 | ParameterInterfaceSync(EngineCore& engine, EventHandler* handler); 23 | ~ParameterInterfaceSync() override; 24 | 25 | ParameterIndex getNumParameters() const override; 26 | void getParameterInfo(ParameterIndex index, ParameterInfo* info) const override; 27 | ConstCharPointer getParameterName(ParameterIndex index) const override; 28 | ConstCharPointer getParameterId(ParameterIndex index) const override; 29 | ParameterValue getParameterValue(ParameterIndex index) override; 30 | void setParameterValue(ParameterIndex index, ParameterValue value, MillisecondTime time = RNBOTimeNow) override; 31 | void scheduleEvent(EventVariant event) override; 32 | void drainEvents() override; 33 | void refreshParameterCountAndValues() override; 34 | void notifyParameterValueChanged(ParameterEvent sourceEvent, ParameterIndex index, ParameterValue value) override; 35 | void drainIncomingQueueToEventList(EventList& eventList, MillisecondTime currentTime) override; 36 | void pushDirtyParameters(MillisecondTime currentTime) override; 37 | void pushOutgoingEvent(EventVariant event) override; 38 | void notifyOutgoingEvents() override; 39 | ParameterValue convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const override; 40 | ParameterValue convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue normalizedValue) const override; 41 | ParameterValue constrainParameterValue(ParameterIndex index, ParameterValue value) const override; 42 | 43 | // dummy implementations 44 | bool isActive() override; 45 | void deactivate() override; 46 | void notifyParameterInterfaceDeleted() override; 47 | 48 | 49 | protected: 50 | 51 | EngineCore& _engine; 52 | EventHandler* _handler; 53 | #ifdef USE_STD_VECTOR 54 | std::vector _parameters; 55 | #else 56 | Vector _parameters; 57 | #endif 58 | }; 59 | 60 | /** 61 | * @private 62 | */ 63 | class ParameterInterfaceTrigger : public ParameterInterfaceSync 64 | { 65 | public: 66 | ParameterInterfaceTrigger(EngineCore& engine, EventHandler* handler); 67 | 68 | void scheduleEvent(EventVariant event) override; 69 | void setScheduleCallback(ScheduleCallback callback) override; 70 | }; 71 | 72 | } // namespace RNBO 73 | 74 | #endif // RNBO_ParameterInterfaceSync_h 75 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/RNBO_JuceAudioProcessorUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_JuceAudioProcessorUtils.h 3 | // 4 | // Created by Rob Sussman on 8/14/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_JuceAudioProcessorUtils_h 9 | #define _RNBO_JuceAudioProcessorUtils_h 10 | 11 | #include "RNBO.h" 12 | #include "RNBO_TimeConverter.h" 13 | 14 | #include 15 | 16 | namespace RNBO { 17 | 18 | // TODO: chop this file, and related 19 | namespace JuceAudioProcessorUtils 20 | { 21 | void fillCurrentEventsFromMidiBuffer(EventList& currentEvents, 22 | const TimeConverter& timeConverter, 23 | juce::MidiBuffer& midiMessages); 24 | 25 | void fillAudioInputBuffers(const std::vector& audioInputs, 26 | size_t sampleFrames, 27 | juce::AudioSampleBuffer& buffer); 28 | 29 | void fillAudioOutputBuffers(const std::vector& audioOutputs, 30 | size_t sampleFrames, 31 | juce::AudioSampleBuffer& buffer); 32 | 33 | 34 | void sendOutgoingMidiEvents(EventList& midiEvents, 35 | MillisecondTime endTime, 36 | TimeConverter timeConverter, 37 | juce::MidiBuffer& midiMessages); 38 | 39 | class ProcessBlockImpl 40 | { 41 | public: 42 | ProcessBlockImpl(juce::AudioSampleBuffer& buffer, juce::MidiBuffer& midiMessages) 43 | : _buffer(buffer) 44 | , _midiMessages(midiMessages) 45 | { 46 | 47 | } 48 | 49 | template 50 | void fillCurrentEvents(EventList& currentEvents, T timeConverter ) const 51 | { 52 | JuceAudioProcessorUtils::fillCurrentEventsFromMidiBuffer(currentEvents, timeConverter, _midiMessages); 53 | } 54 | 55 | void fillAudioInputBuffers(std::vector& audioInputs, size_t sampleFrames) const 56 | { 57 | JuceAudioProcessorUtils::fillAudioInputBuffers(audioInputs, sampleFrames, _buffer); 58 | } 59 | 60 | void fillAudioOutputBuffers(std::vector& audioOutputs, size_t sampleFrames) const 61 | { 62 | JuceAudioProcessorUtils::fillAudioOutputBuffers(audioOutputs, sampleFrames, _buffer); 63 | 64 | RNBO_ASSERT((int) sampleFrames == _buffer.getNumSamples()); 65 | } 66 | 67 | void sendOutgoingMidiEvents(EventList& midiEvents, 68 | MillisecondTime endTime, 69 | TimeConverter timeConverter) 70 | { 71 | JuceAudioProcessorUtils::sendOutgoingMidiEvents(midiEvents, endTime, timeConverter, _midiMessages); 72 | } 73 | 74 | private: 75 | ProcessBlockImpl& operator=(const ProcessBlockImpl&) = delete; 76 | 77 | juce::AudioSampleBuffer& _buffer; 78 | juce::MidiBuffer& _midiMessages; 79 | }; 80 | 81 | } // namespace JuceAudioProcessorUtils 82 | 83 | } // namespace RNBO 84 | 85 | #endif // _RNBO_JuceAudioProcessorUtils_h 86 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_EventSender.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_EventSender.h 3 | // 4 | // Created by Rob Sussman on 1/22/19. 5 | // Extractd from RNBO_EventVariant.h 6 | // 7 | // 8 | 9 | #ifndef _RNBO_EventSender_H_ 10 | #define _RNBO_EventSender_H_ 11 | 12 | #include "RNBO_Types.h" 13 | #include "RNBO_EventTarget.h" 14 | #include "RNBO_EventVariant.h" 15 | #include "RNBO_EmptyEvent.h" 16 | #include "RNBO_ClockEvent.h" 17 | #include "RNBO_MidiEvent.h" 18 | 19 | namespace RNBO { 20 | 21 | /** 22 | * @private 23 | */ 24 | class EventSender { 25 | 26 | public: 27 | 28 | virtual ~EventSender() { } 29 | 30 | virtual void sendEvent(const EventVariant& ev) const { 31 | Event::Type eventType = ev.getType(); 32 | 33 | switch (eventType) { 34 | case Event::Empty: handleEmptyEvent(ev.getEmptyEvent()); break; 35 | case Event::Clock: handleClockEvent(ev.getClockEvent()); break; 36 | case Event::Midi: handleMidiEvent(ev.getMidiEvent()); break; 37 | case Event::DataRef: 38 | case Event::Outlet: 39 | case Event::Parameter: 40 | case Event::Universal: 41 | case Event::Message: 42 | case Event::Preset: 43 | case Event::Tempo: 44 | case Event::Transport: 45 | case Event::BeatTime: 46 | case Event::TimeSignature: 47 | case Event::Startup: 48 | default: break; 49 | } 50 | } 51 | 52 | protected: 53 | 54 | EventSender(EventTarget* fallbackTarget) 55 | : _fallbackTarget(fallbackTarget) 56 | { } 57 | 58 | EventSender(const EventSender& other) = default; 59 | EventSender& operator=(const EventSender& other) = default; 60 | 61 | private: 62 | 63 | void handleEmptyEvent(const EmptyEvent& ee) const { 64 | RNBO_UNUSED(ee); 65 | // nothing to do here 66 | } 67 | 68 | void handleClockEvent(const ClockEvent& ce) const { 69 | EventTarget* eventTarget = ce.getEventTarget() ? ce.getEventTarget() : _fallbackTarget; 70 | 71 | if (!eventTarget) return; // what do we do here? is it even a possibility? 72 | eventTarget->processClockEvent(correctTime(ce.getTime()), ce.getClockIndex(), ce.hasValue(), ce.getValue()); 73 | } 74 | 75 | void handleMidiEvent(const MidiEvent& me) const { 76 | EventTarget* eventTarget = me.getEventTarget() ? me.getEventTarget() : _fallbackTarget; 77 | 78 | if (!eventTarget) return; 79 | 80 | ConstByteArray data = me.getData(); // should midi be const char* or const unsigned char* 81 | if (data) { 82 | Index length = me.getLength(); 83 | int port = me.getPortIndex(); 84 | eventTarget->processMidiEvent(correctTime(me.getTime()), port, data, length); 85 | } 86 | } 87 | 88 | virtual MillisecondTime correctTime(MillisecondTime time) const { 89 | return time; 90 | } 91 | 92 | EventTarget* _fallbackTarget; 93 | 94 | }; 95 | 96 | } // namespace RNBO 97 | 98 | 99 | #endif // #ifndef _RNBO_EventSender_H_ 100 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/RNBODescription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RNBODescription.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 18.11.2023. 6 | // 7 | 8 | import Foundation 9 | 10 | // Define the main struct and its related sub-structs 11 | struct RNBODescription: Codable { 12 | let parameters: [ParameterInfo] 13 | let numParameters, numSignalInParameters, numSignalOutParameters: Int 14 | let numInputChannels, numOutputChannels, numMidiInputPorts, numMidiOutputPorts: Int 15 | let externalDataRefs: [ExternalDataRef] 16 | let patcherSerial: Int 17 | let inports, outports: [Port] 18 | let inlets, outlets: [InletOutlet] 19 | let presetid: String 20 | let meta: Meta 21 | } 22 | 23 | // Define sub-structs used in RNBODescription 24 | struct ParameterInfo: Codable { 25 | let type: String 26 | let index: Int 27 | let name, paramId: String 28 | let minimum, maximum, exponent: Double 29 | let steps: Int 30 | let initialValue: Double 31 | let isEnum: Bool 32 | let enumValues: [EnumValue] 33 | let displayName, unit: String 34 | let order: Int 35 | let debug, visible: Bool 36 | let signalIndex: Int? 37 | let ioType: String 38 | } 39 | 40 | extension ParameterInfo: Identifiable { 41 | var id: String { paramId } 42 | } 43 | 44 | struct ExternalDataRef: Codable { 45 | let id, file, type, tag: String 46 | } 47 | 48 | struct Port: Codable { 49 | let tag, meta: String 50 | } 51 | 52 | struct InletOutlet: Codable { 53 | let type: String 54 | let index: Int? 55 | let tag, meta: String? 56 | 57 | private enum CodingKeys: String, CodingKey { 58 | case type, index, tag, meta 59 | } 60 | } 61 | 62 | struct Meta: Codable { 63 | let architecture, filename, rnboobjname, maxversion: String 64 | let rnboversion, name: String 65 | } 66 | 67 | // Helper structs for handling JSON values and nulls 68 | struct JSONNull: Codable, Hashable {} 69 | 70 | struct EnumValue: Codable { 71 | let string: String 72 | 73 | init(from decoder: Decoder) throws { 74 | let container = try decoder.singleValueContainer() 75 | if let intVal = try? container.decode(Int.self) { 76 | string = String(intVal) 77 | } else if let doubleVal = try? container.decode(Double.self) { 78 | string = String(doubleVal) 79 | } else if let stringVal = try? container.decode(String.self) { 80 | string = stringVal 81 | } else if container.decodeNil() { 82 | string = "null" 83 | } else { 84 | throw DecodingError.typeMismatch(EnumValue.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Failed to decode JSONAny")) 85 | } 86 | } 87 | 88 | func encode(to encoder: Encoder) throws { 89 | var container = encoder.singleValueContainer() 90 | try container.encode(string) 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBOAudioUnit.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyV3AudioUnit5.h 3 | // auv3test5 4 | // 5 | // Created by Ronald Nicholson on 7/31/17. 6 | // Copyright © 2017 HotPaw Productions. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "RNBOEventHandlerProtocol.h" 13 | 14 | extern long int toneCount; 15 | extern double sampleRateHz; 16 | extern float testFrequency; 17 | 18 | extern long int testMagnitude; 19 | 20 | extern void processBuffer(float *p, int len); 21 | 22 | typedef NS_ENUM(uint8_t, MidiCommand) { 23 | MidiCommandNoteOff = 0x80, 24 | MidiCommandNoteOn = 0x90, 25 | MidiCommandAftertouch = 0xA0, 26 | MidiCommandContinuousController = 0xB0, 27 | MidiCommandPatchChange = 0xC0, 28 | MidiCommandChannelPressure = 0xD0, 29 | MidiCommandPitchBend = 0xE0 30 | }; 31 | 32 | @interface RNBOAudioUnit : AUAudioUnit { 33 | // AUAudioUnitBusArray *outputBusArray; 34 | // AUAudioUnitBusArray *inputBusArray; 35 | NSObject *_handler; 36 | } 37 | 38 | - (void)setParameterValue:(size_t)number value:(float)v; 39 | - (void)setParameterValueNormalized:(size_t)number valueNormalized:(float)v; 40 | - (size_t)getParameterCount; 41 | 42 | - (float)getParameterValue:(size_t)number; 43 | 44 | - (float)getParameterInitialValue:(size_t)number; 45 | - (float)getParameterMin:(size_t)number; 46 | - (float)getParameterMax:(size_t)number; 47 | - (float)getParameterExponent:(size_t)number; 48 | - (int)getParameterSteps:(size_t)number; 49 | - (NSString *)getParameterUnit:(size_t)number; 50 | - (NSString *)getParameterDisplayName:(size_t)number; 51 | 52 | - (void)sendMessage:(NSString *)tag; 53 | - (void)sendMessage:(NSString *)tag number:(float)number; 54 | - (void)sendMessage:(NSString *)tag list:(NSArray *)list; 55 | 56 | - (void)sendMidiMessageWithCommand:(MidiCommand)command byte1:(uint8_t)byte1 byte2:(uint8_t)byte2 channel:(uint8_t)channel; 57 | - (void)sendTwoByteMidiMessageWithCommand:(MidiCommand)command byte1:(uint8_t)byte1 channel:(uint8_t)channel; 58 | 59 | - (void)sendNoteOnMessageWithPitch:(uint8_t)pitch velocity:(uint8_t)velocity channel:(uint8_t)channel; 60 | - (void)sendNoteOffMessageWithPitch:(uint8_t)pitch releaseVelocity:(uint8_t)releaseVelocity channel:(uint8_t)channel; 61 | - (void)sendAftertouchMessageWithPitch:(uint8_t)pitch pressure:(uint8_t)pressure channel:(uint8_t)channel; 62 | - (void)sendContinuousControllerWithNumber:(uint8_t)number value:(uint8_t)value channel:(uint8_t)channel; 63 | - (void)sendPatchChangeMessageWithProgram:(uint8_t)program channel:(uint8_t)channel; 64 | - (void)sendChannelPressureMessageWithPressure:(uint8_t)pressure channel:(uint8_t)channel; 65 | - (void)sendPitchBendMessageWithValue:(uint16_t)value channel:(uint8_t)channel; 66 | 67 | - (void)setEventHandler:(NSObject *)handler; 68 | - (void)eventHandlerEventsAvailable; 69 | @end 70 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_EventQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_EventQueue.h 3 | // Created by Timothy Place on 11.08.15. 4 | // 5 | 6 | #ifndef _RNBO_EventQueue_h 7 | #define _RNBO_EventQueue_h 8 | 9 | RNBO_PUSH_DISABLE_WARNINGS 10 | #include "3rdparty/readerwriterqueue/readerwriterqueue.h" 11 | RNBO_POP_DISABLE_WARNINGS 12 | 13 | #ifdef __APPLE__ 14 | #include 15 | #endif 16 | 17 | // disable this on iOS for now as it requires thread-local-storage which iOS seems to not support 18 | // this is a bit of a hack, but fixes build for now 19 | #if TARGET_OS_IPHONE 20 | #define RNBO_MULTIPRODUCER_QUEUE_SUPPORTED 0 21 | #else 22 | #define RNBO_MULTIPRODUCER_QUEUE_SUPPORTED 1 23 | #endif 24 | 25 | #if RNBO_MULTIPRODUCER_QUEUE_SUPPORTED 26 | RNBO_PUSH_DISABLE_WARNINGS 27 | #include "3rdparty/concurrentqueue/concurrentqueue.h" 28 | RNBO_POP_DISABLE_WARNINGS 29 | #endif 30 | 31 | namespace RNBO { 32 | 33 | /** 34 | * @brief A lock-free queue that may have one producer thread, one consumer thread 35 | * 36 | * @tparam T type of event to be queued 37 | */ 38 | template 39 | class EventQueueBase 40 | { 41 | public: 42 | virtual ~EventQueueBase() {} 43 | /** Add an event of any kind to the back of the queue. 44 | @param ev An event to push onto the queue. 45 | */ 46 | virtual void enqueue(const T& ev) = 0; 47 | 48 | /** Fetch the front-most event off of the queue. 49 | @param ev A dummy event to be filled-in upon return. 50 | @return True if an event was successfully retrieved. 51 | Will return false if there are no events left on the queue. 52 | */ 53 | virtual bool dequeue(T& ev) = 0; 54 | }; 55 | 56 | // TODO: could parameterize with e.g. queue size 57 | /** 58 | * @brief A lock-free queue that may have one producer thread, one consumer thread 59 | * 60 | * @tparam T type of event to be queued 61 | * @tparam Q type of queue 62 | */ 63 | template 64 | class EventQueue : public EventQueueBase 65 | { 66 | public: 67 | EventQueue() 68 | : _queue(128) // for now setting inital size to avoid malloc on audio thread at startup 69 | { 70 | 71 | } 72 | 73 | ~EventQueue() override {} 74 | 75 | /** 76 | * @brief Add an event of any kind to the back of the queue. 77 | * 78 | * @param ev An event to push onto the queue. 79 | */ 80 | void enqueue(const T& ev) override { 81 | _queue.enqueue(ev); 82 | } 83 | 84 | /* 85 | * @brief Fetch the front-most event off of the queue. 86 | * 87 | * @param ev A dummy event to be filled-in upon return. 88 | * 89 | * @return True if an event was successfully retrieved. 90 | * @return False if there are no events left on the queue. 91 | */ 92 | bool dequeue(T& ev) override { 93 | return _queue.try_dequeue(ev); 94 | } 95 | private: 96 | Q _queue; 97 | }; 98 | 99 | } // namespace rnbo 100 | 101 | #endif // _RNBO_EventQueue_h 102 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Bindings/RNBOEventHandlerProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBOEventHandlerProtocol.h 3 | // 4 | // 5 | // Created by Alex on 21.02.2023. 6 | // 7 | 8 | #pragma once 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | //struct OpaqueList; 15 | 16 | typedef enum RNBOMessageEventType { 17 | RNBOMessageEventType_Invalid = -1, 18 | RNBOMessageEventType_Number = 0, 19 | RNBOMessageEventType_List, 20 | RNBOMessageEventType_Bang, 21 | RNBOMessageEventType_Max_Type 22 | } RNBOMessageEventType; 23 | 24 | typedef enum RNBOPresetEventType { 25 | RNBOPresetEventType_Invalid = -1, 26 | RNBOPresetEventType_Set = 0, 27 | RNBOPresetEventType_Touched, 28 | RNBOPresetEventType_Get, 29 | RNBOPresetEventType_SettingBegin, 30 | RNBOPresetEventType_SettingEnd, 31 | RNBOPresetEventType_Max_Type 32 | } RNBOPresetEventType; 33 | 34 | 35 | typedef struct RNBOParameterEvent { 36 | bool isValid; 37 | size_t index; 38 | double timeMilliseconds; 39 | double value; 40 | const void *source; 41 | // patchereventtarget 42 | } RNBOParameterEvent; 43 | 44 | typedef struct RNBOMidiEvent { 45 | double timeMilliseconds; 46 | int portIndex; 47 | size_t length; 48 | uint8_t midiData[3]; 49 | // patchereventtarget 50 | } RNBOMidiEvent; 51 | 52 | typedef struct RNBOMessageEvent { 53 | uint32_t tag; 54 | uint32_t objectId; 55 | double eventTime; 56 | RNBOMessageEventType type; 57 | 58 | double numValue; 59 | } RNBOMessageEvent; 60 | 61 | typedef struct RNBOPresetEvent { 62 | double eventTime; 63 | } RNBOPresetEvent; 64 | 65 | typedef struct RNBOTempoEvent { 66 | } RNBOTempoEvent; 67 | 68 | typedef struct RNBOTransportEvent { 69 | } RNBOTransportEvent; 70 | 71 | typedef struct RNBOBeatTimeEvent { 72 | } RNBOBeatTimeEvent; 73 | 74 | typedef struct RNBOTimeSignatureEvent { 75 | } RNBOTimeSignatureEvent; 76 | 77 | typedef struct RNBOStartupEvent { 78 | } RNBOStartupEvent; 79 | 80 | ///> @new 81 | typedef struct RNBOMessageEventBase { 82 | uint32_t tag; 83 | uint32_t objectId; 84 | double eventTime; 85 | } RNBOMessageEventBase; 86 | 87 | @protocol RNBOEventHandlerProtocol 88 | 89 | 90 | 91 | - (void)handleParameterEvent:(RNBOParameterEvent)event; 92 | - (void)handleMidiEvent:(RNBOMidiEvent)event; 93 | - (void)handleMessageEvent:(RNBOMessageEvent)event; 94 | - (void)handlePresetEvent:(RNBOPresetEvent)event; 95 | - (void)handleTempoEvent:(RNBOTempoEvent)event; 96 | - (void)handleTransportEvent:(RNBOTransportEvent)event; 97 | - (void)handleBeatTimeEvent:(RNBOBeatTimeEvent)event; 98 | - (void)handleTimeSignatureEvent:(RNBOTimeSignatureEvent)event; 99 | - (void)handleStartupEvent:(RNBOStartupEvent)event; 100 | 101 | @optional 102 | - (void)handleBangMessageEvent:(RNBOMessageEventBase)event; 103 | - (void)handleFloatMessageEvent:(RNBOMessageEventBase)event value:(float)value; 104 | - (void)handleListMessageEvent:(RNBOMessageEventBase)event value:(NSArray *)value; 105 | @end 106 | 107 | NS_ASSUME_NONNULL_END 108 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_EngineInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_EngineInterface.h 3 | // 4 | // Created by Rob Sussman on 8/25/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_EngineInterface_h_ 9 | #define _RNBO_EngineInterface_h_ 10 | 11 | #include "RNBO_EngineLink.h" 12 | 13 | namespace RNBO { 14 | 15 | class EventTarget; 16 | 17 | /** 18 | * @private 19 | * 20 | * The EngineInterface is passed to the generated code to allow it to talk 21 | * to the Engine 22 | */ 23 | class EngineInterface { 24 | 25 | protected: 26 | // user of EngineInterface should not delete it 27 | ~EngineInterface() { } 28 | 29 | public: 30 | 31 | virtual void scheduleClockEvent(EventTarget* eventTarget, ClockId clockIndex, MillisecondTime delay) = 0; 32 | virtual void scheduleClockEventWithValue(EventTarget* eventTarget, ClockId clockIndex, MillisecondTime delay, ParameterValue value) = 0; 33 | 34 | // remove all clock events from the scheduler, optionally executing the clocks 35 | virtual void flushClockEvents(EventTarget* eventTarget, ClockId clockIndex, bool execute) = 0; 36 | virtual void flushClockEventsWithValue(EventTarget* eventTarget, ClockId clockIndex, ParameterValue value, bool execute) = 0; 37 | 38 | // methods for generated code to send data out of the graph into the engine 39 | virtual void sendMidiEvent(int port, int b1, int b2, int b3, MillisecondTime time = 0.0) = 0; 40 | virtual void sendMidiEventList(int port, const list& data, MillisecondTime time = 0.0) = 0; 41 | 42 | // send an event from an external back into the RNBO graph 43 | virtual void sendOutlet(EngineLink* sender, OutletIndex index, ParameterValue value, SampleOffset sampleOffset = 0) = 0; 44 | 45 | // notify that a certain DataRef has been updated 46 | virtual void sendDataRefUpdated(DataRefIndex index) = 0; 47 | 48 | virtual void sendTempoEvent(Tempo tempo) = 0; 49 | virtual void sendTransportEvent(TransportState state) = 0; 50 | virtual void sendBeatTimeEvent(BeatTime beattime) = 0; 51 | virtual void sendTimeSignatureEvent(int numerator, int denominator) = 0; 52 | 53 | // send a message to the outside world 54 | virtual void sendNumMessage(MessageTag tag, MessageTag objectId, number payload, MillisecondTime time) = 0; 55 | virtual void sendListMessage(MessageTag tag, MessageTag objectId, const list& payload, MillisecondTime time) = 0; 56 | virtual void sendBangMessage(MessageTag tag, MessageTag objectId, MillisecondTime time) = 0; 57 | 58 | // notify the outside world about an internal Parameter Change 59 | virtual void notifyParameterValueChanged(ParameterIndex index, ParameterValue value, bool ignoreSource) = 0; 60 | // schedule a parameter change event 61 | virtual void scheduleParameterChange(ParameterIndex index, ParameterValue value, MillisecondTime offset) = 0; 62 | 63 | virtual void updatePatcherEventTarget(const EventTarget *oldTarget, PatcherEventTarget *newTarget) = 0; 64 | virtual void rescheduleEventTarget(const EventTarget *target) = 0; 65 | 66 | virtual MillisecondTime getCurrentTime() = 0; 67 | 68 | virtual void presetTouched() = 0; 69 | 70 | }; 71 | 72 | } // namespace RNBO 73 | 74 | #endif // #ifndef _RNBO_EngineInterface_h_ 75 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_PatcherStateDummy.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_PatcherStateDummy.h 3 | // 4 | // Created by Jeremy Bernstein on 30.08.16. 5 | // 6 | // 7 | 8 | #ifndef RNBO_PatcherStateDummy_h 9 | #define RNBO_PatcherStateDummy_h 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_PatcherStateInterface.h" 13 | 14 | namespace RNBO { 15 | 16 | /** 17 | * @private 18 | */ 19 | class PatcherStateDummy : public PatcherStateInterface { 20 | 21 | private: 22 | 23 | void add(const char* key, number val) override { RNBO_UNUSED(key); RNBO_UNUSED(val); } 24 | void add(const char* key, Int val) override { RNBO_UNUSED(key); RNBO_UNUSED(val); } 25 | void add(const char* key, Index val) override { RNBO_UNUSED(key); RNBO_UNUSED(val); } 26 | void add(const char* key, bool val) override { RNBO_UNUSED(key); RNBO_UNUSED(val); } 27 | void add(const char* key, ExternalPtr& ext) override { RNBO_UNUSED(key); RNBO_UNUSED(ext); } 28 | void add(const char* key, PatcherEventTarget* patcherEventTarget) override { RNBO_UNUSED(key); RNBO_UNUSED(patcherEventTarget); } 29 | void add(const char* key, const list& theList) override { RNBO_UNUSED(key); RNBO_UNUSED(theList); } 30 | void add(const char* key, DataRef& dataRef) override { RNBO_UNUSED(key); RNBO_UNUSED(dataRef); } 31 | void add(const char* key, MultiDataRef& dataRef) override { RNBO_UNUSED(key); RNBO_UNUSED(dataRef); } 32 | void add(const char* key, signal sig) override { RNBO_UNUSED(key); RNBO_UNUSED(sig); } 33 | void add(const char* key, const char* str) override { RNBO_UNUSED(key); RNBO_UNUSED(str); } 34 | 35 | number getFloat(const char* key) override { RNBO_UNUSED(key); return number(0); } 36 | Int getInt(const char* key) override { RNBO_UNUSED(key); return Index(0); } 37 | Index getIndex(const char* key) override { RNBO_UNUSED(key); return Index(0); } 38 | bool getBool(const char* key) override { RNBO_UNUSED(key); return Index(0); } 39 | ExternalPtr getExternalPtr(const char* key) override { RNBO_UNUSED(key); return nullptr; } 40 | PatcherEventTarget* getEventTarget(const char* key) override { RNBO_UNUSED(key); return nullptr; } 41 | bool isEmpty() const override { return true; } 42 | list getList(const char* key) override { RNBO_UNUSED(key); return _list; } 43 | DataRef& getDataRef(const char *key) override { RNBO_UNUSED(key); return _dataRef; } 44 | MultiDataRef& getMultiDataRef(const char *key) override { RNBO_UNUSED(key); return _multiDataRef; } 45 | signal getSignal(const char *key) override { RNBO_UNUSED(key); return nullptr; } 46 | const char* getString(const char *key) override { RNBO_UNUSED(key); return ""; } 47 | 48 | bool containsValue(const char* key) const override { RNBO_UNUSED(key); return false; } 49 | 50 | PatcherStateInterface& getSubState(const char* key) override { RNBO_UNUSED(key); return *this; } 51 | PatcherStateInterface& getSubStateAt(const char* key, Index i) override { RNBO_UNUSED(key); RNBO_UNUSED(i); return *this; } 52 | const PatcherStateInterface& getSubState(const char* key) const override { RNBO_UNUSED(key); return *this; } 53 | const PatcherStateInterface& getSubStateAt(const char* key, Index i) const override { RNBO_UNUSED(key); RNBO_UNUSED(i); return *this; } 54 | 55 | list _list; 56 | DataRef _dataRef; 57 | MultiDataRef _multiDataRef; 58 | }; 59 | 60 | } 61 | 62 | #endif // RNBO_PatcherStateDummy_h 63 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ClockEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ClockEvent.h 3 | // 4 | // Created by Rob Sussman on 8/6/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_ClockEvent_H_ 9 | #define _RNBO_ClockEvent_H_ 10 | 11 | #include "RNBO_EventTarget.h" 12 | 13 | namespace RNBO { 14 | 15 | /** 16 | * @private 17 | * An clock (Timer) event 18 | */ 19 | class ClockEvent { 20 | 21 | public: 22 | ClockEvent(ClockId clockIndex, MillisecondTime eventTime, EventTarget* eventTarget = nullptr) 23 | : _clockIndex(clockIndex) 24 | , _eventTime(eventTime) 25 | , _value(0) 26 | , _hasValue(false) 27 | , _eventTarget(eventTarget) 28 | { 29 | 30 | } 31 | 32 | ClockEvent(ClockId clockIndex, MillisecondTime eventTime, ParameterValue value, EventTarget* eventTarget = nullptr) 33 | : _clockIndex(clockIndex) 34 | , _eventTime(eventTime) 35 | , _value(value) 36 | , _hasValue(true) 37 | , _eventTarget(eventTarget) 38 | { 39 | 40 | } 41 | 42 | ClockEvent() 43 | : _clockIndex(0) 44 | , _eventTime(0) 45 | , _value(0) 46 | , _hasValue(false) 47 | , _eventTarget(nullptr) 48 | { 49 | } 50 | 51 | bool operator==(const ClockEvent& rhs) const 52 | { 53 | 54 | if (rhs.getClockIndex() != getClockIndex()) 55 | return false; 56 | if (rhs.getTime() != getTime()) 57 | return false; 58 | if (hasValue() != rhs.hasValue()) 59 | return false; 60 | // we know both have same hasValue() 61 | if (hasValue()) { 62 | // we now know that the events are equal if they both have the same value 63 | return rhs.getValue() == getValue(); 64 | } 65 | if (rhs._eventTarget != _eventTarget) 66 | return false; 67 | 68 | // if we get here we know that we don't care about the value 69 | return true; 70 | } 71 | 72 | bool matchesEventTargetAndClockIndex(EventTarget* eventTarget, ClockId clockIndex) const { 73 | return _eventTarget == eventTarget 74 | && _clockIndex == clockIndex; 75 | } 76 | 77 | bool matchesEventTargetAndClockIndex(const ClockEvent& ce) const { 78 | return matchesEventTargetAndClockIndex(ce._eventTarget, ce._clockIndex); 79 | } 80 | 81 | bool matchesEventTargetClockIndexAndValue(EventTarget* eventTarget, ClockId clockIndex, ParameterValue value) const { 82 | return _eventTarget == eventTarget 83 | && _clockIndex == clockIndex 84 | && _value == value; 85 | } 86 | 87 | ClockId getClockIndex() const { return _clockIndex; } 88 | ParameterValue getValue() const { return _value; } 89 | bool hasValue() const { return _hasValue; } 90 | 91 | MillisecondTime getTime() const { return _eventTime; } 92 | EventTarget* getEventTarget() const { return _eventTarget; } 93 | 94 | // debugging 95 | void dumpEvent() const { /* fprintf(stdout, "ClockEvent: eventTarget=%p clockIndex=%ld time=%.3f hasValue=%s value=%.4f\n", _eventTarget, _clockIndex, _eventTime, _hasValue?"true":"false", _value); */ } 96 | 97 | private: 98 | 99 | ClockId _clockIndex; 100 | MillisecondTime _eventTime; 101 | ParameterValue _value; 102 | bool _hasValue; 103 | 104 | friend class EventVariant; 105 | 106 | EventTarget* _eventTarget; 107 | 108 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 109 | 110 | }; 111 | 112 | } // namespace RNBO 113 | 114 | 115 | #endif // #ifndef _RNBO_ClockEvent_H_ 116 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParameterInterfaceAsync.cpp: -------------------------------------------------------------------------------- 1 | #include "RNBO.h" 2 | #include "RNBO_ParameterInterfaceAsyncImpl.h" 3 | 4 | namespace RNBO { 5 | 6 | ParameterInterfaceAsync::ParameterInterfaceAsync(Engine& engine, EventHandler* handler, ParameterEventInterface::Type type) { 7 | if (handler) { 8 | handler->linkToParameterEventInterface(this); 9 | } 10 | 11 | switch (type) { 12 | case ParameterEventInterface::SingleProducer: 13 | handler 14 | ? _impl = std::make_shared >(engine, handler, make_unique(), make_unique()) 15 | : _impl = std::make_shared >(engine, handler, make_unique(), make_unique()); 16 | break; 17 | case ParameterEventInterface::MultiProducer: 18 | _impl = std::make_shared>(engine, handler, make_unique(), make_unique()); 19 | break; 20 | case ParameterEventInterface::Trigger: 21 | case ParameterEventInterface::NotThreadSafe: 22 | // for the non threadsafe version use the ParameterInterfaceSync 23 | RNBO_ASSERT(false); 24 | break; 25 | } 26 | 27 | engine.registerAsyncParameterInterface(_impl); 28 | } 29 | 30 | ParameterInterfaceAsync::~ParameterInterfaceAsync() { 31 | if (_impl->isActive()) { 32 | _impl->notifyParameterInterfaceDeleted(); 33 | } 34 | } 35 | 36 | ParameterIndex ParameterInterfaceAsync::getNumParameters() const { 37 | return _impl->getNumParameters(); 38 | } 39 | 40 | void ParameterInterfaceAsync::getParameterInfo(ParameterIndex index, ParameterInfo* info) const { 41 | _impl->getParameterInfo(index, info); 42 | } 43 | 44 | ConstCharPointer ParameterInterfaceAsync::getParameterName(ParameterIndex index) const { 45 | return _impl->getParameterName(index); 46 | } 47 | 48 | ConstCharPointer ParameterInterfaceAsync::getParameterId(ParameterIndex index) const { 49 | return _impl->getParameterId(index); 50 | } 51 | 52 | ParameterValue ParameterInterfaceAsync::getParameterValue(ParameterIndex index) { 53 | return _impl->getParameterValue(index); 54 | } 55 | 56 | void ParameterInterfaceAsync::setParameterValue(ParameterIndex index, ParameterValue value, MillisecondTime time) { 57 | _impl->setParameterValue(index, value, time); 58 | } 59 | 60 | void ParameterInterfaceAsync::scheduleEvent(EventVariant event) { 61 | _impl->scheduleEvent(event); 62 | } 63 | 64 | void ParameterInterfaceAsync::drainEvents() { 65 | _impl->drainEvents(); 66 | } 67 | 68 | ParameterValue ParameterInterfaceAsync::convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const 69 | { 70 | return _impl->convertToNormalizedParameterValue(index, value); 71 | } 72 | 73 | ParameterValue ParameterInterfaceAsync::convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue normalizedValue) const 74 | { 75 | return _impl->convertFromNormalizedParameterValue(index, normalizedValue); 76 | } 77 | 78 | ParameterValue ParameterInterfaceAsync::constrainParameterValue(ParameterIndex index, ParameterValue value) const 79 | { 80 | return _impl->constrainParameterValue(index, value); 81 | } 82 | 83 | 84 | } // namespace RNBO 85 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_MIDIHelper.h: -------------------------------------------------------------------------------- 1 | #ifndef _RNBO_MIDIHelper_H_ 2 | #define _RNBO_MIDIHelper_H_ 3 | 4 | namespace RNBO { 5 | 6 | enum { 7 | MIDI_InvalidByte = -1, 8 | MIDI_StatusByteReceived = 0, 9 | MIDI_SecondByteReceived, 10 | MIDI_Send2Bytes, 11 | MIDI_NoteOff, 12 | MIDI_NoteOn, 13 | MIDI_Aftertouch, 14 | MIDI_CC, 15 | MIDI_ProgramChange, 16 | MIDI_ChannelPressure, 17 | MIDI_PitchBend, 18 | MIDI_Generic, 19 | 20 | MIDI_Sysex_Started, 21 | MIDI_Sysex_Complete, 22 | 23 | MIDI_NoteOffMask = 0x80, 24 | MIDI_NoteOnMask = 0x90, 25 | MIDI_AfterTouchMask = 0xA0, 26 | MIDI_CCMask = 0xB0, 27 | MIDI_ProgramChangeMask = 0xC0, 28 | MIDI_ChannelPressureMask = 0xD0, 29 | MIDI_PitchBendMask = 0xE0, 30 | 31 | MIDI_CC_Sustain = 64, 32 | MIDI_CC_Sostenuto = 66, 33 | MIDI_CC_AllNotesOff = 123, 34 | MIDI_CC_PressureMSB = 70, 35 | MIDI_CC_PressureLSB = 102, 36 | MIDI_CC_TimbreMSB = 74, 37 | MIDI_CC_TimbreLSB = 106, 38 | 39 | MIDI_SysexStart = 0xF0, 40 | 41 | //system common 42 | MIDI_QuarterFrame = 0xF1, 43 | MIDI_SongPos = 0xF2, 44 | MIDI_SongSel = 0xF3, 45 | MIDI_TuneRequest = 0xF6, 46 | 47 | MIDI_SysexEnd = 0xF7, 48 | 49 | //system realtime 50 | MIDI_Clock = 0xF8, 51 | MIDI_Start = 0xFA, 52 | MIDI_Continue = 0xFB, 53 | MIDI_Stop = 0xFC, 54 | MIDI_ActiveSense = 0xFE, 55 | MIDI_Reset = 0xFF, 56 | 57 | 58 | MIDI_NoteState_Off = 0, 59 | MIDI_NoteState_On = 1, 60 | MIDI_NoteState_Sustained = 2 61 | }; 62 | 63 | static inline int parseMidi(int currentStatus, int byte, int statusbyte) 64 | { 65 | if (byte == 0xF0) { 66 | return MIDI_Sysex_Started; 67 | } 68 | else if (currentStatus == MIDI_Sysex_Started) { 69 | if (byte == 0xF7) { 70 | return MIDI_Sysex_Complete; 71 | } 72 | else if (byte <= 0x7F) { 73 | return currentStatus; 74 | } 75 | else { 76 | return MIDI_InvalidByte; 77 | } 78 | } 79 | 80 | if (byte > 127) return MIDI_StatusByteReceived; 81 | 82 | int command = statusbyte & 0xF0; // get command 83 | 84 | if (currentStatus == MIDI_StatusByteReceived) 85 | { 86 | if (command == MIDI_ProgramChangeMask) return MIDI_ProgramChange; 87 | if (command == MIDI_ChannelPressureMask) return MIDI_ChannelPressure; 88 | if (statusbyte == MIDI_QuarterFrame) return MIDI_QuarterFrame; 89 | if (statusbyte == MIDI_SongSel) return MIDI_SongSel; 90 | return MIDI_SecondByteReceived; 91 | } 92 | else if (currentStatus == MIDI_SecondByteReceived) { 93 | if (command == MIDI_NoteOffMask || (command == MIDI_NoteOnMask && byte == 0)) return MIDI_NoteOff; 94 | if (command == MIDI_NoteOnMask) return MIDI_NoteOn; 95 | if (command == MIDI_AfterTouchMask) return MIDI_Aftertouch; 96 | if (command == MIDI_CCMask) return MIDI_CC; 97 | if (command == MIDI_PitchBendMask) return MIDI_PitchBend; 98 | if (statusbyte == MIDI_SongPos) return MIDI_SongPos; 99 | // probably shouldn't get here 100 | return MIDI_Generic; 101 | } 102 | 103 | return currentStatus; 104 | } 105 | 106 | static inline int getMIDIChannel(int statusbyte) 107 | { 108 | int command = statusbyte & 0xF0; 109 | 110 | if (command >= 0x80 && command <= 0xE0) { 111 | return statusbyte & 0x0F; 112 | } 113 | 114 | return 0; 115 | } 116 | } 117 | 118 | 119 | 120 | #endif // _RNBO_MIDIHelper_H_ 121 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Interface/RNBOEventHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RNBOEventHandler.swift 3 | // SwiftRNBO_Example_multiplatfrom_SwiftUI 4 | // 5 | // Created by Eldar Sadykov on 16.11.2023. 6 | // 7 | 8 | import Foundation 9 | 10 | class RNBOEventHandler: NSObject, RNBOEventHandlerProtocol { 11 | var rnbo: RNBOContext? 12 | 13 | func handle(_ event: RNBOParameterEvent) { 14 | if let rnbo = rnbo { 15 | DispatchQueue.main.async { 16 | rnbo.parameters[event.index].value = event.value 17 | } 18 | 19 | let p = rnbo.parameters[event.index] 20 | print("\(p.info.displayName): \(p.value)") 21 | } 22 | } 23 | 24 | func handle(_ event: RNBOMidiEvent) { 25 | let data = [event.midiData.0, event.midiData.1, event.midiData.2].prefix(event.length) 26 | print("Received MIDI: \(data)") 27 | 28 | let statusByte = event.midiData.0 29 | let channel = statusByte & 0x0F 30 | guard let command = MidiCommand(statusByte: statusByte) else { 31 | print("Unknown MIDI Command") 32 | return 33 | } 34 | 35 | switch command { 36 | case .noteOff: 37 | let note = event.midiData.1 38 | let velocity = event.midiData.2 39 | print("Note Off: Note \(note), Velocity \(velocity), Channel \(channel + 1)") 40 | 41 | case .noteOn: 42 | let note = event.midiData.1 43 | let velocity = event.midiData.2 44 | print("Note On: Note \(note), Velocity \(velocity), Channel \(channel + 1)") 45 | 46 | case .polyphonicKeyPressure: 47 | let note = event.midiData.1 48 | let pressure = event.midiData.2 49 | print("Polyphonic Key Pressure: Note \(note), Pressure \(pressure), Channel \(channel + 1)") 50 | 51 | case .controlChange: 52 | let controller = event.midiData.1 53 | let value = event.midiData.2 54 | print("Control Change: Controller \(controller), Value \(value), Channel \(channel + 1)") 55 | 56 | case .programChange: 57 | let program = event.midiData.1 58 | print("Program Change: Program \(program), Channel \(channel + 1)") 59 | 60 | case .channelPressure: 61 | let pressure = event.midiData.1 62 | print("Channel Pressure: Pressure \(pressure), Channel \(channel + 1)") 63 | 64 | case .pitchBend: 65 | let lsb = event.midiData.1 66 | let msb = event.midiData.2 67 | let value = (Int(msb) << 7) + Int(lsb) 68 | print("Pitch Bend: Value \(value), Channel \(channel + 1)") 69 | } 70 | } 71 | 72 | func handle(_ event: RNBOMessageEvent) { 73 | // print("Message from outport: \(event.tag): \(event.numValue)") 74 | // TODO: 75 | } 76 | 77 | func handle(_ event: RNBOPresetEvent) { 78 | // TODO: 79 | } 80 | 81 | func handle(_ event: RNBOTempoEvent) { 82 | // TODO: 83 | } 84 | 85 | func handle(_ event: RNBOTransportEvent) { 86 | // TODO: 87 | } 88 | 89 | func handle(_ event: RNBOBeatTimeEvent) { 90 | // TODO: 91 | } 92 | 93 | func handle(_ event: RNBOTimeSignatureEvent) { 94 | // TODO: 95 | } 96 | 97 | func handle(_ event: RNBOStartupEvent) { 98 | // TODO: 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcodeproj/xcshareddata/xcschemes/SwiftRNBO_Example_multiplatfrom_SwiftUI.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 42 | 44 | 50 | 51 | 52 | 53 | 59 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/adapters/juce/RNBO_JuceAudioProcessorUtils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_JuceAudioProcessorUtils.cpp 3 | // 4 | // Created by Rob Sussman on 8/14/15. 5 | // 6 | // 7 | 8 | #include "RNBO_JuceAudioProcessorUtils.h" 9 | 10 | namespace RNBO { 11 | 12 | namespace JuceAudioProcessorUtils { 13 | 14 | 15 | void fillCurrentEventsFromMidiBuffer(EventList& currentEvents, 16 | const TimeConverter& timeConverter, 17 | juce::MidiBuffer& midiMessages) 18 | { 19 | if (!midiMessages.isEmpty()) { 20 | 21 | for (auto meta: midiMessages) { 22 | // take the MIDI events coming in via Juce and stuff them inside the list of _currentEvents (the list is sorted by time) 23 | MillisecondTime time = timeConverter.convertSampleOffsetToMilliseconds(meta.samplePosition); 24 | currentEvents.addEvent(MidiEvent(time, 0, meta.data, (Index)meta.numBytes)); 25 | } 26 | 27 | // The JUCE AudioProcessor model is that any events left in the midiBuffer 28 | // are treated as the output of the plugin so we need to clear or else everything 29 | // gets sent on. 30 | midiMessages.clear(); 31 | } 32 | } 33 | 34 | void fillAudioInputBuffers(const std::vector& audioInputs, 35 | size_t sampleFrames, 36 | juce::AudioSampleBuffer& buffer) 37 | { 38 | int channelIndex = 0; 39 | for (SampleValue *pWritePtr : audioInputs) 40 | { 41 | if (channelIndex < buffer.getNumChannels()) 42 | { 43 | const float *pReadPtr = buffer.getReadPointer(channelIndex); 44 | size_t framesLeft = sampleFrames; 45 | while (framesLeft--) 46 | { 47 | *pWritePtr++ = *pReadPtr++; 48 | } 49 | } 50 | else 51 | { 52 | memset(pWritePtr, 0, sampleFrames * sizeof(SampleValue)); 53 | } 54 | channelIndex++; 55 | } 56 | } 57 | 58 | void fillAudioOutputBuffers(const std::vector& audioOutputs, 59 | size_t sampleFrames, 60 | juce::AudioSampleBuffer& buffer) 61 | { 62 | int channelCount = buffer.getNumChannels(); 63 | for (int channelIndex = 0; channelIndex < channelCount; channelIndex++) 64 | { 65 | float *pWritePtr = buffer.getWritePointer(channelIndex); 66 | if (channelIndex < (int)audioOutputs.size()) 67 | { 68 | const SampleValue* pReadPtr = audioOutputs[(size_t)channelIndex]; 69 | size_t framesLeft = sampleFrames; 70 | while (framesLeft--) 71 | { 72 | *pWritePtr++ = (float) *pReadPtr++; 73 | } 74 | } 75 | else 76 | { 77 | buffer.clear(channelIndex, 0, buffer.getNumSamples()); 78 | } 79 | } 80 | } 81 | 82 | void sendOutgoingMidiEvents(EventList& midiEvents, 83 | MillisecondTime endTime, 84 | TimeConverter timeConverter, 85 | juce::MidiBuffer& midiMessages) 86 | { 87 | if (!midiEvents.empty()) { 88 | const auto it = midiEvents.getFirstEventAfterTime(endTime); 89 | // now we have the range of events that are valid for 90 | std::for_each(midiEvents.begin(), 91 | it, 92 | [&timeConverter, &midiMessages](const MidiEvent& ev) { 93 | int sampleNumber = static_cast(timeConverter.convertMillisecondsToSampleOffset(ev.getTime())); 94 | auto midiMessage = juce::MidiMessage(ev.getData(), (int)ev.getLength()); 95 | midiMessages.addEvent(midiMessage, sampleNumber); 96 | }); 97 | midiEvents.erase(midiEvents.begin(), it); 98 | } 99 | } 100 | 101 | 102 | } // namespace JuceAudioProcessorUtils 103 | 104 | } // namespace RNBO 105 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_ParameterEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_ParameterEvent.h 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_ParameterEvent_H_ 9 | #define _RNBO_ParameterEvent_H_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_Math.h" // isnan 13 | 14 | namespace RNBO { 15 | 16 | class PatcherEventTarget; 17 | 18 | // for now this is restricted to float values (so we might re-name this to be ParameterFloatEvent), but in the 19 | // future we might have ParameterStringEvent, ParameterBandEvent etc. 20 | 21 | /** 22 | * An event representing a parameter value change 23 | */ 24 | class ParameterEvent { 25 | 26 | public: 27 | 28 | ParameterEvent() 29 | : _parameterIndex(INVALID_INDEX) 30 | , _eventTime(0) 31 | , _value(0) 32 | , _source(nullptr) 33 | , _eventTarget(nullptr) 34 | { 35 | } 36 | 37 | ParameterEvent(const ParameterEvent& other) = default; 38 | ParameterEvent& operator = (const ParameterEvent& other) = default; 39 | 40 | ParameterEvent(ParameterIndex parameterIndex, MillisecondTime eventTime, ParameterValue value, ParameterInterfaceId source, PatcherEventTarget* eventTarget = nullptr) 41 | : _parameterIndex(parameterIndex) 42 | , _eventTime(eventTime) 43 | , _value(value) 44 | , _source(source) 45 | , _eventTarget(eventTarget) 46 | { 47 | } 48 | 49 | // we want to treat two parameter events as equal if they both have values which are NaNs 50 | // despite the fact that comparing two NaNs will return false 51 | // this way we can avoid notification of non-changes in parameters 52 | bool valuesAreEqual(ParameterValue lhs, ParameterValue rhs) const 53 | { 54 | bool equal = lhs == rhs ? true : false; 55 | if (!equal) { 56 | // treat two NaN values as equal 57 | if (RNBO_Math::rnbo_isnan(lhs) && RNBO_Math::rnbo_isnan(rhs)) { 58 | equal = true; 59 | } 60 | } 61 | return equal; 62 | } 63 | 64 | bool operator==(const ParameterEvent& rhs) const 65 | { 66 | return rhs.getIndex() == getIndex() 67 | && rhs.getTime() == getTime() 68 | && valuesAreEqual(getValue(), rhs.getValue()) 69 | && rhs.getSource() == getSource() 70 | && rhs._eventTarget == _eventTarget; 71 | } 72 | 73 | ParameterIndex getIndex() const { return _parameterIndex; } 74 | ParameterValue getValue() const { return _value; } 75 | ParameterInterfaceId getSource() const { return _source; } 76 | 77 | MillisecondTime getTime() const { return _eventTime; } 78 | PatcherEventTarget* getEventTarget() const { return _eventTarget; } 79 | 80 | bool isValid() const { return _parameterIndex != INVALID_INDEX; } 81 | void invalidate() { _parameterIndex = INVALID_INDEX; } 82 | 83 | // debugging 84 | void dumpEvent() const { 85 | // disabling for now to avoid requiring fprintf support in generated code 86 | // fprintf(stdout, "ParameterEvent: parameterIndex=%d time=%.3f value=%.4f source=%p\n", _parameterIndex, _eventTime, _value, _source); 87 | } 88 | 89 | private: 90 | 91 | ParameterIndex _parameterIndex; 92 | MillisecondTime _eventTime; 93 | ParameterValue _value; 94 | ParameterInterfaceId _source; 95 | 96 | friend class EventVariant; 97 | 98 | PatcherEventTarget* _eventTarget; 99 | 100 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 101 | 102 | }; 103 | 104 | } // namespace RNBO 105 | 106 | #endif // #ifndef _RNBO_ParameterEvent_H_ 107 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/RNBO_MidiEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_MidiEvent.h 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_MidiEvent_H_ 9 | #define _RNBO_MidiEvent_H_ 10 | 11 | 12 | namespace RNBO { 13 | 14 | // Note that this is not derived from anything, it just declares getTime() and 15 | // can therefore be used inside an event list. 16 | 17 | /** 18 | * An event that can hold a timestamped MIDI Event (MIDI Note, pitchbend etc.) 19 | */ 20 | class EventTarget; 21 | 22 | class MidiEvent { 23 | public: 24 | MidiEvent() 25 | : _eventTime(0) 26 | , _portIndex(0) 27 | , _length(0) 28 | , _eventTarget(nullptr) 29 | { 30 | _midiData[0] = 0; 31 | _midiData[1] = 0; 32 | _midiData[2] = 0; 33 | } 34 | 35 | MidiEvent(MillisecondTime eventTime, int portIndex, int b1, int b2, int b3, EventTarget* eventTarget = nullptr) 36 | : _eventTime(eventTime) 37 | , _portIndex(portIndex) 38 | , _eventTarget(eventTarget) 39 | { 40 | // todo: assert b1, b2, and b3 are valid 41 | _midiData[0] = uint8_t(b1); 42 | _midiData[1] = uint8_t(b2); 43 | _midiData[2] = uint8_t(b3); 44 | // let length based on the status 45 | int status = b1 & 0xF0; 46 | if (status == 0xC0 || status == 0xD0 || b1 == 0xF1 || b1 == 0xF3) { 47 | //prog change, channel pressure, quarter frame, song select 48 | _length = 2; 49 | } else if ((b1 >= 0xF8 && b1 <= 0xFF) || b1 == 0xF6) { 50 | //realtime, tune request 51 | _length = 1; 52 | } else { 53 | _length = 3; 54 | } 55 | } 56 | 57 | 58 | MidiEvent(MillisecondTime eventTime, int portIndex, ConstByteArray data, Index length, EventTarget* eventTarget = nullptr) 59 | : _eventTime(eventTime) 60 | , _portIndex(portIndex) 61 | , _eventTarget(eventTarget) 62 | { 63 | const Index maxlen = sizeof(_midiData) / sizeof(_midiData[0]); 64 | for (Index i = 0; i < maxlen; i++) { 65 | _midiData[i] = 0; 66 | } 67 | _length = length > maxlen ? maxlen : length; 68 | // TODO: handle larger midi packets? 69 | for (Index i = 0; i < _length; i++) { 70 | _midiData[i] = data[i]; 71 | } 72 | } 73 | 74 | bool operator==(const MidiEvent& rhs) const 75 | { 76 | return rhs.getTime() == getTime() 77 | && rhs.getPortIndex() == getPortIndex() 78 | && rhs.getData() == getData() 79 | && rhs.getLength() == getLength() 80 | && rhs._eventTarget == _eventTarget; 81 | } 82 | 83 | int getPortIndex() const { return _portIndex; } 84 | ConstByteArray getData() const { return _midiData; } 85 | Index getLength() const { return _length; } 86 | 87 | MillisecondTime getTime() const { return _eventTime; } 88 | EventTarget* getEventTarget() const { return _eventTarget; } 89 | 90 | // debugging 91 | void dumpEvent() const { 92 | // TODO: would be good to have logging that doesn't depend on fprintf 93 | // fprintf(stdout, "MidiEvent: time=%.3f port=%d length=%d b1=%d b2=%d b3=%d\n", _eventTime, _portIndex, _length, _midiData[0], _midiData[1], _midiData[2]); 94 | } 95 | 96 | private: 97 | 98 | MillisecondTime _eventTime; 99 | int _portIndex; 100 | Index _length; 101 | uint8_t _midiData[3]; 102 | 103 | friend class EventVariant; 104 | 105 | EventTarget* _eventTarget; 106 | 107 | void setTime(MillisecondTime eventTime) { _eventTime = eventTime; } 108 | 109 | }; 110 | 111 | } // namespace RNBO 112 | 113 | #endif // #ifndef _RNBO_MidiEvent_H_ 114 | 115 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_Logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_Logger.h 3 | // Created: 25 Jan 2016 2:42:32pm 4 | // Author: stb 5 | // 6 | // 7 | 8 | #ifndef _RNBO_Logger_h_ 9 | #define _RNBO_Logger_h_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_String.h" 13 | #include "RNBO_List.h" 14 | 15 | namespace RNBO { 16 | 17 | class LoggerInterface; 18 | 19 | extern "C" LoggerInterface* console; // enables console->log() usage 20 | 21 | // interface class enables binary compatibility from dynamically compiled clang/llvm code 22 | // templated functions just simplify usage of the interface, but don't really change the class 23 | /** 24 | * @private 25 | */ 26 | class LoggerInterface { 27 | public: 28 | virtual ~LoggerInterface() {} 29 | virtual void log(LogLevel level, const char* message) = 0; 30 | 31 | // can send as many args to log() as you like, similar to javascript 32 | template 33 | void log(ARGS...args) { 34 | String message; 35 | 36 | // template magic to handle arbitrary args 37 | appendArgsToString(message, args...); 38 | 39 | log(Info, message.c_str()); 40 | } 41 | 42 | template 43 | void log(LogLevel level, ARGS...args) { 44 | String message; 45 | 46 | // template magic to handle arbitrary args 47 | appendArgsToString(message, args...); 48 | 49 | log(level, message.c_str()); 50 | } 51 | private: 52 | // implementation details below 53 | // necessary in header for templates to work 54 | 55 | void appendArgument(String& message, const char *str) 56 | { 57 | message += str; 58 | } 59 | 60 | template 61 | void appendArgument(String& message, T val) 62 | { 63 | char buff[N]; 64 | Platform::get()->toString(buff, N, val); 65 | message += buff; 66 | } 67 | 68 | void appendArgument(String& message, const list& l) 69 | { 70 | for (size_t i = 0; i < l.length; i++) { 71 | if (i > 0) { 72 | message += " "; 73 | } 74 | appendArgument(message, l[i]); 75 | } 76 | } 77 | 78 | /** empty argument handling (required for recursive variadic templates) 79 | */ 80 | void appendArgsToString(String& message) 81 | { 82 | RNBO_UNUSED(message); 83 | } 84 | 85 | /** handle N arguments of any type by recursively working through them 86 | and matching them to the type-matched routine above. 87 | */ 88 | template 89 | void appendArgsToString(String& message, FIRST_ARG const& first, REMAINING_ARGS const& ...args) 90 | { 91 | appendArgument(message, first); 92 | bool hasArgs = sizeof...(args) > 0 ? true : false; 93 | if (hasArgs) { 94 | message += " "; 95 | appendArgsToString(message, args...); // recurse 96 | } 97 | } 98 | }; 99 | 100 | /** 101 | * @private 102 | */ 103 | class Logger : public LoggerInterface { 104 | public: 105 | 106 | Logger(); 107 | virtual ~Logger() override; 108 | 109 | static Logger& getInstance(); 110 | 111 | // platform can set callback to take over handling of log messages 112 | using OutputCallback = void(LogLevel level, const char* message); 113 | void setLoggerOutputCallback(OutputCallback* callback); 114 | 115 | void log(LogLevel level, const char* message) override 116 | { 117 | _outputCallback(level, message); 118 | } 119 | 120 | // defaultLogOutputFunction 121 | static void defaultLogOutputFunction(LogLevel level, const char* message); 122 | 123 | private: 124 | 125 | OutputCallback* _outputCallback; 126 | }; 127 | 128 | } 129 | 130 | #endif // _RNBO_Logger_h_ 131 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/src/platforms/stdlib/RNBO_PlatformInterfaceStdLib.h: -------------------------------------------------------------------------------- 1 | #ifndef RNBO_PLATFORM_INTERFACE_STD_H 2 | #define RNBO_PLATFORM_INTERFACE_STD_H 3 | 4 | #include "RNBO_PlatformInterface.h" 5 | #include "src/RNBO_DynamicSymbolRegistry.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace RNBO { 11 | 12 | class PlatformInterfaceStdLib : public PlatformInterface 13 | { 14 | public: 15 | PlatformInterfaceStdLib() 16 | { 17 | Platform::set(this); 18 | } 19 | 20 | ~PlatformInterfaceStdLib() override 21 | { 22 | 23 | } 24 | 25 | void printMessage(const char* message) override 26 | { 27 | std::cout << message << std::endl; 28 | } 29 | 30 | // memory allocation 31 | void* malloc(size_t bytes) override 32 | { 33 | return ::malloc(bytes); 34 | } 35 | 36 | void* calloc(size_t num, size_t size) override 37 | { 38 | return ::calloc(num, size); 39 | } 40 | 41 | void* realloc(void* ptr, size_t bytes) override 42 | { 43 | //::realloc doesn't like zero sized allocations 44 | if (bytes == 0) { 45 | if (ptr) 46 | ::free(ptr); 47 | return nullptr; 48 | } 49 | return ::realloc(ptr, bytes); 50 | } 51 | 52 | void free(void* ptr) override 53 | { 54 | return ::free(ptr); 55 | } 56 | 57 | void* memcpy(void* dest, const void* src, size_t n) override 58 | { 59 | return ::memcpy(dest, src, n); 60 | } 61 | 62 | void* memmove(void* dest, const void* src, size_t n) override 63 | { 64 | return ::memmove(dest, src, n); 65 | } 66 | 67 | void* memset(void *dest, int value, size_t n) override 68 | { 69 | return ::memset(dest, value, n); 70 | } 71 | 72 | size_t strlen(const char *s) override 73 | { 74 | return ::strlen(s); 75 | } 76 | 77 | int strcmp(const char* s1, const char* s2) override 78 | { 79 | return ::strcmp(s1, s2); 80 | } 81 | 82 | char *strcpy(char *dest, const char *src) override 83 | { 84 | return ::strcpy(dest, src); 85 | } 86 | 87 | // string formatting 88 | void toString(char* str, size_t maxlen, number val) override 89 | { 90 | snprintf(str, maxlen, "%f", double(val)); 91 | } 92 | 93 | void toString(char* str, size_t maxlen, int val) override 94 | { 95 | snprintf(str, maxlen, "%d", val); 96 | } 97 | 98 | void toString(char* str, size_t maxlen, unsigned int val) override 99 | { 100 | snprintf(str, maxlen, "%u", val); 101 | } 102 | 103 | void toString(char* str, size_t maxlen, long val) override 104 | { 105 | snprintf(str, maxlen, "%ld", val); 106 | } 107 | 108 | void toString(char* str, size_t maxlen, long long val) override 109 | { 110 | snprintf(str, maxlen, "%lld", val); 111 | } 112 | 113 | void toString(char* str, size_t maxlen, unsigned long val) override 114 | { 115 | snprintf(str, maxlen, "%lu", val); 116 | } 117 | 118 | void toString(char* str, size_t maxlen, unsigned long long val) override 119 | { 120 | snprintf(str, maxlen, "%llu", val); 121 | } 122 | 123 | void toString(char* str, size_t maxlen, void* val) override 124 | { 125 | snprintf(str, maxlen, "%p", val); 126 | } 127 | 128 | void abort() override { 129 | ::abort(); 130 | } 131 | 132 | void error(RuntimeError e, const char* msg) override { 133 | switch (e) { 134 | case RuntimeError::OutOfRange: 135 | throw std::out_of_range(msg); 136 | default: 137 | throw std::runtime_error(msg); 138 | } 139 | } 140 | 141 | void assertTrue(bool v, const char* msg) override { 142 | if (!v) { 143 | throw std::runtime_error(msg); 144 | } 145 | } 146 | }; 147 | 148 | } // namespace RNBO 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_PatcherInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RNBO_PatcherInterface_H_ 3 | // 4 | // Created by Rob Sussman on 8/4/15. 5 | // 6 | // 7 | 8 | #ifndef _RNBO_PatcherInterface_H_ 9 | #define _RNBO_PatcherInterface_H_ 10 | 11 | #include "RNBO_Types.h" 12 | #include "RNBO_ProcessInterface.h" 13 | #include "RNBO_PatcherEventTarget.h" 14 | #include "RNBO_EngineLink.h" 15 | #include "RNBO_ProbingInterface.h" 16 | #include "RNBO_PatcherStateInterface.h" 17 | #include "RNBO_EngineInterface.h" 18 | 19 | namespace RNBO { 20 | 21 | class DataRef; 22 | 23 | class PatcherInterface : public ProcessInterface, 24 | public PatcherEventTarget, 25 | public EngineLink, 26 | public ProbingInterface 27 | { 28 | protected: 29 | // must be deleted by calling destroy() 30 | virtual ~PatcherInterface() { } 31 | 32 | public: 33 | PatcherInterface() 34 | { } 35 | 36 | virtual void destroy() = 0; 37 | 38 | // Parameters: 39 | // - represent state of the patcher that can be set from the Engine 40 | // - "visible" parameters are made available to plugin environments 41 | // - Index identifies a parameter but might change when patcher code is regenerated 42 | // - Index starts at 0 and goes up to getNumParameters() - 1 43 | // - The parameter name is intended for users to see for plugin environments 44 | 45 | virtual void dump() {} 46 | 47 | virtual void getState(PatcherStateInterface& state) 48 | { 49 | RNBO_UNUSED(state); 50 | } 51 | 52 | void initialize() override 53 | { 54 | // you have to overload at least one initialize methods 55 | // assert(false); // can't use assert in Common 56 | } 57 | 58 | virtual void initialize(PatcherStateInterface&) 59 | { 60 | // the state will only be used if the Patcher overloads this function 61 | initialize(); 62 | } 63 | 64 | virtual void getPreset(PatcherStateInterface&) {} 65 | virtual void setPreset(MillisecondTime, PatcherStateInterface&) {} 66 | virtual DataRefIndex getNumDataRefs() const = 0; 67 | virtual DataRef* getDataRef(DataRefIndex index) = 0; 68 | virtual ParameterIndex getNumSignalInParameters() const = 0; 69 | virtual ParameterIndex getNumSignalOutParameters() const = 0; 70 | virtual MessageTagInfo resolveTag(MessageTag tag) const = 0; 71 | virtual MessageIndex getNumMessages() const { return 0; } 72 | virtual const MessageInfo& getMessageInfo(MessageIndex) const { return NullMessageInfo; } 73 | virtual Index getMaxBlockSize() const = 0; 74 | virtual number getSampleRate() const = 0; 75 | virtual bool hasFixedVectorSize() const = 0; 76 | virtual void sendParameter(ParameterIndex, bool) {} 77 | 78 | virtual ParameterValue getPolyParameterValue(PatcherInterface**, ParameterIndex index) { 79 | return getParameterValue(index); 80 | } 81 | 82 | virtual void setPolyParameterValue(PatcherInterface**, ParameterIndex index, ParameterValue v, MillisecondTime time) { 83 | setParameterValue(index, v, time); 84 | } 85 | }; 86 | 87 | /** 88 | * @private 89 | * 90 | * RNBO::default_delete allows putting PatcherInterface into RNBO::UniquePtr 91 | */ 92 | template <> 93 | struct default_delete 94 | { 95 | void operator() (RNBO::PatcherInterface* pi) const 96 | { 97 | pi->destroy(); 98 | } 99 | }; 100 | 101 | } // namespace RNBO 102 | 103 | #ifndef RNBO_NOSTDLIB 104 | 105 | ///@cond INTERNAL 106 | 107 | // std::default_delete for RNBO::PatcherInterface allows putting PatcherInterface into std::unique_ptr 108 | namespace std 109 | { 110 | template <> 111 | struct default_delete 112 | { 113 | void operator() (RNBO::PatcherInterface* pi) const 114 | { 115 | pi->destroy(); 116 | } 117 | }; 118 | } 119 | 120 | ///@endcond INTERNAL 121 | 122 | #endif // RNBO_NOSTDLIB 123 | 124 | 125 | #endif // #ifndef _RNBO_PatcherInterface_H_ 126 | -------------------------------------------------------------------------------- /SwiftRNBO_Example_multiplatfrom_SwiftUI/SwiftRNBO_Example_multiplatfrom_SwiftUI/RNBO/Export/rnbo/common/RNBO_UniquePtr.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBO_UniquePtr.h 3 | // Created: 30 Jun 2016 6:66:66pm 4 | // Author: Jeremy Bernstein 5 | // 6 | // 7 | 8 | #ifndef _RNBO_UNIQUEPTR_H_ 9 | #define _RNBO_UNIQUEPTR_H_ 10 | 11 | namespace RNBO { 12 | 13 | /** 14 | * @brief A destruction policy for a smart pointer like std::default_delete 15 | * 16 | * Used as the default delete method for a UniquePtr. 17 | */ 18 | template 19 | struct default_delete { 20 | 21 | /** 22 | * @brief Calls delete on a pointer 23 | * 24 | * @param p an object or array to delete 25 | */ 26 | void operator() (T* p) const 27 | { 28 | delete p; 29 | } 30 | }; 31 | 32 | /** 33 | * @brief An smart pointer like std::unique_ptr 34 | * 35 | * A unique pointer is a smart pointer that owns and manages another object 36 | * through a pointer and disposes of that object when the UniquePtr goes 37 | * out of scope. Ownership is enforced by deletion of copy construction and 38 | * copy assignment. 39 | * 40 | * @tparam T the type of object to point to 41 | * @tparam Deleter a callable delete for object destruction 42 | * @see default_delete 43 | * 44 | * @code{.cpp} 45 | * { 46 | * auto myPtr = UniquePtr(new int(74)); 47 | * } // myPtr is out of scope and the memory allocated is now freed 48 | * @endcode{} 49 | */ 50 | template > 51 | class UniquePtr { 52 | 53 | public: 54 | 55 | /** 56 | * @brief Construct a UniquePtr 57 | */ 58 | explicit UniquePtr(T* ptr = nullptr) 59 | : _ptr(ptr) 60 | {} 61 | 62 | /** 63 | * @brief Assign the UniquePtr 64 | * 65 | * Effectively the same as calling `reset()` 66 | */ 67 | UniquePtr& operator=(T* ptr) { 68 | reset(ptr); 69 | return *this; 70 | } 71 | 72 | /** 73 | * @brief Copy constructor 74 | * 75 | * Construct a UniquePtr by transfering ownership from `u` to `*this` 76 | * and making `other`'s pointer `nullptr` 77 | */ 78 | UniquePtr(UniquePtr&& other) { 79 | _ptr = other._ptr; 80 | other._ptr = nullptr; 81 | } 82 | 83 | /** 84 | * @brief Move assignment operator 85 | * 86 | * Transfers ownership from `other` to `*this` 87 | */ 88 | UniquePtr& operator=(UniquePtr&& other) { 89 | reset(other.release()); 90 | return *this; 91 | } 92 | 93 | /** 94 | * @brief Destruct the managed object if one exists 95 | */ 96 | ~UniquePtr() { reset(); } 97 | 98 | /** 99 | * @brief Replace the managed object 100 | */ 101 | void reset(T* ptr = nullptr) { 102 | if (ptr == _ptr) return; 103 | 104 | T* old = _ptr; 105 | _ptr = ptr; 106 | if (old != nullptr) Deleter()(old); 107 | } 108 | 109 | /** 110 | * @brief Get a pointer to the managed object 111 | * 112 | * @return a pointer to the managed object if one exists, otherwise `nullptr` 113 | */ 114 | T* get() const { return _ptr; } 115 | 116 | /** 117 | * @brief Release ownership of the managed object 118 | * 119 | * @return a pointer to the managed object 120 | */ 121 | T* release() { T* rv = _ptr; _ptr = nullptr; return rv; } 122 | 123 | /** 124 | * @brief Dereference the pointer to the managed object 125 | */ 126 | T* operator->() const { return _ptr; } 127 | 128 | /** 129 | * @brief Dereference the pointer to the managed object 130 | */ 131 | T& operator*() const { return *_ptr; } 132 | 133 | /** 134 | * @brief Check if there is an associated managed object 135 | * 136 | * @return `true` if `*this` owns an object, `false` otherwise 137 | */ 138 | operator bool() const { return _ptr ? true : false; } 139 | 140 | // disable copy constructor and assignment operator 141 | UniquePtr(const UniquePtr& other) = delete; 142 | UniquePtr& operator=(const UniquePtr& other) = delete; 143 | 144 | private: 145 | 146 | T* _ptr; 147 | }; 148 | 149 | } 150 | 151 | #endif // #ifndef _RNBO_UNIQUEPTR_H_ 152 | --------------------------------------------------------------------------------