SAF
Loading...
Searching...
No Matches
saf_sofa_reader.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-2018 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
35#ifndef __SAF_SOFA_READER_H_INCLUDED__
36#define __SAF_SOFA_READER_H_INCLUDED__
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42#ifdef SAF_ENABLE_SOFA_READER_MODULE
43
44#include "libmysofa/mysofa.h"
45
73
74
75/* ========================================================================== */
76/* Public Structures/Enums */
77/* ========================================================================== */
78
86typedef struct _saf_sofa_container{
87 /* All possible SOFA variables (defaults={-1|NULL}) */
91 float* DataIR;
94 float* DataDelay;
111 float* ListenerUp;
121 /* All possible SOFA variable attributes (defaults=NULL) */
134 /* All possible SOFA global attributes (defaults=NULL) */
136 char* Version;
140 char* APIName;
145 char* Comment;
146 char* DataType;
147 char* History;
148 char* License;
151 char* RoomType;
152 char* Origin;
155 char* Title;
159 /* libmysofa handle, which is used if SAF_ENABLE_NETCDF is not defined */
160 void* hLMSOFA;
163
178
179
180/* ========================================================================== */
181/* Main Functions */
182/* ========================================================================== */
183
208 char* sofa_filepath,
210
217
218#endif /* SAF_ENABLE_SOFA_READER_MODULE */
219
220
221#ifdef __cplusplus
222} /* extern "C" */
223#endif /* __cplusplus */
224
225#endif /* __SAF_SOFA_READER_H_INCLUDED__ */
226
227 /* doxygen addtogroup SOFA_Reader */
void saf_sofa_close(saf_sofa_container *hSOFA)
Frees all SOFA data in a sofa_container.
SAF_SOFA_READER_OPTIONS
SOFA file reader options.
SAF_SOFA_ERROR_CODES saf_sofa_open(saf_sofa_container *hSOFA, char *sofa_filepath, SAF_SOFA_READER_OPTIONS option)
Fills a 'sofa_container' with data found in a SOFA file (GeneralFIR or SimpleFreeFieldHRIR),...
SAF_SOFA_ERROR_CODES
SOFA loader error codes.
@ SAF_SOFA_READER_OPTION_DEFAULT
The default option is SAF_SOFA_READER_OPTION_LIBMYSOFA.
@ SAF_SOFA_READER_OPTION_NETCDF
If SAF_ENABLE_NETCDF is defined, then an alternative SOFA reader may be used.
@ SAF_SOFA_READER_OPTION_LIBMYSOFA
This option uses the libmysofa library to load SOFA files, which is adopted from: https://github....
@ SAF_SOFA_ERROR_INVALID_FILE_OR_FILE_PATH
Not a SOFA file, or no such file was found in the specified location.
@ SAF_SOFA_ERROR_NETCDF_IN_USE
NetCDF is not thread safe!
@ SAF_SOFA_OK
None of the error checks failed.
@ SAF_SOFA_ERROR_FORMAT_UNEXPECTED
The data-type of the SOFA data was not as expected.
@ SAF_SOFA_ERROR_DIMENSIONS_UNEXPECTED
Dimensions of the SOFA data were not as expected.
SOFA container struct comprising all possible data that can be extracted from SOFA 1....
float * DataDelay
Delay in samples; nReceivers x 1.
char * Organisation
Organisation reponsible for the file.
int DataLengthIR
Length of the IRs, in samples.
char * Origin
Where this file came from.
char * SOFAConventionsVersion
SOFA convention number.
int nSources
Number of source/measurement positions.
char * RoomType
Room type (free field etc.)
char * DataSamplingRateUnits
{'hertz'}
char * EmitterPositionUnits
{'degree, degree, metre'|'metre'}
char * ReceiverPositionUnits
{'degree, degree, metre'|'metre'}
float * SourcePosition
Source positions (refer to SourcePositionType & SourcePositionUnits for the convention and units); FL...
int nListeners
Number of listener positions.
char * DateCreated
Date file was created.
char * References
References.
float * ReceiverPosition
Receiver positions (refer to ReceiverPositionType & ReceiverPositionUnits for the convention and unit...
char * SourcePositionUnits
{'degree, degree, metre'|'metre'}
char * Conventions
{'SOFA'}
char * DataType
{'FIR'|'TF'}
char * SourcePositionType
{'cartesian'|'spherical'}
char * ReceiverPositionType
{'cartesian'|'spherical'}
char * EmitterPositionType
{'cartesian'|'spherical'}
char * ListenerPositionType
{'cartesian'|'spherical'}
char * SOFAConventions
{'GeneralFIR'|'GeneralTF'| 'SimpleFreeFieldHRIR'}
char * ListenerPositionUnits
{'degree, degree, metre'|'metre'}
float * EmitterPosition
Positions of acoustic excitation used for the measurement (refer to EmitterPositionType & EmitterPosi...
char * Title
Title of file.
char * Comment
File comments.
char * APIVersion
API version.
float * ListenerPosition
Listener position (The object incorporating all receivers; refer to ListenerPositionType & ListenerPo...
char * ApplicationVersion
Ver.
char * DatabaseName
Name of database this file belongs to.
float * ListenerView
Vector pointing forwards from the listener position (Cartesian); 3 x 1.
float DataSamplingRate
Sampling rate used to measure the IRs.
char * History
History information.
int nEmitters
Number of emitter positions.
char * Version
Version number.
char * APIName
API name.
char * ApplicationName
Name of Application that created file.
char * ListenerViewUnits
{'degree, degree, metre'|'metre'}
void * hLMSOFA
libmysofa handle
char * ListenerShortName
Name of the listener/dummyhead/mic etc.
int nReceivers
Number of ears/number of mics etc.
char * DateModified
Date file was modified.
char * ListenerViewType
{'cartesian'|'spherical'}
float * ListenerUp
Vector pointing upwards from the listener position (Cartesian); 1 x 3 or FLAT: nListeners x 3
char * AuthorContact
Contact information.
char * License
License under which file is provided.
float * DataIR
The impulse response (IR) Data; FLAT:nSources x nReceivers x DataLengthIR.