A few more updates, including new ASIO files (GS).
[rtaudio-cdist.git] / tests / audioprobe.cpp
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
14 int main()
15 {
16   // Create an api map.
17   std::map<int, std::string> apiMap;
18   apiMap[RtAudio::MACOSX_CORE] = "OS-X Core Audio";
19   apiMap[RtAudio::WINDOWS_ASIO] = "Windows ASIO";
20   apiMap[RtAudio::WINDOWS_DS] = "Windows Direct Sound";
21   apiMap[RtAudio::UNIX_JACK] = "Jack Client";
22   apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA";
23   apiMap[RtAudio::LINUX_PULSE] = "Linux PulseAudio";
24   apiMap[RtAudio::LINUX_OSS] = "Linux OSS";
25   apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy";
26
27   std::vector< RtAudio::Api > apis;
28   RtAudio :: getCompiledApi( apis );
29
30   std::cout << "\nRtAudio Version " << RtAudio::getVersion() << std::endl;
31
32   std::cout << "\nCompiled APIs:\n";
33   for ( unsigned int i=0; i<apis.size(); i++ )
34     std::cout << "  " << apiMap[ apis[i] ] << std::endl;
35
36   RtAudio audio;
37   RtAudio::DeviceInfo info;
38
39   std::cout << "\nCurrent API: " << apiMap[ audio.getCurrentApi() ] << std::endl;
40
41   unsigned int devices = audio.getDeviceCount();
42   std::cout << "\nFound " << devices << " device(s) ...\n";
43
44   for (unsigned int i=0; i<devices; i++) {
45     info = audio.getDeviceInfo(i);
46
47     std::cout << "\nDevice Name = " << info.name << '\n';
48     if ( info.probed == false )
49       std::cout << "Probe Status = UNsuccessful\n";
50     else {
51       std::cout << "Probe Status = Successful\n";
52       std::cout << "Output Channels = " << info.outputChannels << '\n';
53       std::cout << "Input Channels = " << info.inputChannels << '\n';
54       std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
55       if ( info.isDefaultOutput ) std::cout << "This is the default output device.\n";
56       else std::cout << "This is NOT the default output device.\n";
57       if ( info.isDefaultInput ) std::cout << "This is the default input device.\n";
58       else std::cout << "This is NOT the default input device.\n";
59       if ( info.nativeFormats == 0 )
60         std::cout << "No natively supported data formats(?)!";
61       else {
62         std::cout << "Natively supported data formats:\n";
63         if ( info.nativeFormats & RTAUDIO_SINT8 )
64           std::cout << "  8-bit int\n";
65         if ( info.nativeFormats & RTAUDIO_SINT16 )
66           std::cout << "  16-bit int\n";
67         if ( info.nativeFormats & RTAUDIO_SINT24 )
68           std::cout << "  24-bit int\n";
69         if ( info.nativeFormats & RTAUDIO_SINT32 )
70           std::cout << "  32-bit int\n";
71         if ( info.nativeFormats & RTAUDIO_FLOAT32 )
72           std::cout << "  32-bit float\n";
73         if ( info.nativeFormats & RTAUDIO_FLOAT64 )
74           std::cout << "  64-bit float\n";
75       }
76       if ( info.sampleRates.size() < 1 )
77         std::cout << "No supported sample rates found!";
78       else {
79         std::cout << "Supported sample rates = ";
80         for (unsigned int j=0; j<info.sampleRates.size(); j++)
81           std::cout << info.sampleRates[j] << " ";
82       }
83       std::cout << std::endl;
84     }
85   }
86   std::cout << std::endl;
87
88   return 0;
89 }