summaryrefslogtreecommitdiff
path: root/example/format_options.adb
blob: 352d3d5f96193da1f3f5c6279337563ae219c98f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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;