4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcprogressbox.h"
26 #include "recordgui.h"
30 DC_Offset::DC_Offset()
33 getting_dc_offset = 0;
34 for(int i = 0; i < MAXCHANNELS; i++) dc_offset[i] = 0;
35 dc_offset_lock = new Mutex;
38 DC_Offset::~DC_Offset()
40 delete dc_offset_lock;
43 void DC_Offset::calibrate_dc_offset(int *output, RecordGUIDCOffsetText **dc_offset_text, int input_channels)
45 this->output = output;
46 this->dc_offset_text = dc_offset_text;
47 this->input_channels = input_channels;
54 // thread out progress box
55 progress = new BC_ProgressBox((int)BC_INFINITY,
61 dc_offset_lock->lock();
63 for(int i = 0; i < input_channels; i++)
65 dc_offset_total[i] = 0;
68 getting_dc_offset = 1;
70 dc_offset_lock->lock(); // wait for result
71 dc_offset_lock->unlock();
73 // thread in progress box
74 progress->stop_progress();
81 for(i = 0; i < input_channels; i++) output[i] = dc_offset[i];
82 for(i = 0; i < input_channels; i++)
84 sprintf(string, "%d", dc_offset[i]);
85 dc_offset_text[i]->update(string);