You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.4KB

  1. // midiprobe.cpp
  2. //
  3. // Simple program to check MIDI inputs and outputs.
  4. //
  5. // by Gary Scavone, 2003-2004.
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include "RtMidi.h"
  9. int main()
  10. {
  11. RtMidiIn *midiin = 0;
  12. RtMidiOut *midiout = 0;
  13. // RtMidiIn constructor
  14. try {
  15. midiin = new RtMidiIn();
  16. }
  17. catch ( RtMidiError &error ) {
  18. error.printMessage();
  19. exit( EXIT_FAILURE );
  20. }
  21. // Check inputs.
  22. unsigned int nPorts = midiin->getPortCount();
  23. std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
  24. std::string portName;
  25. unsigned int i;
  26. for ( i=0; i<nPorts; i++ ) {
  27. try {
  28. portName = midiin->getPortName(i);
  29. }
  30. catch ( RtMidiError &error ) {
  31. error.printMessage();
  32. goto cleanup;
  33. }
  34. std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
  35. }
  36. // RtMidiOut constructor
  37. try {
  38. midiout = new RtMidiOut();
  39. }
  40. catch ( RtMidiError &error ) {
  41. error.printMessage();
  42. exit( EXIT_FAILURE );
  43. }
  44. // Check outputs.
  45. nPorts = midiout->getPortCount();
  46. std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
  47. for ( i=0; i<nPorts; i++ ) {
  48. try {
  49. portName = midiout->getPortName(i);
  50. }
  51. catch ( RtMidiError &error ) {
  52. error.printMessage();
  53. goto cleanup;
  54. }
  55. std::cout << " Output Port #" << i+1 << ": " << portName << '\n';
  56. }
  57. std::cout << '\n';
  58. // Clean up
  59. cleanup:
  60. delete midiin;
  61. delete midiout;
  62. return 0;
  63. }