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.

audioprobe.cpp 3.0KB

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