summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-07-26 19:51:33 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2023-07-26 19:51:33 +1200
commit6a4fd86a07ebe97c8067e0e732efc2f708a2c6a8 (patch)
tree67e44274d89448305c3b54c204789a3e0aae0382
parenta9eb2fc7099b78287faf5765e6b9721ce4e93fc1 (diff)
Changed data buffer types for easier interop with other libraries
-rw-r--r--example/saw_back.adb5
-rw-r--r--example/sine_block.adb5
-rw-r--r--readme.txt2
-rw-r--r--src/portaudio-streams.adb24
-rw-r--r--src/portaudio-streams.ads51
5 files changed, 40 insertions, 47 deletions
diff --git a/example/saw_back.adb b/example/saw_back.adb
index 680a7a2..89f075d 100644
--- a/example/saw_back.adb
+++ b/example/saw_back.adb
@@ -7,17 +7,18 @@
with
Ada.Text_IO,
+ Interfaces,
Portaudio.Streams;
use type
- Portaudio.Streams.Float_32;
+ Interfaces.IEEE_Float_32;
procedure Saw_Back is
- Left_Phase, Right_Phase : Portaudio.Streams.Float_32 := 0.0;
+ Left_Phase, Right_Phase : Interfaces.IEEE_Float_32 := 0.0;
function Saw_Callback
diff --git a/example/sine_block.adb b/example/sine_block.adb
index 52c46fe..5ff5be5 100644
--- a/example/sine_block.adb
+++ b/example/sine_block.adb
@@ -8,6 +8,7 @@ with
Ada.Numerics.Long_Elementary_Functions,
Ada.Text_IO,
+ Interfaces,
Portaudio.Streams;
@@ -30,7 +31,7 @@ procedure Sine_Block is
Sample_Buffer : Pstm.Buffer := Pstm.Wrap (Sample_Array, Per_Buffer, Channels);
type Table_Index is mod 200;
- Sine_Table : array (Table_Index) of Pstm.Float_32;
+ Sine_Table : array (Table_Index) of Interfaces.IEEE_Float_32;
Left_Phase, Right_Phase : Table_Index := 0;
Left_Increment : Table_Index := 1;
@@ -49,7 +50,7 @@ begin
"Buffer Size =" & Pstm.Frame_Amount'Image (Per_Buffer));
for Index in Table_Index loop
- Sine_Table (Index) := Pstm.Float_32
+ Sine_Table (Index) := Interfaces.IEEE_Float_32
(Elem.Sin (Long_Float (Index) / Long_Float (Table_Index'Last_Valid) * Num.Pi * 2.0));
end loop;
diff --git a/readme.txt b/readme.txt
index 1eccee9..7e2d5f3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -13,7 +13,7 @@ C-specific types wherever possible. In particular:
* Pa_Initialize and Pa_Terminate are now automatic
* All error codes have been converted to exceptions
* Void pointers are completely absent
- * Standard error is suppressed in C, so no unexpected text output
+ * Standard error is suppressed in C during init, so no unexpected text output
The package hierarchy is as follows:
diff --git a/src/portaudio-streams.adb b/src/portaudio-streams.adb
index cbcbe7d..6b05008 100644
--- a/src/portaudio-streams.adb
+++ b/src/portaudio-streams.adb
@@ -332,7 +332,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Float_32
+ return Interfaces.IEEE_Float_32
is
Actual : Float_32_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -345,7 +345,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_32
+ return Interfaces.Integer_32
is
Actual : Int_32_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -358,7 +358,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_24
+ return Integer_24
is
Actual : Int_24_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -371,7 +371,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_16
+ return Interfaces.Integer_16
is
Actual : Int_16_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -384,7 +384,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_8
+ return Interfaces.Integer_8
is
Actual : Int_8_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -397,7 +397,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return UInt_8
+ return Interfaces.Unsigned_8
is
Actual : UInt_8_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -410,7 +410,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Float_32)
+ Value : in Interfaces.IEEE_Float_32)
is
Actual : Float_32_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -423,7 +423,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_32)
+ Value : in Interfaces.Integer_32)
is
Actual : Int_32_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -436,7 +436,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_24)
+ Value : in Integer_24)
is
Actual : Int_24_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -449,7 +449,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_16)
+ Value : in Interfaces.Integer_16)
is
Actual : Int_16_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -462,7 +462,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_8)
+ Value : in Interfaces.Integer_8)
is
Actual : Int_8_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
@@ -475,7 +475,7 @@ package body Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in UInt_8)
+ Value : in Interfaces.Unsigned_8)
is
Actual : UInt_8_Array (1 .. Store.My_Channels * Integer (Store.My_Frames));
for Actual'Address use Store.My_Array;
diff --git a/src/portaudio-streams.ads b/src/portaudio-streams.ads
index 8acf758..6eb22bd 100644
--- a/src/portaudio-streams.ads
+++ b/src/portaudio-streams.ads
@@ -33,25 +33,16 @@ package Portaudio.Streams is
UInt_8_Format);
- type Float_32 is new Float;
- for Float_32'Size use 32;
- type Float_32_Array is array (Positive range <>) of Float_32;
+ -- This type isn't usually available in Interfaces
+ type Integer_24 is range -2 ** 23 .. 2 ** 23 - 1;
+ for Integer_24'Size use 24;
- type Int_32 is new Interfaces.Integer_32;
- type Int_32_Array is array (Positive range <>) of Int_32;
-
- type Int_24 is range -2 ** 23 .. 2 ** 23 - 1;
- for Int_24'Size use 24;
- type Int_24_Array is array (Positive range <>) of Int_24;
-
- type Int_16 is new Interfaces.Integer_16;
- type Int_16_Array is array (Positive range <>) of Int_16;
-
- type Int_8 is new Interfaces.Integer_8;
- type Int_8_Array is array (Positive range <>) of Int_8;
-
- type UInt_8 is new Interfaces.Unsigned_8;
- type UInt_8_Array is array (Positive range <>) of UInt_8;
+ type Float_32_Array is array (Positive range <>) of Interfaces.IEEE_Float_32;
+ type Int_32_Array is array (Positive range <>) of Interfaces.Integer_32;
+ type Int_24_Array is array (Positive range <>) of Integer_24;
+ type Int_16_Array is array (Positive range <>) of Interfaces.Integer_16;
+ type Int_8_Array is array (Positive range <>) of Interfaces.Integer_8;
+ type UInt_8_Array is array (Positive range <>) of Interfaces.Unsigned_8;
type Frame_Amount is new Interfaces.Unsigned_32;
@@ -81,84 +72,84 @@ package Portaudio.Streams is
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Float_32
+ return Interfaces.IEEE_Float_32
with Pre => Store.Kind = Float_32_Format;
function Get
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_32
+ return Interfaces.Integer_32
with Pre => Store.Kind = Int_32_Format;
function Get
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_24
+ return Integer_24
with Pre => Store.Kind = Int_24_Format;
function Get
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_16
+ return Interfaces.Integer_16
with Pre => Store.Kind = Int_16_Format;
function Get
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return Int_8
+ return Interfaces.Integer_8
with Pre => Store.Kind = Int_8_Format;
function Get
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive)
- return UInt_8
+ return Interfaces.Unsigned_8
with Pre => Store.Kind = UInt_8_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Float_32)
+ Value : in Interfaces.IEEE_Float_32)
with Pre => Store.Kind = Float_32_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_32)
+ Value : in Interfaces.Integer_32)
with Pre => Store.Kind = Int_32_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_24)
+ Value : in Integer_24)
with Pre => Store.Kind = Int_24_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_16)
+ Value : in Interfaces.Integer_16)
with Pre => Store.Kind = Int_16_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in Int_8)
+ Value : in Interfaces.Integer_8)
with Pre => Store.Kind = Int_8_Format;
procedure Put
(Store : in Buffer;
Frame : in Frame_Amount;
Channel : in Positive;
- Value : in UInt_8)
+ Value : in Interfaces.Unsigned_8)
with Pre => Store.Kind = UInt_8_Format;
function Wrap