Skip to content

Commit 6b4511c

Browse files
committed
swift formatting
1 parent 893875e commit 6b4511c

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

STKAudioKit.playground/Pages/Clarinet.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//: ## Clarinet
22
//: Physical model of a Clarinet
33
import AudioKit
4-
import STKAudioKit
54
import Foundation
65
import PlaygroundSupport
6+
import STKAudioKit
77

88
let playRate = 2.0
99

@@ -13,18 +13,17 @@ let reverb = Reverb(clarinet)
1313

1414
let scale = [0, 2, 4, 5, 7, 9, 11, 12]
1515

16-
1716
let engine = AudioEngine()
1817
engine.output = reverb
1918
try! engine.start()
2019

2120
let t = Timer.scheduledTimer(withTimeInterval: 1.0 / playRate, repeats: true) { _ in
2221
var note = scale.randomElement()!
23-
let octave = (2..<6).randomElement()! * 12
24-
if (0...10).randomElement()! < 1 { note += 1 }
22+
let octave = (2 ..< 6).randomElement()! * 12
23+
if (0 ... 10).randomElement()! < 1 { note += 1 }
2524
if !scale.contains(note % 12) { Log("ACCIDENT!") }
2625

27-
if (0...6).randomElement()! > 1 {
26+
if (0 ... 6).randomElement()! > 1 {
2827
clarinet.trigger(note: MIDINoteNumber(note + octave), velocity: 127)
2928
} else {
3029
clarinet.stop()

STKAudioKit.playground/Pages/Hello World.xcplaygroundpage/Contents.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//: Simple Playground to test if STKAudioKit is working
1+
//: Simple Playground to test if STKAudioKit is working
22
import AudioKit
3-
import STKAudioKit
43
import Foundation
4+
import STKAudioKit
55

66
let shaker = Shaker()
77

@@ -11,7 +11,7 @@ engine.output = shaker
1111
try! engine.start()
1212

1313
while true {
14-
let type = ShakerType(rawValue: (0...22).randomElement()!)!
14+
let type = ShakerType(rawValue: (0 ... 22).randomElement()!)!
1515
print(type)
1616
shaker.trigger(type: type)
1717
sleep(1)

Sources/STKAudioKit/STKPhysicalModels.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright AudioKit. All Rights Reserved.
22

3-
import AVFoundation
43
import AudioKit
54
import AudioKitEX
5+
import AVFoundation
66

77
/// Superclass for STK physical models, do not use directly
8-
public class STKBase: Node, MIDITriggerable {
8+
public class STKBase: Node, MIDITriggerable {
99
/// Connected nodes
1010
public var connections: [Node] { [] }
11-
11+
1212
/// Underlying AVAudioNode
1313
public var avAudioNode: AVAudioNode
14-
14+
1515
/// Initialize the STK Clarinet model
1616
public init(_ code: String) {
1717
avAudioNode = instantiate(instrument: code)
@@ -21,54 +21,53 @@ public class STKBase: Node, MIDITriggerable {
2121
/// STK Clarinet
2222
public class Clarinet: STKBase {
2323
/// Initialize the physical model
24-
public init() { super.init("clar")}
24+
public init() { super.init("clar") }
2525
}
2626

2727
/// STK Flute
2828
public class Flute: STKBase {
2929
/// Initialize the physical model
30-
public init() { super.init("flut")}
30+
public init() { super.init("flut") }
3131
}
3232

3333
/// STK Mandolin
3434
public class MandolinString: STKBase {
3535
/// Initialize the physical model
36-
public init() { super.init("mand")}
36+
public init() { super.init("mand") }
3737
}
3838

3939
/// STK Rhodes Piano
4040
public class RhodesPianoKey: STKBase {
4141
/// Initialize the physical model
42-
public init() { super.init("rhds")}
42+
public init() { super.init("rhds") }
4343
}
4444

4545
/// STK Shaker
4646
public class Shaker: STKBase {
4747
/// Initialize the physical model
48-
public init() { super.init("shak")}
48+
public init() { super.init("shak") }
4949
}
5050

5151
/// STK Tubular Bells
5252
public class TubularBells: STKBase {
5353
/// Initialize the physical model
54-
public init() { super.init("tbel")}
54+
public init() { super.init("tbel") }
5555
}
5656

57-
extension Shaker {
57+
public extension Shaker {
5858
/// Trigger the sound with a set of parameters
5959
///
6060
/// - Parameters:
6161
/// - type: various shaker types are supported
6262
/// - amplitude: how hard to shake
63-
public func trigger(type: ShakerType, amplitude: Double = 0.5) {
63+
func trigger(type: ShakerType, amplitude: Double = 0.5) {
6464
let velocity = MIDIVelocity(amplitude * 127.0)
6565
au.trigger(note: type.rawValue, velocity: velocity)
6666
}
6767
}
6868

6969
/// Type of shaker to use
7070
public enum ShakerType: MIDIByte {
71-
7271
/// Maraca
7372
case maraca = 0
7473

@@ -138,4 +137,3 @@ public enum ShakerType: MIDIByte {
138137
/// Tuned Bamboo Chimes
139138
case tunedBambooChimes = 22
140139
}
141-

Tests/STKAudioKitTests/ValidatedMD5s.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44
extension XCTestCase {
55
func testMD5(_ buffer: AVAudioPCMBuffer) {
66
let localMD5 = buffer.md5
7-
let name = self.description
7+
let name = description
88
XCTAssert(validatedMD5s[name] == buffer.md5, "\nFAILEDMD5 \"\(name)\": \"\(localMD5)\",")
99
}
1010
}

0 commit comments

Comments
 (0)