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.

92 lines
3.2KB

  1. /******************************************/
  2. /*
  3. audioprobe.cpp
  4. by Gary P. Scavone, 2001
  5. Probe audio system and prints device info.
  6. */
  7. /******************************************/
  8. #include "RtAudio.h"
  9. #include <iostream>
  10. #include <map>
  11. int main()
  12. {
  13. // Create an api map.
  14. std::map<int, std::string> apiMap;
  15. apiMap[RtAudio::MACOSX_CORE] = "OS-X Core Audio";
  16. apiMap[RtAudio::WINDOWS_ASIO] = "Windows ASIO";
  17. apiMap[RtAudio::WINDOWS_DS] = "Windows DirectSound";
  18. apiMap[RtAudio::WINDOWS_WASAPI] = "Windows WASAPI";
  19. apiMap[RtAudio::UNIX_JACK] = "Jack Client";
  20. apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA";
  21. apiMap[RtAudio::LINUX_PULSE] = "Linux PulseAudio";
  22. apiMap[RtAudio::LINUX_OSS] = "Linux OSS";
  23. apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy";
  24. std::vector< RtAudio::Api > apis;
  25. RtAudio :: getCompiledApi( apis );
  26. std::cout << "\nRtAudio Version " << RtAudio::getVersion() << std::endl;
  27. std::cout << "\nCompiled APIs:\n";
  28. for ( unsigned int i=0; i<apis.size(); i++ )
  29. std::cout << " " << apiMap[ apis[i] ] << std::endl;
  30. RtAudio audio;
  31. RtAudio::DeviceInfo info;
  32. std::cout << "\nCurrent API: " << apiMap[ audio.getCurrentApi() ] << std::endl;
  33. unsigned int devices = audio.getDeviceCount();
  34. std::cout << "\nFound " << devices << " device(s) ...\n";
  35. for (unsigned int i=0; i<devices; i++) {
  36. info = audio.getDeviceInfo(i);
  37. std::cout << "\nDevice Name = " << info.name << '\n';
  38. std::cout << "Device ID = " << i << '\n';
  39. if ( info.probed == false )
  40. std::cout << "Probe Status = UNsuccessful\n";
  41. else {
  42. std::cout << "Probe Status = Successful\n";
  43. std::cout << "Output Channels = " << info.outputChannels << '\n';
  44. std::cout << "Input Channels = " << info.inputChannels << '\n';
  45. std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
  46. if ( info.isDefaultOutput ) std::cout << "This is the default output device.\n";
  47. else std::cout << "This is NOT the default output device.\n";
  48. if ( info.isDefaultInput ) std::cout << "This is the default input device.\n";
  49. else std::cout << "This is NOT the default input device.\n";
  50. if ( info.nativeFormats == 0 )
  51. std::cout << "No natively supported data formats(?)!";
  52. else {
  53. std::cout << "Natively supported data formats:\n";
  54. if ( info.nativeFormats & RTAUDIO_SINT8 )
  55. std::cout << " 8-bit int\n";
  56. if ( info.nativeFormats & RTAUDIO_SINT16 )
  57. std::cout << " 16-bit int\n";
  58. if ( info.nativeFormats & RTAUDIO_SINT24 )
  59. std::cout << " 24-bit int\n";
  60. if ( info.nativeFormats & RTAUDIO_SINT32 )
  61. std::cout << " 32-bit int\n";
  62. if ( info.nativeFormats & RTAUDIO_FLOAT32 )
  63. std::cout << " 32-bit float\n";
  64. if ( info.nativeFormats & RTAUDIO_FLOAT64 )
  65. std::cout << " 64-bit float\n";
  66. }
  67. if ( info.sampleRates.size() < 1 )
  68. std::cout << "No supported sample rates found!";
  69. else {
  70. std::cout << "Supported sample rates = ";
  71. for (unsigned int j=0; j<info.sampleRates.size(); j++)
  72. std::cout << info.sampleRates[j] << " ";
  73. }
  74. std::cout << std::endl;
  75. }
  76. }
  77. std::cout << std::endl;
  78. return 0;
  79. }