1 #include "automation.inc"
6 IntAutos::IntAutos(EDL *edl, Track *track, int default_)
9 this->default_ = default_;
10 type = AUTOMATION_TYPE_INT;
18 Auto* IntAutos::new_auto()
20 IntAuto *result = new IntAuto(edl, this);
21 result->value = default_;
25 int IntAutos::automation_is_constant(int64_t start, int64_t end)
27 Auto *current_auto, *before = 0, *after = 0;
30 result = 1; // default to constant
31 if(!last && !first) return result; // no automation at all
33 // quickly get autos just outside range
34 get_neighbors(start, end, &before, &after);
38 current_auto = before; // try first auto
42 // test autos in range
46 current_auto->position < end;
47 current_auto = current_auto->next)
50 if(((IntAuto*)current_auto->next)->value != ((IntAuto*)current_auto)->value)
57 double IntAutos::get_automation_constant(int64_t start, int64_t end)
59 Auto *current_auto, *before = 0, *after = 0;
61 // quickly get autos just outside range
62 get_neighbors(start, end, &before, &after);
64 // no auto before range so use first
66 current_auto = before;
70 // no autos at all so use default value
71 if(!current_auto) current_auto = default_auto;
73 return ((IntAuto*)current_auto)->value;
77 void IntAutos::get_extents(float *min,
79 int *coords_undefined,
85 IntAuto *current = (IntAuto*)default_auto;
88 *min = *max = current->value;
89 *coords_undefined = 0;
92 *min = MIN(current->value, *min);
93 *max = MAX(current->value, *max);
96 for(IntAuto *current = (IntAuto*)first; current; current = (IntAuto*)NEXT)
98 if(current->position >= unit_start && current->position < unit_end)
102 *max = *min = current->value;
103 *coords_undefined = 0;
107 *min = MIN(current->value, *min);
108 *max = MAX(current->value, *max);
114 void IntAutos::dump()
116 printf(" Default %p: position: %ld value: %d\n", default_auto, default_auto->position, ((IntAuto*)default_auto)->value);
117 for(Auto* current = first; current; current = NEXT)
119 printf(" %p position: %ld value: %d\n", current, current->position, ((IntAuto*)current)->value);
125 // c-file-style: "linux"