Version 2.1
[rtaudio-cdist.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.h>
12
13 int main(int argc, char *argv[])
14 {
15   RtAudio *audio;
16   RtAudio::RTAUDIO_DEVICE my_info;
17   try {
18     audio = new RtAudio();
19   }
20   catch (RtError &m) {
21     m.printMessage();
22     exit(EXIT_FAILURE);
23   }
24
25   int devices = audio->getDeviceCount();
26   cout << "\nFound " << devices << " devices ...\n";
27
28   for (int i=1; i<=devices; i++) {
29     try {
30       audio->getDeviceInfo(i, &my_info);
31     }
32     catch (RtError &m) {
33       m.printMessage();
34       break;
35     }
36
37     cout << "\nname = " << my_info.name << '\n';
38     if (my_info.probed == true) {
39       cout << "probe successful\n";
40       cout << "maxOutputChans = " << my_info.maxOutputChannels << '\n';
41       cout << "minOutputChans = " << my_info.minOutputChannels << '\n';
42       cout << "maxInputChans = " << my_info.maxInputChannels << '\n';
43       cout << "minInputChans = " << my_info.minInputChannels << '\n';
44       cout << "maxDuplexChans = " << my_info.maxDuplexChannels << '\n';
45       cout << "minDuplexChans = " << my_info.minDuplexChannels << '\n';
46       if (my_info.hasDuplexSupport) cout << "duplex support = true\n";
47       else cout << "duplex support = false\n";
48       if (my_info.isDefault) cout << "is default device = true\n";
49       else cout << "is default device = false\n";
50       cout << "format = " << my_info.nativeFormats << '\n';
51       if (my_info.nSampleRates == -1) {
52         cout << "min_srate = " << my_info.sampleRates[0];
53         cout << ", max_srate = " << my_info.sampleRates[1] << '\n';
54       }
55       else {
56         cout << "sample rates = ";
57         for (int j=0; j<my_info.nSampleRates; j++)
58           cout << my_info.sampleRates[j] << " ";
59         cout << endl;
60       }
61     }
62     else
63       cout << "probe unsuccessful\n";
64   }
65   cout << endl;
66
67   delete audio;
68   return 0;
69 }