1 #include "bcdisplayinfo.h"
6 #include "mainprogress.h"
7 #include "pluginaclient.h"
13 #define _(String) gettext(String)
14 #define gettext_noop(String) String
15 #define N_(String) gettext_noop (String)
25 class InterpolateAllEffect : public PluginAClient
28 InterpolateAllEffect(PluginServer *server);
29 ~InterpolateAllEffect();
33 int is_multichannel();
36 int process_loop(double *buffer, long &output_lenght);
54 MainProgressBar *progress;
60 REGISTER_PLUGIN(InterpolateAllEffect)
69 InterpolateAllEffect::InterpolateAllEffect(PluginServer *server)
70 : PluginAClient(server)
74 InterpolateAllEffect::~InterpolateAllEffect()
81 char* InterpolateAllEffect::plugin_title()
83 return _("Interpolate");
87 int InterpolateAllEffect::is_realtime()
92 int InterpolateAllEffect::is_multichannel()
98 int InterpolateAllEffect::get_parameters()
103 int InterpolateAllEffect::start_loop()
106 char string[BCTEXTLEN];
107 sprintf(string, "%s...", plugin_title());
108 progress = start_progress(string, (PluginClient::end - PluginClient::start));
109 current_position = PluginClient::start;
113 int InterpolateAllEffect::stop_loop()
115 progress->stop_progress();
120 int InterpolateAllEffect::process_loop(double *buffer, long &write_length)
122 //printf("InterpolateAllEffect::process_loop 1\n");
126 // Read a certain amount before the first sample
127 int leadin = PluginClient::in_buffer_size;
128 //printf("InterpolateAllEffect::process_loop 2\n");
129 double buffer[leadin];
130 if(PluginClient::start - leadin < 0) leadin = PluginClient::start;
131 read_samples(buffer, PluginClient::start - leadin, leadin);
132 sample1 = buffer[leadin - 1];
134 // Read a certain amount before the last sample
135 leadin = PluginClient::in_buffer_size;
136 if(PluginClient::end - leadin < 0) leadin = PluginClient::end;
137 read_samples(buffer, PluginClient::end - leadin, leadin);
138 sample2 = buffer[leadin - 1];
140 current_position = PluginClient::start;
142 // Get slope and intercept
143 slope = (sample2 - sample1) /
144 (PluginClient::end - PluginClient::start);
146 //printf("InterpolateAllEffect::process_loop 3\n");
148 //printf("InterpolateAllEffect::process_loop 4\n");
150 int fragment_len = PluginClient::in_buffer_size;
151 if(current_position + fragment_len > PluginClient::end) fragment_len = PluginClient::end - current_position;
152 double intercept2 = intercept + slope * (current_position - PluginClient::start);
153 for(int i = 0; i < fragment_len; i++)
155 buffer[i] = intercept2 + slope * i;
157 current_position += fragment_len;
158 write_length = fragment_len;
159 result = progress->update(PluginClient::end -
160 PluginClient::start +
162 PluginClient::start);
163 if(current_position >= PluginClient::end) result = 1;
164 //printf("InterpolateAllEffect::process_loop 5\n");