Error message on PC #258
Replies: 3 comments 4 replies
-
Hi,
Yes, you should dispose a MIDI device. And that's explicitly stated in the docs: https://melanchall.github.io/drywetmidi/articles/devices/Output-device.html
MIDI system on macOS is much better and you can use the same devices across multiple apps there. But Windows MIDI system provides only exclusive access to devices. As for the moment when to dispose a device, you need to choose it by yourself. But that
is absolutely wrong. Just dispose a device when the app doesn't need it anymore. Common case is to dispose it when the app exits. In case of Unity - when a game has been stopped. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi Max. I think I have reached a dead-end due to my inexperience, but before I switch to another asset, I thought it might be worth asking your advice as you've been so helpful thus far. Firstly to explain my problem: In the short term I've been using DryWetMidi in unity and sending it via IAC bus to software on my Mac to playback GM Midi, but I knew that would have to be fixed at some point by bringing the sound generation inside the game, and that is where I've become stuck. I realise this is not your responsibility as you have made a (fantastic) midi API which is responsible for Midi events only and not audio playback. However, I thought you would probably know if this is possible. If it is not possible, then no problem, I have learnt so much from doing this so it's not been wasted, I will have to go back many steps and refactor my code to work with another asset. However, maybe it is possible, but I'm just not sure. So my question: Is it possible to link DryWetMidi with something like FluidSynth inside Unity, and if so, what is the mechanism I should research to do so? Would that be virtual ports? Or something else? As always, thanks for your API, and your helpful replies :) |
Beta Was this translation helpful? Give feedback.
-
Nice! |
Beta Was this translation helpful? Give feedback.
-
Hi Max.
I've been running your API absolutely fine on my Mac. However a friend had problem on windows. I'm wondering if we can decipher the error. He sent it on Discord so couldn't send the whole error. Here's the bit he sent (I could ask him to email the whole error):
MidiDeviceException: Device is already in use (OUT_OPENRESULT_ALLOCATED).
Melanchall.DryWetMidi.Multimedia.NativeApi.HandleResult[TResult,TException] (TResult result, System.Func`3[T1,T2,TResult] createException) (at <1ee5422f8ce74a06831827bb5f773e0a>:0)
Melanchall.DryWetMidi.Multimedia.NativeApiUtilities.HandleDevicesNativeApiResult[TResult] (TResult result) (at <1ee5422f8ce74a06831827bb5f773e0a>:0)
Melanchall.DryWetMidi.Multimedia.OutputDevice.EnsureHandleIsCreated () (at <1ee5422f8ce74a06831827bb5f773e0a>:0)
He doesn't use MIDI, or even know what it is, so it's very unlikely he's using a MIDI output in another application. And he does have one (MIDI Port) because my app runs a scan for MIDI ports and came back with the classic Microsoft GM synth one.
So I'm guessing that the error is within unity. E.G the MIDI Port is in use by unity and being requested twice, but I don't get this problem on my Mac. I wondered if this could be something to do with disposing the OutputDevice after use in the scripts, I actually hadn't created any disposes because I'm using MIDI all the time in the app I'm making. Should I be disposing it after every MIDI event? Or after every scene? Or just on application close? Or do you think the problem is something else?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions