Version 3.0.2
[rtaudio.git] / tests / info.cpp
1 /******************************************/
2 /*
3   info.cpp
4   by Gary P. Scavone, 2001
5
6   Prints audio system/device info.
7 */
8 /******************************************/
9
10 #include "RtAudio.h"
11 #include <iostream>
12
13 int main(int argc, char *argv[])
14 {
15   RtAudio *audio = 0;
16   RtAudioDeviceInfo info;
17   try {
18     audio = new RtAudio();
19   }
20   catch (RtError &error) {
21     error.printMessage();
22     exit(EXIT_FAILURE);
23   }
24
25   int devices = audio->getDeviceCount();
26   std::cout << "\nFound " << devices << " device(s) ...\n";
27
28   for (int i=1; i<=devices; i++) {
29     try {
30       info = audio->getDeviceInfo(i);
31     }
32     catch (RtError &error) {
33       error.printMessage();
34       break;
35     }
36
37     std::cout << "\nDevice Name = " << info.name << '\n';
38     if (info.probed == false)
39       std::cout << "Probe Status = UNsuccessful\n";
40     else {
41       std::cout << "Probe Status = Successful\n";
42       std::cout << "Output Channels = " << info.outputChannels << '\n';
43       std::cout << "Input Channels = " << info.inputChannels << '\n';
44       std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
45       if (info.isDefault) std::cout << "This is the default device.\n";
46       else std::cout << "This is NOT the default 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
76   delete audio;
77   return 0;
78 }