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.

88 lines
3.0KB

  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 Direct Sound";
  18. apiMap[RtAudio::UNIX_JACK] = "Jack Client";
  19. apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA";
  20. apiMap[RtAudio::LINUX_PULSE] = "Linux PulseAudio";
  21. apiMap[RtAudio::LINUX_OSS] = "Linux OSS";
  22. apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy";
  23. std::vector< RtAudio::Api > apis;
  24. RtAudio :: getCompiledApi( apis );
  25. std::cout << "\nCompiled APIs:\n";
  26. for ( unsigned int i=0; i<apis.size(); i++ )
  27. std::cout << " " << apiMap[ apis[i] ] << std::endl;
  28. RtAudio audio;
  29. RtAudio::DeviceInfo info;
  30. std::cout << "\nCurrent API: " << apiMap[ audio.getCurrentApi() ] << std::endl;
  31. unsigned int devices = audio.getDeviceCount();
  32. std::cout << "\nFound " << devices << " device(s) ...\n";
  33. for (unsigned int i=0; i<devices; i++) {
  34. info = audio.getDeviceInfo(i);
  35. std::cout << "\nDevice Name = " << info.name << '\n';
  36. if ( info.probed == false )
  37. std::cout << "Probe Status = UNsuccessful\n";
  38. else {
  39. std::cout << "Probe Status = Successful\n";
  40. std::cout << "Output Channels = " << info.outputChannels << '\n';
  41. std::cout << "Input Channels = " << info.inputChannels << '\n';
  42. std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
  43. if ( info.isDefaultOutput ) std::cout << "This is the default output device.\n";
  44. else std::cout << "This is NOT the default output device.\n";
  45. if ( info.isDefaultInput ) std::cout << "This is the default input device.\n";
  46. else std::cout << "This is NOT the default input device.\n";
  47. if ( info.nativeFormats == 0 )
  48. std::cout << "No natively supported data formats(?)!";
  49. else {
  50. std::cout << "Natively supported data formats:\n";
  51. if ( info.nativeFormats & RTAUDIO_SINT8 )
  52. std::cout << " 8-bit int\n";
  53. if ( info.nativeFormats & RTAUDIO_SINT16 )
  54. std::cout << " 16-bit int\n";
  55. if ( info.nativeFormats & RTAUDIO_SINT24 )
  56. std::cout << " 24-bit int\n";
  57. if ( info.nativeFormats & RTAUDIO_SINT32 )
  58. std::cout << " 32-bit int\n";
  59. if ( info.nativeFormats & RTAUDIO_FLOAT32 )
  60. std::cout << " 32-bit float\n";
  61. if ( info.nativeFormats & RTAUDIO_FLOAT64 )
  62. std::cout << " 64-bit float\n";
  63. }
  64. if ( info.sampleRates.size() < 1 )
  65. std::cout << "No supported sample rates found!";
  66. else {
  67. std::cout << "Supported sample rates = ";
  68. for (unsigned int j=0; j<info.sampleRates.size(); j++)
  69. std::cout << info.sampleRates[j] << " ";
  70. }
  71. std::cout << std::endl;
  72. }
  73. }
  74. std::cout << std::endl;
  75. return 0;
  76. }