Skip to content
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

rtMidi.mod: openPort() should return true/false #99

Open
GWRon opened this issue Apr 3, 2023 · 1 comment
Open

rtMidi.mod: openPort() should return true/false #99

GWRon opened this issue Apr 3, 2023 · 1 comment

Comments

@GWRon
Copy link
Contributor

GWRon commented Apr 3, 2023

For now rtMidi's openPort looks like this:

	Method openPort(portNumber:Int = 0, portName:String = "RtMidi Input")
		bmx_rtmidiin_openPort(midiPtr, portNumber, portName)
	End Method

if the rtMidi-openPort fails, it rtMidi-library-internally throws an exception (which you can catch in Blitzmax (as @woollybah handles it) - if you knew it could throw something).

Maybe you should extend openPort to catch the exceptions already and simply return "true" or "false" depending on the result. You might have a simple "GetLastError()" if you want to know what failed.

Think it would be at least a bit more "beginner proof".

PS: coming from this thread there: https://www.syntaxbomb.com/blitzmax-blitzmax-ng/chord-displayer/msg347057737

@MidimasterSoft
Copy link

Hi Brucey,

I had problems in finding out, whether a MIDI-port is used by another app. In this case the RT-MIDI throws a exception, which your wrapper can handle already. This means following your examples, will result in a crash.

You should update your examples to:

.....
For Local i:Int = 0 Until midiIn.getPortCount()
	Print "  Input port #" + i + " : " + midiIn.getPortName(i)
Next

Print "Opening " + midiIn.getPortName()

Try
	midiIn.openPort(0)
Catch Exception:Object
	Print "MIDI IN PROBLEM!  port=" + midiIn.getPortName(0)+ "    exception message=" + Exception.ToString()
	End
End Try
midiIn.ignoreTypes(False, False, False)
....

by the way....

There is a RT-MIDI update to version 5.0.0
https://github.com/thestk/rtmidi/blob/master/doc/release.txt

I'm still happy with the old version, but you can better than me see, whether there is a need to update the wrapper too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants