├── Images ├── Visualizer.gif └── VisualizerThumbnail2.png ├── LICENSE ├── README.md ├── Visualizer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── macbook.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── Visualizer ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj └── LaunchScreen.storyboard ├── Info.plist ├── Models └── Conductor.swift ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json ├── SceneDelegate.swift ├── Views ├── AmplitudeVisualizer.swift ├── ContentView.swift └── VerticalBar.swift └── Visualizer.entitlements /Images/Visualizer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matt54/SwiftUI-AudioKit-Visualizer/0fd1f67b9928aeae152fac502d229bcf1d775e01/Images/Visualizer.gif -------------------------------------------------------------------------------- /Images/VisualizerThumbnail2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matt54/SwiftUI-AudioKit-Visualizer/0fd1f67b9928aeae152fac502d229bcf1d775e01/Images/VisualizerThumbnail2.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Matt Pfeiffer 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

SwiftUI-AudioKit-Visualizer

2 | 3 | An iOS audio visualizer application created with SwiftUI and the AudioKit framework. 4 |
5 | 6 |

Visualization

7 |

8 | 9 | 10 | 11 |

12 |
13 | 14 |

Watch With Audio!

15 |
16 | Audio Visualizer Video Link 17 |
18 |
19 | -------------------------------------------------------------------------------- /Visualizer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FA9F16A624D320B200401F2D /* AmplitudeVisualizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9F16A524D320B200401F2D /* AmplitudeVisualizer.swift */; }; 11 | FAC4004F24D326570078C6D4 /* VerticalBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC4004E24D326570078C6D4 /* VerticalBar.swift */; }; 12 | FAC7907C24A7940C00EA977D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC7907B24A7940C00EA977D /* AppDelegate.swift */; }; 13 | FAC7907E24A7940C00EA977D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC7907D24A7940C00EA977D /* SceneDelegate.swift */; }; 14 | FAC7908024A7940C00EA977D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC7907F24A7940C00EA977D /* ContentView.swift */; }; 15 | FAC7908224A7940F00EA977D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FAC7908124A7940F00EA977D /* Assets.xcassets */; }; 16 | FAC7908524A7940F00EA977D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FAC7908424A7940F00EA977D /* Preview Assets.xcassets */; }; 17 | FAC7908824A7940F00EA977D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAC7908624A7940F00EA977D /* LaunchScreen.storyboard */; }; 18 | FAC7909124A7944900EA977D /* AudioKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC7909024A7944900EA977D /* AudioKit.framework */; }; 19 | FAC7909224A7944900EA977D /* AudioKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FAC7909024A7944900EA977D /* AudioKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 20 | FAC7909524A7945700EA977D /* AudioKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC7909424A7945700EA977D /* AudioKitUI.framework */; }; 21 | FAC7909624A7945700EA977D /* AudioKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FAC7909424A7945700EA977D /* AudioKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 22 | FAC7909824A794D700EA977D /* Conductor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC7909724A794D700EA977D /* Conductor.swift */; }; 23 | FAC7909D24A798CE00EA977D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC7909C24A798CE00EA977D /* AudioToolbox.framework */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXCopyFilesBuildPhase section */ 27 | FAC7909324A7944900EA977D /* Embed Frameworks */ = { 28 | isa = PBXCopyFilesBuildPhase; 29 | buildActionMask = 2147483647; 30 | dstPath = ""; 31 | dstSubfolderSpec = 10; 32 | files = ( 33 | FAC7909624A7945700EA977D /* AudioKitUI.framework in Embed Frameworks */, 34 | FAC7909224A7944900EA977D /* AudioKit.framework in Embed Frameworks */, 35 | ); 36 | name = "Embed Frameworks"; 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXCopyFilesBuildPhase section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | FA9F16A524D320B200401F2D /* AmplitudeVisualizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmplitudeVisualizer.swift; sourceTree = ""; }; 43 | FAC4004E24D326570078C6D4 /* VerticalBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerticalBar.swift; sourceTree = ""; }; 44 | FAC7907824A7940B00EA977D /* Visualizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Visualizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | FAC7907B24A7940C00EA977D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 46 | FAC7907D24A7940C00EA977D /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 47 | FAC7907F24A7940C00EA977D /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 48 | FAC7908124A7940F00EA977D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | FAC7908424A7940F00EA977D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 50 | FAC7908724A7940F00EA977D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 51 | FAC7908924A7940F00EA977D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | FAC7909024A7944900EA977D /* AudioKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioKit.framework; path = "../../AudioKit-iOS/AudioKit.framework"; sourceTree = ""; }; 53 | FAC7909424A7945700EA977D /* AudioKitUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioKitUI.framework; path = "../../AudioKit-iOS/AudioKitUI.framework"; sourceTree = ""; }; 54 | FAC7909724A794D700EA977D /* Conductor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Conductor.swift; sourceTree = ""; }; 55 | FAC7909B24A798CE00EA977D /* Visualizer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Visualizer.entitlements; sourceTree = ""; }; 56 | FAC7909C24A798CE00EA977D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | FAC7907524A7940B00EA977D /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | FAC7909524A7945700EA977D /* AudioKitUI.framework in Frameworks */, 65 | FAC7909124A7944900EA977D /* AudioKit.framework in Frameworks */, 66 | FAC7909D24A798CE00EA977D /* AudioToolbox.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | FA300A0924E7448100E4068C /* Views */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | FAC7907F24A7940C00EA977D /* ContentView.swift */, 77 | FA9F16A524D320B200401F2D /* AmplitudeVisualizer.swift */, 78 | FAC4004E24D326570078C6D4 /* VerticalBar.swift */, 79 | ); 80 | path = Views; 81 | sourceTree = ""; 82 | }; 83 | FAA8C38A24E744F800EEEE59 /* Models */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | FAC7909724A794D700EA977D /* Conductor.swift */, 87 | ); 88 | path = Models; 89 | sourceTree = ""; 90 | }; 91 | FAC7906F24A7940B00EA977D = { 92 | isa = PBXGroup; 93 | children = ( 94 | FAC7907A24A7940B00EA977D /* Visualizer */, 95 | FAC7907924A7940B00EA977D /* Products */, 96 | FAC7908F24A7944900EA977D /* Frameworks */, 97 | ); 98 | sourceTree = ""; 99 | }; 100 | FAC7907924A7940B00EA977D /* Products */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | FAC7907824A7940B00EA977D /* Visualizer.app */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | FAC7907A24A7940B00EA977D /* Visualizer */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | FAC7909B24A798CE00EA977D /* Visualizer.entitlements */, 112 | FAC7907B24A7940C00EA977D /* AppDelegate.swift */, 113 | FAC7907D24A7940C00EA977D /* SceneDelegate.swift */, 114 | FAA8C38A24E744F800EEEE59 /* Models */, 115 | FA300A0924E7448100E4068C /* Views */, 116 | FAC7908124A7940F00EA977D /* Assets.xcassets */, 117 | FAC7908624A7940F00EA977D /* LaunchScreen.storyboard */, 118 | FAC7908924A7940F00EA977D /* Info.plist */, 119 | FAC7908324A7940F00EA977D /* Preview Content */, 120 | ); 121 | path = Visualizer; 122 | sourceTree = ""; 123 | }; 124 | FAC7908324A7940F00EA977D /* Preview Content */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | FAC7908424A7940F00EA977D /* Preview Assets.xcassets */, 128 | ); 129 | path = "Preview Content"; 130 | sourceTree = ""; 131 | }; 132 | FAC7908F24A7944900EA977D /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | FAC7909C24A798CE00EA977D /* AudioToolbox.framework */, 136 | FAC7909424A7945700EA977D /* AudioKitUI.framework */, 137 | FAC7909024A7944900EA977D /* AudioKit.framework */, 138 | ); 139 | name = Frameworks; 140 | sourceTree = ""; 141 | }; 142 | /* End PBXGroup section */ 143 | 144 | /* Begin PBXNativeTarget section */ 145 | FAC7907724A7940B00EA977D /* Visualizer */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = FAC7908C24A7940F00EA977D /* Build configuration list for PBXNativeTarget "Visualizer" */; 148 | buildPhases = ( 149 | FAC7907424A7940B00EA977D /* Sources */, 150 | FAC7907524A7940B00EA977D /* Frameworks */, 151 | FAC7907624A7940B00EA977D /* Resources */, 152 | FAC7909324A7944900EA977D /* Embed Frameworks */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | ); 158 | name = Visualizer; 159 | productName = Visualizer; 160 | productReference = FAC7907824A7940B00EA977D /* Visualizer.app */; 161 | productType = "com.apple.product-type.application"; 162 | }; 163 | /* End PBXNativeTarget section */ 164 | 165 | /* Begin PBXProject section */ 166 | FAC7907024A7940B00EA977D /* Project object */ = { 167 | isa = PBXProject; 168 | attributes = { 169 | LastSwiftUpdateCheck = 1150; 170 | LastUpgradeCheck = 1150; 171 | ORGANIZATIONNAME = "Matt Pfeiffer"; 172 | TargetAttributes = { 173 | FAC7907724A7940B00EA977D = { 174 | CreatedOnToolsVersion = 11.5; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = FAC7907324A7940B00EA977D /* Build configuration list for PBXProject "Visualizer" */; 179 | compatibilityVersion = "Xcode 9.3"; 180 | developmentRegion = en; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = FAC7906F24A7940B00EA977D; 187 | productRefGroup = FAC7907924A7940B00EA977D /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | FAC7907724A7940B00EA977D /* Visualizer */, 192 | ); 193 | }; 194 | /* End PBXProject section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | FAC7907624A7940B00EA977D /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | FAC7908824A7940F00EA977D /* LaunchScreen.storyboard in Resources */, 202 | FAC7908524A7940F00EA977D /* Preview Assets.xcassets in Resources */, 203 | FAC7908224A7940F00EA977D /* Assets.xcassets in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | FAC7907424A7940B00EA977D /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | FA9F16A624D320B200401F2D /* AmplitudeVisualizer.swift in Sources */, 215 | FAC7907C24A7940C00EA977D /* AppDelegate.swift in Sources */, 216 | FAC7907E24A7940C00EA977D /* SceneDelegate.swift in Sources */, 217 | FAC4004F24D326570078C6D4 /* VerticalBar.swift in Sources */, 218 | FAC7908024A7940C00EA977D /* ContentView.swift in Sources */, 219 | FAC7909824A794D700EA977D /* Conductor.swift in Sources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXSourcesBuildPhase section */ 224 | 225 | /* Begin PBXVariantGroup section */ 226 | FAC7908624A7940F00EA977D /* LaunchScreen.storyboard */ = { 227 | isa = PBXVariantGroup; 228 | children = ( 229 | FAC7908724A7940F00EA977D /* Base */, 230 | ); 231 | name = LaunchScreen.storyboard; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXVariantGroup section */ 235 | 236 | /* Begin XCBuildConfiguration section */ 237 | FAC7908A24A7940F00EA977D /* Debug */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_ANALYZER_NONNULL = YES; 242 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_ENABLE_OBJC_WEAK = YES; 248 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_COMMA = YES; 251 | CLANG_WARN_CONSTANT_CONVERSION = YES; 252 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INFINITE_RECURSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 260 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 261 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 263 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 264 | CLANG_WARN_STRICT_PROTOTYPES = YES; 265 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 266 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | COPY_PHASE_STRIP = NO; 270 | DEBUG_INFORMATION_FORMAT = dwarf; 271 | ENABLE_STRICT_OBJC_MSGSEND = YES; 272 | ENABLE_TESTABILITY = YES; 273 | GCC_C_LANGUAGE_STANDARD = gnu11; 274 | GCC_DYNAMIC_NO_PIC = NO; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_OPTIMIZATION_LEVEL = 0; 277 | GCC_PREPROCESSOR_DEFINITIONS = ( 278 | "DEBUG=1", 279 | "$(inherited)", 280 | ); 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 13.6; 288 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 289 | MTL_FAST_MATH = YES; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = iphoneos; 292 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 294 | }; 295 | name = Debug; 296 | }; 297 | FAC7908B24A7940F00EA977D /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 303 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 304 | CLANG_CXX_LIBRARY = "libc++"; 305 | CLANG_ENABLE_MODULES = YES; 306 | CLANG_ENABLE_OBJC_ARC = YES; 307 | CLANG_ENABLE_OBJC_WEAK = YES; 308 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_COMMA = YES; 311 | CLANG_WARN_CONSTANT_CONVERSION = YES; 312 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 313 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 314 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INFINITE_RECURSION = YES; 318 | CLANG_WARN_INT_CONVERSION = YES; 319 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 320 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 321 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 323 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 324 | CLANG_WARN_STRICT_PROTOTYPES = YES; 325 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 326 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 327 | CLANG_WARN_UNREACHABLE_CODE = YES; 328 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 329 | COPY_PHASE_STRIP = NO; 330 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 331 | ENABLE_NS_ASSERTIONS = NO; 332 | ENABLE_STRICT_OBJC_MSGSEND = YES; 333 | GCC_C_LANGUAGE_STANDARD = gnu11; 334 | GCC_NO_COMMON_BLOCKS = YES; 335 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 336 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 337 | GCC_WARN_UNDECLARED_SELECTOR = YES; 338 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 | GCC_WARN_UNUSED_FUNCTION = YES; 340 | GCC_WARN_UNUSED_VARIABLE = YES; 341 | IPHONEOS_DEPLOYMENT_TARGET = 13.6; 342 | MTL_ENABLE_DEBUG_INFO = NO; 343 | MTL_FAST_MATH = YES; 344 | SDKROOT = iphoneos; 345 | SWIFT_COMPILATION_MODE = wholemodule; 346 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 347 | VALIDATE_PRODUCT = YES; 348 | }; 349 | name = Release; 350 | }; 351 | FAC7908D24A7940F00EA977D /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 355 | CODE_SIGN_ENTITLEMENTS = Visualizer/Visualizer.entitlements; 356 | CODE_SIGN_STYLE = Automatic; 357 | DEVELOPMENT_ASSET_PATHS = "\"Visualizer/Preview Content\""; 358 | DEVELOPMENT_TEAM = L2FL95P32D; 359 | ENABLE_PREVIEWS = YES; 360 | FRAMEWORK_SEARCH_PATHS = ( 361 | "\"/Users/macbook/Sync/Code/Xcode/AudioDev/AudioKit-iOS\"", 362 | "\"/Users/macbook/Sync/Code/Xcode/HapticsDev/lofelt-studio-0.8.2-mac/sdk/ios-framework/universal\"", 363 | ); 364 | INFOPLIST_FILE = Visualizer/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = ( 366 | "$(inherited)", 367 | "@executable_path/Frameworks", 368 | ); 369 | OTHER_LDFLAGS = "-lc++"; 370 | PRODUCT_BUNDLE_IDENTIFIER = com.MattPfeiffer.Visualizer; 371 | PRODUCT_NAME = "$(TARGET_NAME)"; 372 | SWIFT_VERSION = 5.0; 373 | TARGETED_DEVICE_FAMILY = "1,2"; 374 | }; 375 | name = Debug; 376 | }; 377 | FAC7908E24A7940F00EA977D /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 381 | CODE_SIGN_ENTITLEMENTS = Visualizer/Visualizer.entitlements; 382 | CODE_SIGN_STYLE = Automatic; 383 | DEVELOPMENT_ASSET_PATHS = "\"Visualizer/Preview Content\""; 384 | DEVELOPMENT_TEAM = L2FL95P32D; 385 | ENABLE_PREVIEWS = YES; 386 | FRAMEWORK_SEARCH_PATHS = ( 387 | "\"/Users/macbook/Sync/Code/Xcode/AudioDev/AudioKit-iOS\"", 388 | "\"/Users/macbook/Sync/Code/Xcode/HapticsDev/lofelt-studio-0.8.2-mac/sdk/ios-framework/universal\"", 389 | ); 390 | INFOPLIST_FILE = Visualizer/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = ( 392 | "$(inherited)", 393 | "@executable_path/Frameworks", 394 | ); 395 | OTHER_LDFLAGS = "-lc++"; 396 | PRODUCT_BUNDLE_IDENTIFIER = com.MattPfeiffer.Visualizer; 397 | PRODUCT_NAME = "$(TARGET_NAME)"; 398 | SWIFT_VERSION = 5.0; 399 | TARGETED_DEVICE_FAMILY = "1,2"; 400 | }; 401 | name = Release; 402 | }; 403 | /* End XCBuildConfiguration section */ 404 | 405 | /* Begin XCConfigurationList section */ 406 | FAC7907324A7940B00EA977D /* Build configuration list for PBXProject "Visualizer" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | FAC7908A24A7940F00EA977D /* Debug */, 410 | FAC7908B24A7940F00EA977D /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | FAC7908C24A7940F00EA977D /* Build configuration list for PBXNativeTarget "Visualizer" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | FAC7908D24A7940F00EA977D /* Debug */, 419 | FAC7908E24A7940F00EA977D /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | /* End XCConfigurationList section */ 425 | }; 426 | rootObject = FAC7907024A7940B00EA977D /* Project object */; 427 | } 428 | -------------------------------------------------------------------------------- /Visualizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Visualizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Visualizer.xcodeproj/xcuserdata/macbook.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Visualizer.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Visualizer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 6/27/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Visualizer/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Visualizer/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Visualizer/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Visualizer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSMicrophoneUsageDescription 24 | Required to analyze ambient audio. 25 | UIApplicationSceneManifest 26 | 27 | UIApplicationSupportsMultipleScenes 28 | 29 | UISceneConfigurations 30 | 31 | UIWindowSceneSessionRoleApplication 32 | 33 | 34 | UISceneConfigurationName 35 | Default Configuration 36 | UISceneDelegateClassName 37 | $(PRODUCT_MODULE_NAME).SceneDelegate 38 | 39 | 40 | 41 | 42 | UIBackgroundModes 43 | 44 | audio 45 | 46 | UILaunchStoryboardName 47 | LaunchScreen 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Visualizer/Models/Conductor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Conductor.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 6/27/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import AudioKit 10 | 11 | /// The persistent data object of the application (it does the audio processing and publishes changes to the UI) 12 | final class Conductor : ObservableObject{ 13 | 14 | /// Single shared data model 15 | static let shared = Conductor() 16 | 17 | /// default microphone 18 | let mic = AKMicrophone() 19 | 20 | /// mixing node for microphone input - routes to plotting and recording paths 21 | let micMixer = AKMixer() 22 | 23 | /// time interval in seconds for repeating timer callback 24 | let refreshTimeInterval : Double = 0.02 25 | 26 | /// tap for the fft data 27 | let fft : AKFFTTap 28 | 29 | /// size of fft 30 | let FFT_SIZE = 512 31 | 32 | /// audio sample rate 33 | let sampleRate : double_t = 44100 34 | 35 | /// limiter to prevent excessive volume at the output - just in case, it's the music producer in me :) 36 | let outputLimiter = AKPeakLimiter() 37 | 38 | /// bin amplitude values (range from 0.0 to 1.0) 39 | @Published var amplitudes : [Double] = Array(repeating: 0.5, count: 50) 40 | 41 | /// constructor - runs during initialization of the object 42 | init(){ 43 | 44 | // connect the fft tap to the mic mixer (this allows us to analyze the audio at the micMixer node) 45 | fft = AKFFTTap.init(micMixer) 46 | 47 | // route the audio from the microphone to the limiter 48 | setupMic() 49 | 50 | // set the limiter as the last node in our audio chain 51 | AudioKit.output = outputLimiter 52 | 53 | // do any AudioKit setting changes before starting the AudioKit engine 54 | setAudioKitSettings() 55 | 56 | // start the AudioKit engine 57 | do{ 58 | try AudioKit.start() 59 | } 60 | catch{ 61 | assert(false, error.localizedDescription) 62 | } 63 | 64 | // create a repeating timer at the rate of our chosen time interval - this updates the amplitudes each timer callback 65 | Timer.scheduledTimer(withTimeInterval: refreshTimeInterval, repeats: true) { timer in 66 | self.updateAmplitudes() 67 | } 68 | 69 | } 70 | 71 | /// Sets AudioKit to appropriate settings 72 | func setAudioKitSettings(){ 73 | 74 | do { 75 | try AKSettings.setSession(category: .ambient, with: [.mixWithOthers]) 76 | } catch { 77 | AKLog("Could not set session category.") 78 | } 79 | 80 | } 81 | 82 | /// Does all the setup required for microphone input 83 | func setupMic(){ 84 | 85 | // route mic to the micMixer which is tapped by our fft 86 | mic?.setOutput(to: micMixer) 87 | 88 | // route mixMixer to a mixer with no volume so that we don't output audio 89 | let silentMixer = AKMixer(micMixer) 90 | silentMixer.volume = 0.0 91 | 92 | // route the silent Mixer to the limiter (you must always route the audio chain to AudioKit.output) 93 | silentMixer.setOutput(to: outputLimiter) 94 | 95 | } 96 | 97 | /// Analyze fft data and write to our amplitudes array 98 | @objc func updateAmplitudes(){ 99 | //If you are interested in knowing more about this calculation, I have provided a couple recommended links at the bottom of this file. 100 | 101 | // loop by two through all the fft data 102 | for i in stride(from: 0, to: self.FFT_SIZE - 1, by: 2) { 103 | 104 | // get the real and imaginary parts of the complex number 105 | let real = fft.fftData[i] 106 | let imaginary = fft.fftData[i + 1] 107 | 108 | let normalizedBinMagnitude = 2.0 * sqrt(real * real + imaginary * imaginary) / self.FFT_SIZE 109 | let amplitude = (20.0 * log10(normalizedBinMagnitude)) 110 | 111 | // scale the resulting data 112 | var scaledAmplitude = (amplitude + 250) / 229.80 113 | 114 | // restrict the range to 0.0 - 1.0 115 | if (scaledAmplitude < 0) { 116 | scaledAmplitude = 0 117 | } 118 | if (scaledAmplitude > 1.0) { 119 | scaledAmplitude = 1.0 120 | } 121 | 122 | // add the amplitude to our array (further scaling array to look good in visualizer) 123 | DispatchQueue.main.async { 124 | if(i/2 < self.amplitudes.count){ 125 | self.amplitudes[i/2] = self.mapy(n: scaledAmplitude, start1: 0.3, stop1: 0.9, start2: 0.0, stop2: 1.0) 126 | } 127 | } 128 | } 129 | 130 | } 131 | 132 | /// simple mapping function to scale a value to a different range 133 | func mapy(n:Double, start1:Double, stop1:Double, start2:Double, stop2:Double) -> Double { 134 | return ((n-start1)/(stop1-start1))*(stop2-start2)+start2; 135 | }; 136 | } 137 | 138 | /* 139 | Visual introduction to the fourier transform: 140 | https://www.youtube.com/watch?v=spUNpyF58BY 141 | Shoutout to Grant Sanderson - thank you for your videos! 142 | 143 | Discrete fourier transform: 144 | https://www.youtube.com/watch?v=nl9TZanwbBk 145 | 146 | Fast fourier transform: 147 | https://www.youtube.com/watch?v=E8HeD-MUrjY 148 | Shoutout to Steve Brunton - thank you for your videos! 149 | 150 | Google groups conversation explaining how to use the fft data to calculate bin decibel levels: 151 | https://groups.google.com/g/comp.dsp/c/cZsS1ftN5oI?pli=1 152 | Shoutout to Stephan M. Sprenger - thank you for sharing! 153 | */ 154 | -------------------------------------------------------------------------------- /Visualizer/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Visualizer/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 6/27/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | let contentView = ContentView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView.environmentObject(Conductor.shared)) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Visualizer/Views/AmplitudeVisualizer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AmplitudeVisualizer.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 7/30/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct AmplitudeVisualizer: View { 12 | 13 | @Binding var amplitudes: [Double] 14 | 15 | var body: some View { 16 | HStack(spacing: 0.0){ 17 | ForEach(0 ..< self.amplitudes.count) { number in 18 | VerticalBar(amplitude: self.$amplitudes[number]) 19 | } 20 | } 21 | .background(Color.black) 22 | } 23 | } 24 | 25 | struct AmplitudeVisualizer_Previews: PreviewProvider { 26 | static var previews: some View { 27 | AmplitudeVisualizer(amplitudes: .constant(Array(repeating: 1.0, count: 50))) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Visualizer/Views/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 6/27/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | 13 | @EnvironmentObject var conductor: Conductor 14 | 15 | var body: some View { 16 | AmplitudeVisualizer(amplitudes: $conductor.amplitudes) 17 | .edgesIgnoringSafeArea(.all) 18 | } 19 | } 20 | 21 | struct ContentView_Previews: PreviewProvider { 22 | static var previews: some View { 23 | ContentView().environmentObject(Conductor.shared) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Visualizer/Views/VerticalBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VerticalBar.swift 3 | // Visualizer 4 | // 5 | // Created by Macbook on 7/30/20. 6 | // Copyright © 2020 Matt Pfeiffer. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// Single bar of Amplitude Visualizer 12 | struct VerticalBar: View { 13 | 14 | @Binding var amplitude: Double 15 | 16 | var body: some View { 17 | GeometryReader 18 | { geometry in 19 | ZStack(alignment: .bottom){ 20 | 21 | // Colored rectangle in back of ZStack 22 | Rectangle() 23 | .fill(LinearGradient(gradient: Gradient(colors: [.red, .yellow, .green]), startPoint: .top, endPoint: .center)) 24 | 25 | // blue/purple bar style - try switching this out with the .fill statement above 26 | //.fill(LinearGradient(gradient: Gradient(colors: [Color.init(red: 0.0, green: 1.0, blue: 1.0), .blue, .purple]), startPoint: .top, endPoint: .bottom)) 27 | 28 | // Dynamic black mask padded from bottom in relation to the amplitude 29 | Rectangle() 30 | .fill(Color.black) 31 | .mask(Rectangle().padding(.bottom, geometry.size.height * CGFloat(self.amplitude))) 32 | .animation(.easeOut(duration: 0.15)) 33 | 34 | // White bar with slower animation for floating effect 35 | Rectangle() 36 | .fill(Color.white) 37 | .frame(height: geometry.size.height * 0.005) 38 | .offset(x: 0.0, y: -geometry.size.height * CGFloat(self.amplitude) - geometry.size.height * 0.02) 39 | .animation(.easeOut(duration: 0.6)) 40 | 41 | } 42 | .padding(geometry.size.width * 0.1) 43 | .border(Color.black, width: geometry.size.width * 0.1) 44 | } 45 | } 46 | 47 | } 48 | 49 | struct VerticalBar_Previews: PreviewProvider { 50 | static var previews: some View { 51 | VerticalBar(amplitude: .constant(0.8)) 52 | .previewLayout(.fixed(width: 40, height: 500)) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Visualizer/Visualizer.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------