diff options
| author | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-11 15:14:23 +0200 |
|---|---|---|
| committer | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-11 15:14:23 +0200 |
| commit | 074083dff9003e86c3f307da312a35694e2db7aa (patch) | |
| tree | dfe38b1bbaac221cdfeae7c0e1f65eb822fca9f5 /tests/midiprobe.cpp | |
| parent | 7f9b19c0c889bf4b317cc0686275633713c484d8 (diff) | |
| parent | 9bbab359f008990f89ec574558d528a2f3b55d04 (diff) | |
Merge 1.0.7 into releases
Diffstat (limited to 'tests/midiprobe.cpp')
| -rw-r--r-- | tests/midiprobe.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/midiprobe.cpp b/tests/midiprobe.cpp new file mode 100644 index 0000000..7b4dc8c --- /dev/null +++ b/tests/midiprobe.cpp @@ -0,0 +1,70 @@ +// midiprobe.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; +} |
