Version 2.0
[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 (RtAudioError &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=0; i<devices; i++) {
29     try {
30       audio->getDeviceInfo(i, &my_info);
31     }
32     catch (RtAudioError &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     else
41       cout << "probe unsuccessful\n";
42     cout << "maxOutputChans = " << my_info.maxOutputChannels << '\n';
43     cout << "minOutputChans = " << my_info.minOutputChannels << '\n';
44     cout << "maxInputChans = " << my_info.maxInputChannels << '\n';
45     cout << "minInputChans = " << my_info.minInputChannels << '\n';
46     cout << "maxDuplexChans = " << my_info.maxDuplexChannels << '\n';
47     cout << "minDuplexChans = " << my_info.minDuplexChannels << '\n';
48     if (my_info.hasDuplexSupport)
49       cout << "duplex support = true\n";
50     else
51       cout << "duplex support = false\n";
52     cout << "format = " << my_info.nativeFormats << '\n';
53     if (my_info.nSampleRates == -1)
54       cout << "min_srate = " << my_info.sampleRates[0] << ", max_srate = " << my_info.sampleRates[1] << '\n';
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   cout << endl;
63
64   delete audio;
65   return 0;
66 }