diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2023-07-02 21:36:34 +1200 | 
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2023-07-02 21:36:34 +1200 | 
| commit | 049d2a9a337331295b4a2d4ad13061bc73536236 (patch) | |
| tree | c360b2ce05f91d070c14dad7a3691c1435df7df7 /src/libsndfile-commands.ads | |
Initial commit
Diffstat (limited to 'src/libsndfile-commands.ads')
| -rw-r--r-- | src/libsndfile-commands.ads | 442 | 
1 files changed, 442 insertions, 0 deletions
diff --git a/src/libsndfile-commands.ads b/src/libsndfile-commands.ads new file mode 100644 index 0000000..8540fdc --- /dev/null +++ b/src/libsndfile-commands.ads @@ -0,0 +1,442 @@ + + +--  Programmed by Jedidiah Barber +--  Released into the public domain + + +with + +    Interfaces; + +private with + +    Interfaces.C.Strings; + + +package Libsndfile.Commands is + + +    --------------------------------- +    --  Data Types and Structures  -- +    --------------------------------- + +    type Long_Float_Array is array (Positive range <>) of Long_Float; + + +    type Format_Info is private; + +    function Major +           (Info : in Format_Info) +        return Major_Format; + +    function Minor +           (Info : in Format_Info) +        return Minor_Format; + +    function Endian +           (Info : in Format_Info) +        return Endianness; + +    function Name +           (Info : in Format_Info) +        return String; + +    function Extension +           (Info : in Format_Info) +        return String; + + +    type Embedded_Info is private; + +    function Offset +           (Info : in Embedded_Info) +        return Count_Type; + +    function Length +           (Info : in Embedded_Info) +        return Count_Type; + + +    type Ambisonic is +       (Ambisonic_Unsupported, +        Ambisonic_Off, +        Ambisonic_B_Format); + +    subtype Compression is Long_Float range 0.0 .. 1.0; + + +    type Broadcast_Info is private; + +    function Create +           (Description          : in String; +            Originator           : in String; +            Originator_Reference : in String; +            Origination_Date     : in String; +            Origination_Time     : in String; +            Time_Reference_Low   : in Interfaces.Unsigned_32; +            Time_Reference_High  : in Interfaces.Unsigned_32; +            Version              : in Short_Integer; +            Umid                 : in String; +            Reserved             : in String; +            Coding_History_Size  : in Interfaces.Unsigned_32; +            Coding_History       : in String) +        return Broadcast_Info +    with Pre => +        Description'Length          <= 256 and +        Originator'Length           <= 32  and +        Originator_Reference'Length <= 32  and +        Origination_Date'Length     <= 10  and +        Origination_Time'Length     <= 8   and +        Umid'Length                 <= 64  and +        Reserved'Length             <= 190 and +        Coding_History'Length       <= 256; + +    function Description +           (Info : in Broadcast_Info) +        return String; + +    function Originator +           (Info : in Broadcast_Info) +        return String; + +    function Originator_Reference +           (Info : in Broadcast_Info) +        return String; + +    function Origination_Date +           (Info : in Broadcast_Info) +        return String; + +    function Origination_Time +           (Info : in Broadcast_Info) +        return String; + +    function Time_Reference_Low +           (Info : in Broadcast_Info) +        return Interfaces.Unsigned_32; + +    function Time_Reference_High +           (Info : in Broadcast_Info) +        return Interfaces.Unsigned_32; + +    function Version +           (Info : in Broadcast_Info) +        return Short_Integer; + +    function Umid +           (Info : in Broadcast_Info) +        return String; + +    function Reserved +           (Info : in Broadcast_Info) +        return String; + +    function Coding_History_Size +           (Info : in Broadcast_Info) +        return Interfaces.Unsigned_32; + +    function Coding_History +           (Info : in Broadcast_Info) +        return String; + + +    type Channel_Map is +       (Map_Invalid, +        Map_Mono, +        Map_Left, +        Map_Right, +        Map_Center, +        Map_Front_Left, +        Map_Front_Right, +        Map_Front_Center, +        Map_Rear_Center, +        Map_Rear_Left, +        Map_Rear_Right, +        Map_LFE, +        Map_Front_Left_Of_Center, +        Map_Front_Right_Of_Center, +        Map_Side_Left, +        Map_Side_Right, +        Map_Top_Center, +        Map_Top_Front_Left, +        Map_Top_Front_Right, +        Map_Top_Front_Center, +        Map_Top_Rear_Left, +        Map_Top_Rear_Right, +        Map_Top_Rear_Center, +        Map_Ambisonic_B_W, +        Map_Ambisonic_B_X, +        Map_Ambisonic_B_Y, +        Map_Ambisonic_B_Z, +        Map_Max); + +    type Channel_Map_Array is array (Positive range <>) of Channel_Map; + +    type Bitrate_Mode is +       (Constant_Mode, +        Average_Mode, +        Variable_Mode); + + + + +    ------------------ +    --  Exceptions  -- +    ------------------ + +    --  May be raised by Get_Signal_Maximum, Get_Maximum_All_Channels +    Command_Error : exception; + + + + +    --------------------- +    --  API Interface  -- +    --------------------- + +    function Get_Library_String +           (Buffer : out String) +        return Natural; + +    function Get_Log_Info +           (File   : in  Sound_File; +            Buffer : out String) +        return Natural; + +    function Get_Current_File_Info +           (File : in Sound_File) +        return File_Info; + +    function Calculate_Signal_Maximum +           (File : in Sound_File) +        return Long_Float; + +    function Calculate_Normed_Signal_Maximum +           (File : in Sound_File) +        return Long_Float; + +    function Calculate_Maximum_All_Channels +           (File : in Sound_File) +        return Long_Float_Array; + +    function Calculate_Normed_Maximum_All_Channels +           (File : in Sound_File) +        return Long_Float_Array; + +    function Get_Signal_Maximum +           (File : in Sound_File) +        return Long_Float; + +    function Get_Maximum_All_Channels +           (File : in Sound_File) +        return Long_Float_Array; + +    procedure Set_Normed_Float +           (File  : in Sound_File; +            Value : in Boolean); + +    procedure Set_Normed_Double +           (File  : in Sound_File; +            Value : in Boolean); + +    function Get_Normed_Float +           (File : in Sound_File) +        return Boolean; + +    function Get_Normed_Double +           (File : in Sound_File) +        return Boolean; + +    procedure Set_Scale_Float_Integer_Read +           (File  : in Sound_File; +            Value : in Boolean); + +    procedure Set_Scale_Integer_Float_Write +           (File  : in Sound_File; +            Value : in Boolean); + +    function Get_Simple_Format_Count +        return Natural; + +    function Get_Simple_Format +           (Index : in Positive) +        return Format_Info; + +    function Get_Format_Info +           (Format : in Major_Format) +        return Format_Info; + +    function Get_Format_Info +           (Format : in Minor_Format) +        return Format_Info; + +    function Get_Format_Major_Count +        return Natural; + +    function Get_Format_Major +           (Index : in Positive) +        return Format_Info; + +    function Get_Format_Subtype_Count +        return Natural; + +    function Get_Format_Subtype +           (Index : in Positive) +        return Format_Info; + +    procedure Set_Add_Peak_Chunk +           (File  : in Sound_File; +            Value : in Boolean); + +    procedure Update_Header_Now +           (File : in Sound_File); + +    procedure Set_Update_Header_Auto +           (File  : in Sound_File; +            Value : in Boolean); + +    procedure File_Truncate +           (File     : in Sound_File; +            Position : in Count_Type); + +    procedure Set_Raw_Start_Offset +           (File     : in Sound_File; +            Position : in Count_Type); + +    procedure Set_Clipping +           (File  : in Sound_File; +            Value : in Boolean); + +    function Get_Clipping +           (File : in Sound_File) +        return Boolean; + +    function Get_Embedded_File_Info +           (File : in Sound_File) +        return Embedded_Info; + +    function Wavex_Get_Ambisonic +           (File : in Sound_File) +        return Ambisonic; + +    procedure Wavex_Set_Ambisonic +           (File  : in Sound_File; +            Value : in Ambisonic); + +    procedure Set_Variable_Bitrate_Encoding_Quality +           (File  : in Sound_File; +            Value : in Long_Long_Float); + +    procedure Set_Ogg_Page_Latency_Milliseconds +           (File  : in Sound_File; +            Value : in Long_Long_Float); + +    function Get_Ogg_Stream_Serial +           (File : in Sound_File) +        return Integer; + +    procedure Set_Compression_Level +           (File  : in Sound_File; +            Value : in Compression); + +    function Raw_Data_Needs_Endswap +           (File : in Sound_File) +        return Boolean; + +    function Get_Broadcast_Info +           (File : in Sound_File) +        return Broadcast_Info; + +    procedure Set_Broadcast_Info +           (File  : in Sound_File; +            Value : in Broadcast_Info); + +    function Get_Channel_Map_Info +           (File : in Sound_File) +        return Channel_Map_Array; + +    procedure Set_Channel_Map_Info +           (File  : in Sound_File; +            Value : in Channel_Map_Array); + +    --  Get_Cart_Info goes here + +    --  Set_Cart_Info goes here + +    --  Get_Loop_Info goes here + +    --  Get_Instrument goes here + +    --  Set_Instrument goes here + +    function Get_Cue_Count +           (File : in Sound_File) +        return Interfaces.Unsigned_32; + +    --  Get_Cue goes here + +    --  Set_Cue goes here + +    --  Why the hell would you design this command in this way? +    --  You shouldn't have to intentionally try to set the thing after writing +    --  in order to find the value of it. +    procedure RF64_Auto_Downgrade +           (File  : in Sound_File; +            Value : in Boolean); + +    function Get_Original_Samplerate +           (File : in Sound_File) +        return Natural; + +    procedure Set_Original_Samplerate +           (File  : in Sound_File; +            Value : in Natural); + +    function Get_Bitrate_Mode +           (File : in Sound_File) +        return Bitrate_Mode; + +    procedure Set_Bitrate_Mode +           (File  : in Sound_File; +            Value : in Bitrate_Mode); + + +private + + +    --  This corresponds to the C-side SF_FORMAT_INFO +    type Format_Info is record +        My_Format    : Interfaces.C.int; +        My_Name      : Interfaces.C.Strings.chars_ptr; +        My_Extension : Interfaces.C.Strings.chars_ptr; +    end record with Convention => C; + + +    --  This cannot correspond to the C-side SF_EMBED_FILE_INFO struct since +    --  sf_count_t can vary +    type Embedded_Info is record +        My_Offset : Interfaces.Integer_64; +        My_Length : Interfaces.Integer_64; +    end record with Convention => C; + + +    --  This corresponds to the C-side SF_BROADCAST_INFO +    type Broadcast_Info is record +        My_Description          : Interfaces.C.char_array (1 .. 256); +        My_Originator           : Interfaces.C.char_array (1 .. 32); +        My_Originator_Reference : Interfaces.C.char_array (1 .. 32); +        My_Origination_Date     : Interfaces.C.char_array (1 .. 10); +        My_Origination_Time     : Interfaces.C.char_array (1 .. 8); +        My_Time_Reference_Low   : Interfaces.C.unsigned; +        My_Time_Reference_High  : Interfaces.C.unsigned; +        My_Version              : Interfaces.C.short; +        My_Umid                 : Interfaces.C.char_array (1 .. 64); +        My_Reserved             : Interfaces.C.char_array (1 .. 190); +        My_Coding_History_Size  : Interfaces.C.unsigned; +        My_Coding_History       : Interfaces.C.char_array (1 .. 256); +    end record with Convention => C; + + +end Libsndfile.Commands; + +  | 
