PitchToValue.hpp
1 #pragma once
2 #include <halp/callback.hpp>
3 #include <halp/meta.hpp>
4 #include <halp/midi.hpp>
5 #include <libremidi/message.hpp>
6 
7 namespace Nodes::PitchToValue
8 {
9 struct Node
10 {
11  halp_meta(name, "Midi Pitch")
12  halp_meta(c_name, "PitchToValue")
13  halp_meta(category, "Midi")
14  halp_meta(author, "ossia score")
15  halp_meta(manual_url, "https://ossia.io/score-docs/processes/midi-utilities.html#midi-pitch")
16  halp_meta(description, "Extract a MIDI pitch")
17  halp_meta(uuid, "29ce484f-cb56-4501-af79-88768fa261c3")
18 
19  struct
20  {
21  halp::midi_bus<"in", libremidi::message> midi;
22  } inputs;
23  struct
24  {
25  struct : halp::timed_callback<"out", int>
26  {
27  halp_meta(unit, "midipitch");
28  } out;
29  } outputs;
30 
31  void operator()()
32  {
33  for(const auto& note : inputs.midi)
34  {
35  if(note.get_message_type() == libremidi::message_type::NOTE_ON)
36  outputs.out(note.timestamp, (int)note.bytes[1]);
37  }
38  }
39 };
40 }
Definition: PitchToValue.hpp:10