Skip to content

Commit

Permalink
add option for normalization of Ambisonics files
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Jun 7, 2024
1 parent e4d61cf commit 6b88ac4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugins/src/tascar_ap_sndfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ap_sndfile_cfg_t : public TASCAR::audioplugin_base_t {
std::string license;
std::string attribution;
std::string channelorder;
std::string normalization = "FuMa";
};

ap_sndfile_cfg_t::ap_sndfile_cfg_t(const TASCAR::audioplugin_cfg_t& cfg)
Expand Down Expand Up @@ -81,9 +82,11 @@ ap_sndfile_cfg_t::ap_sndfile_cfg_t(const TASCAR::audioplugin_cfg_t& cfg)
"(ignores attributes `position' and `loop')");
GET_ATTRIBUTE_BOOL(transport, "Use session time base");
GET_ATTRIBUTE_BOOL(mute, "Load muted");
GET_ATTRIBUTE(channelorder, "",
"Channel order in case of First Order Ambisonics recordings, "
GET_ATTRIBUTE(channelorder, "FuMa|ACN|none",
"Channel order in case of First Order Ambisonics files, "
"``FuMa'', ``ACN'' or ``none''");
GET_ATTRIBUTE(normalization, "FuMa|SN3D",
"Normalization in case of First Order Ambisonics files.");
if(start < 0)
throw TASCAR::ErrMsg("file start time must be positive.");
}
Expand Down Expand Up @@ -160,6 +163,11 @@ void ap_sndfile_t::load_file()
} else
throw TASCAR::ErrMsg("Invalid channel order: \"" + channelorder +
"\"");
if(normalization == "SN3D")
*(sndf[0]) *= sqrtf(0.5f);
else if(normalization != "FuMa")
throw TASCAR::ErrMsg("Invalid normalization: \"" + normalization +
"\". Must be \"FuMa\" or \"SN3D\".");
} else {
for(uint32_t ch = 0; ch < n_channels; ++ch) {
sndf.push_back(
Expand Down

0 comments on commit 6b88ac4

Please sign in to comment.