blob: c26696443eef6a5b478e8578a0303ed34c487436 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-- Programmed by Jedidiah Barber
-- Released into the public domain
with
Ada.Text_IO,
Portaudio;
use type
Portaudio.Float_32;
procedure Saw_Back is
Left_Phase, Right_Phase : Portaudio.Float_32 := 0.0;
function Saw_Callback
(Input : in Portaudio.Sample_Buffer;
Output : in Portaudio.Sample_Buffer;
Frames : in Portaudio.Frame_Amount;
Timing : in Portaudio.Callback_Time_Info;
Flags : in Portaudio.Callback_Flags)
return Portaudio.Callback_Result is
begin
for Frame in 1 .. Frames loop
Output.Put (Frame, 1, Left_Phase);
Output.Put (Frame, 2, Right_Phase);
Left_Phase := Left_Phase + 0.01;
if Left_Phase >= 1.0 then
Left_Phase := -1.0;
end if;
Right_Phase := Right_Phase + 0.03;
if Right_Phase >= 1.0 then
Right_Phase := -1.0;
end if;
end loop;
return Portaudio.Continue;
end Saw_Callback;
Saw_Stream : Portaudio.Audio_Stream;
begin
Ada.Text_IO.Put_Line ("PortAudio Test: output sawtooth wave.");
Saw_Stream.Open_Default
(Input_Channels => 0,
Output_Channels => 2,
Format => Portaudio.Float_32_Sample,
Sample_Rate => 44100.0,
Buffer_Frames => 256,
Callback => Saw_Callback'Unrestricted_Access);
Saw_Stream.Start;
delay 4.0;
Saw_Stream.Stop;
Saw_Stream.Close;
Ada.Text_IO.Put_Line ("Test finished.");
end Saw_Back;
|