-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
150 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"data" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "drum1.wav" | ||
} | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"data" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "drum2.wav" | ||
} | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"data" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "drum3.wav" | ||
} | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Drummer.swift | ||
// Magic Drumpad | ||
// | ||
// Created by Damiaan on 18/06/17. | ||
// Copyright © 2017 Damiaan Dufaux. All rights reserved. | ||
// | ||
|
||
import AVFoundation | ||
import AppKit | ||
|
||
let drum1 = NSDataAsset(name: .init("drum1"))!.data | ||
let drum2 = NSDataAsset(name: .init("drum2"))!.data | ||
let drum3 = NSDataAsset(name: .init("drum3"))!.data | ||
|
||
var drum1players = [AVAudioPlayer]() | ||
var drum2players = [AVAudioPlayer]() | ||
var drum3players = [AVAudioPlayer]() | ||
|
||
let count = 100 | ||
func initDrummers() { | ||
for _ in 1...count { drum1players.append(try! AVAudioPlayer(data: drum1)) } | ||
for _ in 1...count { drum2players.append(try! AVAudioPlayer(data: drum2)) } | ||
for _ in 1...count { drum3players.append(try! AVAudioPlayer(data: drum3)) } | ||
} | ||
|
||
func playDrum1() { | ||
let player = drum1players.first {!$0.isPlaying} | ||
player?.play() | ||
} | ||
func playDrum2() { | ||
let player = drum2players.first {!$0.isPlaying} | ||
player?.play() | ||
} | ||
func playDrum3() { | ||
let player = drum3players.first {!$0.isPlaying} | ||
player?.play() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters