Skip to content

Commit 664ffdb

Browse files
committed
don't store guitar stuff in keyboard
1 parent 67cc778 commit 664ffdb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Demo/Shared/ContentView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ struct ContentView: View {
5454
layout: .isomorphic,
5555
noteOn: noteOn, noteOff: noteOff)
5656
Keyboard(layout: .guitar(openPitches: [Pitch(64), Pitch(59), Pitch(55), Pitch(50), Pitch(45), Pitch(40)], fretcount: 22),
57-
noteOn: noteOn, noteOff: noteOff)
57+
noteOn: noteOn, noteOff: noteOff) { pitch, isActivated in
58+
KeyboardKey(pitch: pitch,
59+
isActivated: isActivated,
60+
text: pitch.note(in: .F).description,
61+
pressedColor: Color(PitchColor.newtonian[Int(pitch.pitchClass)]),
62+
alignment: .center)
63+
}
5864
Keyboard(pitchRange: Pitch(48)...Pitch(65),
5965
layout: .isomorphic) { pitch, isActivated in
6066
KeyboardKey(pitch: pitch,

Sources/Keyboard/Keyboard.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ public struct Keyboard<Content>: View where Content: View {
1212
var noteOff: (Pitch) -> Void
1313
var layout: KeyboardLayout
1414

15-
// For guitar
16-
var openPitches: [Pitch] = []
17-
var fretCount: Int = 0
18-
1915
public init(pitchRange: ClosedRange<Pitch> = (Pitch(60)...Pitch(72)),
2016
latching: Bool = false,
2117
layout: KeyboardLayout = .piano,
@@ -68,14 +64,12 @@ extension Keyboard where Content == KeyboardKey {
6864
self.noteOff = noteOff
6965
var alignment: Alignment = .bottom
7066
switch layout {
71-
case .guitar(let openPitches, let fretCount):
72-
self.openPitches = openPitches
73-
self.fretCount = fretCount
67+
case .guitar(_, _):
7468
alignment = .center
7569
case .pianoRoll:
7670
alignment = .trailing
7771
default:
78-
self.fretCount = 0
72+
alignment = .bottom
7973

8074
}
8175
self.content = { KeyboardKey(pitch: $0, isActivated: $1, flatTop: layout == .piano, alignment: alignment) }

0 commit comments

Comments
 (0)