00001 #include "bcprogressbox.h" 00002 #include "dcoffset.h" 00003 #include "mutex.h" 00004 #include "recordgui.h" 00005 00006 #include <libintl.h> 00007 #define _(String) gettext(String) 00008 #define gettext_noop(String) String 00009 #define N_(String) gettext_noop (String) 00010 00011 00012 00013 DC_Offset::DC_Offset() 00014 : Thread() 00015 { 00016 getting_dc_offset = 0; 00017 for(int i = 0; i < MAXCHANNELS; i++) dc_offset[i] = 0; 00018 dc_offset_lock = new Mutex; 00019 } 00020 00021 DC_Offset::~DC_Offset() 00022 { 00023 delete dc_offset_lock; 00024 } 00025 00026 int DC_Offset::calibrate_dc_offset(int *output, RecordGUIDCOffsetText **dc_offset_text, int input_channels) 00027 { 00028 this->output = output; 00029 this->dc_offset_text = dc_offset_text; 00030 this->input_channels = input_channels; 00031 start(); 00032 } 00033 00034 00035 void DC_Offset::run() 00036 { 00037 // thread out progress box 00038 progress = new BC_ProgressBox((int)BC_INFINITY, 00039 (int)BC_INFINITY, 00040 _("DC Offset"), 00041 256000); 00042 progress->start(); 00043 00044 dc_offset_lock->lock(); 00045 dc_offset_count = 0; 00046 for(int i = 0; i < input_channels; i++) 00047 { 00048 dc_offset_total[i] = 0; 00049 dc_offset[i] = 0; 00050 } 00051 getting_dc_offset = 1; 00052 00053 dc_offset_lock->lock(); // wait for result 00054 dc_offset_lock->unlock(); 00055 00056 // thread in progress box 00057 progress->stop_progress(); 00058 delete progress; 00059 00060 char string[256]; 00061 int i; 00062 00063 // update interface 00064 for(i = 0; i < input_channels; i++) output[i] = dc_offset[i]; 00065 for(i = 0; i < input_channels; i++) 00066 { 00067 sprintf(string, "%ld", dc_offset[i]); 00068 dc_offset_text[i]->update(string); 00069 } 00070 } 00071
1.5.5