Skip to content

Commit 9731564

Browse files
committed
Merge branch 'main' of https://github.com/AudioKit/Keyboard
2 parents 1b03cf6 + 2b7b074 commit 9731564

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

Sources/Keyboard/KeyContainer.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import Tonic
55

66
/// This handles the interaction for key, so the user can provide their own
77
/// visual representation.
8-
struct KeyContainer<Content: View>: View {
8+
public struct KeyContainer<Content: View>: View {
99
let content: (Pitch, Bool) -> Content
1010

1111
var pitch: Pitch
1212
@ObservedObject var model: KeyboardModel
1313

1414
var zIndex: Int
1515

16+
/// Initialize the Container
17+
/// - Parameters:
18+
/// - model: KeyboardModel holding all the keys
19+
/// - pitch: Pitch of this key
20+
/// - zIndex: Layering in z-axis
21+
/// - content: View defining how to render a specific key
1622
init(model: KeyboardModel,
1723
pitch: Pitch,
1824
zIndex: Int = 0,

Sources/Keyboard/Keyboard.docc/Keyboard.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SwiftUI music keyboard
44

55
## Overview
66

7-
Code is hosted on Github: [](https://github.com/AudioKit/Keyboard/)
7+
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.
88

99
![Demo Screenshot](demo)
1010

@@ -21,8 +21,3 @@ Keyboard aims to be an easy-to-use musical keyboard with:
2121
- Good user interface
2222
- Good performance. We rely on SwiftUI's drag gestures
2323

24-
## Topics
25-
26-
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->
27-
28-
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->

Sources/Keyboard/Keyboard.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import SwiftUI
77
public struct Keyboard<Content>: View where Content: View {
88
let content: (Pitch, Bool) -> Content
99

10-
@StateObject var model: KeyboardModel = .init()
10+
/// model contains the keys, their status and touches
11+
@StateObject public var model: KeyboardModel = .init()
1112

1213
var latching: Bool
1314
var noteOn: (Pitch, CGPoint) -> Void

Sources/Keyboard/KeyboardModel.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import SwiftUI
44
import Tonic
55

6-
class KeyboardModel: ObservableObject {
6+
/// Observable model calling back on noteOn and noteOff and storing the touch locations
7+
public class KeyboardModel: ObservableObject {
78
var keyRectInfos: [KeyRectInfo] = []
89
var noteOn: (Pitch, CGPoint) -> Void = { _, _ in }
910
var noteOff: (Pitch) -> Void = { _ in }
@@ -35,12 +36,13 @@ class KeyboardModel: ObservableObject {
3536
}
3637
}
3738

38-
@Published var touchedPitches = PitchSet() {
39+
/// all touched notes
40+
@Published public var touchedPitches = PitchSet() {
3941
willSet { triggerEvents(from: touchedPitches, to: newValue) }
4042
}
4143

4244
/// Either latched keys or keys active due to external MIDI events.
43-
@Published var externallyActivatedPitches = PitchSet() {
45+
@Published public var externallyActivatedPitches = PitchSet() {
4446
willSet { triggerEvents(from: externallyActivatedPitches, to: newValue) }
4547
}
4648

Sources/Keyboard/MIDIMonitorKeyboard.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extension GraphicsContext {
99
}
1010
}
1111

12+
/// MIDIMonitorKeyboard
1213
@available(iOS 15, macOS 12, *)
1314
public struct MIDIMonitorKeyboard: View {
1415

0 commit comments

Comments
 (0)