4 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "bctimer.inc"
29 #include "pluginaclient.h"
41 EchoPrefix(const char *p) : prefix(p) {}
45 class EchoTitle : public EchoPrefix, public BC_Title {
46 char string[BCSTRLEN];
47 char *preset(int value) {
48 sprintf(string, "%s%d", prefix, value);
51 char *preset(double value) {
52 sprintf(string, "%s%.3f", prefix, value);
56 void update(int value) { BC_Title::update(preset(value)); }
57 void update(double value) { BC_Title::update(preset(value)); }
59 EchoTitle(int x, int y, const char *pfx, int value)
60 : EchoPrefix(pfx), BC_Title(x, y, preset(value)) {}
61 EchoTitle(int x, int y, const char *pfx, double value)
62 : EchoPrefix(pfx),BC_Title(x, y, preset(value)) {}
69 class EchoLevel : public BC_FPot
72 EchoLevel(EchoWindow *window, int x, int y);
78 class EchoAtten : public BC_FPot
81 EchoAtten(EchoWindow *window, int x, int y);
87 class EchoOffset : public BC_FPot
90 EchoOffset(EchoWindow *window, int x, int y);
97 class EchoWindow : public PluginClientWindow
100 EchoWindow(Echo *plugin);
103 void create_objects();
105 int resize_event(int w, int h);
107 EchoTitle *level_title;
110 EchoTitle *atten_title;
112 EchoTitle *offset_title;
125 int equivalent(EchoConfig &that);
126 void copy_from(EchoConfig &that);
127 void interpolate(EchoConfig &prev, EchoConfig &next,
128 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
135 class Echo : public PluginAClient
140 double *ip, *op; // in ptr, out ptr
141 double *bfr, *lmt; // first, limit
142 void reset() { ip = op = bfr; lmt = bfr + bsz; }
144 ring_buffer(int sz) { bfr = new double[bsz = sz]; reset(); }
145 ~ring_buffer() { delete [] bfr; }
146 void clear() { memset(bfr, 0, bsz*sizeof(*bfr)); }
147 double &icur() { return *ip; }
148 double &ocur() { return *op; }
149 double &inxt() { double &v=*ip; if( ++ip>=lmt ) ip=bfr; return v; }
150 double &onxt() { double &v=*op; if( ++op>=lmt ) op=bfr; return v; }
151 int64_t iseek(int64_t n) { ip = bfr+(n%bsz); return n; }
152 int64_t oseek(int64_t n) { op = bfr+(n%bsz); return n; }
156 Echo(PluginServer *server);
159 PLUGIN_CLASS_MEMBERS2(EchoConfig)
161 int is_multichannel();
162 int process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate);
164 void read_data(KeyFrame *keyframe);
165 void save_data(KeyFrame *keyframe);
169 void alloc_buffers(int nch, int isz, int rsz);
170 void delete_buffers();