2 #include "confirmsave.h"
9 #include "gainwindow.h"
19 GainConfig::GainConfig()
24 int GainConfig::equivalent(GainConfig &that)
26 return EQUIV(level, that.level);
29 void GainConfig::copy_from(GainConfig &that)
31 this->level = that.level;
34 void GainConfig::interpolate(GainConfig &prev,
38 int64_t current_frame)
40 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
41 double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
42 level = prev.level * prev_scale + next.level * next_scale;
53 Gain::Gain(PluginServer *server)
54 : PluginAClient(server)
56 PLUGIN_CONSTRUCTOR_MACRO
61 PLUGIN_DESTRUCTOR_MACRO
64 char* Gain::plugin_title() { return N_("Gain"); }
65 int Gain::is_realtime() { return 1; }
68 SHOW_GUI_MACRO(Gain, GainThread)
69 SET_STRING_MACRO(Gain)
70 RAISE_WINDOW_MACRO(Gain)
72 LOAD_CONFIGURATION_MACRO(Gain, GainConfig)
74 int Gain::process_realtime(int64_t size, double *input_ptr, double *output_ptr)
78 double gain = db.fromdb(config.level);
80 for(int64_t i = 0; i < size; i++)
82 output_ptr[i] = input_ptr[i] * gain;
90 int Gain::load_defaults()
92 char directory[BCTEXTLEN];
94 // set the default directory
95 sprintf(directory, "%sgain.rc", get_defaultdir());
99 defaults = new BC_Hash(directory);
103 config.level = defaults->get("LEVEL", config.level);
108 int Gain::save_defaults()
110 defaults->update("LEVEL", config.level);
115 void Gain::save_data(KeyFrame *keyframe)
119 // cause xml file to store data directly in text
120 output.set_shared_string(keyframe->data, MESSAGESIZE);
122 output.tag.set_title("GAIN");
123 output.tag.set_property("LEVEL", config.level);
125 output.append_newline();
126 output.terminate_string();
129 void Gain::read_data(KeyFrame *keyframe)
132 // cause xml file to read directly from text
133 input.set_shared_string(keyframe->data, strlen(keyframe->data));
136 result = input.read_tag();
140 if(input.tag.title_is("GAIN"))
142 config.level = input.tag.get_property("LEVEL", config.level);
147 void Gain::update_gui()
151 load_configuration();
152 thread->window->lock_window();
153 thread->window->level->update(config.level);
154 thread->window->unlock_window();