summaryrefslogtreecommitdiff
path: root/tests/info.cpp
blob: a4cfcf24d5e6be952b04426111b32d8cd20953a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/******************************************/
/*
  info.cpp
  by Gary P. Scavone, 2001

  Prints audio system/device info.
*/
/******************************************/

#include "RtAudio.h"
#include <iostream.h>

int main(int argc, char *argv[])
{
  RtAudio *audio;
  RtAudio::RTAUDIO_DEVICE my_info;
  try {
    audio = new RtAudio();
  }
  catch (RtAudioError &m) {
    m.printMessage();
    exit(EXIT_FAILURE);
  }

  int devices = audio->getDeviceCount();
  cout << "\nFound " << devices << " devices ...\n";

  for (int i=0; i<devices; i++) {
    try {
      audio->getDeviceInfo(i, &my_info);
    }
    catch (RtAudioError &m) {
      m.printMessage();
      break;
    }

    cout << "\nname = " << my_info.name << '\n';
    if (my_info.probed == true)
      cout << "probe successful\n";
    else
      cout << "probe unsuccessful\n";
    cout << "maxOutputChans = " << my_info.maxOutputChannels << '\n';
    cout << "minOutputChans = " << my_info.minOutputChannels << '\n';
    cout << "maxInputChans = " << my_info.maxInputChannels << '\n';
    cout << "minInputChans = " << my_info.minInputChannels << '\n';
    cout << "maxDuplexChans = " << my_info.maxDuplexChannels << '\n';
    cout << "minDuplexChans = " << my_info.minDuplexChannels << '\n';
    if (my_info.hasDuplexSupport)
      cout << "duplex support = true\n";
    else
      cout << "duplex support = false\n";
    cout << "format = " << my_info.nativeFormats << '\n';
    if (my_info.nSampleRates == -1)
      cout << "min_srate = " << my_info.sampleRates[0] << ", max_srate = " << my_info.sampleRates[1] << '\n';
    else {
      cout << "sample rates = ";
      for (int j=0; j<my_info.nSampleRates; j++)
        cout << my_info.sampleRates[j] << " ";
      cout << endl;
    }
  }
  cout << endl;

  delete audio;
  return 0;
}