r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / dcoffset.C
blobe7da81208c2597b80a859d4013a6fcb7a5682498
1 #include "bcprogressbox.h"
2 #include "dcoffset.h"
3 #include "mutex.h"
4 #include "recordgui.h"
6 #include <libintl.h>
7 #define _(String) gettext(String)
8 #define gettext_noop(String) String
9 #define N_(String) gettext_noop (String)
13 DC_Offset::DC_Offset()
14  : Thread()
16         getting_dc_offset = 0;
17         for(int i = 0; i < MAXCHANNELS; i++) dc_offset[i] = 0;
18         dc_offset_lock = new Mutex;
21 DC_Offset::~DC_Offset()
23         delete dc_offset_lock;
26 int DC_Offset::calibrate_dc_offset(int *output, RecordGUIDCOffsetText **dc_offset_text, int input_channels)
28         this->output = output;
29         this->dc_offset_text = dc_offset_text;
30         this->input_channels = input_channels;
31         start();
35 void DC_Offset::run()
37 // thread out progress box
38         progress = new BC_ProgressBox((int)BC_INFINITY, 
39                 (int)BC_INFINITY, 
40                 _("DC Offset"), 
41                 256000);
42         progress->start();
44         dc_offset_lock->lock();
45         dc_offset_count = 0;
46         for(int i = 0; i < input_channels; i++) 
47         {
48                 dc_offset_total[i] = 0;
49                 dc_offset[i] = 0;
50         }
51         getting_dc_offset = 1;
52         
53         dc_offset_lock->lock();       // wait for result
54         dc_offset_lock->unlock();
56 // thread in progress box
57         progress->stop_progress();
58         delete progress;
59         
60         char string[256];
61         int i;
63 // update interface
64         for(i = 0; i < input_channels; i++) output[i] = dc_offset[i];
65         for(i = 0; i < input_channels; i++)
66         {
67                 sprintf(string, "%ld", dc_offset[i]);
68                 dc_offset_text[i]->update(string);
69         }