OpenDAFF C++ API  v1.7
Directional Audio File Format
DAFFHeader.h
Go to the documentation of this file.
1 /*
2  * -------------------------------------------------------------------------------------
3  *
4  * OpenDAFF - A free, open source software package for directional audio data
5  * Copyright 2016 Institute of Technical Acoustics, RWTH Aachen University
6  * OpenDAFF is distributed under the Apache License Version 2.0.
7  *
8  * ------------------------------------------------------------------------------------
9  *
10  */
11 
12 /*
13  * In this file packaged data structures are defined,
14  * so basically with identical member memory layout as in the DAFF files
15  *
16  */
17 
18 #ifndef IW_DAFF_HEADER
19 #define IW_DAFF_HEADER
20 
21 #include "Utils.h"
22 
23 #ifdef _MSC_VER
24 // No packing attribute on Microsoft Compilers
25 #define DAFF_PACK_ATTR
26 #else
27 // Packing attribute requires for the GCC
28 #define DAFF_PACK_ATTR __attribute__((__packed__))
29 // #define HANDLE_PRAGMA_PACK_PUSH_POP // try this with your gcc compiler, if packing errors occur
30 #endif
31 
32 /* +---------------------------------------------------+
33  | |
34  | DAFF file block idenfiticators (IDs) |
35  | |
36  +---------------------------------------------------+ */
37 
39 static const int FILEBLOCK_DAFF1_MAIN_HEADER_ID = 0x0001;
40 
42 static const int FILEBLOCK_DAFF1_CONTENT_HEADER_ID = 0x0002;
43 
45 static const int FILEBLOCK_DAFF1_RECORD_DESC_ID = 0x0003;
46 
48 static const int FILEBLOCK_DAFF1_DATA_ID = 0x0004;
49 
51 static const int FILEBLOCK_DAFF1_METADATA_ID = 0x0005;
52 
53 
54 /* +---------------------------------------------------+
55  | |
56  | DAFF file format header |
57  | |
58  +---------------------------------------------------+ */
59 
62 {
63 #pragma pack(push,1)
64  uint8_t pcSignature[ 2 ];
66  int32_t iNumFileBlocks;
68 
69  // << From here file block entries succeed >>
70 #pragma pack(pop)
71 
73  inline void fixEndianness()
74  {
75  DAFF::le2se_4byte( &iFileFormatVersion, 1 );
76  DAFF::le2se_4byte( &iNumFileBlocks, 1 );
77  };
79 
80 
83 {
84 #pragma pack(push,1)
85  int32_t iID; // File block identifier
86  uint64_t ui64Offset; // Start offset of the block within the file
87  uint64_t ui64Size; // Size of the block [Bytes]
88 #pragma pack(pop)
89 
91  inline void fixEndianness()
92  {
93  DAFF::le2se_4byte( &iID, 1 );
94  DAFF::le2se_8byte( &ui64Offset, 1 );
95  DAFF::le2se_8byte( &ui64Size, 1 );
96  };
98 
99 /* +---------------------------------------------------+
100  | |
101  | DAFF file format main header |
102  | |
103  +---------------------------------------------------+ */
104 
106 {
107 #pragma pack(push,1)
108  // Common definitions
109  int32_t iContentType;
110  int32_t iQuantization;
111  int32_t iNumChannels;
112  int32_t iNumRecords;
114  int32_t iMetadataIndex;
115 
116  int32_t iAlphaPoints;
117  float fAlphaStart, fAlphaEnd;
118  int32_t iBetaPoints;
119  float fBetaStart, fBetaEnd;
120 
121  float fOrientYaw;
122  float fOrientPitch;
123  float fOrientRoll;
124 
125 #pragma pack(pop)
126 
128  inline void fixEndianness()
129  {
130  DAFF::le2se_4byte( &iContentType, 1 );
131  DAFF::le2se_4byte( &iQuantization, 1 );
132  DAFF::le2se_4byte( &iNumChannels, 1 );
133  DAFF::le2se_4byte( &iNumRecords, 1 );
134  DAFF::le2se_4byte( &iElementsPerRecord, 1 );
135  DAFF::le2se_4byte( &iMetadataIndex, 1 );
136 
137  DAFF::le2se_4byte( &iAlphaPoints, 1 );
138  DAFF::le2se_4byte( &fAlphaStart, 1 );
139  DAFF::le2se_4byte( &fAlphaEnd, 1 );
140  DAFF::le2se_4byte( &iBetaPoints, 1 );
141  DAFF::le2se_4byte( &fBetaStart, 1 );
142  DAFF::le2se_4byte( &fBetaEnd, 1 );
143 
144  DAFF::le2se_4byte( &fOrientYaw, 1 );
145  DAFF::le2se_4byte( &fOrientPitch, 1 );
146  DAFF::le2se_4byte( &fOrientRoll, 1 );
147  };
149 
152 {
153 #pragma pack(push,1)
154  float fSamplerate;
157 #pragma pack(pop)
158 
160  inline void fixEndianness()
161  {
162  DAFF::le2se_4byte( &fSamplerate, 1 );
163  DAFF::le2se_4byte( &iMinFilterOffset, 1 );
164  DAFF::le2se_4byte( &iMaxEffectiveFilterLength, 1 );
165  };
167 
170 {
171 #pragma pack(push,1)
172  float fMax;
173  int32_t iNumFreqs;
174 
175  // Next: Support frequency values [in Hertz] (float)
176 #pragma pack(pop)
177 
179  inline void fixEndianness()
180  {
181  DAFF::le2se_4byte( &fMax, 1 );
182  DAFF::le2se_4byte( &iNumFreqs, 1 );
183  };
185 
188 {
189 #pragma pack(push,1)
190  int32_t iNumFreqs;
191 
192 #pragma pack(pop)
193 
195  inline void fixEndianness()
196  {
197  DAFF::le2se_4byte( &iNumFreqs, 1 );
198  };
200 
203 {
204 #pragma pack(push,1)
205  float fMax;
206  int32_t iNumFreqs;
207 
208 #pragma pack(pop)
209 
211  inline void fixEndianness()
212  {
213  DAFF::le2se_4byte( &fMax, 1 );
214  DAFF::le2se_4byte( &iNumFreqs, 1 );
215  };
217 
220 {
221 #pragma pack(push,1)
222  int32_t iNumDFTCoeffs;
223  int32_t iTransformSize;
224  float fSamplerate;
225  float fMax;
226 #pragma pack(pop)
227 
229  inline void fixEndianness()
230  {
231  DAFF::le2se_4byte( &iNumDFTCoeffs, 1 );
232  DAFF::le2se_4byte( &iTransformSize, 1 );
233  DAFF::le2se_4byte( &fSamplerate, 1 );
234  DAFF::le2se_4byte( &fMax, 1 );
235  };
237 
238 /* +---------------------------------------------------+
239  | |
240  | DAFF record descriptors |
241  | |
242  +---------------------------------------------------+ */
243 
244 // Default record channel descriptor for records with constant size.
245 // (Used for: MS, PS, MPS and DFT content)
247 {
248 #pragma pack(push,1)
249  int32_t iMetaDataIndex;
250  uint64_t ui64DataOffset;
251 #pragma pack(pop)
252 
254  inline void fixEndianness()
255  {
256  DAFF::le2se_4byte( &iMetaDataIndex, 1 );
257  DAFF::le2se_8byte( &ui64DataOffset, 1 );
258  };
260 
263 {
264 #pragma pack(push,1)
265  int32_t iMetaDataIndex;
266  uint64_t ui64DataOffset;
267  int32_t iLeadingZeros;
268  int32_t iElementLength;
269 #pragma pack(pop)
270 
272  inline void fixEndianness()
273  {
274  DAFF::le2se_4byte( &iMetaDataIndex, 1 );
275  DAFF::le2se_8byte( &ui64DataOffset, 1 );
276  DAFF::le2se_4byte( &iLeadingZeros, 1 );
277  DAFF::le2se_4byte( &iElementLength, 1 );
278  };
280 
281 #endif // IW_DAFF_HEADER
DAFF file format content header for phase spectra.
Definition: DAFFHeader.h:187
float fOrientPitch
@ Yaw angle of the orientation [°]
Definition: DAFFHeader.h:122
void fixEndianness()
@ Roll angle of the orientation [°]
Definition: DAFFHeader.h:128
float fBetaStart
@ Number of measurement points in beta range [0°, 180°]
Definition: DAFFHeader.h:119
void fixEndianness()
@ Maximum effective Filterlength among all IRs
Definition: DAFFHeader.h:160
void fixEndianness()
@ Number of support frequencies
Definition: DAFFHeader.h:195
int32_t iMinFilterOffset
@ Samplingrate [in Hertz]
Definition: DAFFHeader.h:155
DAFF file format content header for magnitude spectra.
Definition: DAFFHeader.h:169
int32_t iLeadingZeros
@ Position inside the file where samples/coefficients reside (in bytes)
Definition: DAFFHeader.h:267
void fixEndianness()
@ Number of data values (length of element of record channel for a single channel, only)
Definition: DAFFHeader.h:272
uint8_t pcSignature[2]
Definition: DAFFHeader.h:64
uint64_t ui64DataOffset
@ Index in metadata table (C-style indexing: beginning with 0)
Definition: DAFFHeader.h:250
void fixEndianness()
@ Maximum magnitude value over all records/channels/frequencies
Definition: DAFFHeader.h:229
int32_t iID
Definition: DAFFHeader.h:85
uint64_t ui64DataOffset
@ Index in metadata table (C-style indexing: beginning with 0)
Definition: DAFFHeader.h:266
void fixEndianness()
@ Number of file blocks
Definition: DAFFHeader.h:73
int32_t iElementLength
@ Offset of actual data within impulse response (leading zeros that are not included in DAFF data) ...
Definition: DAFFHeader.h:268
int32_t iAlphaPoints
@ Index of global metadata
Definition: DAFFHeader.h:116
int32_t iElementsPerRecord
@ Overall number of records
Definition: DAFFHeader.h:113
int32_t iNumFileBlocks
@ (digits 0-2 => minor version, other digits => major version)
Definition: DAFFHeader.h:67
void fixEndianness()
@ Number of support frequencies
Definition: DAFFHeader.h:179
float fSamplerate
@ DFT transform size
Definition: DAFFHeader.h:224
This is the (pre) header of DAFF files.
Definition: DAFFHeader.h:61
DAFF file format content header for discrete Fourier spectra.
Definition: DAFFHeader.h:219
float fMax
@ Samplingrate [in Hertz]
Definition: DAFFHeader.h:225
float fAlphaStart
@ Number of measurement points in alpha range [0°, 360°)
Definition: DAFFHeader.h:117
int32_t iNumRecords
@ Number of channels
Definition: DAFFHeader.h:112
int32_t iFileFormatVersion
@ The magical signature
Definition: DAFFHeader.h:65
A file block entry.
Definition: DAFFHeader.h:82
int32_t iMetadataIndex
@ Number of elements per records (number of taps/DFT coefficients)
Definition: DAFFHeader.h:114
#define DAFF_PACK_ATTR
Definition: DAFFHeader.h:28
int32_t iTransformSize
@ Number of (stored) DFT coefficients (= complex elements per record)
Definition: DAFFHeader.h:223
int32_t iQuantization
@ Identificator of the database content type
Definition: DAFFHeader.h:110
void fixEndianness()
Convert the little-endian file format into the systems endianness.
Definition: DAFFHeader.h:91
int32_t iNumFreqs
@ Maximum magnitude value over all records/channels/frequencies
Definition: DAFFHeader.h:206
uint64_t ui64Offset
Definition: DAFFHeader.h:86
void fixEndianness()
@ Position inside the file where samples/coefficients reside
Definition: DAFFHeader.h:254
void(* le2se_4byte)(void *src, size_t count)
Definition: Utils.cpp:102
DAFF file format content header for impulse responses.
Definition: DAFFHeader.h:151
int32_t iMaxEffectiveFilterLength
@ Minimum offset (number of leading zeros) among all IRs
Definition: DAFFHeader.h:156
int32_t iNumChannels
@ Quantization of samples/coefficients
Definition: DAFFHeader.h:111
uint64_t ui64Size
Definition: DAFFHeader.h:87
int32_t iNumFreqs
@ Maximum magnitude value over all records/channels/frequencies
Definition: DAFFHeader.h:173
void fixEndianness()
@ Number of support frequencies
Definition: DAFFHeader.h:211
int32_t iBetaPoints
@ Alpha range boundaries
Definition: DAFFHeader.h:118
void(* le2se_8byte)(void *src, size_t count)
Definition: Utils.cpp:103
float fOrientRoll
@ Pitch angle of the orientation [°]
Definition: DAFFHeader.h:123
DAFF file format content header for magnitude-phase spectra.
Definition: DAFFHeader.h:202
Record channel descriptor: impulse responses content.
Definition: DAFFHeader.h:262
float fOrientYaw
@ Beta range boundaries
Definition: DAFFHeader.h:121
int32_t iContentType
Definition: DAFFHeader.h:109
OpenDAFF is a project from the Institute of Technical Acoustics, RWTH Aachen University, Germany.