text
stringlengths 0
234
|
|---|
(System.Address,
|
paTestData_Ptr);
|
--------------------
|
-- paTestCallback --
|
--------------------
|
function paTestCallback
|
(inputBuffer : System.Address;
|
outputBuffer : System.Address;
|
framesPerBuffer : Interfaces.C.unsigned_long;
|
timeInfo : access PA_Stream_Callback_Time_Info;
|
statusFlags : PA_Stream_Callback_Flags;
|
userData : System.Address)
|
return PA_Stream_Callback_Result
|
is
|
pragma Unreferenced (inputBuffer);
|
pragma Unreferenced (timeInfo);
|
pragma Unreferenced (statusFlags);
|
oBuff : Float_Star := Convert (outputBuffer);
|
lData : constant paTestData_Ptr := Convert (userData);
|
begin
|
for i in 1 .. Integer (framesPerBuffer) loop
|
declare
|
output : Float := 0.0;
|
phaseInc : Long_Float := 0.02;
|
phase : Long_Float;
|
begin
|
for j in 1 .. lData.all.numSines loop
|
-- Advance phase of next oscillator.
|
phase := lData.all.phases (j);
|
phase := phase + phaseInc;
|
if phase > Two_Pi then
|
phase := phase - Two_Pi;
|
end if;
|
phaseInc := phaseInc * 1.02;
|
if phaseInc > 0.5 then
|
phaseInc := phaseInc * 0.5;
|
end if;
|
-- This is not a very efficient way to calc sines.
|
output := output + Sin (Float (phase));
|
lData.all.phases (j) := phase;
|
end loop;
|
oBuff.all := output / Float (lData.all.numSines);
|
Float_Ptrs.Increment (oBuff);
|
Function Definition: procedure exercise8 is
|
Function Body: Count_Failed : exception; -- Exception to be raised when counting fails
|
Gen : Generator; -- Random number generator
|
protected type Transaction_Manager (N : Positive) is
|
entry Finished;
|
entry Wait_Until_Aborted;
|
procedure Signal_Abort;
|
private
|
Finished_Gate_Open : Boolean := False;
|
Aborted : Boolean := False;
|
end Transaction_Manager;
|
protected body Transaction_Manager is
|
-- PART 1 --
|
entry Finished when Finished_Gate_Open or Finished'Count = N is
|
begin
|
if Finished'Count = N - 1 then
|
Finished_Gate_Open := True;
|
end if;
|
if Finished'Count = 0 then
|
Finished_Gate_Open := False;
|
end if;
|
end Finished;
|
-- PART 2 --
|
entry Wait_Until_Aborted when Aborted is
|
begin
|
if Wait_Until_Aborted'Count = 0 then
|
Aborted := False;
|
end if;
|
end Wait_Until_Aborted;
|
procedure Signal_Abort is
|
begin
|
Aborted := True;
|
end Signal_Abort;
|
end Transaction_Manager;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.