Skip to content

Commit 4eb420f

Browse files
author
Paige Plander
committed
Initial Commit
0 parents  commit 4eb420f

27 files changed

+763
-0
lines changed

Drummer/Drummer.xcodeproj/project.pbxproj

+410
Large diffs are not rendered by default.

Drummer/Drummer.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Drummer/Drummer/AppDelegate.swift

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// AppDelegate.swift
3+
// Drummer
4+
//
5+
// Created by Paige Plander on 1/13/17.
6+
// Copyright © 2017 iosdecal. 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: [UIApplicationLaunchOptionsKey: 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+
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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" : "1x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "29x29",
26+
"scale" : "3x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "40x40",
36+
"scale" : "3x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "57x57",
41+
"scale" : "1x"
42+
},
43+
{
44+
"idiom" : "iphone",
45+
"size" : "57x57",
46+
"scale" : "2x"
47+
},
48+
{
49+
"size" : "60x60",
50+
"idiom" : "iphone",
51+
"filename" : "120by120.png",
52+
"scale" : "2x"
53+
},
54+
{
55+
"idiom" : "iphone",
56+
"size" : "60x60",
57+
"scale" : "3x"
58+
},
59+
{
60+
"idiom" : "ipad",
61+
"size" : "20x20",
62+
"scale" : "1x"
63+
},
64+
{
65+
"idiom" : "ipad",
66+
"size" : "20x20",
67+
"scale" : "2x"
68+
},
69+
{
70+
"idiom" : "ipad",
71+
"size" : "29x29",
72+
"scale" : "1x"
73+
},
74+
{
75+
"idiom" : "ipad",
76+
"size" : "29x29",
77+
"scale" : "2x"
78+
},
79+
{
80+
"idiom" : "ipad",
81+
"size" : "40x40",
82+
"scale" : "1x"
83+
},
84+
{
85+
"idiom" : "ipad",
86+
"size" : "40x40",
87+
"scale" : "2x"
88+
},
89+
{
90+
"idiom" : "ipad",
91+
"size" : "50x50",
92+
"scale" : "1x"
93+
},
94+
{
95+
"idiom" : "ipad",
96+
"size" : "50x50",
97+
"scale" : "2x"
98+
},
99+
{
100+
"idiom" : "ipad",
101+
"size" : "72x72",
102+
"scale" : "1x"
103+
},
104+
{
105+
"idiom" : "ipad",
106+
"size" : "72x72",
107+
"scale" : "2x"
108+
},
109+
{
110+
"size" : "76x76",
111+
"idiom" : "ipad",
112+
"filename" : "76by76.png",
113+
"scale" : "1x"
114+
},
115+
{
116+
"size" : "76x76",
117+
"idiom" : "ipad",
118+
"filename" : "152by152.png",
119+
"scale" : "2x"
120+
},
121+
{
122+
"size" : "83.5x83.5",
123+
"idiom" : "ipad",
124+
"filename" : "167by167.png",
125+
"scale" : "2x"
126+
}
127+
],
128+
"info" : {
129+
"version" : 1,
130+
"author" : "xcode"
131+
}
132+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--Drummer View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController id="BYZ-38-t0r" customClass="DrummerViewController" customModule="Drummer" customModuleProvider="target" sceneMemberID="viewController">
16+
<layoutGuides>
17+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
18+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
19+
</layoutGuides>
20+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
24+
</view>
25+
</viewController>
26+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
27+
</objects>
28+
</scene>
29+
</scenes>
30+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// DrummerViewController.swift
3+
// Drummer
4+
//
5+
// Created by Paige Plander on 1/13/17.
6+
// Copyright © 2017 iosdecal. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class DrummerViewController: UIViewController {
12+
13+
// Drum Kit 0 (Acoustic Drum Kit)
14+
let drumKit0 = DrumKit(drumKitID: 0)
15+
16+
// Drum Kit 1 (Electronic Drum Kit)
17+
let drumKit1 = DrumKit(drumKitID: 1)
18+
19+
// The currently selected drum kit (default = 0)
20+
var currentDrumKit: DrumKit?
21+
22+
override func viewDidLoad() {
23+
super.viewDidLoad()
24+
// sets the default drum kit to drumkit0
25+
currentDrumKit = drumKit0
26+
}
27+
28+
// YOUR CODE HERE
29+
30+
31+
}

Drummer/Drummer/Info.plist

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UILaunchStoryboardName</key>
24+
<string>LaunchScreen</string>
25+
<key>UIMainStoryboardFile</key>
26+
<string>Main</string>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
<key>UISupportedInterfaceOrientations~ipad</key>
38+
<array>
39+
<string>UIInterfaceOrientationPortrait</string>
40+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
41+
<string>UIInterfaceOrientationLandscapeLeft</string>
42+
<string>UIInterfaceOrientationLandscapeRight</string>
43+
</array>
44+
</dict>
45+
</plist>

Drummer/Drummer/Model/DrumKit.swift

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// Drummer.swift
3+
// Drummer
4+
//
5+
// Created by Paige Plander on 12/28/16.
6+
// Copyright © 2016 Paige Plander. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
/// Model class for drumkits (you will not need to edit this file, but it will help to read through it)
12+
class DrumKit {
13+
14+
/// The ID number to indicate which drum kit the user is playing
15+
private var drumKitID: Int
16+
17+
/// Filenames for the available drum sounds for drum kit 0
18+
private static let drumKit0AudioFileNames = ["drumkit0-0.wav", "drumkit0-1.wav", "drumkit0-2.wav", "drumkit0-3.wav", "drumkit0-4.wav", "drumkit0-5.wav", "drumkit0-kick.wav"]
19+
20+
/// Filenames for the available drum sounds for drum kit 1
21+
private static let drumKit1AudioFileNames = ["drumkit1-0.wav", "drumkit1-1.wav", "drumkit1-2.wav", "drumkit1-3.wav", "drumkit1-4.wav", "drumkit1-5.wav", "drumkit1-kick.wav"]
22+
23+
24+
init(drumKitID: Int) {
25+
self.drumKitID = drumKitID
26+
}
27+
28+
/// Plays the audio file for drum associated with the given tag
29+
///
30+
/// - Parameter tag: The tag of the drum button pressed
31+
func playDrumSound(forDrumWithTag tag: Int) {
32+
switch drumKitID {
33+
case 0:
34+
SystemSoundID.playSound(withFilename: DrumKit.drumKit0AudioFileNames[tag])
35+
case 1:
36+
SystemSoundID.playSound(withFilename: DrumKit.drumKit1AudioFileNames[tag])
37+
default:
38+
print("Error - drum kit \(drumKitID) does not exist.")
39+
}
40+
}
41+
}
42+
43+
44+
/// Framework used for sound playback (you can ignore the extension for this lab)
45+
import AudioToolbox
46+
47+
extension SystemSoundID {
48+
static func playSound(withFilename filename: String) {
49+
var sound: SystemSoundID = 0
50+
if let soundURL = Bundle.main.url(forResource: filename, withExtension: nil) {
51+
AudioServicesCreateSystemSoundID(soundURL as CFURL, &sound)
52+
AudioServicesPlaySystemSound(sound)
53+
}
54+
}
55+
}
56+

0 commit comments

Comments
 (0)