2 #include <Fx/Types.hpp>
4 #include <halp/audio.hpp>
5 #include <halp/callback.hpp>
6 #include <halp/controls.hpp>
7 #include <halp/meta.hpp>
15 halp_meta(name,
"Free metronome")
16 halp_meta(c_name,
"Metro")
17 halp_meta(category,
"Control/Generators")
18 halp_meta(author,
"ossia score")
19 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/control-utilities.html#free-metronome")
20 halp_meta(description,
"Metronome which is not synced to the parent quantization settings")
22 halp_meta(uuid,
"50439197-521E-4ED0-A3B7-EDD8DEAEAC93")
27 halp::log_hslider_f32<
"Frequency", halp::range{0.01f, 100.f, 1.f}> frequency;
28 struct : halp::toggle<
"Quantify">
32 std::array<std::string_view, 2> values{
"Free",
"Sync"};
39 halp::timed_callback<
"out"> out;
43 static constexpr int64_t get_period(
bool use_tempo,
double quantif,
double freq,
double tempo,
int sr)
47 const auto whole_dur = 240. / tempo;
48 const auto whole_samples = whole_dur * sr;
49 return quantif * whole_samples;
57 static constexpr int64_t next_date(int64_t cur_date, int64_t period)
59 return (int64_t)(period * (cur_date / period));
63 void prepare(halp::setup s) { setup = s; }
66 using tick = halp::tick_musical;
67 void operator()(
const halp::tick_musical& tk)
69 if(tk.start_position_in_quarters < tk.end_position_in_quarters)
72 const auto period = get_period(
73 inputs.quantify, inputs.dur.value, inputs.frequency, tk.tempo, setup.rate);
75 const auto next = next_date(tk.position_in_frames, period);
78 outputs.out(next - tk.position_in_frames);
Definition: LFO_v2.hpp:68