15 halp_meta(name,
"Free metronome (old)")
16 halp_meta(c_name,
"Metro")
17 halp_meta(category,
"Timing/Control")
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_flag(deprecated);
23 halp_meta(uuid,
"50439197-521E-4ED0-A3B7-EDD8DEAEAC93")
28 halp::log_hslider_f32<
"Frequency", halp::range{0.01f, 100.f, 1.f}> frequency;
29 struct : halp::toggle<
"Quantify">
33 std::array<std::string_view, 2> values{
"Free",
"Sync"};
40 halp::timed_callback<
"out"> out;
44 static constexpr int64_t get_period(
bool use_tempo,
double quantif,
double freq,
double tempo,
int sr)
48 const auto whole_dur = 240. / tempo;
49 const auto whole_samples = whole_dur * sr;
50 return quantif * whole_samples;
59 static constexpr int64_t
next_date(int64_t cur_date, int64_t period)
61 return period * ((cur_date + period - 1) / period);
65 void prepare(halp::setup s) { setup = s; }
68 using tick = halp::tick_musical;
69 void operator()(
const halp::tick_musical& tk)
71 if(tk.start_position_in_quarters < tk.end_position_in_quarters)
74 const auto period = get_period(
75 inputs.quantify, inputs.dur.value, inputs.frequency, tk.tempo, setup.rate);
79 const auto next =
next_date(tk.position_in_frames, period);
82 outputs.out(next - tk.position_in_frames);