Loading...
Searching...
No Matches
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
7namespace Recording
8{
18{
19 void operator()(const RecordData& proc, const TimeVal& msecs, double msec, float val)
20 {
21 // An address whose first value comes after the recording started has
22 // nothing to hold yet.
23 const auto& points = proc.segment.points();
24 if(!points.empty())
25 proc.segment.addPoint(msec - 1, points.rbegin()->second);
26 proc.segment.addPoint(msec, val);
27 static_cast<Automation::ProcessModel*>(proc.curveModel.parent())->setDuration(msecs);
28 }
29};
30
40{
41 void operator()(const RecordData& proc, const TimeVal& msecs, double msec, float val)
42 {
43 proc.segment.addPoint(msec, val);
44 static_cast<Automation::ProcessModel*>(proc.curveModel.parent())->setDuration(msecs);
45 }
46};
47
48template <typename RecordingPolicy>
50{
51 AutomationRecorder& recorder;
52 const State::Address& addr;
53 TimeVal msecs;
54
55 void operator()(std::array<float, 2> val)
56 {
57 const double msec = msecs.msec();
58 auto it = recorder.vec2_records.find(addr);
59 SCORE_ASSERT(it != recorder.vec2_records.end());
60
61 const auto& proc_data = it->second;
62
63 const constexpr std::size_t N = 2;
64 for(std::size_t i = 0; i < N; i++)
65 {
66 RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
67 }
68 }
69
70 void operator()(std::array<float, 3> val)
71 {
72 const double msec = msecs.msec();
73 auto it = recorder.vec3_records.find(addr);
74 SCORE_ASSERT(it != recorder.vec3_records.end());
75
76 const auto& proc_data = it->second;
77
78 const constexpr std::size_t N = 3;
79 for(std::size_t i = 0; i < N; i++)
80 {
81 RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
82 }
83 }
84
85 void operator()(std::array<float, 4> val)
86 {
87 const double msec = msecs.msec();
88 auto it = recorder.vec4_records.find(addr);
89 SCORE_ASSERT(it != recorder.vec4_records.end());
90
91 const auto& proc_data = it->second;
92
93 const constexpr std::size_t N = 4;
94 for(std::size_t i = 0; i < N; i++)
95 {
96 RecordingPolicy{}(proc_data[i], msecs, msec, val[i]);
97 }
98 }
99
100 void handle_numeric(float newval)
101 {
102 const double msec = msecs.msec();
103 auto it = recorder.numeric_records.find(addr);
104 SCORE_ASSERT(it != recorder.numeric_records.end());
105
106 const RecordData& proc_data = it->second;
107
108 RecordingPolicy{}(proc_data, msecs, msec, newval);
109 }
110
111 void operator()(float f) { handle_numeric(f); }
112
113 void operator()(int f) { handle_numeric(f); }
114
115 void operator()(char f) { handle_numeric(f); }
116
117 void operator()(bool f) { handle_numeric(f); }
118
119 template <typename... T>
120 void operator()(const T&...)
121 {
122 }
123};
124}
Definition AutomationModel.hpp:36
Definition RecordManager.hpp:27
The MessagePolicy struct.
Definition RecordAutomationParameterCallbackVisitor.hpp:40
The ParameterPolicy struct.
Definition RecordAutomationParameterCallbackVisitor.hpp:18
Definition RecordAutomationParameterCallbackVisitor.hpp:50
Definition RecordData.hpp:26
The Address struct.
Definition Address.hpp:81
Definition TimeValue.hpp:21