6 FloatAuto::FloatAuto(EDL *edl, FloatAutos *autos)
7 : Auto(edl, (Autos*)autos)
11 control_out_value = 0;
12 control_in_position = 0;
13 control_out_position = 0;
16 FloatAuto::~FloatAuto()
20 int FloatAuto::operator==(Auto &that)
22 return identical((FloatAuto*)&that);
26 int FloatAuto::operator==(FloatAuto &that)
28 return identical((FloatAuto*)&that);
32 int FloatAuto::identical(FloatAuto *src)
34 return EQUIV(value, src->value) &&
35 EQUIV(control_in_value, src->control_in_value) &&
36 EQUIV(control_out_value, src->control_out_value) &&
37 control_in_position == src->control_in_position &&
38 control_out_position == src->control_out_position;
41 float FloatAuto::value_to_percentage()
43 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
44 return (value - autos->min) / (autos->max - autos->min);
47 float FloatAuto::invalue_to_percentage()
49 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
50 return (value + control_in_value - autos->min) /
51 (autos->max - autos->min);
54 float FloatAuto::outvalue_to_percentage()
56 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
57 return (value + control_out_value - autos->min) /
58 (autos->max - autos->min);
61 float FloatAuto::percentage_to_value(float percentage)
63 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
64 return percentage * (autos->max - autos->min) + autos->min;
67 float FloatAuto::percentage_to_invalue(float percentage)
69 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
70 return percentage * (autos->max - autos->min) + autos->min - value;
73 float FloatAuto::percentage_to_outvalue(float percentage)
75 //printf("FloatAuto::value_to_percentage %f %f %f %f\n", value, autos->min, autos->max, (value - autos->min) / (autos->max - autos->min));
76 return percentage * (autos->max - autos->min) + autos->min - value;
79 void FloatAuto::copy_from(Auto *that)
81 copy_from((FloatAuto*)that);
84 void FloatAuto::copy_from(FloatAuto *that)
86 //printf("FloatAuto::copy_from(IntAuto *that) %f %f\n", value, that->value);
87 Auto::copy_from(that);
88 this->value = that->value;
89 this->control_in_value = that->control_in_value;
90 this->control_out_value = that->control_out_value;
91 this->control_in_position = that->control_in_position;
92 this->control_out_position = that->control_out_position;
95 int FloatAuto::value_to_str(char *string, float value)
99 sprintf(string, "+%.2f", value);
101 sprintf(string, "%.2f", value);
110 if(value < 1 && value > -1)
113 string[j] = string[0];
121 while(string[j] != 0) string[i++] = string[j++];
127 void FloatAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
129 file->tag.set_title("AUTO");
131 file->tag.set_property("POSITION", 0);
133 file->tag.set_property("POSITION", position - start);
134 file->tag.set_property("VALUE", value);
135 file->tag.set_property("CONTROL_IN_VALUE", control_in_value);
136 file->tag.set_property("CONTROL_OUT_VALUE", control_out_value);
137 file->tag.set_property("CONTROL_IN_POSITION", control_in_position);
138 file->tag.set_property("CONTROL_OUT_POSITION", control_out_position);
140 file->append_newline();
143 void FloatAuto::load(FileXML *file)
145 value = file->tag.get_property("VALUE", value);
146 control_in_value = file->tag.get_property("CONTROL_IN_VALUE", control_in_value);
147 control_out_value = file->tag.get_property("CONTROL_OUT_VALUE", control_out_value);
148 control_in_position = file->tag.get_property("CONTROL_IN_POSITION", control_in_position);
149 control_out_position = file->tag.get_property("CONTROL_OUT_POSITION", control_out_position);