From 6a4fd86a07ebe97c8067e0e732efc2f708a2c6a8 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 26 Jul 2023 19:51:33 +1200 Subject: Changed data buffer types for easier interop with other libraries --- src/portaudio-streams.adb | 24 +++++++++++----------- src/portaudio-streams.ads | 51 +++++++++++++++++++---------------------------- 2 files changed, 33 insertions(+), 42 deletions(-) (limited to 'src') 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 -- cgit