summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2024-09-16 12:25:41 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2024-09-16 12:25:41 +1200
commit87e42e46a5d898698ad5cbcd71b3877d2c319084 (patch)
tree5416594999b269e4890e0cb8a0d1c66a4f48a383 /example
parenta9a297e8f7282bcc9b3ffb14862160bb1abad511 (diff)
Off-by-one bugs fixed, more testing programs, change to Integer_AddressHEADmaster
Diffstat (limited to 'example')
-rw-r--r--example/format_options.adb77
-rw-r--r--example/info_list.adb74
2 files changed, 151 insertions, 0 deletions
diff --git a/example/format_options.adb b/example/format_options.adb
new file mode 100644
index 0000000..352d3d5
--- /dev/null
+++ b/example/format_options.adb
@@ -0,0 +1,77 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+-- This program tests out the Option_List and Sample_Format datatypes
+
+
+with
+
+ Ada.Characters.Latin_1,
+ Ada.Text_IO,
+ Libao;
+
+
+procedure Format_Options is
+
+ package Latin renames Ada.Characters.Latin_1;
+ package TIO renames Ada.Text_IO;
+
+ My_Options : Libao.Option_List;
+
+ My_Format : Libao.Sample_Format := Libao.Create
+ (Bits => 16,
+ Rate => 44100,
+ Channels => 4,
+ Byte_Format => Libao.Big_Endian,
+ Channel_Matrix => Libao.Quadraphonic);
+
+begin
+
+
+ TIO.Put_Line ("libao datatype testing");
+ TIO.New_Line;
+
+
+ declare
+ Temp : Libao.Option_List := Libao.Empty_Options;
+ begin
+ Temp.Append ("one", "two");
+ Temp.Append ("three", "four");
+ Temp.Append ("five", "six");
+
+ TIO.Put_Line ("Temporary options created with");
+ for Index in Integer range 1 .. Temp.Length loop
+ TIO.Put_Line (Latin.HT & Temp.Key (Index) & " -> " & Temp.Value (Index));
+ end loop;
+ TIO.New_Line;
+
+ My_Options := Temp;
+ Temp.Append ("should not", "be seen");
+ end;
+
+
+ My_Options.Append ("added", "thing");
+ TIO.Put_Line ("The main testing options now are");
+ for Index in Integer range 1 .. My_Options.Length loop
+ TIO.Put_Line (Latin.HT & My_Options.Key (Index) & " -> " & My_Options.Value (Index));
+ end loop;
+ TIO.New_Line;
+
+
+ TIO.Put_Line ("The created sample format is");
+ TIO.Put_Line (Latin.HT & "Bits =" & Integer'Image (My_Format.Bits));
+ TIO.Put_Line (Latin.HT & "Rate =" & Integer'Image (My_Format.Rate));
+ TIO.Put_Line (Latin.HT & "Channels =" & Integer'Image (My_Format.Channels));
+ TIO.Put_Line (Latin.HT & "Byte Format = " & Libao.Endianness'Image (My_Format.Byte_Format));
+ TIO.Put (Latin.HT & "Channel Matrix = ");
+ for Mnemonic of My_Format.Channel_Matrix loop
+ TIO.Put (Libao.Channel_Mnemonic'Image (Mnemonic) & " ");
+ end loop;
+ TIO.New_Line;
+
+
+end Format_Options;
+
+
diff --git a/example/info_list.adb b/example/info_list.adb
new file mode 100644
index 0000000..5dcdcf0
--- /dev/null
+++ b/example/info_list.adb
@@ -0,0 +1,74 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+-- This program displays information about all available libao drivers
+
+
+with
+
+ Ada.Characters.Latin_1,
+ Ada.Strings.Fixed,
+ Ada.Text_IO,
+ Libao;
+
+use type
+
+ Libao.Output_Kind;
+
+
+procedure Info_List is
+
+ package Latin renames Ada.Characters.Latin_1;
+ package Str renames Ada.Strings;
+ package TIO renames Ada.Text_IO;
+
+ function "*"
+ (Left : in Natural;
+ Right : in Character)
+ return String
+ renames Ada.Strings.Fixed."*";
+
+ My_Information : Libao.Info_Array := Libao.Driver_Info_List;
+
+begin
+
+ TIO.Put_Line ("libao driver information");
+ TIO.New_Line;
+
+ TIO.Put_Line ("Is big endian: " & Boolean'Image (Libao.Is_Big_Endian));
+ TIO.Put_Line ("Number of drivers:" & Integer'Image (My_Information'Length));
+ TIO.Put_Line ("Default driver:" & Libao.Driver_ID_Number'Image (Libao.Default_Driver_ID));
+ TIO.New_Line;
+
+ for Item of My_Information loop
+ TIO.Put_Line (36 * '-' & " Driver ID #" & Str.Fixed.Trim
+ (Libao.Driver_ID_Number'Image (Libao.Driver_ID (Item.Short_Name)), Str.Left));
+
+ TIO.Put_Line ("Kind: " & Libao.Output_Kind'Image (Item.Kind));
+ TIO.Put_Line ("Name: " & Item.Name);
+ TIO.Put_Line ("Short name: " & Item.Short_Name);
+ TIO.Put_Line ("Preferred byte format: " &
+ Libao.Endianness'Image (Item.Preferred_Byte_Format));
+ TIO.Put_Line ("Priority Level:" & Positive'Image (Item.Priority_Level));
+ TIO.Put_Line ("Comment: " & Item.Comment);
+
+ if Item.Kind = Libao.File_Output then
+ TIO.Put_Line ("File extension: " & Libao.File_Extension
+ (Libao.Driver_ID (Item.Short_Name)));
+ end if;
+
+ TIO.Put_Line ("Option count:" & Integer'Image (Item.Option_Count));
+ for Index in Integer range 1 .. Item.Option_Count loop
+ TIO.Put_Line (Latin.HT & "#" & Str.Fixed.Trim (Integer'Image (Index), Str.Left) &
+ " " & Item.Option_Key (Index));
+ end loop;
+
+ TIO.Put_Line (46 * '-');
+ TIO.New_Line;
+ end loop;
+
+end Info_List;
+
+