Skip to content

Commit 7763a02

Browse files
committed
Small code fixes, add an usefule for_nth_mapped_n2 function in predicate_reflection
1 parent d4cc209 commit 7763a02

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

examples/Advanced/Granular/Granolette.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class Granolette
4444
return;
4545

4646
if(outputs.audio.channels != inputs.sound.channels())
47+
{
4748
outputs.audio.request_channels(inputs.sound.channels());
49+
return;
50+
}
4851

4952
// Just take the first channel of the soundfile.
5053
// in is a std::span

examples/Helpers/ValueDelay.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <Gamma/Delay.h>
66
#include <Gamma/ipl.h>
7+
#include <halp/audio.hpp>
78
#include <halp/compat/gamma.hpp>
89
#include <halp/controls.hpp>
910
#include <halp/controls_fmt.hpp>

include/avnd/binding/ossia/node.hpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -851,22 +851,13 @@ class safe_node_base : public safe_node_base_base<T>
851851
return true;
852852
}
853853

854-
void soundfile_release_request(std::string& str, int idx)
855-
{
856-
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
857-
}
858-
859-
void soundfile_load_request(std::string& str, int idx)
860-
{
861-
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
862-
}
863854
void midifile_load_request(std::string& str, int idx)
864855
{
865-
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
856+
fprintf(stderr, "midifile_load_request %s:%d\n", str.c_str(), idx);
866857
}
867858
void raw_file_load_request(std::string& str, int idx)
868859
{
869-
fprintf(stderr, "%s:%d\n", str.c_str(), idx);
860+
fprintf(stderr, "raw_file_load_request %s:%d\n", str.c_str(), idx);
870861
}
871862

872863
template <std::size_t N, std::size_t NField>

include/avnd/binding/ossia/port_run_preprocess.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ struct process_before_run
300300
if(!str)
301301
return;
302302

303-
self.soundfile_load_request(*str, Idx);
303+
self.soundfiles.load_request(*str, Idx);
304304
}
305305

306306
template <avnd::midifile_port Field, std::size_t Idx>

include/avnd/binding/ossia/soundfiles.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ struct soundfile_storage : soundfile_input_storage<T>
162162
}
163163
}
164164
}
165+
166+
// std::function<void(std::string& str, int idx)> release_request;
167+
std::function<void(std::string& str, int idx)> load_request;
165168
};
166169
}
167170

include/avnd/common/struct_reflection.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,28 @@ struct predicate_introspection
500500
}(indices_n{});
501501
}
502502
}
503+
static constexpr void
504+
for_nth_mapped_n2(type& unfiltered_fields, int n, auto&& func) noexcept
505+
{
506+
if constexpr(size > 0)
507+
{
508+
auto stack_size_helper
509+
= [&]<std::size_t Index, std::size_t LocalIndex>() constexpr noexcept {
510+
func(
511+
pfr::get<Index>(unfiltered_fields), avnd::predicate_index<LocalIndex>{},
512+
avnd::field_index<Index>{});
513+
};
514+
515+
[stack_size_helper, k = index_map[n], &func,
516+
&unfiltered_fields]<typename K, K... Index, size_t... LocalIndex>(
517+
std::integer_sequence<K, Index...>,
518+
std::integer_sequence<size_t, LocalIndex...>) {
519+
(void)((Index == k
520+
&& (stack_size_helper.template operator()<Index, LocalIndex>(), true))
521+
|| ...);
522+
}(indices_n{}, std::make_index_sequence<size>{});
523+
}
524+
}
503525
};
504526

505527
template <>

0 commit comments

Comments
 (0)