00001 #include "bcdisplayinfo.h"
00002 #include "bcsignals.h"
00003 #include "clip.h"
00004 #include "bchash.h"
00005 #include "filexml.h"
00006 #include "language.h"
00007 #include "parametric.h"
00008 #include "picon_png.h"
00009 #include "units.h"
00010 #include "vframe.h"
00011
00012 #include <math.h>
00013 #include <string.h>
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 REGISTER_PLUGIN(ParametricEQ)
00024
00025
00026
00027
00028
00029
00030
00031
00032 ParametricBand::ParametricBand()
00033 {
00034 freq = 440;
00035 quality = 1;
00036 magnitude = 0;
00037 mode = NONE;
00038 }
00039
00040
00041 int ParametricBand::equivalent(ParametricBand &that)
00042 {
00043 if(freq == that.freq &&
00044 EQUIV(quality, that.quality) &&
00045 EQUIV(magnitude, that.magnitude) &&
00046 mode == that.mode)
00047 {
00048 return 1;
00049 }
00050 else
00051 return 0;
00052 }
00053
00054
00055 void ParametricBand::copy_from(ParametricBand &that)
00056 {
00057 freq = that.freq;
00058 quality = that.quality;
00059 magnitude = that.magnitude;
00060 mode = that.mode;
00061 }
00062
00063 void ParametricBand::interpolate(ParametricBand &prev,
00064 ParametricBand &next,
00065 double prev_scale,
00066 double next_scale)
00067 {
00068 freq = (int)(prev.freq * prev_scale + next.freq * next_scale + 0.5);
00069 quality = prev.quality * prev_scale + next.quality * next_scale;
00070 magnitude = prev.magnitude * prev_scale + next.magnitude * next_scale;
00071 mode = prev.mode;
00072 }
00073
00074
00075
00076
00077
00078 ParametricConfig::ParametricConfig()
00079 {
00080 wetness = INFINITYGAIN;
00081 }
00082
00083
00084 int ParametricConfig::equivalent(ParametricConfig &that)
00085 {
00086 for(int i = 0; i < BANDS; i++)
00087 if(!band[i].equivalent(that.band[i])) return 0;
00088
00089 if(!EQUIV(wetness, that.wetness)) return 0;
00090 return 1;
00091 }
00092
00093 void ParametricConfig::copy_from(ParametricConfig &that)
00094 {
00095 wetness = that.wetness;
00096 for(int i = 0; i < BANDS; i++)
00097 band[i].copy_from(that.band[i]);
00098 }
00099
00100 void ParametricConfig::interpolate(ParametricConfig &prev,
00101 ParametricConfig &next,
00102 int64_t prev_frame,
00103 int64_t next_frame,
00104 int64_t current_frame)
00105 {
00106 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
00107 double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
00108 wetness = prev.wetness;
00109 for(int i = 0; i < BANDS; i++)
00110 {
00111 band[i].interpolate(prev.band[i], next.band[i], prev_scale, next_scale);
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 ParametricFreq::ParametricFreq(ParametricEQ *plugin, int x, int y, int band)
00134 : BC_QPot(x, y, plugin->config.band[band].freq)
00135 {
00136 this->plugin = plugin;
00137 this->band = band;
00138 }
00139
00140 int ParametricFreq::handle_event()
00141 {
00142 plugin->config.band[band].freq = get_value();
00143 plugin->send_configure_change();
00144 plugin->thread->window->update_canvas();
00145 return 1;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155 ParametricQuality::ParametricQuality(ParametricEQ *plugin, int x, int y, int band)
00156 : BC_FPot(x, y, plugin->config.band[band].quality, 0, 1)
00157 {
00158 this->plugin = plugin;
00159 this->band = band;
00160 set_precision(0.01);
00161 }
00162
00163 int ParametricQuality::handle_event()
00164 {
00165 plugin->config.band[band].quality = get_value();
00166 plugin->send_configure_change();
00167 plugin->thread->window->update_canvas();
00168 return 1;
00169 }
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 ParametricMagnitude::ParametricMagnitude(ParametricEQ *plugin, int x, int y, int band)
00182 : BC_FPot(x, y, plugin->config.band[band].magnitude, -MAXMAGNITUDE, MAXMAGNITUDE)
00183 {
00184 this->plugin = plugin;
00185 this->band = band;
00186 }
00187
00188 int ParametricMagnitude::handle_event()
00189 {
00190 plugin->config.band[band].magnitude = get_value();
00191 plugin->send_configure_change();
00192 plugin->thread->window->update_canvas();
00193 return 1;
00194 }
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 ParametricMode::ParametricMode(ParametricEQ *plugin, int x, int y, int band)
00205 : BC_PopupMenu(x,
00206 y,
00207 150,
00208 mode_to_text(plugin->config.band[band].mode))
00209 {
00210
00211 this->plugin = plugin;
00212 this->band = band;
00213 }
00214
00215 void ParametricMode::create_objects()
00216 {
00217 add_item(new BC_MenuItem(mode_to_text(ParametricBand::LOWPASS)));
00218 add_item(new BC_MenuItem(mode_to_text(ParametricBand::HIGHPASS)));
00219 add_item(new BC_MenuItem(mode_to_text(ParametricBand::BANDPASS)));
00220 add_item(new BC_MenuItem(mode_to_text(ParametricBand::NONE)));
00221 }
00222
00223
00224 int ParametricMode::handle_event()
00225 {
00226 plugin->config.band[band].mode = text_to_mode(get_text());
00227 plugin->send_configure_change();
00228 plugin->thread->window->update_canvas();
00229 return 1;
00230 }
00231
00232 int ParametricMode::text_to_mode(char *text)
00233 {
00234 if(!strcmp(mode_to_text(ParametricBand::LOWPASS), text)) return ParametricBand::LOWPASS;
00235 if(!strcmp(mode_to_text(ParametricBand::HIGHPASS), text)) return ParametricBand::HIGHPASS;
00236 if(!strcmp(mode_to_text(ParametricBand::BANDPASS), text)) return ParametricBand::BANDPASS;
00237 if(!strcmp(mode_to_text(ParametricBand::NONE), text)) return ParametricBand::NONE;
00238 return ParametricBand::BANDPASS;
00239 }
00240
00241
00242
00243 char* ParametricMode::mode_to_text(int mode)
00244 {
00245 switch(mode)
00246 {
00247 case ParametricBand::LOWPASS:
00248 return _("Lowpass");
00249 break;
00250 case ParametricBand::HIGHPASS:
00251 return _("Highpass");
00252 break;
00253 case ParametricBand::BANDPASS:
00254 return _("Bandpass");
00255 break;
00256 case ParametricBand::NONE:
00257 return _("None");
00258 break;
00259 }
00260 return "";
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 ParametricBandGUI::ParametricBandGUI(ParametricEQ *plugin, ParametricWindow *window, int x, int y, int band)
00274 {
00275 this->plugin = plugin;
00276 this->band = band;
00277 this->window = window;
00278 this->x = x;
00279 this->y = y;
00280 }
00281
00282 ParametricBandGUI::~ParametricBandGUI()
00283 {
00284 }
00285
00286
00287 #define X1 10
00288 #define X2 60
00289 #define X3 110
00290 #define X4 160
00291
00292
00293 void ParametricBandGUI::create_objects()
00294 {
00295 window->add_subwindow(freq = new ParametricFreq(plugin, X1, y, band));
00296 window->add_subwindow(quality = new ParametricQuality(plugin, X2, y, band));
00297 window->add_subwindow(magnitude = new ParametricMagnitude(plugin, X3, y, band));
00298 window->add_subwindow(mode = new ParametricMode(plugin, X4, y, band));
00299 mode->create_objects();
00300 }
00301
00302 void ParametricBandGUI::update_gui()
00303 {
00304 freq->update(plugin->config.band[band].freq);
00305 quality->update(plugin->config.band[band].quality);
00306 magnitude->update(plugin->config.band[band].magnitude);
00307 }
00308
00309
00310
00311
00312
00313
00314 ParametricWetness::ParametricWetness(ParametricEQ *plugin, int x, int y)
00315 : BC_FPot(x, y, plugin->config.wetness, INFINITYGAIN, 0)
00316 {
00317 this->plugin = plugin;
00318 }
00319
00320 int ParametricWetness::handle_event()
00321 {
00322 plugin->config.wetness = get_value();
00323 plugin->send_configure_change();
00324 plugin->thread->window->update_canvas();
00325 return 1;
00326 }
00327
00328
00329
00330
00331
00332
00333 ParametricWindow::ParametricWindow(ParametricEQ *plugin, int x, int y)
00334 : BC_Window(plugin->gui_string,
00335 x,
00336 y,
00337 320,
00338 400,
00339 320,
00340 400,
00341 0,
00342 0,
00343 1)
00344 {
00345 this->plugin = plugin;
00346 }
00347
00348 ParametricWindow::~ParametricWindow()
00349 {
00350 for(int i = 0; i < BANDS; i++)
00351 delete bands[i];
00352 }
00353
00354 void ParametricWindow::create_objects()
00355 {
00356 int y = 35;
00357 SET_TRACE
00358
00359 add_subwindow(new BC_Title(X1, 10, _("Freq")));
00360 add_subwindow(new BC_Title(X2, 10, _("Qual")));
00361 add_subwindow(new BC_Title(X3, 10, _("Level")));
00362 add_subwindow(new BC_Title(X4, 10, _("Mode")));
00363 for(int i = 0; i < BANDS; i++)
00364 {
00365 bands[i] = new ParametricBandGUI(plugin, this, 10, y, i);
00366 bands[i]->create_objects();
00367 y += 50;
00368 }
00369
00370 SET_TRACE
00371 add_subwindow(new BC_Title(10, y + 10, _("Wetness:")));
00372 add_subwindow(wetness = new ParametricWetness(plugin, 80, y));
00373 y += 50;
00374 int canvas_x = 30;
00375 int canvas_y = y;
00376 int canvas_w = get_w() - canvas_x - 10;
00377 int canvas_h = get_h() - canvas_y - 30;
00378 add_subwindow(canvas = new BC_SubWindow(canvas_x,
00379 canvas_y,
00380 canvas_w,
00381 canvas_h,
00382 WHITE));
00383
00384 SET_TRACE
00385
00386 set_font(SMALLFONT);
00387 #define MAJOR_DIVISIONS 4
00388 #define MINOR_DIVISIONS 5
00389 for(int i = 0; i <= MAJOR_DIVISIONS; i++)
00390 {
00391 int y1 = canvas_y + canvas_h - i * (canvas_h / MAJOR_DIVISIONS) - 2;
00392 int y2 = y1 + 3;
00393 int x1 = canvas_x - 25;
00394 int x2 = canvas_x - 10;
00395 int x3 = canvas_x - 2;
00396
00397 char string[BCTEXTLEN];
00398 if(i == 0)
00399 sprintf(string, "oo");
00400 else
00401 sprintf(string, "%d", i * 5 - 5);
00402
00403 set_color(BLACK);
00404 draw_text(x1 + 1, y2 + 1, string);
00405 draw_line(x2 + 1, y1 + 1, x3 + 1, y1 + 1);
00406 set_color(RED);
00407 draw_text(x1, y2, string);
00408 draw_line(x2, y1, x3, y1);
00409
00410 if(i < MAJOR_DIVISIONS)
00411 {
00412 for(int j = 1; j < MINOR_DIVISIONS; j++)
00413 {
00414 int y3 = y1 - j * (canvas_h / MAJOR_DIVISIONS) / MINOR_DIVISIONS;
00415 int x4 = x3 - 5;
00416 set_color(BLACK);
00417 draw_line(x4 + 1, y3 + 1, x3 + 1, y3 + 1);
00418 set_color(RED);
00419 draw_line(x4, y3, x3, y3);
00420 }
00421 }
00422 }
00423
00424 SET_TRACE
00425 #undef MAJOR_DIVISIONS
00426 #define MAJOR_DIVISIONS 5
00427 for(int i = 0; i <= MAJOR_DIVISIONS; i++)
00428 {
00429 int freq = Freq::tofreq(i * TOTALFREQS / MAJOR_DIVISIONS);
00430 int x1 = canvas_x + i * canvas_w / MAJOR_DIVISIONS;
00431 int y1 = canvas_y + canvas_h + 20;
00432 char string[BCTEXTLEN];
00433 sprintf(string, "%d", freq);
00434 int x2 = x1 - get_text_width(SMALLFONT, string);
00435 int y2 = y1 - 10;
00436 int y3 = y2 - 5;
00437 int y4 = canvas_y + canvas_h;
00438
00439 set_color(BLACK);
00440 draw_text(x2 + 1, y1 + 1, string);
00441 draw_line(x1 + 1, y4 + 1, x1 + 1, y2 + 1);
00442 set_color(RED);
00443 draw_text(x2, y1, string);
00444 draw_line(x1, y4, x1, y2);
00445
00446 if(i < MAJOR_DIVISIONS)
00447 {
00448 #undef MINOR_DIVISIONS
00449 #define MINOR_DIVISIONS 5
00450 for(int j = 0; j < MINOR_DIVISIONS; j++)
00451 {
00452 int x3 = (int)(x1 +
00453 (canvas_w / MAJOR_DIVISIONS) -
00454 exp(-(double)j * 0.7) *
00455 (canvas_w / MAJOR_DIVISIONS));
00456 set_color(BLACK);
00457 draw_line(x3 + 1, y4 + 1, x3 + 1, y3 + 1);
00458 set_color(RED);
00459 draw_line(x3, y4, x3, y3);
00460 }
00461 }
00462 }
00463
00464 SET_TRACE
00465 update_canvas();
00466 show_window();
00467 SET_TRACE
00468 }
00469
00470 int ParametricWindow::close_event()
00471 {
00472
00473 set_done(1);
00474 return 1;
00475 }
00476
00477 void ParametricWindow::update_gui()
00478 {
00479 for(int i = 0; i < BANDS; i++)
00480 bands[i]->update_gui();
00481 wetness->update(plugin->config.wetness);
00482 update_canvas();
00483 }
00484
00485
00486 void ParametricWindow::update_canvas()
00487 {
00488 double scale = 1;
00489 int y1 = canvas->get_h() / 2;
00490 int niquist = plugin->PluginAClient::project_sample_rate / 2;
00491 int wetness = canvas->get_h() -
00492 (int)((plugin->config.wetness - INFINITYGAIN) /
00493 -INFINITYGAIN *
00494 canvas->get_h() /
00495 4);
00496
00497 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
00498
00499
00500
00501
00502
00503
00504 canvas->set_color(BLACK);
00505
00506 plugin->calculate_envelope();
00507 for(int i = 0; i < canvas->get_w() - 1; i++)
00508 {
00509 int freq = Freq::tofreq(i * TOTALFREQS / canvas->get_w());
00510 int index = freq * WINDOW_SIZE / 2 / niquist;
00511 if(freq < niquist)
00512 {
00513 double magnitude = plugin->envelope[index];
00514 int y2 = canvas->get_h() * 3 / 4;
00515
00516 if(magnitude > 1)
00517 {
00518 y2 -= (int)(DB::todb(magnitude) *
00519 canvas->get_h() *
00520 3 /
00521 4 /
00522 15);
00523 }
00524 else
00525 {
00526 y2 += (int)((1 - magnitude) * canvas->get_h() / 4);
00527 }
00528 if(i > 0) canvas->draw_line(i - 1, y1, i, y2);
00529 y1 = y2;
00530 }
00531 else
00532 {
00533 canvas->draw_line(i - 1, y1, i, y1);
00534 }
00535 }
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 canvas->flash();
00550 }
00551
00552
00553
00554
00555
00556
00557
00558 PLUGIN_THREAD_OBJECT(ParametricEQ, ParametricThread, ParametricWindow)
00559
00560
00561
00562
00563
00564
00565
00566 ParametricFFT::ParametricFFT(ParametricEQ *plugin)
00567 : CrossfadeFFT()
00568 {
00569 this->plugin = plugin;
00570 }
00571
00572 ParametricFFT::~ParametricFFT()
00573 {
00574 }
00575
00576
00577 int ParametricFFT::signal_process()
00578 {
00579 for(int i = 0; i < window_size / 2; i++)
00580 {
00581 double result = plugin->envelope[i] * sqrt(freq_real[i] * freq_real[i] + freq_imag[i] * freq_imag[i]);
00582 double angle = atan2(freq_imag[i], freq_real[i]);
00583 freq_real[i] = result * cos(angle);
00584 freq_imag[i] = result * sin(angle);
00585 }
00586
00587 symmetry(window_size, freq_real, freq_imag);
00588 return 0;
00589 }
00590
00591 int ParametricFFT::read_samples(int64_t output_sample,
00592 int samples,
00593 double *buffer)
00594 {
00595 return plugin->read_samples(buffer,
00596 0,
00597 plugin->get_samplerate(),
00598 output_sample,
00599 samples);
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609 ParametricEQ::ParametricEQ(PluginServer *server)
00610 : PluginAClient(server)
00611 {
00612 PLUGIN_CONSTRUCTOR_MACRO
00613 fft = 0;
00614 need_reconfigure = 1;
00615 }
00616
00617 ParametricEQ::~ParametricEQ()
00618 {
00619 PLUGIN_DESTRUCTOR_MACRO
00620
00621 if(fft) delete fft;
00622 }
00623
00624 NEW_PICON_MACRO(ParametricEQ)
00625
00626 SHOW_GUI_MACRO(ParametricEQ, ParametricThread)
00627
00628 RAISE_WINDOW_MACRO(ParametricEQ)
00629
00630 SET_STRING_MACRO(ParametricEQ)
00631
00632 LOAD_CONFIGURATION_MACRO(ParametricEQ, ParametricConfig)
00633
00634
00635 char* ParametricEQ::plugin_title() { return N_("EQ Parametric"); }
00636 int ParametricEQ::is_realtime() { return 1; }
00637
00638 void ParametricEQ::read_data(KeyFrame *keyframe)
00639 {
00640 FileXML input;
00641 input.set_shared_string(keyframe->data, strlen(keyframe->data));
00642
00643 int result = 0;
00644 while(!result)
00645 {
00646 result = input.read_tag();
00647
00648 if(!result)
00649 {
00650 if(input.tag.title_is("PARAMETRICEQ"))
00651 {
00652 config.wetness = input.tag.get_property("WETNESS", config.wetness);
00653 }
00654 else
00655 if(input.tag.title_is("BAND"))
00656 {
00657 int band = input.tag.get_property("NUMBER", 0);
00658 config.band[band].freq = input.tag.get_property("FREQ", config.band[band].freq);
00659 config.band[band].quality = input.tag.get_property("QUALITY", config.band[band].quality);
00660 config.band[band].magnitude = input.tag.get_property("MAGNITUDE", config.band[band].magnitude);
00661 config.band[band].mode = input.tag.get_property("MODE", config.band[band].mode);
00662 }
00663 }
00664 }
00665 }
00666
00667 void ParametricEQ::save_data(KeyFrame *keyframe)
00668 {
00669 FileXML output;
00670 output.set_shared_string(keyframe->data, MESSAGESIZE);
00671
00672 output.tag.set_title("PARAMETRICEQ");
00673 output.tag.set_property("WETNESS", config.wetness);
00674 output.append_tag();
00675 output.append_newline();
00676
00677 for(int i = 0; i < BANDS; i++)
00678 {
00679 output.tag.set_title("BAND");
00680 output.tag.set_property("NUMBER", i);
00681 output.tag.set_property("FREQ", config.band[i].freq);
00682 output.tag.set_property("QUALITY", config.band[i].quality);
00683 output.tag.set_property("MAGNITUDE", config.band[i].magnitude);
00684 output.tag.set_property("MODE", config.band[i].mode);
00685 output.append_tag();
00686 output.tag.set_title("/BAND");
00687 output.append_tag();
00688 output.append_newline();
00689 }
00690
00691 output.tag.set_title("/PARAMETRICEQ");
00692 output.append_tag();
00693 output.terminate_string();
00694 }
00695
00696 void ParametricEQ::reconfigure()
00697 {
00698 if(!fft)
00699 {
00700 fft = new ParametricFFT(this);
00701 fft->initialize(WINDOW_SIZE);
00702 }
00703
00704
00705
00706
00707 calculate_envelope();
00708
00709 for(int i = 0; i < WINDOW_SIZE / 2; i++)
00710 {
00711 if(envelope[i] < 0) envelope[i] = 0;
00712 }
00713
00714 need_reconfigure = 0;
00715 }
00716
00717 double ParametricEQ::calculate_envelope()
00718 {
00719 double wetness = DB::fromdb(config.wetness);
00720 int niquist = PluginAClient::project_sample_rate / 2;
00721
00722
00723
00724 for(int i = 0; i < WINDOW_SIZE / 2; i++)
00725 {
00726 envelope[i] = wetness;
00727 }
00728
00729 for(int pass = 0; pass < 2; pass++)
00730 {
00731 for(int band = 0; band < BANDS; band++)
00732 {
00733 switch(config.band[band].mode)
00734 {
00735 case ParametricBand::LOWPASS:
00736 if(pass == 1)
00737 {
00738 double magnitude = DB::fromdb(config.band[band].magnitude);
00739 int cutoff = (int)((float)config.band[band].freq / niquist * WINDOW_SIZE / 2);
00740 for(int i = 0; i < WINDOW_SIZE / 2; i++)
00741 {
00742 if(i < cutoff)
00743 envelope[i] += magnitude;
00744 }
00745 }
00746 break;
00747
00748 case ParametricBand::HIGHPASS:
00749 if(pass == 1)
00750 {
00751 double magnitude = DB::fromdb(config.band[band].magnitude);
00752 int cutoff = (int)((float)config.band[band].freq / niquist * WINDOW_SIZE / 2);
00753 for(int i = 0; i < WINDOW_SIZE / 2; i++)
00754 {
00755 if(i > cutoff)
00756 envelope[i] += magnitude;
00757 }
00758 }
00759 break;
00760
00761 case ParametricBand::BANDPASS:
00762 if(pass == 0)
00763 {
00764 double magnitude = (config.band[band].magnitude > 0) ?
00765 (DB::fromdb(config.band[band].magnitude) - 1) :
00766 (-1 + DB::fromdb(config.band[band].magnitude));
00767 double sigma = (config.band[band].quality < 1) ?
00768 (1.0 - config.band[band].quality) :
00769 0.01;
00770 sigma /= 4;
00771 double a = (double)config.band[band].freq / niquist;
00772 double normalize = gauss(sigma, 0, 0);
00773 if(config.band[band].magnitude <= -MAXMAGNITUDE)
00774 magnitude = -1;
00775
00776 for(int i = 0; i < WINDOW_SIZE / 2; i++)
00777 envelope[i] += magnitude *
00778 gauss(sigma, a, (double)i / (WINDOW_SIZE / 2)) /
00779 normalize;
00780 }
00781 break;
00782 }
00783 }
00784 }
00785 return 0;
00786 }
00787
00788 double ParametricEQ::gauss(double sigma, double a, double x)
00789 {
00790 if(EQUIV(sigma, 0)) sigma = 0.01;
00791
00792 return 1.0 /
00793 sqrt(2 * M_PI * sigma * sigma) *
00794 exp(-(x - a) * (x - a) /
00795 (2 * sigma * sigma));
00796 }
00797
00798
00799
00800 int ParametricEQ::process_buffer(int64_t size,
00801 double *buffer,
00802 int64_t start_position,
00803 int sample_rate)
00804 {
00805 need_reconfigure |= load_configuration();
00806 if(need_reconfigure) reconfigure();
00807
00808
00809 fft->process_buffer(start_position, size, buffer, get_direction());
00810 return 0;
00811 }
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821 int ParametricEQ::load_defaults()
00822 {
00823 char directory[BCTEXTLEN], string[BCTEXTLEN];
00824 sprintf(directory, "%sparametriceq.rc", BCASTDIR);
00825 defaults = new BC_Hash(directory);
00826 defaults->load();
00827
00828 config.wetness = defaults->get("WETNESS", config.wetness);
00829 for(int i = 0; i < BANDS; i++)
00830 {
00831 sprintf(string, "FREQ_%d", i);
00832 config.band[i].freq = defaults->get(string, config.band[i].freq);
00833 sprintf(string, "QUALITY_%d", i);
00834 config.band[i].quality = defaults->get(string, config.band[i].quality);
00835 sprintf(string, "MAGNITUDE_%d", i);
00836 config.band[i].magnitude = defaults->get(string, config.band[i].magnitude);
00837 sprintf(string, "MODE_%d", i);
00838 config.band[i].mode = defaults->get(string, config.band[i].mode);
00839 }
00840 return 0;
00841 }
00842
00843 int ParametricEQ::save_defaults()
00844 {
00845 char string[BCTEXTLEN];
00846
00847 defaults->update("WETNESS", config.wetness);
00848
00849
00850 for(int i = 0; i < BANDS; i++)
00851 {
00852 sprintf(string, "FREQ_%d", i);
00853 defaults->update(string, config.band[i].freq);
00854 sprintf(string, "QUALITY_%d", i);
00855 defaults->update(string, config.band[i].quality);
00856 sprintf(string, "MAGNITUDE_%d", i);
00857 defaults->update(string, config.band[i].magnitude);
00858 sprintf(string, "MODE_%d", i);
00859 defaults->update(string, config.band[i].mode);
00860 }
00861
00862
00863 defaults->save();
00864
00865 return 0;
00866 }
00867
00868
00869 void ParametricEQ::reset()
00870 {
00871 need_reconfigure = 1;
00872 thread = 0;
00873 fft = 0;
00874 }
00875
00876 void ParametricEQ::update_gui()
00877 {
00878 if(thread)
00879 {
00880 load_configuration();
00881 thread->window->lock_window("ParametricEQ::update_gui");
00882 thread->window->update_gui();
00883 thread->window->unlock_window();
00884 }
00885 }
00886
00887
00888