diff --git a/Sources/Keyboard/KeyContainer.swift b/Sources/Keyboard/KeyContainer.swift index 40c0e4b..6094ec0 100644 --- a/Sources/Keyboard/KeyContainer.swift +++ b/Sources/Keyboard/KeyContainer.swift @@ -5,7 +5,7 @@ import Tonic /// This handles the interaction for key, so the user can provide their own /// visual representation. -struct KeyContainer: View { +public struct KeyContainer: View { let content: (Pitch, Bool) -> Content var pitch: Pitch @@ -13,6 +13,12 @@ struct KeyContainer: View { var zIndex: Int + /// Initialize the Container + /// - Parameters: + /// - model: KeyboardModel holding all the keys + /// - pitch: Pitch of this key + /// - zIndex: Layering in z-axis + /// - content: View defining how to render a specific key init(model: KeyboardModel, pitch: Pitch, zIndex: Int = 0, diff --git a/Sources/Keyboard/Keyboard.docc/Keyboard.md b/Sources/Keyboard/Keyboard.docc/Keyboard.md index 5814058..9d06c0b 100644 --- a/Sources/Keyboard/Keyboard.docc/Keyboard.md +++ b/Sources/Keyboard/Keyboard.docc/Keyboard.md @@ -4,7 +4,7 @@ SwiftUI music keyboard ## Overview -Code is hosted on Github: [](https://github.com/AudioKit/Keyboard/) +See the [AudioKit Cookbook](https://github.com/AudioKit/Cookbook/) for examples and see the source code for API of all Keyboard elements. This documentation gives a rudimentary overview but lacks most of the finer details. ![Demo Screenshot](demo) @@ -21,8 +21,3 @@ Keyboard aims to be an easy-to-use musical keyboard with: - Good user interface - Good performance. We rely on SwiftUI's drag gestures -## Topics - -### Group - -- ``Symbol`` diff --git a/Sources/Keyboard/Keyboard.swift b/Sources/Keyboard/Keyboard.swift index fb4b501..0e71575 100644 --- a/Sources/Keyboard/Keyboard.swift +++ b/Sources/Keyboard/Keyboard.swift @@ -7,7 +7,8 @@ import SwiftUI public struct Keyboard: View where Content: View { let content: (Pitch, Bool) -> Content - @StateObject var model: KeyboardModel = .init() + /// model contains the keys, their status and touches + @StateObject public var model: KeyboardModel = .init() var latching: Bool var noteOn: (Pitch, CGPoint) -> Void diff --git a/Sources/Keyboard/KeyboardModel.swift b/Sources/Keyboard/KeyboardModel.swift index 03b3dac..4a10b87 100644 --- a/Sources/Keyboard/KeyboardModel.swift +++ b/Sources/Keyboard/KeyboardModel.swift @@ -3,7 +3,8 @@ import SwiftUI import Tonic -class KeyboardModel: ObservableObject { +/// Observable model calling back on noteOn and noteOff and storing the touch locations +public class KeyboardModel: ObservableObject { var keyRectInfos: [KeyRectInfo] = [] var noteOn: (Pitch, CGPoint) -> Void = { _, _ in } var noteOff: (Pitch) -> Void = { _ in } @@ -35,12 +36,13 @@ class KeyboardModel: ObservableObject { } } - @Published var touchedPitches = PitchSet() { + /// all touched notes + @Published public var touchedPitches = PitchSet() { willSet { triggerEvents(from: touchedPitches, to: newValue) } } /// Either latched keys or keys active due to external MIDI events. - @Published var externallyActivatedPitches = PitchSet() { + @Published public var externallyActivatedPitches = PitchSet() { willSet { triggerEvents(from: externallyActivatedPitches, to: newValue) } } diff --git a/Sources/Keyboard/MIDIMonitorKeyboard.swift b/Sources/Keyboard/MIDIMonitorKeyboard.swift index b92257b..0e739ba 100644 --- a/Sources/Keyboard/MIDIMonitorKeyboard.swift +++ b/Sources/Keyboard/MIDIMonitorKeyboard.swift @@ -9,8 +9,9 @@ extension GraphicsContext { } } +/// MIDIMonitorKeyboard @available(iOS 15, macOS 12, *) -struct MIDIMonitorKeyboard: View { +public struct MIDIMonitorKeyboard: View { var layout: KeyboardLayout var activatedPitches: PitchSet