Skip to content

Commit

Permalink
Small code fixes, add an usefule for_nth_mapped_n2 function in predic…
Browse files Browse the repository at this point in the history
…ate_reflection
  • Loading branch information
jcelerier committed May 5, 2024
1 parent d4cc209 commit 7763a02
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
3 changes: 3 additions & 0 deletions examples/Advanced/Granular/Granolette.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class Granolette
return;

if(outputs.audio.channels != inputs.sound.channels())
{
outputs.audio.request_channels(inputs.sound.channels());
return;
}

// Just take the first channel of the soundfile.
// in is a std::span
Expand Down
1 change: 1 addition & 0 deletions examples/Helpers/ValueDelay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <Gamma/Delay.h>
#include <Gamma/ipl.h>
#include <halp/audio.hpp>
#include <halp/compat/gamma.hpp>
#include <halp/controls.hpp>
#include <halp/controls_fmt.hpp>
Expand Down
13 changes: 2 additions & 11 deletions include/avnd/binding/ossia/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,22 +851,13 @@ class safe_node_base : public safe_node_base_base<T>
return true;
}

void soundfile_release_request(std::string& str, int idx)
{
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
}

void soundfile_load_request(std::string& str, int idx)
{
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
}
void midifile_load_request(std::string& str, int idx)
{
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
fprintf(stderr, "midifile_load_request %s:%d\n", str.c_str(), idx);
}
void raw_file_load_request(std::string& str, int idx)
{
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
fprintf(stderr, "raw_file_load_request %s:%d\n", str.c_str(), idx);
}

template <std::size_t N, std::size_t NField>
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/ossia/port_run_preprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ struct process_before_run
if(!str)
return;

self.soundfile_load_request(*str, Idx);
self.soundfiles.load_request(*str, Idx);
}

template <avnd::midifile_port Field, std::size_t Idx>
Expand Down
3 changes: 3 additions & 0 deletions include/avnd/binding/ossia/soundfiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ struct soundfile_storage : soundfile_input_storage<T>
}
}
}

// std::function<void(std::string& str, int idx)> release_request;
std::function<void(std::string& str, int idx)> load_request;
};
}

Expand Down
22 changes: 22 additions & 0 deletions include/avnd/common/struct_reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,28 @@ struct predicate_introspection
}(indices_n{});
}
}
static constexpr void
for_nth_mapped_n2(type& unfiltered_fields, int n, auto&& func) noexcept
{
if constexpr(size > 0)
{
auto stack_size_helper
= [&]<std::size_t Index, std::size_t LocalIndex>() constexpr noexcept {
func(
pfr::get<Index>(unfiltered_fields), avnd::predicate_index<LocalIndex>{},
avnd::field_index<Index>{});
};

[stack_size_helper, k = index_map[n], &func,
&unfiltered_fields]<typename K, K... Index, size_t... LocalIndex>(
std::integer_sequence<K, Index...>,
std::integer_sequence<size_t, LocalIndex...>) {
(void)((Index == k
&& (stack_size_helper.template operator()<Index, LocalIndex>(), true))
|| ...);
}(indices_n{}, std::make_index_sequence<size>{});
}
}
};

template <>
Expand Down

0 comments on commit 7763a02

Please sign in to comment.