AudioKit MIDIListener 强制我覆盖它的协议
AudioKit MIDIListener force me to override its protocol
嗨,我是 AudioKit 的新手
我试着跟着playground写了一个简单的midi listener
https://github.com/AudioKit/AudioKit/blob/v5-master/Playgrounds/Playback.playground/Pages/MIDI%20Input.xcplaygroundpage/Contents.swift
但是,当我创建“class MIDIReceiver: MIDIListener”时,我无法将其内部留空,xcode 要求我重写函数。
“类型 'MIDIReceiver' 不符合协议 'MIDIListener'”
截图在这里
https://i.stack.imgur.com/kUtBs.jpg
我真的需要覆盖它们吗?或者funcs的那些参数怎么填?
谢谢
--- 添加于 10 月 21 日 ---
我想我明白了...
目前的方法是:
class MIDIReceiver: MIDIListener {
func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDINoteOff(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIController(_ controller: MIDIByte, value: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIAftertouch(noteNumber: MIDINoteNumber, pressure: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIAftertouch(_ pressure: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIPitchWheel(_ pitchWheelValue: MIDIWord, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIProgramChange(_ program: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDISystemCommand(_ data: [MIDIByte], portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDISetupChange() {
<#code#>
}
func receivedMIDIPropertyChange(propertyChangeInfo: MIDIObjectPropertyChangeNotification) {
<#code#>
}
func receivedMIDINotification(notification: MIDINotification) {
<#code#>
}
}
Xcode 说“在范围内找不到类型“MIDITimeStamp”、“MIDIUniqID”和“MIDINotification”
导入CoreMIDI后,没有报错
谢谢
只需点击红色圆圈并按“修复”,它就会为您添加所有协议方法。然后你可以将代码放入你需要的代码中。所有的协议方法都是必需的,因为当使事情成为可选的(或创建执行默认操作的协议的扩展)时,结果是如果我们更新协议而开发人员忽略更新,他们将失去他们的 midi 功能。现在,如果我们更改内容,您必须保持最新状态。
嗨,我是 AudioKit 的新手
我试着跟着playground写了一个简单的midi listener https://github.com/AudioKit/AudioKit/blob/v5-master/Playgrounds/Playback.playground/Pages/MIDI%20Input.xcplaygroundpage/Contents.swift
但是,当我创建“class MIDIReceiver: MIDIListener”时,我无法将其内部留空,xcode 要求我重写函数。 “类型 'MIDIReceiver' 不符合协议 'MIDIListener'”
截图在这里 https://i.stack.imgur.com/kUtBs.jpg
我真的需要覆盖它们吗?或者funcs的那些参数怎么填?
谢谢
--- 添加于 10 月 21 日 ---
我想我明白了...
目前的方法是:
class MIDIReceiver: MIDIListener {
func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDINoteOff(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIController(_ controller: MIDIByte, value: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIAftertouch(noteNumber: MIDINoteNumber, pressure: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIAftertouch(_ pressure: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIPitchWheel(_ pitchWheelValue: MIDIWord, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDIProgramChange(_ program: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDISystemCommand(_ data: [MIDIByte], portID: MIDIUniqueID?, offset: MIDITimeStamp) {
<#code#>
}
func receivedMIDISetupChange() {
<#code#>
}
func receivedMIDIPropertyChange(propertyChangeInfo: MIDIObjectPropertyChangeNotification) {
<#code#>
}
func receivedMIDINotification(notification: MIDINotification) {
<#code#>
}
}
Xcode 说“在范围内找不到类型“MIDITimeStamp”、“MIDIUniqID”和“MIDINotification”
导入CoreMIDI后,没有报错
谢谢
只需点击红色圆圈并按“修复”,它就会为您添加所有协议方法。然后你可以将代码放入你需要的代码中。所有的协议方法都是必需的,因为当使事情成为可选的(或创建执行默认操作的协议的扩展)时,结果是如果我们更新协议而开发人员忽略更新,他们将失去他们的 midi 功能。现在,如果我们更改内容,您必须保持最新状态。