summaryrefslogtreecommitdiff
path: root/src/libsndfile-commands.ads
blob: 8540fdcad0eeb00d7bfb4781c50d4d54ce15cffc (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
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;