     }
 
     @IBAction func setChannelRadioButton(_ sender: Any?) {
+        guard let midiDocument = midiDocument else { return }
+
         if let matrix = sender as? NSMatrix {
             if matrix.selectedCell()?.tag == 0 {
                 midiDocument.showAllChannels()

    }

    private func buttonStateForInputSources(_ sources: [InputStreamSource]) -> NSControl.StateValue {
        let selectedSources = midiDocument.selectedInputSources

        var areAnySelected = false

    }

    private func changeFilter(tag: Int, state: NSControl.StateValue) {
        guard let midiDocument = midiDocument else { return }

        let turnBitsOn: Bool
        switch state {
        case .on, .mixed:
