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
31 #include "bctimer.inc"
35 #include "pluginaclient.h"
44 #define MAX_WINDOW 262144
48 #define MAX_COLUMNS 1024
51 #define MAX_HISTORY 32
55 #define WAVEFORM_NO_TRIGGER 1
56 #define WAVEFORM_RISING_TRIGGER 2
57 #define WAVEFORM_FALLING_TRIGGER 3
60 #define CHANNEL0_COLOR WHITE
61 #define CHANNEL1_COLOR PINK
63 class AudioScopeHistory : public BC_IPot
66 AudioScopeHistory(AudioScope *plugin,
73 class AudioScopeWindowSize : public BC_PopupMenu
76 AudioScopeWindowSize(AudioScope *plugin,
84 class AudioScopeWindowSizeTumbler : public BC_Tumbler
87 AudioScopeWindowSizeTumbler(AudioScope *plugin, int x, int y);
88 int handle_up_event();
89 int handle_down_event();
93 class AudioScopeFragmentSize : public BC_PopupMenu
96 AudioScopeFragmentSize(AudioScope *plugin,
104 class AudioScopeFragmentSizeTumbler : public BC_Tumbler
107 AudioScopeFragmentSizeTumbler(AudioScope *plugin, int x, int y);
108 int handle_up_event();
109 int handle_down_event();
114 class AudioScopeMode : public BC_PopupMenu
117 AudioScopeMode(AudioScope *plugin,
121 static const char* mode_to_text(int mode);
122 static int text_to_mode(const char *text);
123 void create_objects();
127 class AudioScopeTriggerLevel : public BC_FPot
130 AudioScopeTriggerLevel(AudioScope *plugin, int x, int y);
137 class AudioScopeCanvas : public BC_SubWindow
140 AudioScopeCanvas(AudioScope *plugin,
145 int button_press_event();
146 int button_release_event();
147 int cursor_motion_event();
148 void calculate_point();
156 int current_operation;
161 class AudioScopeWindow : public PluginClientWindow
164 AudioScopeWindow(AudioScope *plugin);
167 void create_objects();
169 int resize_event(int w, int h);
170 void calculate_probe(int x, int y, int do_overlay);
175 BC_Title *window_size_title;
176 AudioScopeWindowSize *window_size;
177 AudioScopeWindowSizeTumbler *window_size_tumbler;
180 BC_Title *history_size_title;
181 AudioScopeHistory *history_size;
183 AudioScopeCanvas *canvas;
185 BC_Title *mode_title;
186 AudioScopeMode *mode;
188 BC_Title *trigger_level_title;
189 AudioScopeTriggerLevel *trigger_level;
191 BC_Title *probe_sample;
192 BC_Title *probe_level0;
193 BC_Title *probe_level1;
204 class AudioScopeConfig
208 int equivalent(AudioScopeConfig &that);
209 void copy_from(AudioScopeConfig &that);
210 void interpolate(AudioScopeConfig &prev,
211 AudioScopeConfig &next,
214 int64_t current_frame);
219 double trigger_level;
222 // Header for data buffer
226 // Total fragments in this buffer
231 // Nothing goes after this
235 class AudioScopeFrame
238 AudioScopeFrame(int data_size, int channels);
243 float *data[CHANNELS];
248 class AudioScope : public PluginAClient
251 AudioScope(PluginServer *server);
254 PLUGIN_CLASS_MEMBERS2(AudioScopeConfig)
256 int is_multichannel();
257 int process_buffer(int64_t size,
259 int64_t start_position,
261 void read_data(KeyFrame *keyframe);
262 void save_data(KeyFrame *keyframe);
264 void render_gui(void *data, int size);
269 int need_reconfigure;
270 // Data buffer for frequency & magnitude
272 // Accumulate data for windowing
273 Samples *audio_buffer[CHANNELS];
274 // Total samples in the buffer
276 // Last window size rendered
278 // Total windows sent to current GUI
280 // Starting sample in audio_buffer.
281 int64_t audio_buffer_start;
282 // Total floats allocated in data buffer
284 // Accumulates canvas pixels until the next update_gui
285 ArrayList<AudioScopeFrame*> frame_buffer;
286 // Past frames for the shadow effect
287 ArrayList<AudioScopeFrame*> frame_history;
289 AudioScopeFrame *current_frame;
290 // Header from last data buffer
291 data_header_t header;
292 // Time of last GUI update