Skip to content

Commit

Permalink
updated to swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
genedelisa committed Nov 1, 2016
1 parent 20aa807 commit 0f73de1
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ clean: true
copyright: "2016 © Gene De Lisa. See LICENSE for more details. [Rockhopper Technologies](http://rockhoppertech.com/)"
readme_path: ./README.md
output: docs/swiftDocs
swift_version: 2.1.1
swift_version: 3.0
xcodebuild-arguments: -scheme,MIDISynth
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# file: .travis.yml
language: objective-c
osx_image: xcode6.4
osx_image: xcode8
xcode_project: MIDISynth

before_install:
Expand Down
23 changes: 20 additions & 3 deletions MIDISynth.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,21 @@
B0E9F6A81B5D52940035EEBA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Gene De Lisa";
TargetAttributes = {
B050231D1C6A92F500ACED32 = {
CreatedOnToolsVersion = 7.2;
};
B0E9F6AF1B5D52950035EEBA = {
CreatedOnToolsVersion = 7.0;
DevelopmentTeam = 4UDK2944TW;
LastSwiftMigration = 0800;
};
B0E9F6CC1B5D52950035EEBA = {
CreatedOnToolsVersion = 7.0;
DevelopmentTeam = 4UDK2944TW;
LastSwiftMigration = 0800;
TestTargetID = B0E9F6AF1B5D52950035EEBA;
};
};
Expand Down Expand Up @@ -382,8 +386,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -405,7 +411,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -427,8 +433,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -444,9 +452,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -456,32 +465,38 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4UDK2944TW;
INFOPLIST_FILE = MIDISynth/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.rockhoppertech.MIDISynth;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
B0E9F6D81B5D52950035EEBA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 4UDK2944TW;
INFOPLIST_FILE = MIDISynth/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.rockhoppertech.MIDISynth;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
B0E9F6DA1B5D52950035EEBA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 4UDK2944TW;
INFOPLIST_FILE = MIDISynthTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.rockhoppertech.MIDISynthTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MIDISynth.app/MIDISynth";
};
name = Debug;
Expand All @@ -490,10 +505,12 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 4UDK2944TW;
INFOPLIST_FILE = MIDISynthTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.rockhoppertech.MIDISynthTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MIDISynth.app/MIDISynth";
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions MIDISynth/AVAudioUnitDistortionEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AVAudioUnitDistortionEffect: AVAudioUnitEffect {
super.init(audioComponentDescription: description)
}

func setFinalMix(finalMix:Float) {
func setFinalMix(_ finalMix:Float) {

let status = AudioUnitSetParameter(
self.audioUnit,
Expand All @@ -57,13 +57,13 @@ class AVAudioUnitDistortionEffect: AVAudioUnitEffect {
}
}

func setDelay(value:Float) {
func setDelay(_ value:Float) {
setAudioUnitParameterValue(audioUnit, parameterType: kDistortionParam_Delay, value: 0.0)
}
// etc for the rest


func getAudioUnitParameterValue(audioUnit:AudioUnit , parameterType:AudioUnitParameterID ) -> Float {
func getAudioUnitParameterValue(_ audioUnit:AudioUnit , parameterType:AudioUnitParameterID ) -> Float {

var value = AudioUnitParameterValue(0.0)
let status = AudioUnitGetParameter(audioUnit,
Expand All @@ -78,7 +78,7 @@ class AVAudioUnitDistortionEffect: AVAudioUnitEffect {
}
}

func setAudioUnitParameterValue(audioUnit:AudioUnit , parameterType:AudioUnitParameterID, value:Float) {
func setAudioUnitParameterValue(_ audioUnit:AudioUnit , parameterType:AudioUnitParameterID, value:Float) {

let status = AudioUnitSetParameter(audioUnit,
parameterType,
Expand Down
29 changes: 15 additions & 14 deletions MIDISynth/AVAudioUnitMIDISynth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
/// Loads the default sound font.
/// If the file is not found, halt with an error message.
func loadMIDISynthSoundFont() {
guard let bankURL = NSBundle.mainBundle().URLForResource("FluidR3 GM2-2", withExtension: "SF2") else {
guard let bankURL = Bundle.main.url(forResource: "FluidR3 GM2-2", withExtension: "SF2") else {
fatalError("Get the default sound font URL correct!")
}

Expand All @@ -54,15 +54,16 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {

/// Loads the specified sound font.
/// - parameter bankURL: A URL to the sound font.
func loadMIDISynthSoundFont(var bankURL:NSURL) {
func loadMIDISynthSoundFont(_ bankURL:URL) {
var bankURL = bankURL

let status = AudioUnitSetProperty(
self.audioUnit,
AudioUnitPropertyID(kMusicDeviceProperty_SoundBankURL),
AudioUnitScope(kAudioUnitScope_Global),
0,
&bankURL,
UInt32(sizeof(bankURL.dynamicType)))
UInt32(MemoryLayout<URL>.size))

if status != OSStatus(noErr) {
print("error \(status)")
Expand All @@ -81,12 +82,12 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
/// - precondition: the graph must be initialized
///
/// [Doug's post](http://prod.lists.apple.com/archives/coreaudio-api/2016/Jan/msg00018.html)
func loadPatches(patches:[UInt32]) throws {
func loadPatches(_ patches:[UInt32]) throws {

if let e = engine {
if !e.running {
if !e.isRunning {
print("audio engine needs to be running")
throw AVAudioUnitMIDISynthError.EngineNotStarted
throw AVAudioUnitMIDISynthError.engineNotStarted
}
}

Expand All @@ -99,8 +100,8 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
AudioUnitScope(kAudioUnitScope_Global),
0,
&enabled,
UInt32(sizeof(UInt32)))
if status != OSStatus(noErr) {
UInt32(MemoryLayout<UInt32>.size))
if status != noErr {
print("error \(status)")
}
// let bankSelectCommand = UInt32(0xB0 | 0)
Expand All @@ -110,7 +111,7 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
for patch in patches {
print("preloading patch \(patch)")
status = MusicDeviceMIDIEvent(self.audioUnit, pcCommand, patch, 0, 0)
if status != OSStatus(noErr) {
if status != noErr {
print("error \(status)")
AudioUtils.CheckError(status)
}
Expand All @@ -123,8 +124,8 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
AudioUnitScope(kAudioUnitScope_Global),
0,
&enabled,
UInt32(sizeof(UInt32)))
if status != OSStatus(noErr) {
UInt32(MemoryLayout<UInt32>.size))
if status != noErr {
print("error \(status)")
}

Expand All @@ -141,9 +142,9 @@ class AVAudioUnitMIDISynth: AVAudioUnitMIDIInstrument {
///
/// - BadSoundFont:
/// The specified sound font is no good
enum AVAudioUnitMIDISynthError: ErrorType {
enum AVAudioUnitMIDISynthError: Error {
/// The AVAudioEngine needs to be started and it's not.
case EngineNotStarted
case engineNotStarted
/// The specified sound font is no good.
case BadSoundFont
case badSoundFont
}
12 changes: 6 additions & 6 deletions MIDISynth/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
Loading

0 comments on commit 0f73de1

Please sign in to comment.