-- Programmed by Jedidiah Barber -- Released into the public domain with Ada.Text_IO, Portaudio.Streams; use type Portaudio.Streams.Float_32; procedure Saw_Back is Left_Phase, Right_Phase : Portaudio.Streams.Float_32 := 0.0; function Saw_Callback (Input : in Portaudio.Streams.Buffer; Output : in Portaudio.Streams.Buffer; Frames : in Portaudio.Streams.Frame_Amount; Timing : in Portaudio.Streams.Time_Info; Flags : in Portaudio.Streams.Callback_Flags) return Portaudio.Streams.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.Streams.Continue; end Saw_Callback; Saw_Stream : Portaudio.Streams.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.Streams.Float_32_Format, 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;