-- Programmed by Jedidiah Barber -- Released into the public domain pragma Ada_2012; 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 tagged 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 record Offset : Count_Type; Length : Count_Type; end record; type Ambisonic is (Ambisonic_Unsupported, Ambisonic_Off, Ambisonic_B_Format); subtype Compression is Long_Float range 0.0 .. 1.0; type Broadcast_Info is record Description : String (1 .. 256); Originator : String (1 .. 32); Originator_Reference : String (1 .. 32); Origination_Date : String (1 .. 10); Origination_Time : String (1 .. 8); Time_Reference_Low : Interfaces.Unsigned_32; Time_Reference_High : Interfaces.Unsigned_32; Version : Short_Integer; Umid : String (1 .. 64); Reserved : String (1 .. 190); Coding_History_Size : Interfaces.Unsigned_32; Coding_History : String (1 .. 256); end record; 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 Cart_Timer is record Usage : String (1 .. 4); Value : Interfaces.Integer_32; end record; type Cart_Timer_Array is array (Positive range <>) of Cart_Timer; -- Is 1024 enough? Who knows! I hate this API Max_Cart_Tag_Size : constant Natural := 1024; type Cart_Info (Tag_Size : Natural) is record Version : String (1 .. 4); Title : String (1 .. 64); Artist : String (1 .. 64); Cut_ID : String (1 .. 64); Client_ID : String (1 .. 64); Category : String (1 .. 64); Classification : String (1 .. 64); Out_Cue : String (1 .. 64); Start_Date : String (1 .. 10); Start_Time : String (1 .. 8); End_Date : String (1 .. 10); End_Time : String (1 .. 8); Producer_App_ID : String (1 .. 64); Producer_App_Version : String (1 .. 64); User_Defined : String (1 .. 64); Level_Reference : Long_Integer; Post_Timers : Cart_Timer_Array (1 .. 8); Reserved : String (1 .. 276); URL : String (1 .. 1024); Tag_Text : String (1 .. Tag_Size); end record; type Loop_Mode is (No_Loop, Loop_Forward, Loop_Backward, Loop_Alternating); type Beats_Per_Minute is delta 10.0**(-2) digits 5 range 0.0 .. 655.0; subtype MIDI_Note is Integer range -1 .. 127; No_Note : constant MIDI_Note := -1; type Integer_Array is array (Positive range <>) of Integer; type Loop_Info is record Time_Sig_Num : Short_Integer; Time_Sig_Den : Short_Integer; Mode : Loop_Mode; Beats : Positive; BPM : Beats_Per_Minute; Root_Key : MIDI_Note; Future : Integer_Array (1 .. 6); end record; -- Many of these fields should likely be something more specific -- However it is hard to tell exactly what would be best type Instrument_Data is record Gain : Integer; Basenote : Character; Detune : Character; Velocity_Low : Character; Velocity_High : Character; Key_Low : Character; Key_High : Character; end record; type Loop_Data is record Mode : Loop_Mode; Start : Interfaces.Unsigned_32; Finish : Interfaces.Unsigned_32; Count : Interfaces.Unsigned_32; end record; type Loop_Data_Array is array (Positive range <>) of Loop_Data; type Instrument_Info is tagged private; function Create (Base : in Instrument_Data; Repeats : in Loop_Data_Array) return Instrument_Info with Pre => Repeats'Length <= 16; function Base (Info : in Instrument_Info) return Instrument_Data; function Repeats (Info : in Instrument_Info) return Loop_Data_Array with Post => Repeats'Result'Length <= 16; type Cue_Marker is record Index : Integer; Position : Interfaces.Unsigned_32; FCC_Chunk : Integer; Chunk_Start : Integer; Block_Start : Integer; Sample_Offset : Interfaces.Unsigned_32; Name : String (1 .. 256); end record; type Cue_Marker_Array is array (Positive range <>) of Cue_Marker; type Bitrate_Mode is (Constant_Mode, Average_Mode, Variable_Mode); ------------------ -- Exceptions -- ------------------ 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); function Get_Cart_Info (File : in Sound_File) return Cart_Info with Post => Get_Cart_Info'Result.Tag_Size <= Max_Cart_Tag_Size; procedure Set_Cart_Info (File : in Sound_File; Info : in Cart_Info) with Pre => Info.Tag_Size <= Max_Cart_Tag_Size; function Get_Loop_Info (File : in Sound_File) return Loop_Info; function Get_Instrument (File : in Sound_File) return Instrument_Info; procedure Set_Instrument (File : in Sound_File; Info : in Instrument_Info); function Get_Cue_Count (File : in Sound_File) return Interfaces.Unsigned_32; function Get_Cue (File : in Sound_File) return Cue_Marker_Array with Post => Get_Cue'Result'Length <= 100; procedure Set_Cue (File : in Sound_File; Info : in Cue_Marker_Array) with Pre => Info'Length <= 100; -- 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 C_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; type Format_Info is tagged record C_Data : C_Format_Info; end record; -- This cannot correspond to the C-side SF_EMBED_FILE_INFO struct since -- sf_count_t can vary type C_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 C_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; -- This corresponds to the C-side SF_CART_TIMER type C_Cart_Timer is record My_Usage : Interfaces.C.char_array (1 .. 4); My_Value : Interfaces.Integer_32; end record with Convention => C; type C_Cart_Timer_Array is array (Positive range <>) of C_Cart_Timer; -- This corresponds to the C-side SF_CART_INFO type C_Cart_Info is record My_Version : Interfaces.C.char_array (1 .. 4); My_Title : Interfaces.C.char_array (1 .. 64); My_Artist : Interfaces.C.char_array (1 .. 64); My_Cut_ID : Interfaces.C.char_array (1 .. 64); My_Client_ID : Interfaces.C.char_array (1 .. 64); My_Category : Interfaces.C.char_array (1 .. 64); My_Classification : Interfaces.C.char_array (1 .. 64); My_Out_Cue : Interfaces.C.char_array (1 .. 64); My_Start_Date : Interfaces.C.char_array (1 .. 10); My_Start_Time : Interfaces.C.char_array (1 .. 8); My_End_Date : Interfaces.C.char_array (1 .. 10); My_End_Time : Interfaces.C.char_array (1 .. 8); My_Producer_App_ID : Interfaces.C.char_array (1 .. 64); My_Producer_App_Version : Interfaces.C.char_array (1 .. 64); My_User_Def : Interfaces.C.char_array (1 .. 64); My_Level_Reference : Interfaces.C.long; My_Post_Timers : C_Cart_Timer_Array (1 .. 8); My_Reserved : Interfaces.C.char_array (1 .. 276); My_URL : Interfaces.C.char_array (1 .. 1024); My_Tag_Text_Size : Interfaces.C.unsigned; My_Tag_Text : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Cart_Tag_Size)); end record with Convention => C; type C_Int_Array is array (Positive range <>) of Interfaces.C.int; -- This corresponds to the C-side SF_LOOP_INFO struct type C_Loop_Info is record My_Time_Sig_Num : Interfaces.C.short; My_Time_Sig_Den : Interfaces.C.short; My_Loop_Mode : Interfaces.C.int; My_Num_Beats : Interfaces.C.int; My_BPM : Interfaces.C.C_float; My_Root_Key : Interfaces.C.int; My_Future : C_Int_Array (1 .. 6); end record with Convention => C; type C_Loop_Data is record My_Mode : Interfaces.C.int; My_Start : Interfaces.C.unsigned; My_End : Interfaces.C.unsigned; My_Count : Interfaces.C.unsigned; end record with Convention => C; type C_Loop_Data_Array is array (Positive range <>) of C_Loop_Data; -- This corresponds to the C-side SF_INSTRUMENT struct type C_Instrument_Info is record My_Gain : Interfaces.C.int; My_Basenote : Interfaces.C.char; My_Detune : Interfaces.C.char; My_Velocity_Lo : Interfaces.C.char; My_Velocity_Hi : Interfaces.C.char; My_Key_Lo : Interfaces.C.char; My_Key_Hi : Interfaces.C.char; My_Loop_Count : Interfaces.C.int; My_Loops : C_Loop_Data_Array (1 .. 16); end record with Convention => C; type Instrument_Info is tagged record C_Data : C_Instrument_Info; end record; type C_Cue is record My_Indx : Interfaces.Integer_32; My_Position : Interfaces.Unsigned_32; My_FCC_Chunk : Interfaces.Integer_32; My_Chunk_Start : Interfaces.Integer_32; My_Block_Start : Interfaces.Integer_32; My_Sample_Offset : Interfaces.Unsigned_32; My_Name : Interfaces.C.char_array (1 .. 256); end record with Convention => C; type C_Cue_Array is array (Positive range <>) of C_Cue; -- This corresponds to the C-side SF_CUES struct type C_Cue_Info is record My_Cue_Count : Interfaces.C.int; My_Cue_Points : C_Cue_Array (1 .. 100); end record with Convention => C; function To_Ada (Num : in Interfaces.C.int) return Loop_Mode; function To_C (Enum : in Loop_Mode) return Interfaces.C.int; end Libsndfile.Commands;