Audio plugin host https://kx.studio/carla
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.

73 lines
1.9KB

  1. // midiprobe.cpp
  2. //
  3. // Simple program to check MIDI inputs and outputs.
  4. //
  5. // by Gary Scavone, 2003-2012.
  6. #include <iostream>
  7. #include <cstdlib>
  8. #include <map>
  9. #include "RtMidi.h"
  10. int main()
  11. {
  12. // Create an api map.
  13. std::map<int, std::string> apiMap;
  14. apiMap[RtMidi::MACOSX_CORE] = "OS-X CoreMidi";
  15. apiMap[RtMidi::WINDOWS_MM] = "Windows MultiMedia";
  16. apiMap[RtMidi::WINDOWS_KS] = "Windows Kernel Straming";
  17. apiMap[RtMidi::UNIX_JACK] = "Jack Client";
  18. apiMap[RtMidi::LINUX_ALSA] = "Linux ALSA";
  19. apiMap[RtMidi::RTMIDI_DUMMY] = "RtMidi Dummy";
  20. std::vector< RtMidi::Api > apis;
  21. RtMidi :: getCompiledApi( apis );
  22. std::cout << "\nCompiled APIs:\n";
  23. for ( unsigned int i=0; i<apis.size(); i++ )
  24. std::cout << " " << apiMap[ apis[i] ] << std::endl;
  25. RtMidiIn *midiin = 0;
  26. RtMidiOut *midiout = 0;
  27. try {
  28. // RtMidiIn constructor ... exception possible
  29. midiin = new RtMidiIn();
  30. std::cout << "\nCurrent input API: " << apiMap[ midiin->getCurrentApi() ] << std::endl;
  31. // Check inputs.
  32. unsigned int nPorts = midiin->getPortCount();
  33. std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
  34. for ( unsigned i=0; i<nPorts; i++ ) {
  35. std::string portName = midiin->getPortName(i);
  36. std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
  37. }
  38. // RtMidiOut constructor ... exception possible
  39. midiout = new RtMidiOut();
  40. std::cout << "\nCurrent output API: " << apiMap[ midiout->getCurrentApi() ] << std::endl;
  41. // Check outputs.
  42. nPorts = midiout->getPortCount();
  43. std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
  44. for ( unsigned i=0; i<nPorts; i++ ) {
  45. std::string portName = midiout->getPortName(i);
  46. std::cout << " Output Port #" << i+1 << ": " << portName << std::endl;
  47. }
  48. std::cout << std::endl;
  49. } catch ( RtError &error ) {
  50. error.printMessage();
  51. }
  52. delete midiin;
  53. delete midiout;
  54. return 0;
  55. }