Skip to content

Commit

Permalink
don't store guitar stuff in keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Aug 9, 2022
1 parent 67cc778 commit 664ffdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Demo/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ struct ContentView: View {
layout: .isomorphic,
noteOn: noteOn, noteOff: noteOff)
Keyboard(layout: .guitar(openPitches: [Pitch(64), Pitch(59), Pitch(55), Pitch(50), Pitch(45), Pitch(40)], fretcount: 22),
noteOn: noteOn, noteOff: noteOff)
noteOn: noteOn, noteOff: noteOff) { pitch, isActivated in
KeyboardKey(pitch: pitch,
isActivated: isActivated,
text: pitch.note(in: .F).description,
pressedColor: Color(PitchColor.newtonian[Int(pitch.pitchClass)]),
alignment: .center)
}
Keyboard(pitchRange: Pitch(48)...Pitch(65),
layout: .isomorphic) { pitch, isActivated in
KeyboardKey(pitch: pitch,
Expand Down
10 changes: 2 additions & 8 deletions Sources/Keyboard/Keyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public struct Keyboard<Content>: View where Content: View {
var noteOff: (Pitch) -> Void
var layout: KeyboardLayout

// For guitar
var openPitches: [Pitch] = []
var fretCount: Int = 0

public init(pitchRange: ClosedRange<Pitch> = (Pitch(60)...Pitch(72)),
latching: Bool = false,
layout: KeyboardLayout = .piano,
Expand Down Expand Up @@ -68,14 +64,12 @@ extension Keyboard where Content == KeyboardKey {
self.noteOff = noteOff
var alignment: Alignment = .bottom
switch layout {
case .guitar(let openPitches, let fretCount):
self.openPitches = openPitches
self.fretCount = fretCount
case .guitar(_, _):
alignment = .center
case .pianoRoll:
alignment = .trailing
default:
self.fretCount = 0
alignment = .bottom

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

0 comments on commit 664ffdb

Please sign in to comment.