From 28903b731494b2b0423b3137678d9a6398771c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fur=20Bozkurt?= Date: Thu, 1 Feb 2024 21:40:05 +0000 Subject: [PATCH 1/2] Add demo for instruments, implement plucked string instrument --- .../xcshareddata/swiftpm/Package.resolved | 51 +-- .../project.pbxproj | 421 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 63 +++ .../Assets.xcassets/Contents.json | 6 + .../Conductor.swift | 33 ++ .../ContentView.swift | 55 +++ .../Instrument.swift | 25 ++ .../Preview Assets.xcassets/Contents.json | 6 + .../STKAudioKitInstrumentsDemo.entitlements | 10 + .../STKAudioKitInstrumentsDemoApp.swift | 30 ++ .../contents.xcworkspacedata | 4 + Sources/CSTKAudioKit/PluckedDSP.mm | 40 ++ Sources/STKAudioKit/STKPhysicalModels.swift | 6 + 16 files changed, 745 insertions(+), 31 deletions(-) create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.pbxproj create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/Contents.json create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Conductor.swift create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/ContentView.swift create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements create mode 100644 Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemoApp.swift create mode 100644 STKAudioKit.playground/playground.xcworkspace/contents.xcworkspacedata create mode 100644 Sources/CSTKAudioKit/PluckedDSP.mm diff --git a/Demo/STKAudioKitDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/STKAudioKitDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index cc430a4..466ebd9 100644 --- a/Demo/STKAudioKitDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Demo/STKAudioKitDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,34 +1,23 @@ { - "object": { - "pins": [ - { - "package": "AudioKit", - "repositoryURL": "https://github.com/AudioKit/AudioKit", - "state": { - "branch": null, - "revision": "cb50a6878535735fd1f10c8b8e5e96864630836c", - "version": "5.5.4" - } - }, - { - "package": "AudioKitEX", - "repositoryURL": "https://github.com/AudioKit/AudioKitEX", - "state": { - "branch": null, - "revision": "22183bcf7e8c6baf15e59c1126a4c541e044cec5", - "version": "5.5.2" - } - }, - { - "package": "AudioKitUI", - "repositoryURL": "https://github.com/AudioKit/AudioKitUI.git", - "state": { - "branch": null, - "revision": "f9459fa0c1029055da48d974e8b6acb88b171c4d", - "version": "0.2.0" - } + "pins" : [ + { + "identity" : "audiokit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/AudioKit/AudioKit", + "state" : { + "revision" : "cb50a6878535735fd1f10c8b8e5e96864630836c", + "version" : "5.5.4" } - ] - }, - "version": 1 + }, + { + "identity" : "audiokitui", + "kind" : "remoteSourceControl", + "location" : "https://github.com/AudioKit/AudioKitUI.git", + "state" : { + "revision" : "f9459fa0c1029055da48d974e8b6acb88b171c4d", + "version" : "0.2.0" + } + } + ], + "version" : 2 } diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.pbxproj b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a499c6a --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.pbxproj @@ -0,0 +1,421 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + 0C9AA1A22B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9AA1A12B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemoApp.swift */; }; + 0C9AA1A42B6B5BFF00A4A2D6 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9AA1A32B6B5BFF00A4A2D6 /* ContentView.swift */; }; + 0C9AA1A62B6B5C0000A4A2D6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C9AA1A52B6B5C0000A4A2D6 /* Assets.xcassets */; }; + 0C9AA1AA2B6B5C0000A4A2D6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C9AA1A92B6B5C0000A4A2D6 /* Preview Assets.xcassets */; }; + 0C9AA1CE2B6B5C2700A4A2D6 /* STKAudioKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0C9AA1CD2B6B5C2700A4A2D6 /* STKAudioKit */; }; + 0C9AA1D42B6B5D5D00A4A2D6 /* STKAudioKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0C9AA1D32B6B5D5D00A4A2D6 /* STKAudioKit */; }; + 0C9AA1D82B6B5E7B00A4A2D6 /* Conductor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9AA1D72B6B5E7B00A4A2D6 /* Conductor.swift */; }; + 0CE2CF662B6C1B8100D908BF /* Instrument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CE2CF652B6C1B8100D908BF /* Instrument.swift */; }; + 0CE2CF6C2B6C1D8C00D908BF /* Keyboard in Frameworks */ = {isa = PBXBuildFile; productRef = 0CE2CF6B2B6C1D8C00D908BF /* Keyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0C9AA19E2B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = STKAudioKitInstrumentsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0C9AA1A12B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STKAudioKitInstrumentsDemoApp.swift; sourceTree = ""; }; + 0C9AA1A32B6B5BFF00A4A2D6 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 0C9AA1A52B6B5C0000A4A2D6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0C9AA1A72B6B5C0000A4A2D6 /* STKAudioKitInstrumentsDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = STKAudioKitInstrumentsDemo.entitlements; sourceTree = ""; }; + 0C9AA1A92B6B5C0000A4A2D6 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 0C9AA1D72B6B5E7B00A4A2D6 /* Conductor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Conductor.swift; sourceTree = ""; }; + 0CE2CF652B6C1B8100D908BF /* Instrument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Instrument.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0C9AA19B2B6B5BFF00A4A2D6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CE2CF6C2B6C1D8C00D908BF /* Keyboard in Frameworks */, + 0C9AA1CE2B6B5C2700A4A2D6 /* STKAudioKit in Frameworks */, + 0C9AA1D42B6B5D5D00A4A2D6 /* STKAudioKit in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0C9AA1952B6B5BFF00A4A2D6 = { + isa = PBXGroup; + children = ( + 0C9AA1A02B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo */, + 0C9AA19F2B6B5BFF00A4A2D6 /* Products */, + ); + sourceTree = ""; + }; + 0C9AA19F2B6B5BFF00A4A2D6 /* Products */ = { + isa = PBXGroup; + children = ( + 0C9AA19E2B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + 0C9AA1A02B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo */ = { + isa = PBXGroup; + children = ( + 0C9AA1A12B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemoApp.swift */, + 0C9AA1A32B6B5BFF00A4A2D6 /* ContentView.swift */, + 0C9AA1D72B6B5E7B00A4A2D6 /* Conductor.swift */, + 0CE2CF652B6C1B8100D908BF /* Instrument.swift */, + 0C9AA1A52B6B5C0000A4A2D6 /* Assets.xcassets */, + 0C9AA1A72B6B5C0000A4A2D6 /* STKAudioKitInstrumentsDemo.entitlements */, + 0C9AA1A82B6B5C0000A4A2D6 /* Preview Content */, + ); + path = STKAudioKitInstrumentsDemo; + sourceTree = ""; + }; + 0C9AA1A82B6B5C0000A4A2D6 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 0C9AA1A92B6B5C0000A4A2D6 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0C9AA19D2B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0C9AA1C32B6B5C0000A4A2D6 /* Build configuration list for PBXNativeTarget "STKAudioKitInstrumentsDemo" */; + buildPhases = ( + 0C9AA19A2B6B5BFF00A4A2D6 /* Sources */, + 0C9AA19B2B6B5BFF00A4A2D6 /* Frameworks */, + 0C9AA19C2B6B5BFF00A4A2D6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = STKAudioKitInstrumentsDemo; + packageProductDependencies = ( + 0C9AA1CD2B6B5C2700A4A2D6 /* STKAudioKit */, + 0C9AA1D32B6B5D5D00A4A2D6 /* STKAudioKit */, + 0CE2CF6B2B6C1D8C00D908BF /* Keyboard */, + ); + productName = STKAudioKitInstrumentsDemo; + productReference = 0C9AA19E2B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0C9AA1962B6B5BFF00A4A2D6 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1510; + LastUpgradeCheck = 1510; + TargetAttributes = { + 0C9AA19D2B6B5BFF00A4A2D6 = { + CreatedOnToolsVersion = 15.1; + }; + }; + }; + buildConfigurationList = 0C9AA1992B6B5BFF00A4A2D6 /* Build configuration list for PBXProject "STKAudioKitInstrumentsDemo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0C9AA1952B6B5BFF00A4A2D6; + packageReferences = ( + 0C9AA1D22B6B5D5D00A4A2D6 /* XCLocalSwiftPackageReference "../.." */, + 0CE2CF6A2B6C1D8C00D908BF /* XCRemoteSwiftPackageReference "Keyboard" */, + ); + productRefGroup = 0C9AA19F2B6B5BFF00A4A2D6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0C9AA19D2B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0C9AA19C2B6B5BFF00A4A2D6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0C9AA1AA2B6B5C0000A4A2D6 /* Preview Assets.xcassets in Resources */, + 0C9AA1A62B6B5C0000A4A2D6 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0C9AA19A2B6B5BFF00A4A2D6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CE2CF662B6C1B8100D908BF /* Instrument.swift in Sources */, + 0C9AA1A42B6B5BFF00A4A2D6 /* ContentView.swift in Sources */, + 0C9AA1D82B6B5E7B00A4A2D6 /* Conductor.swift in Sources */, + 0C9AA1A22B6B5BFF00A4A2D6 /* STKAudioKitInstrumentsDemoApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 0C9AA1C12B6B5C0000A4A2D6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 0C9AA1C22B6B5C0000A4A2D6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + 0C9AA1C42B6B5C0000A4A2D6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"STKAudioKitInstrumentsDemo/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.1; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.audiokit.STKAudioKitInstrumentsDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0C9AA1C52B6B5C0000A4A2D6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"STKAudioKitInstrumentsDemo/Preview Content\""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.1; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.audiokit.STKAudioKitInstrumentsDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0C9AA1992B6B5BFF00A4A2D6 /* Build configuration list for PBXProject "STKAudioKitInstrumentsDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0C9AA1C12B6B5C0000A4A2D6 /* Debug */, + 0C9AA1C22B6B5C0000A4A2D6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0C9AA1C32B6B5C0000A4A2D6 /* Build configuration list for PBXNativeTarget "STKAudioKitInstrumentsDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0C9AA1C42B6B5C0000A4A2D6 /* Debug */, + 0C9AA1C52B6B5C0000A4A2D6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 0C9AA1D22B6B5D5D00A4A2D6 /* XCLocalSwiftPackageReference "../.." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 0CE2CF6A2B6C1D8C00D908BF /* XCRemoteSwiftPackageReference "Keyboard" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "git@github.com:AudioKit/Keyboard.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.3.7; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 0C9AA1CD2B6B5C2700A4A2D6 /* STKAudioKit */ = { + isa = XCSwiftPackageProductDependency; + productName = STKAudioKit; + }; + 0C9AA1D32B6B5D5D00A4A2D6 /* STKAudioKit */ = { + isa = XCSwiftPackageProductDependency; + productName = STKAudioKit; + }; + 0CE2CF6B2B6C1D8C00D908BF /* Keyboard */ = { + isa = XCSwiftPackageProductDependency; + package = 0CE2CF6A2B6C1D8C00D908BF /* XCRemoteSwiftPackageReference "Keyboard" */; + productName = Keyboard; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 0C9AA1962B6B5BFF00A4A2D6 /* Project object */; +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AccentColor.colorset/Contents.json b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..532cd72 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,63 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/Contents.json b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Conductor.swift b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Conductor.swift new file mode 100644 index 0000000..c352624 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Conductor.swift @@ -0,0 +1,33 @@ +// +// Conductor.swift +// STKAudioKitInstrumentsDemo +// +// Created by Ugur Bozkurt on 01/02/2024. +// + +import AudioKit +import AudioKitEX +import STKAudioKit +import SwiftUI + +final class Conductor: ObservableObject, HasAudioEngine { + let engine = AudioEngine() + + @Published var selectedInstrument: Instrument = .plucked + + private lazy var mixer: Mixer = { + Mixer(Instrument.nodes.map(\.value)) + }() + + init() { + engine.output = mixer + } + + func play(midiNote: UInt8) { + selectedInstrument.node.trigger(note: midiNote) + } + + func stop() { + selectedInstrument.node.stop() + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/ContentView.swift b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/ContentView.swift new file mode 100644 index 0000000..6ce4f51 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/ContentView.swift @@ -0,0 +1,55 @@ +// +// ContentView.swift +// STKAudioKitInstrumentsDemo +// +// Created by Ugur Bozkurt on 01/02/2024. +// + +import SwiftUI +import Keyboard + +struct ContentView: View { + @StateObject var conductor = Conductor() + + func noteOn(pitch: Pitch, point: CGPoint) { + conductor.play(midiNote: pitch.midiNoteNumber.magnitude) + } + + func noteOff(pitch: Pitch) { + print("note off \(pitch)") + } + + var body: some View { + VStack(spacing: 20) { + List{ + Picker("Select an instrument", selection: $conductor.selectedInstrument) { + ForEach(Instrument.allCases) { instrument in + Text(instrument.rawValue.capitalized) + } + } + + Button("Stop") { + conductor.stop() + } + .buttonStyle(.borderedProminent) + + } + Keyboard(layout: .piano(pitchRange: Pitch(48)...Pitch(82)), + noteOn: noteOn, + noteOff: noteOff) + .frame(height: 100) + } + .padding() + .navigationTitle("Instrument") + .onAppear { + conductor.start() + } + .onDisappear { + conductor.stop() + } + } +} + +#Preview { + ContentView() +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift new file mode 100644 index 0000000..e07d2ea --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift @@ -0,0 +1,25 @@ +// +// Instrument.swift +// STKAudioKitInstrumentsDemo +// +// Created by Ugur Bozkurt on 01/02/2024. +// + +import STKAudioKit +import Foundation + +enum Instrument: String, Hashable, CaseIterable, Identifiable { + var id: Self { self } + + case plucked, mandolin, flute + + static var nodes: [Instrument: STKBase] = [ + .plucked: Plucked(), + .mandolin: MandolinString(), + .flute: Flute() + ] + + var node: STKBase { + Self.nodes[self]! + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Preview Content/Preview Assets.xcassets/Contents.json b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemoApp.swift b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemoApp.swift new file mode 100644 index 0000000..9b7ca20 --- /dev/null +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemoApp.swift @@ -0,0 +1,30 @@ +// +// STKAudioKitInstrumentsDemoApp.swift +// STKAudioKitInstrumentsDemo +// +// Created by Ugur Bozkurt on 01/02/2024. +// + +import SwiftUI +import AVFoundation + +@main +struct STKAudioKitInstrumentsDemoApp: App { + init() { + #if os(iOS) + do { + try AVAudioSession.sharedInstance().setCategory(.playAndRecord, + options: [.defaultToSpeaker, .mixWithOthers, .allowBluetoothA2DP]) + try AVAudioSession.sharedInstance().setActive(true) + } catch let err { + print(err) + } + #endif + } + + var body: some Scene { + WindowGroup { + ContentView().padding() + } + } +} diff --git a/STKAudioKit.playground/playground.xcworkspace/contents.xcworkspacedata b/STKAudioKit.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..94b2795 --- /dev/null +++ b/STKAudioKit.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,4 @@ + + + diff --git a/Sources/CSTKAudioKit/PluckedDSP.mm b/Sources/CSTKAudioKit/PluckedDSP.mm new file mode 100644 index 0000000..2fd1d9f --- /dev/null +++ b/Sources/CSTKAudioKit/PluckedDSP.mm @@ -0,0 +1,40 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" +#import "StkBundleHelper.h" + +#include "Plucked.h" + +class PluckedDSP : public STKInstrumentDSP { +private: + stk::Plucked *plucked = nullptr; + +public: + PluckedDSP() {} + ~PluckedDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + auto bundle = [StkBundleHelper moduleBundle]; + auto directoryURL = [bundle.resourceURL URLByAppendingPathComponent:@"rawwaves"]; + + stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); + + stk::Stk::setSampleRate(sampleRate); + plucked = new stk::Plucked(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return plucked; + } + + void deinit() override { + DSPBase::deinit(); + delete plucked; + plucked = nullptr; + } + +}; + +AK_REGISTER_DSP(PluckedDSP, "plck"); diff --git a/Sources/STKAudioKit/STKPhysicalModels.swift b/Sources/STKAudioKit/STKPhysicalModels.swift index 67750e2..0a94230 100644 --- a/Sources/STKAudioKit/STKPhysicalModels.swift +++ b/Sources/STKAudioKit/STKPhysicalModels.swift @@ -36,6 +36,12 @@ public class MandolinString: STKBase { public init() { super.init("mand") } } +/// STK Plucked +public class Plucked: STKBase { + /// Initialize the physical model + public init() { super.init("plck") } +} + /// STK Rhodes Piano public class RhodesPianoKey: STKBase { /// Initialize the physical model From ba9553a05bcd5e8fb25aa001c5072308d8035f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fur=20Bozkurt?= Date: Thu, 1 Feb 2024 23:49:34 +0000 Subject: [PATCH 2/2] Added blowHole, brass, plucked string, sax, sitar, stifkarp (plucked string) instruments --- .../Instrument.swift | 15 +++++-- Sources/CSTKAudioKit/BlowHoleDSP.mm | 40 +++++++++++++++++++ Sources/CSTKAudioKit/BrassDSP.mm | 34 ++++++++++++++++ Sources/CSTKAudioKit/PluckedDSP.mm | 2 +- Sources/CSTKAudioKit/SaxofonyDSP.mm | 40 +++++++++++++++++++ Sources/CSTKAudioKit/SitarDSP.mm | 40 +++++++++++++++++++ Sources/CSTKAudioKit/StifKarpDSP.mm | 40 +++++++++++++++++++ Sources/STKAudioKit/STKPhysicalModels.swift | 30 ++++++++++++++ 8 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 Sources/CSTKAudioKit/BlowHoleDSP.mm create mode 100644 Sources/CSTKAudioKit/BrassDSP.mm create mode 100644 Sources/CSTKAudioKit/SaxofonyDSP.mm create mode 100644 Sources/CSTKAudioKit/SitarDSP.mm create mode 100644 Sources/CSTKAudioKit/StifKarpDSP.mm diff --git a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift index e07d2ea..5c4793b 100644 --- a/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift +++ b/Demo/STKAudioKitInstrumentsDemo/STKAudioKitInstrumentsDemo/Instrument.swift @@ -11,12 +11,21 @@ import Foundation enum Instrument: String, Hashable, CaseIterable, Identifiable { var id: Self { self } - case plucked, mandolin, flute + case blowHole, brass, clarinet, flute, mandolin, plucked, rhodesPianoKey, sax, shaker, tubularBells, stifKarp, sitar static var nodes: [Instrument: STKBase] = [ - .plucked: Plucked(), + .blowHole: BlowHole(), + .brass: Brass(), + .clarinet: Clarinet(), + .flute: Flute(), .mandolin: MandolinString(), - .flute: Flute() + .plucked: Plucked(), + .rhodesPianoKey: RhodesPianoKey(), + .sax: Saxofony(), + .shaker: Shaker(), + .tubularBells: TubularBells(), + .stifKarp: StifKarp(), + .sitar: Sitar() ] var node: STKBase { diff --git a/Sources/CSTKAudioKit/BlowHoleDSP.mm b/Sources/CSTKAudioKit/BlowHoleDSP.mm new file mode 100644 index 0000000..af9017e --- /dev/null +++ b/Sources/CSTKAudioKit/BlowHoleDSP.mm @@ -0,0 +1,40 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" +#import "StkBundleHelper.h" + +#include "BlowHole.h" + +class BlowHoleDSP : public STKInstrumentDSP { +private: + stk::BlowHole *blowHole = nullptr; + +public: + BlowHoleDSP() {} + ~BlowHoleDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + auto bundle = [StkBundleHelper moduleBundle]; + auto directoryURL = [bundle.resourceURL URLByAppendingPathComponent:@"rawwaves"]; + + stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); + + stk::Stk::setSampleRate(sampleRate); + blowHole = new stk::BlowHole(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return blowHole; + } + + void deinit() override { + DSPBase::deinit(); + delete blowHole; + blowHole = nullptr; + } + +}; + +AK_REGISTER_DSP(BlowHoleDSP, "blwh"); diff --git a/Sources/CSTKAudioKit/BrassDSP.mm b/Sources/CSTKAudioKit/BrassDSP.mm new file mode 100644 index 0000000..3076dbb --- /dev/null +++ b/Sources/CSTKAudioKit/BrassDSP.mm @@ -0,0 +1,34 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" + +#include "Brass.h" + +class BrassDSP : public STKInstrumentDSP { +private: + stk::Brass *brass = nullptr; + +public: + BrassDSP() {} + ~BrassDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + stk::Stk::setSampleRate(sampleRate); + brass = new stk::Brass(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return brass; + } + + void deinit() override { + DSPBase::deinit(); + delete brass; + brass = nullptr; + } + +}; + +AK_REGISTER_DSP(BrassDSP, "bras"); diff --git a/Sources/CSTKAudioKit/PluckedDSP.mm b/Sources/CSTKAudioKit/PluckedDSP.mm index 2fd1d9f..988d469 100644 --- a/Sources/CSTKAudioKit/PluckedDSP.mm +++ b/Sources/CSTKAudioKit/PluckedDSP.mm @@ -22,7 +22,7 @@ void init(int channelCount, double sampleRate) override { stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); stk::Stk::setSampleRate(sampleRate); - plucked = new stk::Plucked(/*lowestFrequency*/100); + plucked = new stk::Plucked(/*lowestFrequency*/50); } stk::Instrmnt* getInstrument() override { diff --git a/Sources/CSTKAudioKit/SaxofonyDSP.mm b/Sources/CSTKAudioKit/SaxofonyDSP.mm new file mode 100644 index 0000000..9bb27ee --- /dev/null +++ b/Sources/CSTKAudioKit/SaxofonyDSP.mm @@ -0,0 +1,40 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" +#import "StkBundleHelper.h" + +#include "Saxofony.h" + +class SaxofonyDSP : public STKInstrumentDSP { +private: + stk::Saxofony *saxofony = nullptr; + +public: + SaxofonyDSP() {} + ~SaxofonyDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + auto bundle = [StkBundleHelper moduleBundle]; + auto directoryURL = [bundle.resourceURL URLByAppendingPathComponent:@"rawwaves"]; + + stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); + + stk::Stk::setSampleRate(sampleRate); + saxofony = new stk::Saxofony(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return saxofony; + } + + void deinit() override { + DSPBase::deinit(); + delete saxofony; + saxofony = nullptr; + } + +}; + +AK_REGISTER_DSP(SaxofonyDSP, "saxf"); diff --git a/Sources/CSTKAudioKit/SitarDSP.mm b/Sources/CSTKAudioKit/SitarDSP.mm new file mode 100644 index 0000000..91fadb4 --- /dev/null +++ b/Sources/CSTKAudioKit/SitarDSP.mm @@ -0,0 +1,40 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" +#import "StkBundleHelper.h" + +#include "Sitar.h" + +class SitarDSP : public STKInstrumentDSP { +private: + stk::Sitar *sitar = nullptr; + +public: + SitarDSP() {} + ~SitarDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + auto bundle = [StkBundleHelper moduleBundle]; + auto directoryURL = [bundle.resourceURL URLByAppendingPathComponent:@"rawwaves"]; + + stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); + + stk::Stk::setSampleRate(sampleRate); + sitar = new stk::Sitar(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return sitar; + } + + void deinit() override { + DSPBase::deinit(); + delete sitar; + sitar = nullptr; + } + +}; + +AK_REGISTER_DSP(SitarDSP, "sitr"); diff --git a/Sources/CSTKAudioKit/StifKarpDSP.mm b/Sources/CSTKAudioKit/StifKarpDSP.mm new file mode 100644 index 0000000..a7ae6f7 --- /dev/null +++ b/Sources/CSTKAudioKit/StifKarpDSP.mm @@ -0,0 +1,40 @@ +// Copyright AudioKit. All Rights Reserved. + +#import "STKInstrumentDSP.h" +#import "StkBundleHelper.h" + +#include "StifKarp.h" + +class StifKarpDSP : public STKInstrumentDSP { +private: + stk::StifKarp *stifKarp = nullptr; + +public: + StifKarpDSP() {} + ~StifKarpDSP() = default; + + void init(int channelCount, double sampleRate) override { + DSPBase::init(channelCount, sampleRate); + + auto bundle = [StkBundleHelper moduleBundle]; + auto directoryURL = [bundle.resourceURL URLByAppendingPathComponent:@"rawwaves"]; + + stk::Stk::setRawwavePath(directoryURL.fileSystemRepresentation); + + stk::Stk::setSampleRate(sampleRate); + stifKarp = new stk::StifKarp(/*lowestFrequency*/100); + } + + stk::Instrmnt* getInstrument() override { + return stifKarp; + } + + void deinit() override { + DSPBase::deinit(); + delete stifKarp; + stifKarp = nullptr; + } + +}; + +AK_REGISTER_DSP(StifKarpDSP, "stif"); diff --git a/Sources/STKAudioKit/STKPhysicalModels.swift b/Sources/STKAudioKit/STKPhysicalModels.swift index 0a94230..55adbbd 100644 --- a/Sources/STKAudioKit/STKPhysicalModels.swift +++ b/Sources/STKAudioKit/STKPhysicalModels.swift @@ -60,6 +60,36 @@ public class TubularBells: STKBase { public init() { super.init("tbel") } } +/// STK Blow Hole +public class BlowHole: STKBase { + /// Initialize the physical model + public init() { super.init("blwh") } +} + +/// STK Saxofony +public class Saxofony: STKBase { + /// Initialize the physical model + public init() { super.init("saxf") } +} + +/// STK Brass +public class Brass: STKBase { + /// Initialize the physical model + public init() { super.init("bras") } +} + +/// STK StifKarp +public class StifKarp: STKBase { + /// Initialize the physical model + public init() { super.init("stif") } +} + +/// STK Sitar +public class Sitar: STKBase { + /// Initialize the physical model + public init() { super.init("sitr") } +} + public extension Shaker { /// Trigger the sound with a set of parameters ///