Skip to content

Commit

Permalink
Refactor demo
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymmarkov committed Oct 23, 2016
1 parent c42a927 commit 5111ec1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Example/GuitarTuner/GuitarTuner/Source/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewController: UIViewController {
return label
}()

lazy var offsetLabel: UILabel = { [unowned self] in
lazy var offsetLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 28)
label.textColor = UIColor.white
Expand All @@ -43,10 +43,8 @@ class ViewController: UIViewController {
return button
}()

lazy var pitchEngine: PitchEngine = { [unowned self] in
var config = Config()
config.transformStrategy = .yin
config.estimationStrategy = .yin
lazy var pitchEngine: PitchEngine = { [weak self] in
var config = Config(estimationStrategy: .yin)
let pitchEngine = PitchEngine(config: config, delegate: self)
pitchEngine.levelThreshold = -30.0

Expand Down Expand Up @@ -85,7 +83,7 @@ class ViewController: UIViewController {
offsetLabel.isHidden = !pitchEngine.active
}

// MARK: - Constrains
// MARK: - Layout

func setupLayout() {
let totalSize = UIScreen.main.bounds
Expand Down Expand Up @@ -140,7 +138,7 @@ extension ViewController: PitchEngineDelegate {
let offsetPercentage = pitch.closestOffset.percentage
let absOffsetPercentage = abs(offsetPercentage)

NSLog("pitch : \(pitch.note.string) - percentage : \(offsetPercentage)")
print("pitch : \(pitch.note.string) - percentage : \(offsetPercentage)")

guard absOffsetPercentage > 1.0 else {
return
Expand All @@ -159,7 +157,6 @@ extension ViewController: PitchEngineDelegate {
}

public func pitchEngineWentBelowLevelThreshold(_ pitchEngine: PitchEngine) {

print("Below level threshold")
}

}

0 comments on commit 5111ec1

Please sign in to comment.