Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# User-specific xcconfig files
Xcode-config/DEVELOPMENT_TEAM.xcconfig
31 changes: 25 additions & 6 deletions AudioWaveformGraph.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
3D29594227B2C7B300BA7C0A /* DEVELOPMENT_TEAM.template.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 3D29593F27B2C7B300BA7C0A /* DEVELOPMENT_TEAM.template.xcconfig */; };
3D29594327B2C7B300BA7C0A /* DEVELOPMENT_TEAM.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 3D29594027B2C7B300BA7C0A /* DEVELOPMENT_TEAM.xcconfig */; };
3D29594427B2C7B300BA7C0A /* Shared.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 3D29594127B2C7B300BA7C0A /* Shared.xcconfig */; };
EF1512EB258BDA8000F064A6 /* UIKitExtras.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF1512EA258BDA8000F064A6 /* UIKitExtras.swift */; };
EFC5909725840B1500E5D4B4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFC5909625840B1500E5D4B4 /* AppDelegate.swift */; };
EFC5909925840B1500E5D4B4 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFC5909825840B1500E5D4B4 /* SceneDelegate.swift */; };
Expand All @@ -29,6 +32,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3D29593F27B2C7B300BA7C0A /* DEVELOPMENT_TEAM.template.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DEVELOPMENT_TEAM.template.xcconfig; sourceTree = "<group>"; };
3D29594027B2C7B300BA7C0A /* DEVELOPMENT_TEAM.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DEVELOPMENT_TEAM.xcconfig; sourceTree = "<group>"; };
3D29594127B2C7B300BA7C0A /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = "<group>"; };
EF1512EA258BDA8000F064A6 /* UIKitExtras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitExtras.swift; sourceTree = "<group>"; };
EFC5909325840B1500E5D4B4 /* AudioWaveformGraph.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AudioWaveformGraph.app; sourceTree = BUILT_PRODUCTS_DIR; };
EFC5909625840B1500E5D4B4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -64,13 +70,25 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3D29593E27B2C7B300BA7C0A /* Xcode-config */ = {
isa = PBXGroup;
children = (
3D29593F27B2C7B300BA7C0A /* DEVELOPMENT_TEAM.template.xcconfig */,
3D29594027B2C7B300BA7C0A /* DEVELOPMENT_TEAM.xcconfig */,
3D29594127B2C7B300BA7C0A /* Shared.xcconfig */,
);
path = "Xcode-config";
sourceTree = "<group>";
};
EFC5908A25840B1500E5D4B4 = {
isa = PBXGroup;
children = (
3D29593E27B2C7B300BA7C0A /* Xcode-config */,
EFC5909525840B1500E5D4B4 /* AudioWaveformGraph */,
EFC5909425840B1500E5D4B4 /* Products */,
);
sourceTree = "<group>";
usesTabs = 0;
};
EFC5909425840B1500E5D4B4 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -191,7 +209,10 @@
files = (
EFC590A325840B1700E5D4B4 /* LaunchScreen.storyboard in Resources */,
EFC590AC25840B7500E5D4B4 /* audio.mp3 in Resources */,
3D29594227B2C7B300BA7C0A /* DEVELOPMENT_TEAM.template.xcconfig in Resources */,
3D29594327B2C7B300BA7C0A /* DEVELOPMENT_TEAM.xcconfig in Resources */,
EFC590A025840B1700E5D4B4 /* Assets.xcassets in Resources */,
3D29594427B2C7B300BA7C0A /* Shared.xcconfig in Resources */,
EFC5909E25840B1500E5D4B4 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -245,6 +266,7 @@
/* Begin XCBuildConfiguration section */
EFC590A525840B1700E5D4B4 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3D29594127B2C7B300BA7C0A /* Shared.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -294,7 +316,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand All @@ -306,6 +328,7 @@
};
EFC590A625840B1700E5D4B4 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3D29594127B2C7B300BA7C0A /* Shared.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -349,7 +372,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -366,9 +389,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = AudioWaveformGraph/AudioWaveformGraph.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 899AA7RGN5;
INFOPLIST_FILE = AudioWaveformGraph/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -388,9 +409,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = AudioWaveformGraph/AudioWaveformGraph.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 899AA7RGN5;
INFOPLIST_FILE = AudioWaveformGraph/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
10 changes: 9 additions & 1 deletion AudioWaveformGraph/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,29 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {


var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 13, *) {
// Do nothing / do things that should only be done for iOS 13.
} else {
// Do iOS 12 specific window setup.
}

// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

@available(iOS 13, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

@available(iOS 13, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
Expand Down
18 changes: 12 additions & 6 deletions AudioWaveformGraph/Graph/DataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ class DataProvider {
idx += hopSize
}

summarySampleMax = vDSP.maximum(workingAvgSamples)
summarySampleMin = vDSP.minimum(workingAvgSamples)
if #available(iOS 13, *) {
summarySampleMax = vDSP.maximum(workingAvgSamples)
summarySampleMin = vDSP.minimum(workingAvgSamples)
}
else {
vDSP_maxv(workingAvgSamples, 1, &summarySampleMax, vDSP_Length(workingAvgSamples.count))
vDSP_minv(workingAvgSamples, 1, &summarySampleMin, vDSP_Length(workingAvgSamples.count))
}

summarySamples = workingAvgSamples

Expand All @@ -65,11 +71,11 @@ class DataProvider {
}

func sample(at time: Double) -> Float {
guard let summarySamples = summarySamples else { return 0 }
var summarySampleIdx = Int(time / duration * Double(summarySamples.count))
// `time` can dip below 0 if rubber-banding to before the first or after the last sample while scrolling.
guard (0.0..<duration).contains(time) else { return 0 }

// fail safe
summarySampleIdx = min(summarySampleIdx, summarySamples.count - 1)
guard let summarySamples = summarySamples else { return 0 }
let summarySampleIdx = Int(time / duration * Double(summarySamples.count))

return summarySamples[summarySampleIdx]
}
Expand Down
1 change: 1 addition & 0 deletions AudioWaveformGraph/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

@available(iOS 13, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
Expand Down
8 changes: 5 additions & 3 deletions AudioWaveformGraph/Utilities/MathUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import Accelerate

func fast_mean(_ a: [Float], startIdx: Int, endIdx: Int) -> Float {
var mean: Float = 0
// todo: dangling pointer warning is safe in this case since it's never accessed outside of scope, but should be fixed
let ptr = UnsafePointer<Float>(a)
vDSP_meanv(ptr + startIdx, 1, &mean, UInt(endIdx - startIdx))

a.withUnsafeBufferPointer { bufferPointer in
let ptr = bufferPointer.baseAddress!
vDSP_meanv(ptr + startIdx, 1, &mean, UInt(endIdx - startIdx))
}

return mean
}
Expand Down
1 change: 1 addition & 0 deletions Xcode-config/DEVELOPMENT_TEAM.template.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEVELOPMENT_TEAM = AB1234C5DE
51 changes: 51 additions & 0 deletions Xcode-config/Shared.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
DEVELOPMENT_TEAM = 899AA7RGN5

#include? "DEVELOPMENT_TEAM.xcconfig"

// Create the file DEVELOPMENT_TEAM.xcconfig
// in the "Xcode-config" directory within the project directory
// with the following build setting:
// DEVELOPMENT_TEAM = [Your TeamID]

// One way to find your Team ID is to set the “Development Team”
// build setting (Xcode key: "DEVELOPMENT_TEAM") and have a look
// at the “Source Control” changes (menu item “Commit…”/⌥⌘C).
// Just make sure that this change doesn’t actually get commited.

// You can also find your Team ID by logging into your Apple Developer account
// and going to
// https://developer.apple.com/account/#/membership
// It should be listed under “Team ID”.

// To set this system up for your own project,
// copy the "Xcode-config" directory there,
// add it to your Xcode project,
// navigate to your project settings
// (root icon in the Xcode Project Navigator)
// click on the project icon there,
// click on the “Info” tab
// under “Configurations”
// open the “Debug”, “Release”,
// and any other build configurations you might have.
// There you can set the pull-down menus in the
// “Based on Configuration File” column to “Shared”.
// Your work in Xcode is done.

// Don’t forget to add the DEVELOPMENT_TEAM.xcconfig file to your .gitignore:
// # User-specific xcconfig files
// Xcode-config/DEVELOPMENT_TEAM.xcconfig
// The two lines above are an example.
// Please don’t copy the comment slashes over though.

// You can and should now replace the “DevelopmentTeam = AB1234C5DE;” entries in
// .xcodeproj/project.pbxproj
// with “DevelopmentTeam = "";”
// They would otherwise override the Team ID set via this config file and its include.
// Please note that .pbxproj files use straight quotes.

// When you commit changes to the Xcode project file
// after changing settings in “Signing & Capabilities”
// Entries like these may appear in your file changes/commit diff preview:
// CODE_SIGN_IDENTITY = …;
// CODE_SIGN_STYLE = Manual/Automatic;
// Please make sure not to commit them to source control.