summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-07-17 21:03:46 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2023-07-17 21:03:46 +1200
commit8463ca926a038bab28772c56bf5b32b0a7403853 (patch)
tree7f1edea7571bb5e5b67b5f2b15e9a3140148a676 /src
parent17ed86acaee20590b3ef4d1eea10f2fd27bd3350 (diff)
Sine wave blocking example added, fixed Buffer wrapping bug
Diffstat (limited to 'src')
-rw-r--r--src/portaudio-streams.adb48
-rw-r--r--src/portaudio-streams.ads54
2 files changed, 54 insertions, 48 deletions
diff --git a/src/portaudio-streams.adb b/src/portaudio-streams.adb
index 0df71ee..cbcbe7d 100644
--- a/src/portaudio-streams.adb
+++ b/src/portaudio-streams.adb
@@ -485,81 +485,81 @@ package body Portaudio.Streams is
end Put;
function Wrap
- (Store : access Float_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Float_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_float_32,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Wrap
- (Store : access Int_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_int_32,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Wrap
- (Store : access Int_24_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_24_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_int_24,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Wrap
- (Store : access Int_16_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_16_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_int_16,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Wrap
- (Store : access Int_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_int_8,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Wrap
- (Store : access UInt_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in UInt_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
(My_Sam_Code => pa_uint_8,
My_Channels => Channels,
My_Frames => Frames,
- My_Array => Store.all'Address);
+ My_Array => Store'Address);
end Wrap;
function Create
diff --git a/src/portaudio-streams.ads b/src/portaudio-streams.ads
index bdd6247..8acf758 100644
--- a/src/portaudio-streams.ads
+++ b/src/portaudio-streams.ads
@@ -57,6 +57,12 @@ package Portaudio.Streams is
type Frame_Amount is new Interfaces.Unsigned_32;
+ -- Acts as a wrapper around the arrays given above.
+ -- This both avoids the use of void pointers, and also
+ -- allows for easier reference to arrays by frame/channel.
+ -- Since it is only a pointer wrapper, please ensure that
+ -- every Buffer lives at least as long as any array used
+ -- to make it.
type Buffer is tagged private;
function Kind
@@ -156,46 +162,46 @@ package Portaudio.Streams is
with Pre => Store.Kind = UInt_8_Format;
function Wrap
- (Store : access Float_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Float_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : access Int_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : access Int_24_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_24_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : access Int_16_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_16_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : access Int_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in Int_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : access UInt_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : in UInt_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
- with Pre => Store.all'Length = Frames * Frame_Amount (Channels);
+ with Pre => Store'Length = Frames * Frame_Amount (Channels);
type Parameters is private;