Skip to content

Commit

Permalink
avoid methods for storing states, print list of simplices in hoa3d
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Jun 27, 2024
1 parent 68d9725 commit 9763ad7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
5 changes: 1 addition & 4 deletions libtascar/include/vbap3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace TASCAR {
public:
const float* weights;

private:
//private:
class simplex_t {
public:
simplex_t() : c1(-1), c2(-1), c3(-1){};
Expand Down Expand Up @@ -85,9 +85,6 @@ namespace TASCAR {
double l31;
double l32;
double l33;
// double g1;
// double g2;
// double g3;
};
std::vector<simplex_t> simplices;
};
Expand Down
6 changes: 6 additions & 0 deletions libtascar/src/hoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ void decoder_t::create_allrad(uint32_t order,
Hdecoder_virtual.create_pinv(M, virtual_spkpos);
// computation of VBAP gains for each virtual speaker
TASCAR::vbap3d_t vbap(spkpos);
DEBUG(vbap.simplices.size());
for(size_t k = 0; k < vbap.simplices.size(); ++k) {
std::cerr << " simplex " << k << ": " << vbap.simplices[k].c1 << " "
<< vbap.simplices[k].c2 << " " << vbap.simplices[k].c3
<< std::endl;
}
for(uint32_t acn = 0; acn < amb_channels; ++acn)
for(uint32_t vspk = 0; vspk < virtual_spkpos.size(); ++vspk) {
vbap.encode(virtual_spkpos[vspk]);
Expand Down
18 changes: 10 additions & 8 deletions plugins/src/receivermod_hoa3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class hoa3d_dec_t : public TASCAR::receivermod_base_speaker_t {
data_t(uint32_t order);
// ambisonic weights:
std::vector<float> B;
std::vector<float> newB;
std::vector<float> deltaB;
};
hoa3d_dec_t(tsccfg::node_t xmlsrc);
~hoa3d_dec_t();
Expand All @@ -49,22 +51,24 @@ class hoa3d_dec_t : public TASCAR::receivermod_base_speaker_t {
uint32_t channels;
HOA::encoder_t encode;
HOA::decoder_t decode;
std::vector<float> B;
std::vector<float> deltaB;
std::vector<TASCAR::wave_t> amb_sig;
double decwarnthreshold;
bool allowallrad = false;
};

void hoa3d_dec_t::configure()
{
DEBUG(channels);
DEBUG(spkpos.size());
TASCAR::receivermod_base_speaker_t::configure();
amb_sig = std::vector<TASCAR::wave_t>(channels, TASCAR::wave_t(n_fragment));
}

hoa3d_dec_t::data_t::data_t(uint32_t channels)
{
B = std::vector<float>(channels, 0.0f);
newB = std::vector<float>(channels, 0.0f);
deltaB = std::vector<float>(channels, 0.0f);
}

hoa3d_dec_t::hoa3d_dec_t(tsccfg::node_t xmlsrc)
Expand Down Expand Up @@ -92,8 +96,6 @@ hoa3d_dec_t::hoa3d_dec_t(tsccfg::node_t xmlsrc)
"\"allowallrad\" to \"true\".");
encode.set_order(order);
channels = (order + 1) * (order + 1);
B = std::vector<float>(channels, 0.0f);
deltaB = std::vector<float>(channels, 0.0f);
if(method == "pinv")
decode.create_pinv(order, spkpos.get_positions());
else if(method == "allrad")
Expand Down Expand Up @@ -139,14 +141,14 @@ void hoa3d_dec_t::add_pointsource(const TASCAR::pos_t& prel, double,
throw TASCAR::ErrMsg("Invalid data type.");
float az = prel.azim();
float el = prel.elev();
encode(az, el, B);
encode(az, el, state->newB);
for(uint32_t index = 0; index < channels; ++index)
deltaB[index] = (B[index] - state->B[index]) * t_inc;
state->deltaB[index] = (state->newB[index] - state->B[index]) * t_inc;
for(uint32_t t = 0; t < chunk.size(); ++t)
for(uint32_t index = 0; index < channels; ++index)
amb_sig[index][t] += (state->B[index] += deltaB[index]) * chunk[t];
amb_sig[index][t] += (state->B[index] += state->deltaB[index]) * chunk[t];
for(uint32_t index = 0; index < channels; ++index)
state->B[index] = B[index];
state->B[index] = state->newB[index];
}

void hoa3d_dec_t::postproc(std::vector<TASCAR::wave_t>& output)
Expand Down

0 comments on commit 9763ad7

Please sign in to comment.