2 #include <Engine/Node/SimpleApi.hpp>
4 #include <ossia/network/value/value_conversion.hpp>
14 static const constexpr
auto prettyName =
"Midi hi-res input";
15 static const constexpr
auto objectKey =
"MidiHiResIn";
16 static const constexpr
auto category =
"Midi";
17 static const constexpr
auto author =
"ossia score";
18 static const constexpr
auto kind = Process::ProcessCategory::MidiEffect;
19 static const constexpr
auto description =
"Creates a float from MSB/LSB CCs";
20 static const constexpr
auto tags = std::array<const char*, 0>{};
21 static const uuid_constexpr
auto uuid
22 = make_uuid(
"28ca746e-c304-4ba6-bd5b-78934a1dec55");
24 static const constexpr value_in value_ins[]{{
"msb",
false}, {
"lsb",
false}};
25 static const constexpr value_out value_outs[]{
"int",
"float"};
28 using control_policy = ossia::safe_nodes::default_tick;
31 run(
const ossia::value_port& msb,
const ossia::value_port& lsb, ossia::value_port& out,
32 ossia::value_port& out_f,
const ossia::token_request& tk,
33 ossia::exec_state_facade st)
35 auto& msbs = msb.get_data();
36 auto& lsbs = lsb.get_data();
37 if(msbs.empty() && lsbs.empty())
40 const auto m = msbs.empty() ? 0 : ossia::convert<int>(msbs.back().value);
41 const auto l = lsbs.empty() ? 0 : ossia::convert<int>(lsbs.back().value);
43 auto [start, dur] = st.timings(tk);
44 out.write_value(m * 127 + l, start);
45 out_f.write_value(
double(m * 127 + l) / (128. * 128.), start);
53 static const constexpr
auto prettyName =
"Midi hi-res output";
54 static const constexpr
auto objectKey =
"MidiHiResOut";
55 static const constexpr
auto category =
"Midi";
56 static const constexpr
auto author =
"ossia score";
57 static const constexpr
auto kind = Process::ProcessCategory::MidiEffect;
58 static const constexpr
auto description
59 =
"Creates MIDI LSB/MSB from a 0-16384 or 0-1 value";
60 static const constexpr
auto tags = std::array<const char*, 0>{};
61 static const uuid_constexpr
auto uuid
62 = make_uuid(
"d6f5173b-b823-4571-b31f-660832b6132b");
64 static const constexpr value_in value_ins[]{
"int",
"float"};
65 static const constexpr value_out value_outs[]{
"msb",
"lsb"};
68 using control_policy = ossia::safe_nodes::default_tick;
71 run(
const ossia::value_port& in,
const ossia::value_port& in_f, ossia::value_port& msb,
72 ossia::value_port& lsb,
const ossia::token_request& tk,
73 ossia::exec_state_facade st)
75 for(
auto& [val, t] : in.get_data())
77 const int32_t v = ossia::convert<int>(val);
78 const int32_t m = ossia::clamp(int32_t(v / 127), 0, 127);
79 const int32_t l = ossia::clamp(int32_t(v - m * 127), 0, 127);
81 msb.write_value(m, t);
82 lsb.write_value(l, t);
85 for(
auto& [val, t] : in_f.get_data())
87 const float v = ossia::convert<float>(val) * (128. * 128.);
88 const int32_t m = ossia::clamp(int32_t(v / 127.), 0, 127);
89 const int32_t l = ossia::clamp(int32_t(v - m * 127), 0, 127);
91 msb.write_value(m, t);
92 lsb.write_value(l, t);
Definition: MidiHiRes.hpp:50