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