Mercurial > hg > sv-dependency-builds
comparison src/portaudio_20161030_catalina_patch/bindings/cpp/example/devs.cxx @ 162:d43aab368df9
Duplicate for patch testing
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 30 Oct 2019 11:25:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
161:4797bbf470e7 | 162:d43aab368df9 |
---|---|
1 #include <iostream> | |
2 #include "portaudiocpp/PortAudioCpp.hxx" | |
3 | |
4 #ifdef WIN32 | |
5 #include "portaudiocpp/AsioDeviceAdapter.hxx" | |
6 #endif | |
7 | |
8 // --------------------------------------------------------------------------------------- | |
9 | |
10 void printSupportedStandardSampleRates( | |
11 const portaudio::DirectionSpecificStreamParameters &inputParameters, | |
12 const portaudio::DirectionSpecificStreamParameters &outputParameters) | |
13 { | |
14 static double STANDARD_SAMPLE_RATES[] = { | |
15 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, | |
16 44100.0, 48000.0, 88200.0, 96000.0, -1 }; // negative terminated list | |
17 | |
18 int printCount = 0; | |
19 | |
20 for (int i = 0; STANDARD_SAMPLE_RATES[i] > 0; ++i) | |
21 { | |
22 portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, STANDARD_SAMPLE_RATES[i], 0, paNoFlag); | |
23 | |
24 if (tmp.isSupported()) | |
25 { | |
26 if (printCount == 0) | |
27 { | |
28 std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 | |
29 printCount = 1; | |
30 } | |
31 else if (printCount == 4) | |
32 { | |
33 std::cout << "," << std::endl; | |
34 std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 | |
35 printCount = 1; | |
36 } | |
37 else | |
38 { | |
39 std::cout << ", " << STANDARD_SAMPLE_RATES[i]; // 8.2 | |
40 ++printCount; | |
41 } | |
42 } | |
43 } | |
44 | |
45 if (printCount == 0) | |
46 std::cout << "None" << std::endl; | |
47 else | |
48 std::cout << std::endl; | |
49 } | |
50 | |
51 // --------------------------------------------------------------------------------------- | |
52 | |
53 int main(int, char*[]); | |
54 int main(int, char*[]) | |
55 { | |
56 try | |
57 { | |
58 portaudio::AutoSystem autoSys; | |
59 | |
60 portaudio::System &sys = portaudio::System::instance(); | |
61 | |
62 std::cout << "PortAudio version number = " << sys.version() << std::endl; | |
63 std::cout << "PortAudio version text = '" << sys.versionText() << "'" << std::endl; | |
64 | |
65 int numDevices = sys.deviceCount(); | |
66 std::cout << "Number of devices = " << numDevices << std::endl; | |
67 | |
68 for (portaudio::System::DeviceIterator i = sys.devicesBegin(); i != sys.devicesEnd(); ++i) | |
69 { | |
70 std::cout << "--------------------------------------- device #" << (*i).index() << std::endl; | |
71 | |
72 // Mark global and API specific default devices: | |
73 bool defaultDisplayed = false; | |
74 | |
75 if ((*i).isSystemDefaultInputDevice()) | |
76 { | |
77 std::cout << "[ Default Input"; | |
78 defaultDisplayed = true; | |
79 } | |
80 else if ((*i).isHostApiDefaultInputDevice()) | |
81 { | |
82 std::cout << "[ Default " << (*i).hostApi().name() << " Input"; | |
83 defaultDisplayed = true; | |
84 } | |
85 | |
86 if ((*i).isSystemDefaultOutputDevice()) | |
87 { | |
88 std::cout << (defaultDisplayed ? "," : "["); | |
89 std::cout << " Default Output"; | |
90 defaultDisplayed = true; | |
91 } | |
92 else if ((*i).isHostApiDefaultOutputDevice()) | |
93 { | |
94 std::cout << (defaultDisplayed ? "," : "["); | |
95 std::cout << " Default " << (*i).hostApi().name() << " Output"; | |
96 defaultDisplayed = true; | |
97 } | |
98 | |
99 if (defaultDisplayed) | |
100 std::cout << " ]" << std::endl; | |
101 | |
102 // Print device info: | |
103 std::cout << "Name = " << (*i).name() << std::endl; | |
104 std::cout << "Host API = " << (*i).hostApi().name() << std::endl; | |
105 std::cout << "Max inputs = " << (*i).maxInputChannels() << ", Max outputs = " << (*i).maxOutputChannels() << std::endl; | |
106 | |
107 std::cout << "Default low input latency = " << (*i).defaultLowInputLatency() << std::endl; // 8.3 | |
108 std::cout << "Default low output latency = " << (*i).defaultLowOutputLatency() << std::endl; // 8.3 | |
109 std::cout << "Default high input latency = " << (*i).defaultHighInputLatency() << std::endl; // 8.3 | |
110 std::cout << "Default high output latency = " << (*i).defaultHighOutputLatency() << std::endl; // 8.3 | |
111 | |
112 #ifdef WIN32 | |
113 // ASIO specific latency information: | |
114 if ((*i).hostApi().typeId() == paASIO) | |
115 { | |
116 portaudio::AsioDeviceAdapter asioDevice((*i)); | |
117 | |
118 std::cout << "ASIO minimum buffer size = " << asioDevice.minBufferSize() << std::endl; | |
119 std::cout << "ASIO maximum buffer size = " << asioDevice.maxBufferSize() << std::endl; | |
120 std::cout << "ASIO preferred buffer size = " << asioDevice.preferredBufferSize() << std::endl; | |
121 | |
122 if (asioDevice.granularity() == -1) | |
123 std::cout << "ASIO buffer granularity = power of 2" << std::endl; | |
124 else | |
125 std::cout << "ASIO buffer granularity = " << asioDevice.granularity() << std::endl; | |
126 } | |
127 #endif // WIN32 | |
128 | |
129 std::cout << "Default sample rate = " << (*i).defaultSampleRate() << std::endl; // 8.2 | |
130 | |
131 // Poll for standard sample rates: | |
132 portaudio::DirectionSpecificStreamParameters inputParameters((*i), (*i).maxInputChannels(), portaudio::INT16, true, 0.0, NULL); | |
133 portaudio::DirectionSpecificStreamParameters outputParameters((*i), (*i).maxOutputChannels(), portaudio::INT16, true, 0.0, NULL); | |
134 | |
135 if (inputParameters.numChannels() > 0) | |
136 { | |
137 std::cout << "Supported standard sample rates" << std::endl; | |
138 std::cout << " for half-duplex 16 bit " << inputParameters.numChannels() << " channel input = " << std::endl; | |
139 printSupportedStandardSampleRates(inputParameters, portaudio::DirectionSpecificStreamParameters::null()); | |
140 } | |
141 | |
142 if (outputParameters.numChannels() > 0) | |
143 { | |
144 std::cout << "Supported standard sample rates" << std::endl; | |
145 std::cout << " for half-duplex 16 bit " << outputParameters.numChannels() << " channel output = " << std::endl; | |
146 printSupportedStandardSampleRates(portaudio::DirectionSpecificStreamParameters::null(), outputParameters); | |
147 } | |
148 | |
149 if (inputParameters.numChannels() > 0 && outputParameters.numChannels() > 0) | |
150 { | |
151 std::cout << "Supported standard sample rates" << std::endl; | |
152 std::cout << " for full-duplex 16 bit " << inputParameters.numChannels() << " channel input, " << outputParameters.numChannels() << " channel output = " << std::endl; | |
153 printSupportedStandardSampleRates(inputParameters, outputParameters); | |
154 } | |
155 } | |
156 | |
157 std::cout << "----------------------------------------------" << std::endl; | |
158 } | |
159 catch (const portaudio::PaException &e) | |
160 { | |
161 std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl; | |
162 } | |
163 catch (const portaudio::PaCppException &e) | |
164 { | |
165 std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl; | |
166 } | |
167 catch (const std::exception &e) | |
168 { | |
169 std::cout << "A generic exception occured: " << e.what() << std::endl; | |
170 } | |
171 catch (...) | |
172 { | |
173 std::cout << "An unknown exception occured." << std::endl; | |
174 } | |
175 | |
176 return 0; | |
177 } |