Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

intautos.C

Go to the documentation of this file.
00001 #include "automation.inc"
00002 #include "clip.h"
00003 #include "intauto.h"
00004 #include "intautos.h"
00005 
00006 IntAutos::IntAutos(EDL *edl, Track *track, int default_)
00007  : Autos(edl, track)
00008 {
00009         this->default_ = default_;
00010         type = AUTOMATION_TYPE_INT;
00011 }
00012 
00013 IntAutos::~IntAutos()
00014 {
00015 }
00016 
00017 
00018 Auto* IntAutos::new_auto()
00019 {
00020         IntAuto *result = new IntAuto(edl, this);
00021         result->value = default_;
00022         return result;
00023 }
00024 
00025 int IntAutos::automation_is_constant(int64_t start, int64_t end)
00026 {
00027         Auto *current_auto, *before = 0, *after = 0;
00028         int result;
00029 
00030         result = 1;          // default to constant
00031         if(!last && !first) return result; // no automation at all
00032 
00033 // quickly get autos just outside range 
00034         get_neighbors(start, end, &before, &after);
00035 
00036 // autos before range
00037         if(before) 
00038                 current_auto = before;   // try first auto
00039         else 
00040                 current_auto = first;
00041 
00042 // test autos in range  
00043         for( ; result && 
00044                 current_auto && 
00045                 current_auto->next && 
00046                 current_auto->position < end; 
00047                 current_auto = current_auto->next)
00048         {
00049 // not constant
00050                 if(((IntAuto*)current_auto->next)->value != ((IntAuto*)current_auto)->value) 
00051                         result = 0;
00052         }
00053 
00054         return result;
00055 }
00056 
00057 double IntAutos::get_automation_constant(int64_t start, int64_t end)
00058 {
00059         Auto *current_auto, *before = 0, *after = 0;
00060         
00061 // quickly get autos just outside range 
00062         get_neighbors(start, end, &before, &after);
00063 
00064 // no auto before range so use first
00065         if(before)
00066                 current_auto = before;
00067         else
00068                 current_auto = first;
00069 
00070 // no autos at all so use default value
00071         if(!current_auto) current_auto = default_auto;
00072 
00073         return ((IntAuto*)current_auto)->value;
00074 }
00075 
00076 
00077 void IntAutos::get_extents(float *min, 
00078         float *max,
00079         int *coords_undefined,
00080         int64_t unit_start,
00081         int64_t unit_end)
00082 {
00083         if(!first)
00084         {
00085                 IntAuto *current = (IntAuto*)default_auto;
00086                 if(*coords_undefined)
00087                 {
00088                         *min = *max = current->value;
00089                         *coords_undefined = 0;
00090                 }
00091 
00092                 *min = MIN(current->value, *min);
00093                 *max = MAX(current->value, *max);
00094         }
00095 
00096         for(IntAuto *current = (IntAuto*)first; current; current = (IntAuto*)NEXT)
00097         {
00098                 if(current->position >= unit_start && current->position < unit_end)
00099                 {
00100                         if(coords_undefined)
00101                         {
00102                                 *max = *min = current->value;
00103                                 *coords_undefined = 0;
00104                         }
00105                         else
00106                         {
00107                                 *min = MIN(current->value, *min);
00108                                 *max = MAX(current->value, *max);
00109                         }
00110                 }
00111         }
00112 }
00113 
00114 void IntAutos::dump()
00115 {
00116         printf("        Default %p: position: %ld value: %d\n", default_auto, default_auto->position, ((IntAuto*)default_auto)->value);
00117         for(Auto* current = first; current; current = NEXT)
00118         {
00119                 printf("        %p position: %ld value: %d\n", current, current->position, ((IntAuto*)current)->value);
00120         }
00121 }

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4