RecordAutomationParameterCallbackVisitor.hpp
1 #pragma once
2 #include <Curve/Segment/PointArray/PointArraySegment.hpp>
3 
4 #include <Automation/AutomationModel.hpp>
5 #include <Recording/Record/RecordManager.hpp>
6 
7 namespace Recording
8 {
18 {
19  void operator()(const RecordData& proc, const TimeVal& msecs, double msec, float val)
20  {
21  auto last = proc.segment.points().rbegin();
22  proc.segment.addPoint(msec - 1, last->second);
23  proc.segment.addPoint(msec, val);
24  static_cast<Automation::ProcessModel*>(proc.curveModel.parent())->setDuration(msecs);
25  }
26 };
27 
37 {
38  void operator()(const RecordData& proc, const TimeVal& msecs, double msec, float val)
39  {
40  proc.segment.addPoint(msec, val);
41  static_cast<Automation::ProcessModel*>(proc.curveModel.parent())->setDuration(msecs);
42  }
43 };
44 
45 template <typename RecordingPolicy>
47 {
48  AutomationRecorder& recorder;
49  const State::Address& addr;
50  TimeVal msecs;
51 
52  void operator()(std::array<float, 2> val)
53  {
54  const double msec = msecs.msec();
55  auto it = recorder.vec2_records.find(addr);
56  SCORE_ASSERT(it != recorder.vec2_records.end());
57 
58  const auto& proc_data = it->second;
59 
60  const constexpr std::size_t N = 2;
61  for(std::size_t i = 0; i < N; i++)
62  {
63  RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
64  }
65  }
66 
67  void operator()(std::array<float, 3> val)
68  {
69  const double msec = msecs.msec();
70  auto it = recorder.vec3_records.find(addr);
71  SCORE_ASSERT(it != recorder.vec3_records.end());
72 
73  const auto& proc_data = it->second;
74 
75  const constexpr std::size_t N = 3;
76  for(std::size_t i = 0; i < N; i++)
77  {
78  RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
79  }
80  }
81 
82  void operator()(std::array<float, 4> val)
83  {
84  const double msec = msecs.msec();
85  auto it = recorder.vec4_records.find(addr);
86  SCORE_ASSERT(it != recorder.vec4_records.end());
87 
88  const auto& proc_data = it->second;
89 
90  const constexpr std::size_t N = 4;
91  for(std::size_t i = 0; i < N; i++)
92  {
93  RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
94  }
95  }
96 
97  void handle_numeric(float newval)
98  {
99  const double msec = msecs.msec();
100  auto it = recorder.numeric_records.find(addr);
101  SCORE_ASSERT(it != recorder.numeric_records.end());
102 
103  const RecordData& proc_data = it->second;
104 
105  RecordingPolicy{}(proc_data, msecs, msec, newval);
106  }
107 
108  void operator()(float f) { handle_numeric(f); }
109 
110  void operator()(int f) { handle_numeric(f); }
111 
112  void operator()(char f) { handle_numeric(f); }
113 
114  void operator()(bool f) { handle_numeric(f); }
115 
116  template <typename... T>
117  void operator()(const T&...)
118  {
119  }
120 };
121 }
Definition: AutomationModel.hpp:36
Definition: RecordManager.hpp:27
The MessagePolicy struct.
Definition: RecordAutomationParameterCallbackVisitor.hpp:37
The ParameterPolicy struct.
Definition: RecordAutomationParameterCallbackVisitor.hpp:18
Definition: RecordAutomationParameterCallbackVisitor.hpp:47
Definition: RecordData.hpp:26
The Address struct.
Definition: Address.hpp:58
Definition: TimeValue.hpp:21