├── PlayAudioFIle.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── michal.xcuserdatad │ └── xcschemes │ ├── PlayAudioFIle.xcscheme │ └── xcschememanagement.plist ├── PlayAudioFIle ├── .gitignore ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── AudioData.swift ├── AudioPlayer.swift ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DisplayAudioFile.swift ├── Info.plist └── ViewController.swift ├── PlayAudioFIleTests ├── Info.plist └── PlayAudioFIleTests.swift ├── PlayAudioFIleUITests ├── Info.plist └── PlayAudioFIleUITests.swift ├── README.md └── test.mp3 /PlayAudioFIle.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 90DD16701DC191F9008D0EC5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DD166F1DC191F9008D0EC5 /* AppDelegate.swift */; }; 11 | 90DD16721DC191F9008D0EC5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DD16711DC191F9008D0EC5 /* ViewController.swift */; }; 12 | 90DD16751DC191F9008D0EC5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD16731DC191F9008D0EC5 /* Main.storyboard */; }; 13 | 90DD16771DC191F9008D0EC5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 90DD16761DC191F9008D0EC5 /* Assets.xcassets */; }; 14 | 90DD167A1DC191F9008D0EC5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD16781DC191F9008D0EC5 /* LaunchScreen.storyboard */; }; 15 | 90DD16851DC191F9008D0EC5 /* PlayAudioFIleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DD16841DC191F9008D0EC5 /* PlayAudioFIleTests.swift */; }; 16 | 90DD16901DC191F9008D0EC5 /* PlayAudioFIleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DD168F1DC191F9008D0EC5 /* PlayAudioFIleUITests.swift */; }; 17 | 90DD169E1DC1921B008D0EC5 /* AudioPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DD169D1DC1921B008D0EC5 /* AudioPlayer.swift */; }; 18 | 90DF5D2D1DC249FF00938D70 /* AudioData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DF5D2C1DC249FF00938D70 /* AudioData.swift */; }; 19 | 90DF5D2F1DC26D1600938D70 /* DisplayAudioFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90DF5D2E1DC26D1600938D70 /* DisplayAudioFile.swift */; }; 20 | 90DF5D5F1DC2D57100938D70 /* test.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 90DF5D5E1DC2D57100938D70 /* test.mp3 */; }; 21 | 90DF5D611DC2D6D300938D70 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 90DF5D601DC2D6D300938D70 /* .gitignore */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 90DD16811DC191F9008D0EC5 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 90DD16641DC191F9008D0EC5 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 90DD166B1DC191F9008D0EC5; 30 | remoteInfo = PlayAudioFIle; 31 | }; 32 | 90DD168C1DC191F9008D0EC5 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 90DD16641DC191F9008D0EC5 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 90DD166B1DC191F9008D0EC5; 37 | remoteInfo = PlayAudioFIle; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 90DD166C1DC191F9008D0EC5 /* PlayAudioFIle.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PlayAudioFIle.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 90DD166F1DC191F9008D0EC5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | 90DD16711DC191F9008D0EC5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 45 | 90DD16741DC191F9008D0EC5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 90DD16761DC191F9008D0EC5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 90DD16791DC191F9008D0EC5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 90DD167B1DC191F9008D0EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 90DD16801DC191F9008D0EC5 /* PlayAudioFIleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlayAudioFIleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 90DD16841DC191F9008D0EC5 /* PlayAudioFIleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayAudioFIleTests.swift; sourceTree = ""; }; 51 | 90DD16861DC191F9008D0EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 90DD168B1DC191F9008D0EC5 /* PlayAudioFIleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlayAudioFIleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 90DD168F1DC191F9008D0EC5 /* PlayAudioFIleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayAudioFIleUITests.swift; sourceTree = ""; }; 54 | 90DD16911DC191F9008D0EC5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 90DD169D1DC1921B008D0EC5 /* AudioPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioPlayer.swift; sourceTree = ""; }; 56 | 90DF5D2C1DC249FF00938D70 /* AudioData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioData.swift; sourceTree = ""; }; 57 | 90DF5D2E1DC26D1600938D70 /* DisplayAudioFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayAudioFile.swift; sourceTree = ""; }; 58 | 90DF5D5E1DC2D57100938D70 /* test.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = test.mp3; sourceTree = ""; }; 59 | 90DF5D601DC2D6D300938D70 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 90DD16691DC191F9008D0EC5 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 90DD167D1DC191F9008D0EC5 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 90DD16881DC191F9008D0EC5 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | 90DD16631DC191F9008D0EC5 = { 88 | isa = PBXGroup; 89 | children = ( 90 | 90DD166E1DC191F9008D0EC5 /* PlayAudioFIle */, 91 | 90DD16831DC191F9008D0EC5 /* PlayAudioFIleTests */, 92 | 90DD168E1DC191F9008D0EC5 /* PlayAudioFIleUITests */, 93 | 90DD166D1DC191F9008D0EC5 /* Products */, 94 | 90DF5D1F1DC239A000938D70 /* AudioFiles */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | 90DD166D1DC191F9008D0EC5 /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 90DD166C1DC191F9008D0EC5 /* PlayAudioFIle.app */, 102 | 90DD16801DC191F9008D0EC5 /* PlayAudioFIleTests.xctest */, 103 | 90DD168B1DC191F9008D0EC5 /* PlayAudioFIleUITests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | 90DD166E1DC191F9008D0EC5 /* PlayAudioFIle */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 90DD166F1DC191F9008D0EC5 /* AppDelegate.swift */, 112 | 90DD16711DC191F9008D0EC5 /* ViewController.swift */, 113 | 90DD169D1DC1921B008D0EC5 /* AudioPlayer.swift */, 114 | 90DF5D2C1DC249FF00938D70 /* AudioData.swift */, 115 | 90DF5D2E1DC26D1600938D70 /* DisplayAudioFile.swift */, 116 | 90DD16731DC191F9008D0EC5 /* Main.storyboard */, 117 | 90DD16761DC191F9008D0EC5 /* Assets.xcassets */, 118 | 90DD16781DC191F9008D0EC5 /* LaunchScreen.storyboard */, 119 | 90DD167B1DC191F9008D0EC5 /* Info.plist */, 120 | 90DF5D601DC2D6D300938D70 /* .gitignore */, 121 | ); 122 | path = PlayAudioFIle; 123 | sourceTree = ""; 124 | }; 125 | 90DD16831DC191F9008D0EC5 /* PlayAudioFIleTests */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 90DD16841DC191F9008D0EC5 /* PlayAudioFIleTests.swift */, 129 | 90DD16861DC191F9008D0EC5 /* Info.plist */, 130 | ); 131 | path = PlayAudioFIleTests; 132 | sourceTree = ""; 133 | }; 134 | 90DD168E1DC191F9008D0EC5 /* PlayAudioFIleUITests */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 90DD168F1DC191F9008D0EC5 /* PlayAudioFIleUITests.swift */, 138 | 90DD16911DC191F9008D0EC5 /* Info.plist */, 139 | ); 140 | path = PlayAudioFIleUITests; 141 | sourceTree = ""; 142 | }; 143 | 90DF5D1F1DC239A000938D70 /* AudioFiles */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 90DF5D5E1DC2D57100938D70 /* test.mp3 */, 147 | ); 148 | name = AudioFiles; 149 | sourceTree = ""; 150 | }; 151 | /* End PBXGroup section */ 152 | 153 | /* Begin PBXNativeTarget section */ 154 | 90DD166B1DC191F9008D0EC5 /* PlayAudioFIle */ = { 155 | isa = PBXNativeTarget; 156 | buildConfigurationList = 90DD16941DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIle" */; 157 | buildPhases = ( 158 | 90DD16681DC191F9008D0EC5 /* Sources */, 159 | 90DD16691DC191F9008D0EC5 /* Frameworks */, 160 | 90DD166A1DC191F9008D0EC5 /* Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | ); 166 | name = PlayAudioFIle; 167 | productName = PlayAudioFIle; 168 | productReference = 90DD166C1DC191F9008D0EC5 /* PlayAudioFIle.app */; 169 | productType = "com.apple.product-type.application"; 170 | }; 171 | 90DD167F1DC191F9008D0EC5 /* PlayAudioFIleTests */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = 90DD16971DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIleTests" */; 174 | buildPhases = ( 175 | 90DD167C1DC191F9008D0EC5 /* Sources */, 176 | 90DD167D1DC191F9008D0EC5 /* Frameworks */, 177 | 90DD167E1DC191F9008D0EC5 /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | 90DD16821DC191F9008D0EC5 /* PBXTargetDependency */, 183 | ); 184 | name = PlayAudioFIleTests; 185 | productName = PlayAudioFIleTests; 186 | productReference = 90DD16801DC191F9008D0EC5 /* PlayAudioFIleTests.xctest */; 187 | productType = "com.apple.product-type.bundle.unit-test"; 188 | }; 189 | 90DD168A1DC191F9008D0EC5 /* PlayAudioFIleUITests */ = { 190 | isa = PBXNativeTarget; 191 | buildConfigurationList = 90DD169A1DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIleUITests" */; 192 | buildPhases = ( 193 | 90DD16871DC191F9008D0EC5 /* Sources */, 194 | 90DD16881DC191F9008D0EC5 /* Frameworks */, 195 | 90DD16891DC191F9008D0EC5 /* Resources */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | 90DD168D1DC191F9008D0EC5 /* PBXTargetDependency */, 201 | ); 202 | name = PlayAudioFIleUITests; 203 | productName = PlayAudioFIleUITests; 204 | productReference = 90DD168B1DC191F9008D0EC5 /* PlayAudioFIleUITests.xctest */; 205 | productType = "com.apple.product-type.bundle.ui-testing"; 206 | }; 207 | /* End PBXNativeTarget section */ 208 | 209 | /* Begin PBXProject section */ 210 | 90DD16641DC191F9008D0EC5 /* Project object */ = { 211 | isa = PBXProject; 212 | attributes = { 213 | LastSwiftUpdateCheck = 0800; 214 | LastUpgradeCheck = 1010; 215 | ORGANIZATIONNAME = borama; 216 | TargetAttributes = { 217 | 90DD166B1DC191F9008D0EC5 = { 218 | CreatedOnToolsVersion = 8.0; 219 | DevelopmentTeam = 7G4JF8R3R6; 220 | LastSwiftMigration = 1010; 221 | ProvisioningStyle = Automatic; 222 | }; 223 | 90DD167F1DC191F9008D0EC5 = { 224 | CreatedOnToolsVersion = 8.0; 225 | DevelopmentTeam = 7G4JF8R3R6; 226 | LastSwiftMigration = 1010; 227 | ProvisioningStyle = Automatic; 228 | TestTargetID = 90DD166B1DC191F9008D0EC5; 229 | }; 230 | 90DD168A1DC191F9008D0EC5 = { 231 | CreatedOnToolsVersion = 8.0; 232 | DevelopmentTeam = 7G4JF8R3R6; 233 | LastSwiftMigration = 1010; 234 | ProvisioningStyle = Automatic; 235 | TestTargetID = 90DD166B1DC191F9008D0EC5; 236 | }; 237 | }; 238 | }; 239 | buildConfigurationList = 90DD16671DC191F9008D0EC5 /* Build configuration list for PBXProject "PlayAudioFIle" */; 240 | compatibilityVersion = "Xcode 3.2"; 241 | developmentRegion = English; 242 | hasScannedForEncodings = 0; 243 | knownRegions = ( 244 | en, 245 | Base, 246 | ); 247 | mainGroup = 90DD16631DC191F9008D0EC5; 248 | productRefGroup = 90DD166D1DC191F9008D0EC5 /* Products */; 249 | projectDirPath = ""; 250 | projectRoot = ""; 251 | targets = ( 252 | 90DD166B1DC191F9008D0EC5 /* PlayAudioFIle */, 253 | 90DD167F1DC191F9008D0EC5 /* PlayAudioFIleTests */, 254 | 90DD168A1DC191F9008D0EC5 /* PlayAudioFIleUITests */, 255 | ); 256 | }; 257 | /* End PBXProject section */ 258 | 259 | /* Begin PBXResourcesBuildPhase section */ 260 | 90DD166A1DC191F9008D0EC5 /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | 90DF5D611DC2D6D300938D70 /* .gitignore in Resources */, 265 | 90DD167A1DC191F9008D0EC5 /* LaunchScreen.storyboard in Resources */, 266 | 90DD16771DC191F9008D0EC5 /* Assets.xcassets in Resources */, 267 | 90DF5D5F1DC2D57100938D70 /* test.mp3 in Resources */, 268 | 90DD16751DC191F9008D0EC5 /* Main.storyboard in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | 90DD167E1DC191F9008D0EC5 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | 90DD16891DC191F9008D0EC5 /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXResourcesBuildPhase section */ 287 | 288 | /* Begin PBXSourcesBuildPhase section */ 289 | 90DD16681DC191F9008D0EC5 /* Sources */ = { 290 | isa = PBXSourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | 90DD16721DC191F9008D0EC5 /* ViewController.swift in Sources */, 294 | 90DD16701DC191F9008D0EC5 /* AppDelegate.swift in Sources */, 295 | 90DF5D2D1DC249FF00938D70 /* AudioData.swift in Sources */, 296 | 90DF5D2F1DC26D1600938D70 /* DisplayAudioFile.swift in Sources */, 297 | 90DD169E1DC1921B008D0EC5 /* AudioPlayer.swift in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | 90DD167C1DC191F9008D0EC5 /* Sources */ = { 302 | isa = PBXSourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 90DD16851DC191F9008D0EC5 /* PlayAudioFIleTests.swift in Sources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | 90DD16871DC191F9008D0EC5 /* Sources */ = { 310 | isa = PBXSourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 90DD16901DC191F9008D0EC5 /* PlayAudioFIleUITests.swift in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | /* End PBXSourcesBuildPhase section */ 318 | 319 | /* Begin PBXTargetDependency section */ 320 | 90DD16821DC191F9008D0EC5 /* PBXTargetDependency */ = { 321 | isa = PBXTargetDependency; 322 | target = 90DD166B1DC191F9008D0EC5 /* PlayAudioFIle */; 323 | targetProxy = 90DD16811DC191F9008D0EC5 /* PBXContainerItemProxy */; 324 | }; 325 | 90DD168D1DC191F9008D0EC5 /* PBXTargetDependency */ = { 326 | isa = PBXTargetDependency; 327 | target = 90DD166B1DC191F9008D0EC5 /* PlayAudioFIle */; 328 | targetProxy = 90DD168C1DC191F9008D0EC5 /* PBXContainerItemProxy */; 329 | }; 330 | /* End PBXTargetDependency section */ 331 | 332 | /* Begin PBXVariantGroup section */ 333 | 90DD16731DC191F9008D0EC5 /* Main.storyboard */ = { 334 | isa = PBXVariantGroup; 335 | children = ( 336 | 90DD16741DC191F9008D0EC5 /* Base */, 337 | ); 338 | name = Main.storyboard; 339 | sourceTree = ""; 340 | }; 341 | 90DD16781DC191F9008D0EC5 /* LaunchScreen.storyboard */ = { 342 | isa = PBXVariantGroup; 343 | children = ( 344 | 90DD16791DC191F9008D0EC5 /* Base */, 345 | ); 346 | name = LaunchScreen.storyboard; 347 | sourceTree = ""; 348 | }; 349 | /* End PBXVariantGroup section */ 350 | 351 | /* Begin XCBuildConfiguration section */ 352 | 90DD16921DC191F9008D0EC5 /* Debug */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ALWAYS_SEARCH_USER_PATHS = NO; 356 | CLANG_ANALYZER_NONNULL = YES; 357 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 358 | CLANG_CXX_LIBRARY = "libc++"; 359 | CLANG_ENABLE_MODULES = YES; 360 | CLANG_ENABLE_OBJC_ARC = YES; 361 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 362 | CLANG_WARN_BOOL_CONVERSION = YES; 363 | CLANG_WARN_COMMA = YES; 364 | CLANG_WARN_CONSTANT_CONVERSION = YES; 365 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 366 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 367 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 368 | CLANG_WARN_EMPTY_BODY = YES; 369 | CLANG_WARN_ENUM_CONVERSION = YES; 370 | CLANG_WARN_INFINITE_RECURSION = YES; 371 | CLANG_WARN_INT_CONVERSION = YES; 372 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 373 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 374 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 375 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 376 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 377 | CLANG_WARN_STRICT_PROTOTYPES = YES; 378 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 379 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 380 | CLANG_WARN_UNREACHABLE_CODE = YES; 381 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 382 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 383 | COPY_PHASE_STRIP = NO; 384 | DEBUG_INFORMATION_FORMAT = dwarf; 385 | ENABLE_STRICT_OBJC_MSGSEND = YES; 386 | ENABLE_TESTABILITY = YES; 387 | GCC_C_LANGUAGE_STANDARD = gnu99; 388 | GCC_DYNAMIC_NO_PIC = NO; 389 | GCC_NO_COMMON_BLOCKS = YES; 390 | GCC_OPTIMIZATION_LEVEL = 0; 391 | GCC_PREPROCESSOR_DEFINITIONS = ( 392 | "DEBUG=1", 393 | "$(inherited)", 394 | ); 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 397 | GCC_WARN_UNDECLARED_SELECTOR = YES; 398 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 399 | GCC_WARN_UNUSED_FUNCTION = YES; 400 | GCC_WARN_UNUSED_VARIABLE = YES; 401 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 402 | MTL_ENABLE_DEBUG_INFO = YES; 403 | ONLY_ACTIVE_ARCH = YES; 404 | SDKROOT = iphoneos; 405 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 406 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 407 | TARGETED_DEVICE_FAMILY = "1,2"; 408 | }; 409 | name = Debug; 410 | }; 411 | 90DD16931DC191F9008D0EC5 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ALWAYS_SEARCH_USER_PATHS = NO; 415 | CLANG_ANALYZER_NONNULL = YES; 416 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 417 | CLANG_CXX_LIBRARY = "libc++"; 418 | CLANG_ENABLE_MODULES = YES; 419 | CLANG_ENABLE_OBJC_ARC = YES; 420 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 421 | CLANG_WARN_BOOL_CONVERSION = YES; 422 | CLANG_WARN_COMMA = YES; 423 | CLANG_WARN_CONSTANT_CONVERSION = YES; 424 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 425 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 426 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INFINITE_RECURSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 432 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 433 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 434 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 435 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 436 | CLANG_WARN_STRICT_PROTOTYPES = YES; 437 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 438 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 439 | CLANG_WARN_UNREACHABLE_CODE = YES; 440 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 441 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 442 | COPY_PHASE_STRIP = NO; 443 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 444 | ENABLE_NS_ASSERTIONS = NO; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | GCC_C_LANGUAGE_STANDARD = gnu99; 447 | GCC_NO_COMMON_BLOCKS = YES; 448 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 449 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 450 | GCC_WARN_UNDECLARED_SELECTOR = YES; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | GCC_WARN_UNUSED_FUNCTION = YES; 453 | GCC_WARN_UNUSED_VARIABLE = YES; 454 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 455 | MTL_ENABLE_DEBUG_INFO = NO; 456 | SDKROOT = iphoneos; 457 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 458 | TARGETED_DEVICE_FAMILY = "1,2"; 459 | VALIDATE_PRODUCT = YES; 460 | }; 461 | name = Release; 462 | }; 463 | 90DD16951DC191F9008D0EC5 /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 467 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 468 | INFOPLIST_FILE = PlayAudioFIle/Info.plist; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 470 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIle; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 473 | SWIFT_VERSION = 4.2; 474 | }; 475 | name = Debug; 476 | }; 477 | 90DD16961DC191F9008D0EC5 /* Release */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 482 | INFOPLIST_FILE = PlayAudioFIle/Info.plist; 483 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 484 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIle; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 487 | SWIFT_VERSION = 4.2; 488 | }; 489 | name = Release; 490 | }; 491 | 90DD16981DC191F9008D0EC5 /* Debug */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 495 | BUNDLE_LOADER = "$(TEST_HOST)"; 496 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 497 | INFOPLIST_FILE = PlayAudioFIleTests/Info.plist; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIleTests; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 502 | SWIFT_VERSION = 4.2; 503 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlayAudioFIle.app/PlayAudioFIle"; 504 | }; 505 | name = Debug; 506 | }; 507 | 90DD16991DC191F9008D0EC5 /* Release */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 511 | BUNDLE_LOADER = "$(TEST_HOST)"; 512 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 513 | INFOPLIST_FILE = PlayAudioFIleTests/Info.plist; 514 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 515 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIleTests; 516 | PRODUCT_NAME = "$(TARGET_NAME)"; 517 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 518 | SWIFT_VERSION = 4.2; 519 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlayAudioFIle.app/PlayAudioFIle"; 520 | }; 521 | name = Release; 522 | }; 523 | 90DD169B1DC191F9008D0EC5 /* Debug */ = { 524 | isa = XCBuildConfiguration; 525 | buildSettings = { 526 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 527 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 528 | INFOPLIST_FILE = PlayAudioFIleUITests/Info.plist; 529 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 530 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIleUITests; 531 | PRODUCT_NAME = "$(TARGET_NAME)"; 532 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 533 | SWIFT_VERSION = 4.2; 534 | TEST_TARGET_NAME = PlayAudioFIle; 535 | }; 536 | name = Debug; 537 | }; 538 | 90DD169C1DC191F9008D0EC5 /* Release */ = { 539 | isa = XCBuildConfiguration; 540 | buildSettings = { 541 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 542 | DEVELOPMENT_TEAM = 7G4JF8R3R6; 543 | INFOPLIST_FILE = PlayAudioFIleUITests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 545 | PRODUCT_BUNDLE_IDENTIFIER = co.borama.PlayAudioFIleUITests; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 548 | SWIFT_VERSION = 4.2; 549 | TEST_TARGET_NAME = PlayAudioFIle; 550 | }; 551 | name = Release; 552 | }; 553 | /* End XCBuildConfiguration section */ 554 | 555 | /* Begin XCConfigurationList section */ 556 | 90DD16671DC191F9008D0EC5 /* Build configuration list for PBXProject "PlayAudioFIle" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | 90DD16921DC191F9008D0EC5 /* Debug */, 560 | 90DD16931DC191F9008D0EC5 /* Release */, 561 | ); 562 | defaultConfigurationIsVisible = 0; 563 | defaultConfigurationName = Release; 564 | }; 565 | 90DD16941DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIle" */ = { 566 | isa = XCConfigurationList; 567 | buildConfigurations = ( 568 | 90DD16951DC191F9008D0EC5 /* Debug */, 569 | 90DD16961DC191F9008D0EC5 /* Release */, 570 | ); 571 | defaultConfigurationIsVisible = 0; 572 | defaultConfigurationName = Release; 573 | }; 574 | 90DD16971DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIleTests" */ = { 575 | isa = XCConfigurationList; 576 | buildConfigurations = ( 577 | 90DD16981DC191F9008D0EC5 /* Debug */, 578 | 90DD16991DC191F9008D0EC5 /* Release */, 579 | ); 580 | defaultConfigurationIsVisible = 0; 581 | defaultConfigurationName = Release; 582 | }; 583 | 90DD169A1DC191F9008D0EC5 /* Build configuration list for PBXNativeTarget "PlayAudioFIleUITests" */ = { 584 | isa = XCConfigurationList; 585 | buildConfigurations = ( 586 | 90DD169B1DC191F9008D0EC5 /* Debug */, 587 | 90DD169C1DC191F9008D0EC5 /* Release */, 588 | ); 589 | defaultConfigurationIsVisible = 0; 590 | defaultConfigurationName = Release; 591 | }; 592 | /* End XCConfigurationList section */ 593 | }; 594 | rootObject = 90DD16641DC191F9008D0EC5 /* Project object */; 595 | } 596 | -------------------------------------------------------------------------------- /PlayAudioFIle.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PlayAudioFIle.xcodeproj/xcuserdata/michal.xcuserdatad/xcschemes/PlayAudioFIle.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /PlayAudioFIle.xcodeproj/xcuserdata/michal.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PlayAudioFIle.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 90DD166B1DC191F9008D0EC5 16 | 17 | primary 18 | 19 | 20 | 90DD167F1DC191F9008D0EC5 21 | 22 | primary 23 | 24 | 25 | 90DD168A1DC191F9008D0EC5 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PlayAudioFIle/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /PlayAudioFIle/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PlayAudioFIle 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 Michal Bojanowicz. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /PlayAudioFIle/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /PlayAudioFIle/AudioData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AudioData.swift 3 | // PlayAudioFIle 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 Michal Bojanowicz. All rights reserved. 7 | // 8 | 9 | import AVFoundation 10 | 11 | class AudioData { 12 | 13 | func readFileIntoBuffer(audioUrl: URL) throws -> AVAudioPCMBuffer { 14 | 15 | let audioFile = try AVAudioFile(forReading: audioUrl) 16 | let audioFileFormat = audioFile.processingFormat 17 | let audioFileSize = UInt32(audioFile.length) 18 | let audioBuffer = AVAudioPCMBuffer(pcmFormat: audioFileFormat, frameCapacity: audioFileSize)! 19 | try audioFile.read(into: audioBuffer) 20 | return audioBuffer 21 | } 22 | 23 | // get audio data from whole file 24 | func getAudioDataFromFile(audioUrl: URL) throws -> (L: [Float], R: [Float]) { 25 | 26 | let audioBuffer = try readFileIntoBuffer(audioUrl: audioUrl) 27 | let (L, R) = getDataFromBuffer(audioBuffer: audioBuffer) 28 | 29 | print("AudioData audio max R: \(String(describing: R.max()))") 30 | return (L, R) 31 | } 32 | 33 | func getAverageValues(array: [Float], numberOfChunks: Int = 100) -> [Float] { 34 | var averageValuesArray: [Float] = [] 35 | let length = array.count 36 | let stride = Double(length) / Double(numberOfChunks) 37 | 38 | for i in 0.. [(L: Float, R: Float)] { 54 | 55 | var audioAveragesArray: [(L: Float, R: Float)] = [] 56 | 57 | let (L,R) = getDataFromBuffer(audioBuffer: audioBuffer) 58 | let audioBufferLength = audioBuffer.frameLength 59 | let stride = Double(audioBufferLength) / Double (numberOfFrames) 60 | let frameSize = Int(stride) 61 | 62 | for i in 0.. [(L: Float, R: Float)] { 83 | var audioValuesArray: [(L:Float, R: Float)] = [] 84 | let (L, R) = getDataFromBuffer(audioBuffer: audioBuffer) 85 | let stride = Double(L.count) / Double(numberOfFrames) 86 | 87 | for i in 0..[Float] { 99 | var valuesAtChunks: [Float] = [] 100 | let stride = Double(values.count) / Double(numberOfChunks) 101 | for i in 0.. (L: [Float],R: [Float]) { 109 | 110 | let audioBufferSize = Int(audioBuffer.frameLength) 111 | 112 | var Ldata:[Float] 113 | var Rdata:[Float] 114 | 115 | if let leftpointer = audioBuffer.floatChannelData?[0] { 116 | let LdataBuffer = UnsafeBufferPointer(start: leftpointer, count: audioBufferSize) 117 | Ldata = Array(LdataBuffer) 118 | } else { 119 | Ldata = [0.0] 120 | } 121 | 122 | if let rightPointer = audioBuffer.floatChannelData?[1] { 123 | let RdataBuffer = UnsafeBufferPointer(start: rightPointer, count: audioBufferSize) 124 | Rdata = Array(RdataBuffer) 125 | } else { 126 | Rdata = [0.0] 127 | } 128 | 129 | return (Ldata, Rdata) 130 | 131 | } 132 | 133 | func getAverageAudioChannels(audioBuffer: AVAudioPCMBuffer) -> [Float] { 134 | 135 | let (Ldata, Rdata) = getDataFromBuffer(audioBuffer: audioBuffer) 136 | 137 | return zip(Ldata, Rdata).map { $0 + $1 / 2.0 } 138 | 139 | } 140 | 141 | func getMaxSignal(audioBuffer: AVAudioPCMBuffer) -> Float { 142 | 143 | let (Ldata, Rdata) = getDataFromBuffer(audioBuffer: audioBuffer) 144 | 145 | let absoluteValues = zip(Ldata, Rdata).map { abs($0) > abs($1) ? abs($0) : abs($1) } 146 | 147 | return absoluteValues.max()! 148 | 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /PlayAudioFIle/AudioPlayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayAudio.swift 3 | // PlayAudioFIle 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 Michal Bojanowicz. All rights reserved. 7 | // 8 | 9 | import AVFoundation 10 | 11 | protocol AudioPlayerDelegate: class { 12 | func audioSignal(didReceiveBuffer buffer: AVAudioPCMBuffer, 13 | timeStamp: AVAudioTime) 14 | 15 | } 16 | 17 | class AudioPlayer { 18 | 19 | weak var delegate: AudioPlayerDelegate? 20 | 21 | fileprivate var audioEngine: AVAudioEngine! 22 | fileprivate var audioPlayer: AVAudioPlayerNode! 23 | fileprivate let bus = 0 24 | let audioData = AudioData() 25 | 26 | 27 | // MARK: - Play Audio 28 | func play(audioUrl: URL) throws { 29 | 30 | let AVBufferSize = 1024 31 | let session = AVAudioSession.sharedInstance() 32 | try session.setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.playback)), mode: AVAudioSession.Mode.default) 33 | 34 | audioEngine = AVAudioEngine() 35 | audioPlayer = AVAudioPlayerNode() 36 | 37 | let audioFile = try AVAudioFile(forReading: audioUrl) 38 | 39 | audioEngine.attach(audioPlayer) 40 | audioEngine.connect(audioPlayer, to: audioEngine.outputNode, format: audioFile.processingFormat) 41 | 42 | audioPlayer.scheduleFile(audioFile, at: nil, completionHandler: nil) 43 | 44 | // right now this one is not used, it could be used to draw signal level, send current position of playing 45 | audioEngine.outputNode.installTap(onBus: bus, bufferSize: AVAudioFrameCount(AVBufferSize), format: nil) { 46 | buffer, time in 47 | 48 | DispatchQueue.main.async { 49 | self.delegate?.audioSignal(didReceiveBuffer: buffer, timeStamp: time) 50 | // print(time) 51 | 52 | } 53 | } 54 | 55 | audioEngine.prepare() 56 | try audioEngine.start() 57 | 58 | audioPlayer.play() 59 | } 60 | 61 | 62 | func stop() { 63 | if audioPlayer != nil { 64 | audioPlayer.stop() 65 | audioPlayer = nil 66 | } 67 | if audioEngine != nil { 68 | audioEngine.stop() 69 | audioEngine.reset() 70 | audioEngine = nil 71 | } 72 | } 73 | 74 | } 75 | 76 | 77 | // Helper function inserted by Swift 4.2 migrator. 78 | fileprivate func convertFromAVAudioSessionCategory(_ input: AVAudioSession.Category) -> String { 79 | return input.rawValue 80 | } 81 | -------------------------------------------------------------------------------- /PlayAudioFIle/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 | 27 | 28 | -------------------------------------------------------------------------------- /PlayAudioFIle/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /PlayAudioFIle/DisplayAudioFile.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisplayAudioFile.swift 3 | // PlayAudioFIle 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 Michal Bojanowicz. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DisplayAudioFile: UIView { 12 | 13 | 14 | var lines: [Float] = [] 15 | 16 | override func draw(_ rect: CGRect) { 17 | let middleLine = makeMiddleLine(width: self.frame.width, height: self.frame.height) 18 | 19 | drawVerticalLines(array: lines) 20 | UIColor.green.setStroke() 21 | middleLine.stroke() 22 | } 23 | 24 | override func layoutSubviews() { 25 | super.layoutSubviews() 26 | self.setNeedsDisplay() 27 | } 28 | 29 | 30 | func makeMiddleLine(width: CGFloat, height: CGFloat) ->UIBezierPath { 31 | let y = height / 2.0 32 | let line = UIBezierPath() 33 | line.move(to: CGPoint(x:0, y:y)) 34 | line.addLine(to: CGPoint(x: width - 1.0,y: y)) 35 | line.lineWidth = 1.0 36 | 37 | return line 38 | } 39 | 40 | 41 | func makeVerticalLine(x: CGFloat, yFrom: CGFloat, yTo: CGFloat) ->UIBezierPath { 42 | let line = UIBezierPath() 43 | line.move(to: CGPoint(x: x, y: yFrom)) 44 | line.addLine(to: CGPoint(x: x, y: yTo)) 45 | line.lineWidth = 1.0 46 | 47 | return line 48 | } 49 | 50 | func makeVerticalLines(values: [Float]) ->[UIBezierPath] { 51 | var vertLinesArray: [UIBezierPath] = [] 52 | let currentWidth = self.frame.width 53 | let currentHeight = self.frame.height 54 | let stride = currentWidth / CGFloat(values.count) 55 | let scale = currentHeight 56 | 57 | for i in 0.. 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PlayAudioFIle/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // PlayAudioFIle 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 Michal Bojanowicz. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | class ViewController: UIViewController { 13 | @IBOutlet weak var displayAudioView: DisplayAudioFile! 14 | 15 | let audioData = AudioData() 16 | let audioPlayer = AudioPlayer() 17 | var path = Bundle.main.url(forResource: "test", withExtension: "mp3") // crashes if the file is not found 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | // Do any additional setup after loading the view, typically from a nib. 22 | 23 | 24 | } 25 | 26 | override func didReceiveMemoryWarning() { 27 | super.didReceiveMemoryWarning() 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | @IBAction func startBtnAction() { 32 | do {try audioPlayer.play(audioUrl: path!)} catch {print("catched")} 33 | displayWaveform () 34 | } 35 | 36 | @IBAction func stopBtnAction() { 37 | audioPlayer.stop() 38 | } 39 | 40 | func displayWaveform () { 41 | do { 42 | 43 | // read audio buffer from file right now will crash if file not found 44 | let audioBuffer = try audioData.readFileIntoBuffer(audioUrl: path!) 45 | 46 | // converts audio buffer into array of tuples (L: Float, R: Float) corresponding to audio samples 47 | let audioValues = audioData.getDataFromBuffer(audioBuffer: audioBuffer) 48 | 49 | // don't need both channels to display waveform 50 | let leftChannelData = audioValues.L 51 | 52 | // we don't need do draw every sample, draw only averages, numberOfChunks = into how many chunks we split the file 53 | let averagesLeft = audioData.getAverageValues(array: leftChannelData, numberOfChunks: 500) 54 | 55 | displayAudioView.lines = averagesLeft 56 | displayAudioView.setNeedsDisplay() 57 | } catch {print("can't read file into buffer")} 58 | 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /PlayAudioFIleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PlayAudioFIleTests/PlayAudioFIleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayAudioFIleTests.swift 3 | // PlayAudioFIleTests 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 borama. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PlayAudioFIle 11 | 12 | class PlayAudioFIleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /PlayAudioFIleUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PlayAudioFIleUITests/PlayAudioFIleUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlayAudioFIleUITests.swift 3 | // PlayAudioFIleUITests 4 | // 5 | // Created by michal on 27/10/16. 6 | // Copyright © 2016 borama. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class PlayAudioFIleUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PlayAudioFile 2 | example how to play audio file using AVAudioFile, AVAudioEngine, AVAudioPlayerNode. 3 | besides playing audio it captures samples using AVAudioPCMBuffer 4 | also it draws audio file wave form in DisplayView 5 | -------------------------------------------------------------------------------- /test.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/standinga/PlayAudioFile/b9404db4d554e9484366717e4169b8e620216079/test.mp3 --------------------------------------------------------------------------------