Skip to content

Commit

Permalink
fix multucanal nn~ in multi inlet outlet setup
Browse files Browse the repository at this point in the history
  • Loading branch information
caillonantoine committed May 11, 2023
1 parent 2bf45fe commit 9d169a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/backend/backend.cpp
Expand Up @@ -35,12 +35,13 @@ void Backend::perform(std::vector<float *> in_buffer,

// COPY BUFFER INTO A TENSOR
std::vector<at::Tensor> tensor_in;
for (int i(0); i < in_buffer.size(); i++) {
tensor_in.push_back(torch::from_blob(in_buffer[i], {1, 1, n_vec}));
}
for (auto buf : in_buffer)
tensor_in.push_back(torch::from_blob(buf, {1, 1, n_vec}));

auto cat_tensor_in = torch::cat(tensor_in, 1);
cat_tensor_in = cat_tensor_in.reshape({n_batches, in_dim, -1, in_ratio});
cat_tensor_in = cat_tensor_in.reshape({in_dim, n_batches, -1, in_ratio});
cat_tensor_in = cat_tensor_in.select(-1, -1);
cat_tensor_in = cat_tensor_in.permute({1, 0, 2});

if (m_cuda_available)
cat_tensor_in = cat_tensor_in.to(CUDA);
Expand Down
10 changes: 1 addition & 9 deletions src/frontend/maxmsp/mc.nn_tilde/mc.nn_tilde.cpp
Expand Up @@ -37,6 +37,7 @@ class mc_nn_tilde : public object<mc_nn_tilde>, public mc_operator<> {
// INLETS OUTLETS
std::vector<std::unique_ptr<inlet<>>> m_inlets;
std::vector<std::unique_ptr<outlet<>>> m_outlets;

// CHANNELS
std::vector<int> chans;
int get_batches();
Expand Down Expand Up @@ -391,17 +392,8 @@ void mc_nn_tilde::perform(audio_bundle input, audio_bundle output) {
}

// COPY CIRCULAR BUFFER TO OUTPUT
// for (int c(0); c < output.channel_count(); c++) {
// auto out = output.samples(c);
// auto current_batch = c % get_batches();
// m_out_buffer[c].get(out, vec_size);
// }
std::cout << output.channel_count() << ";" << m_out_dim << std::endl;
std::cout << m_outlets.size() << ";" << get_batches() << std::endl;
for (int b(0); b < get_batches(); b++) {
for (int d(0); d < m_outlets.size(); d++) {
std::cout << b << ";" << d << ";" << b * m_outlets.size() + d
<< std::endl;
auto out = output.samples(d * get_batches() + b);
m_out_buffer[b * m_outlets.size() + d].get(out, vec_size);
}
Expand Down

0 comments on commit 9d169a8

Please sign in to comment.