-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get V5 MIDI to work at all. #2261
Comments
I have written a midi monitor in swiftUI that works and is basically set up just like how you have it except that instead of opening up inputs on init, I have a start function that I call when the SwiftUI appears:
and in the conductor:
See if that change helps. |
I updated with your code. Unfortunately I'm still not getting any output. Here's the other parts of the code. app entry point: import SwiftUI
@main
struct AKTestSetupApp: App {
let midiData = Conductor()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(midiData)
}
}
} View for MIDI import SwiftUI
struct ContentView: View {
@EnvironmentObject var midi: Conductor
var body: some View {
Text("Test midi inputs \(midi.noteNumber)")
.onAppear {
midi.start()
}
.onDisappear {
midi.stop()
}
}
} model class Conductor: AKMIDIListener, ObservableObject {
// Single shared instance of this class
static let sharedInstance = Conductor()
var midi = AKMIDI()
@Published var noteNumber: UInt8 = 0 // Should update on midi fire
func start() {
midi.openInput(name: "Session 1")
midi.openInput()
midi.addListener(self)
}
func stop() {
midi.closeAllInputs()
}
func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID? = nil, offset: MIDITimeStamp = 0) {
print("MidiNote received: \(self.noteNumber) on channel: \(channel) and port ID: \(String(describing: portID)) ")
DispatchQueue.main.async {
self.noteNumber = noteNumber
}
}
func receivedMIDINoteOff(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, offset: MIDITimeStamp) {
print("MidiNote off: \(noteNumber) on channel: \(channel) and port ID: \(String(describing: portID)) ")
DispatchQueue.main.async {
self.noteNumber = 0
}
}
} |
Does it say anything in your output console? You may have forgotten to add background modes / audio in your project settings. That is required for midi. |
And this setting is even more hidden in Xcode 12 than it was before. |
This is what it says in the console:
Where are these setting located? |
I found them hang tight let me test this out |
Hmmm, it should have triggered this bit of code:
so if that is the problem, then there's a new problem where CheckError is not being called. |
Yeah I definitely didn't get any errors and updating those settings didn't change anything as far as the output |
I see you are using a SwiftUI app, that is pretty cutting edge, I have only done SwiftUI interfaces. Are you running on a device or on macOS? We could do a screenshare if you like. |
Which version of AudioKit are you using and how do you have it installed? |
I'm using the v5-develop branch of AudioKit installed through swift package manager. The app is for iOS. |
Nice. I'm pretty happy with the workflow now. Sorry your app isn't working, want to zoom and have a look together? |
Yeah we can should I post the link here? |
I know you guy are hard at work trying to update everything for the new release but just wanted to make you aware I can't get MIDI to work at all in a SwiftUI app on Xcode 12. I've followed some examples online and I can't so much as get a signal to register in a super simple project. So I wasn't sure if it's not working at all at the moment or if it's something on my end.
Here's the model I'm using it's completely barebones
I'm then registering this to the environment object in my main app file. So I'm not sure if it's something I'm doing wrong. Or if you guys are just in the weeds right now getting everything ready.
The text was updated successfully, but these errors were encountered: