2 #include "confirmsave.h"
8 #include "gainwindow.h"
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
23 GainConfig::GainConfig()
28 int GainConfig::equivalent(GainConfig &that)
30 return EQUIV(level, that.level);
33 void GainConfig::copy_from(GainConfig &that)
35 this->level = that.level;
38 void GainConfig::interpolate(GainConfig &prev,
42 int64_t current_frame)
44 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
45 double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
46 level = prev.level * prev_scale + next.level * next_scale;
57 Gain::Gain(PluginServer *server)
58 : PluginAClient(server)
60 PLUGIN_CONSTRUCTOR_MACRO
65 PLUGIN_DESTRUCTOR_MACRO
68 char* Gain::plugin_title() { return _("Gain"); }
69 int Gain::is_realtime() { return 1; }
72 SHOW_GUI_MACRO(Gain, GainThread)
73 SET_STRING_MACRO(Gain)
74 RAISE_WINDOW_MACRO(Gain)
76 LOAD_CONFIGURATION_MACRO(Gain, GainConfig)
78 int Gain::process_realtime(int64_t size, double *input_ptr, double *output_ptr)
82 double gain = db.fromdb(config.level);
84 for(int64_t i = 0; i < size; i++)
86 output_ptr[i] = input_ptr[i] * gain;
94 int Gain::load_defaults()
98 // set the default directory
99 sprintf(directory, "%sgain.rc", get_defaultdir());
103 defaults = new Defaults(directory);
107 config.level = defaults->get("LEVEL", config.level);
112 int Gain::save_defaults()
114 defaults->update("LEVEL", config.level);
119 void Gain::save_data(KeyFrame *keyframe)
123 // cause xml file to store data directly in text
124 output.set_shared_string(keyframe->data, MESSAGESIZE);
126 output.tag.set_title("GAIN");
127 output.tag.set_property("LEVEL", config.level);
129 output.append_newline();
130 output.terminate_string();
133 void Gain::read_data(KeyFrame *keyframe)
136 // cause xml file to read directly from text
137 input.set_shared_string(keyframe->data, strlen(keyframe->data));
140 result = input.read_tag();
144 if(input.tag.title_is("GAIN"))
146 config.level = input.tag.get_property("LEVEL", config.level);
151 void Gain::update_gui()
155 load_configuration();
156 thread->window->lock_window();
157 thread->window->level->update(config.level);
158 thread->window->unlock_window();