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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
-- Programmed by Jedidiah Barber
-- Released into the public domain
with
Ada.Characters.Latin_1,
Ada.Text_IO,
Portaudio.Devices,
Portaudio.Streams;
use type
Portaudio.Device_Index,
Portaudio.Time;
procedure Device_List is
package Latin renames Ada.Characters.Latin_1;
package TIO renames Ada.Text_IO;
package Paud renames Portaudio;
function Image
(Num : in Integer)
return String
is
Test_Out : constant String := Integer'Image (Num);
begin
if Test_Out (Test_Out'First) = ' ' then
return Test_Out (Test_Out'First + 1 .. Test_Out'Last);
else
return Test_Out;
end if;
end Image;
function Image
(Num : in Paud.Time)
return String is
begin
if Num < 0.0 then
return "N/A";
else
return Paud.Image (Num * 1000.0) & "ms";
end if;
end Image;
function Image
(Num : in Paud.Hertz)
return String is
begin
return Paud.Hertz_Image (Num / 1000.0) & "kHz";
end Image;
procedure Put_Supported_Standard_Sample_Rates
(In_Params : access Paud.Streams.Parameters;
Out_Params : access Paud.Streams.Parameters)
is
Standard_Sample_Rates : constant array (Positive range <>) of Paud.Hertz :=
(8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0,
32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 192000.0);
Put_Counter : Natural := 0;
begin
for Rate of Standard_Sample_Rates loop
if Paud.Streams.Is_Format_Supported (In_Params, Out_Params, Rate) then
case Put_Counter is
when 0 =>
TIO.Put (Latin.HT & Image (Rate));
Put_Counter := 1;
when 4 =>
TIO.Put (Latin.LF & Latin.HT & Image (Rate));
Put_Counter := 1;
when others =>
TIO.Put (", " & Image (Rate));
Put_Counter := Put_Counter + 1;
end case;
end if;
end loop;
if Put_Counter = 0 then
TIO.Put_Line ("None");
else
TIO.New_Line;
end if;
end Put_Supported_Standard_Sample_Rates;
Num_Devices : Natural;
Current_Device : Paud.Devices.Device_Info;
Current_Host_API : Paud.Devices.Host_API_Info;
Displayed_Default : Boolean;
Input_Params : aliased Paud.Streams.Parameters;
Output_Params : aliased Paud.Streams.Parameters;
begin
TIO.Put_Line ("PortAudio version: " & Paud.Image (Paud.Get_Version));
TIO.Put_Line ("Version text: " & Paud.Get_Version_Info.Text);
Num_Devices := Paud.Devices.Get_Device_Count;
TIO.Put_Line ("Number of devices = " & Image (Num_Devices));
for Index in Paud.Device_Index (1) .. Paud.Device_Index (Num_Devices) loop
Current_Device := Paud.Devices.Get_Device_Info (Index);
Current_Host_API := Paud.Devices.Get_Host_API_Info (Current_Device.Host_API);
Displayed_Default := False;
TIO.New_Line;
TIO.Put_Line ("--------------------------------------- device #" &
Image (Integer (Index)));
if Index = Paud.Devices.Get_Default_Input_Device then
TIO.Put ("[ Default Input");
Displayed_Default := True;
elsif Index = Current_Host_API.Default_Input_Device then
TIO.Put ("[ Default " & Current_Host_API.Name & " Input");
Displayed_Default := True;
end if;
if Index = Paud.Devices.Get_Default_Output_Device then
if Displayed_Default then
TIO.Put (",");
else
TIO.Put ("[");
end if;
TIO.Put (" Default Output");
Displayed_Default := True;
elsif Index = Current_Host_API.Default_Output_Device then
if Displayed_Default then
TIO.Put (",");
else
TIO.Put ("[");
end if;
TIO.Put (" Default " & Current_Host_API.Name & " Output");
Displayed_Default := True;
end if;
if Displayed_Default then
TIO.Put_Line (" ]");
end if;
TIO.Put_Line ("Name = " & Current_Device.Name);
TIO.Put_Line ("Host API = " & Current_Host_API.Name);
TIO.Put_Line ("Max inputs = " & Image (Current_Device.Max_Input_Channels) &
", Max outputs = " & Image (Current_Device.Max_Output_Channels));
TIO.Put_Line ("Default low input latency = " & Image
(Current_Device.Default_Low_Input_Latency));
TIO.Put_Line ("Default low output latency = " & Image
(Current_Device.Default_Low_Output_Latency));
TIO.Put_Line ("Default high input latency = " & Image
(Current_Device.Default_High_Input_Latency));
TIO.Put_Line ("Default high output latency = " & Image
(Current_Device.Default_High_Output_Latency));
TIO.Put_Line ("Default sample rate = " & Image
(Current_Device.Default_Sample_Rate));
Input_Params := Paud.Streams.Create
(Index, Current_Device.Max_Input_Channels, Paud.Streams.Int_16_Format, 0.0);
Output_Params := Paud.Streams.Create
(Index, Current_Device.Max_Output_Channels, Paud.Streams.Int_16_Format, 0.0);
if Current_Device.Max_Input_Channels > 0 then
TIO.Put_Line ("Supported standard sample rates");
TIO.Put_Line (" for half-duplex 16 bit " &
Image (Current_Device.Max_Input_Channels) & " channel input =");
Put_Supported_Standard_Sample_Rates (Input_Params'Access, null);
end if;
if Current_Device.Max_Output_Channels > 0 then
TIO.Put_Line ("Supported standard sample rates");
TIO.Put_Line (" for half-duplex 16 bit " &
Image (Current_Device.Max_Output_Channels) & " channel output =");
Put_Supported_Standard_Sample_Rates (null, Output_Params'Access);
end if;
if Current_Device.Max_Input_Channels > 0 and Current_Device.Max_Output_Channels > 0 then
TIO.Put_Line ("Supported standard sample rates");
TIO.Put_Line (" for full-duplex 16 bit " &
Image (Current_Device.Max_Input_Channels) & " channel input, " &
Image (Current_Device.Max_Output_Channels) & " channel output =");
Put_Supported_Standard_Sample_Rates (Input_Params'Access, Output_Params'Access);
end if;
end loop;
TIO.New_Line;
TIO.Put_Line ("----------------------------------------------");
end Device_List;
|