2 #include <Engine/Node/SimpleApi.hpp>
13 static const constexpr
auto prettyName =
"Free metronome";
14 static const constexpr
auto objectKey =
"Metro";
15 static const constexpr
auto category =
"Control/Generators";
16 static const constexpr
auto author =
"ossia score";
17 static const constexpr
auto kind = Process::ProcessCategory::Generator;
18 static const constexpr
auto description
19 =
"Metronome which is not synced to the parent quantization settings";
21 static const constexpr
auto tags = std::array<const char*, 0>{};
22 static const uuid_constexpr
auto uuid
23 = make_uuid(
"50439197-521E-4ED0-A3B7-EDD8DEAEAC93");
25 static const constexpr value_out value_outs[]{
"out"};
27 static const constexpr
auto controls = tuplet::make_tuple(
28 Control::Widgets::MusicalDurationChooser(), Control::Widgets::LFOFreqSlider(),
32 static constexpr int64_t
33 get_period(
bool use_tempo,
double quantif,
double freq,
double tempo,
int sr)
37 const auto whole_dur = 240. / tempo;
38 const auto whole_samples = whole_dur * sr;
39 return quantif * whole_samples;
47 static constexpr ossia::time_value
48 next_date(ossia::time_value cur_date, int64_t period)
50 return ossia::time_value{(int64_t)(period * (1 + cur_date.impl / period))};
53 using control_policy = ossia::safe_nodes::last_tick;
55 run(
float quantif,
float freq,
bool val, ossia::value_port& res,
56 ossia::token_request tk, ossia::exec_state_facade st)
58 if(tk.date > tk.prev_date)
60 const auto period = get_period(val, quantif, freq, tk.tempo, st.sampleRate());
61 const auto next = next_date(tk.prev_date, period * st.samplesToModel());
65 ossia::impulse{}, tk.to_physical_time_in_tick(next, st.modelToSamples()));
Definition: score-lib-process/Control/Widgets.hpp:374