KeyboardController

final class KeyboardController : UIViewController
extension KeyboardController: ControllerConfiguration
extension KeyboardController: Keyboard

Controller for the keyboard view. Creates the individual Key views and handles touch event detection within them. The controller creates an entire 108 keyboard which it then shows only a part of on the screen. The keyboard can be shifted up/down by octaves or by sliding via touch (if enabled).

  • Flag indicating that the audio is currently muted, and playing a note will not generate any sound

    Declaration

    Swift

    var isMuted: Bool { get set }
  • Initialize controller with view loaded

    Declaration

    Swift

    override func viewDidLoad()
  • Redraw keyboard after layout change.

    Declaration

    Swift

    override func viewDidLayoutSubviews()

Configuration

Touch Processing

  • Begin processing a touch event for the keyboard

    Declaration

    Swift

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

    Parameters

    touches

    the touch events that started

    event

    the event that spawned the touches

  • Update touch events for the keyboard

    Declaration

    Swift

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?)

    Parameters

    touches

    the touch events that moved

    event

    the event that spawned the touches

  • Complete touch events for the keyboard

    Declaration

    Swift

    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)

    Parameters

    touches

    the touch events that stopped

    event

    the event that spawned the touches

  • Cancel touch events for the keyboard

    Declaration

    Swift

    override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?)

    Parameters

    touches

    the touch events that stopped

    event

    the event that spawned the touches

Keyboard Protocol

  • Notification that the given note is being played (eg by MIDI event)

    Declaration

    Swift

    func noteIsOn(note: UInt8)

    Parameters

    note

    the MIDI note value being played

  • Notification that the given note is not being played (eg by MIDI event)

    Declaration

    Swift

    func noteIsOff(note: UInt8)

    Parameters

    note

    the MIDI note value not being played

  • The current lowest MIDI note of the keyboard (mutable)

    Declaration

    Swift

    var lowestNote: Note { get set }
  • The current highest MIDI note of the keyboard (read-only)

    Declaration

    Swift

    var highestNote: Note { get }
  • Demand that all keys stop playing audio.

    Declaration

    Swift

    func releaseAllKeys()