6 #include "localsession.h"
8 FloatAuto::FloatAuto(EDL *edl, FloatAutos *autos)
9 : Auto(edl, (Autos*)autos)
13 control_out_value = 0;
14 control_in_position = 0;
15 control_out_position = 0;
18 FloatAuto::~FloatAuto()
22 int FloatAuto::operator==(Auto &that)
24 return identical((FloatAuto*)&that);
28 int FloatAuto::operator==(FloatAuto &that)
30 return identical((FloatAuto*)&that);
34 int FloatAuto::identical(FloatAuto *src)
36 return EQUIV(value, src->value) &&
37 EQUIV(control_in_value, src->control_in_value) &&
38 EQUIV(control_out_value, src->control_out_value) &&
39 control_in_position == src->control_in_position &&
40 control_out_position == src->control_out_position;
43 float FloatAuto::value_to_percentage()
46 float automation_min = edl->local_session->automation_mins[autos->autogrouptype];
47 float automation_max = edl->local_session->automation_maxs[autos->autogrouptype];
48 float automation_range = automation_max - automation_min;
49 return (value - automation_min) / automation_range;
52 float FloatAuto::invalue_to_percentage()
55 float automation_min = edl->local_session->automation_mins[autos->autogrouptype];
56 float automation_max = edl->local_session->automation_maxs[autos->autogrouptype];
57 float automation_range = automation_max - automation_min;
58 return (value + control_in_value - automation_min) /
62 float FloatAuto::outvalue_to_percentage()
65 float automation_min = edl->local_session->automation_mins[autos->autogrouptype];
66 float automation_max = edl->local_session->automation_maxs[autos->autogrouptype];
67 float automation_range = automation_max - automation_min;
68 return (value + control_out_value - automation_min) /
72 // float FloatAuto::percentage_to_value(float percentage)
74 // return percentage * (autos->max - autos->min) + autos->min;
77 // float FloatAuto::percentage_to_invalue(float percentage)
79 // return percentage * (autos->max - autos->min) + autos->min - value;
82 // float FloatAuto::percentage_to_outvalue(float percentage)
84 // return percentage * (autos->max - autos->min) + autos->min - value;
87 void FloatAuto::copy_from(Auto *that)
89 copy_from((FloatAuto*)that);
92 void FloatAuto::copy_from(FloatAuto *that)
94 Auto::copy_from(that);
95 this->value = that->value;
96 this->control_in_value = that->control_in_value;
97 this->control_out_value = that->control_out_value;
98 this->control_in_position = that->control_in_position;
99 this->control_out_position = that->control_out_position;
102 int FloatAuto::value_to_str(char *string, float value)
106 sprintf(string, "+%.2f", value);
108 sprintf(string, "%.2f", value);
117 if(value < 1 && value > -1)
120 string[j] = string[0];
128 while(string[j] != 0) string[i++] = string[j++];
134 void FloatAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
136 file->tag.set_title("AUTO");
138 file->tag.set_property("POSITION", 0);
140 file->tag.set_property("POSITION", position - start);
141 file->tag.set_property("VALUE", value);
142 file->tag.set_property("CONTROL_IN_VALUE", control_in_value);
143 file->tag.set_property("CONTROL_OUT_VALUE", control_out_value);
144 file->tag.set_property("CONTROL_IN_POSITION", control_in_position);
145 file->tag.set_property("CONTROL_OUT_POSITION", control_out_position);
147 file->tag.set_title("/AUTO");
149 file->append_newline();
152 void FloatAuto::load(FileXML *file)
154 value = file->tag.get_property("VALUE", value);
155 control_in_value = file->tag.get_property("CONTROL_IN_VALUE", control_in_value);
156 control_out_value = file->tag.get_property("CONTROL_OUT_VALUE", control_out_value);
157 control_in_position = file->tag.get_property("CONTROL_IN_POSITION", control_in_position);
158 control_out_position = file->tag.get_property("CONTROL_OUT_POSITION", control_out_position);