summaryrefslogtreecommitdiff
path: root/tests/midiinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/midiinfo.cpp')
-rw-r--r--tests/midiinfo.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/midiinfo.cpp b/tests/midiinfo.cpp
new file mode 100644
index 0000000..58a6275
--- /dev/null
+++ b/tests/midiinfo.cpp
@@ -0,0 +1,70 @@
+// midiinfo.cpp
+//
+// Simple program to check MIDI inputs and outputs.
+//
+// by Gary Scavone, 2003-2004.
+
+#include <iostream>
+#include "RtMidi.h"
+
+int main()
+{
+ RtMidiIn *midiin = 0;
+ RtMidiOut *midiout = 0;
+
+ // RtMidiIn constructor
+ try {
+ midiin = new RtMidiIn();
+ }
+ catch (RtError &error) {
+ error.printMessage();
+ exit(EXIT_FAILURE);
+ }
+
+ // Check inputs.
+ unsigned int nPorts = midiin->getPortCount();
+ std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
+ std::string portName;
+ unsigned int i;
+ for ( i=0; i<nPorts; i++ ) {
+ try {
+ portName = midiin->getPortName(i);
+ }
+ catch (RtError &error) {
+ error.printMessage();
+ goto cleanup;
+ }
+ std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
+ }
+
+ // RtMidiOut constructor
+ try {
+ midiout = new RtMidiOut();
+ }
+ catch (RtError &error) {
+ error.printMessage();
+ exit(EXIT_FAILURE);
+ }
+
+ // Check outputs.
+ nPorts = midiout->getPortCount();
+ std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
+ for ( i=0; i<nPorts; i++ ) {
+ try {
+ portName = midiout->getPortName(i);
+ }
+ catch (RtError &error) {
+ error.printMessage();
+ goto cleanup;
+ }
+ std::cout << " Output Port #" << i+1 << ": " << portName << '\n';
+ }
+ std::cout << '\n';
+
+ // Clean up
+ cleanup:
+ delete midiin;
+ delete midiout;
+
+ return 0;
+}