prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / dcoffset.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #include "bcprogressbox.h"
23 #include "dcoffset.h"
24 #include "language.h"
25 #include "mutex.h"
26 #include "recordgui.h"
27
28
29
30 DC_Offset::DC_Offset()
31  : Thread()
32 {
33         getting_dc_offset = 0;
34         for(int i = 0; i < MAXCHANNELS; i++) dc_offset[i] = 0;
35         dc_offset_lock = new Mutex;
36 }
37
38 DC_Offset::~DC_Offset()
39 {
40         delete dc_offset_lock;
41 }
42
43 int DC_Offset::calibrate_dc_offset(int *output, RecordGUIDCOffsetText **dc_offset_text, int input_channels)
44 {
45         this->output = output;
46         this->dc_offset_text = dc_offset_text;
47         this->input_channels = input_channels;
48         start();
49         return 0;
50 }
51
52
53 void DC_Offset::run()
54 {
55 // thread out progress box
56         progress = new BC_ProgressBox((int)BC_INFINITY, 
57                 (int)BC_INFINITY, 
58                 _("DC Offset"), 
59                 256000);
60         progress->start();
61
62         dc_offset_lock->lock();
63         dc_offset_count = 0;
64         for(int i = 0; i < input_channels; i++) 
65         {
66                 dc_offset_total[i] = 0;
67                 dc_offset[i] = 0;
68         }
69         getting_dc_offset = 1;
70         
71         dc_offset_lock->lock();       // wait for result
72         dc_offset_lock->unlock();
73
74 // thread in progress box
75         progress->stop_progress();
76         delete progress;
77         
78         char string[256];
79         int i;
80
81 // update interface
82         for(i = 0; i < input_channels; i++) output[i] = dc_offset[i];
83         for(i = 0; i < input_channels; i++)
84         {
85                 sprintf(string, "%ld", (long)dc_offset[i]);
86                 dc_offset_text[i]->update(string);
87         }
88 }
89