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
22 #include "audioscope.h"
23 #include "bcdisplayinfo.h"
24 #include "bcsignals.h"
33 #include "transportque.inc"
42 REGISTER_PLUGIN(AudioScope)
45 AudioScopeConfig::AudioScopeConfig()
47 window_size = MAX_WINDOW;
53 int AudioScopeConfig::equivalent(AudioScopeConfig &that)
55 return window_size == that.window_size &&
56 history_size == that.history_size &&
58 EQUIV(trigger_level, that.trigger_level);
61 void AudioScopeConfig::copy_from(AudioScopeConfig &that)
63 window_size = that.window_size;
64 history_size = that.history_size;
66 trigger_level = that.trigger_level;
69 void AudioScopeConfig::interpolate(AudioScopeConfig &prev,
70 AudioScopeConfig &next,
73 int64_t current_frame)
77 CLAMP(history_size, MIN_HISTORY, MAX_HISTORY - 1);
82 AudioScopeFrame::AudioScopeFrame(int data_size, int channels)
84 this->size = data_size;
85 this->channels = channels;
86 for(int i = 0; i < CHANNELS; i++)
87 data[i] = new float[data_size];
91 AudioScopeFrame::~AudioScopeFrame()
93 for(int i = 0; i < CHANNELS; i++)
103 AudioScopeHistory::AudioScopeHistory(AudioScope *plugin,
108 plugin->config.history_size,
112 this->plugin = plugin;
115 int AudioScopeHistory::handle_event()
117 plugin->config.history_size = get_value();
118 plugin->send_configure_change();
129 AudioScopeWindowSize::AudioScopeWindowSize(AudioScope *plugin,
138 this->plugin = plugin;
141 int AudioScopeWindowSize::handle_event()
143 plugin->config.window_size = atoi(get_text());
144 plugin->send_configure_change();
149 AudioScopeWindowSizeTumbler::AudioScopeWindowSizeTumbler(AudioScope *plugin, int x, int y)
153 this->plugin = plugin;
156 int AudioScopeWindowSizeTumbler::handle_up_event()
158 plugin->config.window_size *= 2;
159 if(plugin->config.window_size > MAX_WINDOW)
160 plugin->config.window_size = MAX_WINDOW;
161 char string[BCTEXTLEN];
162 sprintf(string, "%d", plugin->config.window_size);
163 ((AudioScopeWindow*)plugin->get_thread()->get_window())->window_size->set_text(string);
164 plugin->send_configure_change();
168 int AudioScopeWindowSizeTumbler::handle_down_event()
170 plugin->config.window_size /= 2;
171 if(plugin->config.window_size < MIN_WINDOW)
172 plugin->config.window_size = MIN_WINDOW;
173 char string[BCTEXTLEN];
174 sprintf(string, "%d", plugin->config.window_size);
175 ((AudioScopeWindow*)plugin->get_thread()->get_window())->window_size->set_text(string);
176 plugin->send_configure_change();
184 AudioScopeCanvas::AudioScopeCanvas(AudioScope *plugin,
189 : BC_SubWindow(x, y, w, h, BLACK)
191 this->plugin = plugin;
192 current_operation = NONE;
195 int AudioScopeCanvas::button_press_event()
197 if(is_event_win() && cursor_inside())
200 current_operation = DRAG;
201 plugin->send_configure_change();
207 int AudioScopeCanvas::button_release_event()
209 if(current_operation == DRAG)
211 current_operation = NONE;
217 int AudioScopeCanvas::cursor_motion_event()
219 if(current_operation == DRAG)
228 void AudioScopeCanvas::calculate_point()
230 int x = get_cursor_x();
231 int y = get_cursor_y();
232 CLAMP(x, 0, get_w() - 1);
233 CLAMP(y, 0, get_h() - 1);
235 ((AudioScopeWindow*)plugin->thread->window)->calculate_probe(x, y, 1);
237 //printf("AudioScopeCanvas::calculate_point %d %d\n", __LINE__, Freq::tofreq(freq_index));
246 AudioScopeTriggerLevel::AudioScopeTriggerLevel(AudioScope *plugin, int x, int y)
247 : BC_FPot(x, y, plugin->config.trigger_level, (float)-1.0, (float)1.0)
249 this->plugin = plugin;
253 int AudioScopeTriggerLevel::handle_event()
255 AudioScopeWindow *window = (AudioScopeWindow*)plugin->thread->window;
256 window->draw_trigger();
257 plugin->config.trigger_level = get_value();
258 plugin->send_configure_change();
259 window->draw_trigger();
260 window->canvas->flash();
268 AudioScopeMode::AudioScopeMode(AudioScope *plugin,
274 mode_to_text(plugin->config.mode))
276 this->plugin = plugin;
279 void AudioScopeMode::create_objects()
281 add_item(new BC_MenuItem(mode_to_text(XY_MODE)));
282 add_item(new BC_MenuItem(mode_to_text(WAVEFORM_NO_TRIGGER)));
283 add_item(new BC_MenuItem(mode_to_text(WAVEFORM_RISING_TRIGGER)));
284 add_item(new BC_MenuItem(mode_to_text(WAVEFORM_FALLING_TRIGGER)));
287 int AudioScopeMode::handle_event()
289 if(plugin->config.mode != text_to_mode(get_text()))
291 AudioScopeWindow *window = (AudioScopeWindow*)plugin->thread->window;
292 window->probe_x = -1;
293 window->probe_y = -1;
294 plugin->config.mode = text_to_mode(get_text());
295 plugin->send_configure_change();
297 window->canvas->clear_box(0, 0, window->canvas->get_w(), window->canvas->get_h());
298 window->draw_overlay();
299 window->canvas->flash();
304 const char* AudioScopeMode::mode_to_text(int mode)
310 case WAVEFORM_NO_TRIGGER:
311 return _("Waveform");
312 case WAVEFORM_RISING_TRIGGER:
313 return _("Rising Trigger");
314 case WAVEFORM_FALLING_TRIGGER:
316 return _("Falling Trigger");
320 int AudioScopeMode::text_to_mode(const char *text)
322 if(!strcmp(mode_to_text(XY_MODE), text)) return XY_MODE;
323 if(!strcmp(mode_to_text(WAVEFORM_NO_TRIGGER), text)) return WAVEFORM_NO_TRIGGER;
324 if(!strcmp(mode_to_text(WAVEFORM_RISING_TRIGGER), text)) return WAVEFORM_RISING_TRIGGER;
325 if(!strcmp(mode_to_text(WAVEFORM_FALLING_TRIGGER), text)) return WAVEFORM_FALLING_TRIGGER;
337 AudioScopeWindow::AudioScopeWindow(AudioScope *plugin)
338 : PluginClientWindow(plugin, plugin->w, plugin->h, xS(320), yS(320), 1)
340 this->plugin = plugin;
345 AudioScopeWindow::~AudioScopeWindow()
349 void AudioScopeWindow::create_objects()
351 int x = plugin->get_theme()->widget_border;
353 char string[BCTEXTLEN];
355 add_subwindow(canvas = new AudioScopeCanvas(plugin,
360 plugin->get_theme()->widget_border * 4 -
361 BC_Title::calculate_h(this, "X") * 3));
362 canvas->set_cursor(CROSS_CURSOR, 0, 0);
365 y += canvas->get_h() + plugin->get_theme()->widget_border;
367 add_subwindow(history_size_title = new BC_Title(x, y, _("History Size:")));
368 x += history_size_title->get_w() + plugin->get_theme()->widget_border;
369 add_subwindow(history_size = new AudioScopeHistory(plugin,
372 x += history_size->get_w() + plugin->get_theme()->widget_border;
376 sprintf(string, "%d", plugin->config.window_size);
377 add_subwindow(window_size_title = new BC_Title(x, y, _("Window Size:")));
379 x += window_size_title->get_w() + plugin->get_theme()->widget_border;
380 add_subwindow(window_size = new AudioScopeWindowSize(plugin, x, y, string));
381 x += window_size->get_w();
382 add_subwindow(window_size_tumbler = new AudioScopeWindowSizeTumbler(plugin, x, y));
384 for(int i = MIN_WINDOW; i <= MAX_WINDOW; i *= 2)
386 sprintf(string, "%d", i);
387 window_size->add_item(new BC_MenuItem(string));
390 x += window_size_tumbler->get_w() + plugin->get_theme()->widget_border;
394 y += window_size->get_h() + plugin->get_theme()->widget_border;
395 add_subwindow(mode_title = new BC_Title(x, y, _("Mode:")));
397 x += mode_title->get_w() + plugin->get_theme()->widget_border;
398 add_subwindow(mode = new AudioScopeMode(plugin, x, y));
399 mode->create_objects();
401 x += mode->get_w() + plugin->get_theme()->widget_border;
403 add_subwindow(trigger_level_title = new BC_Title(x, y, _("Trigger level:")));
405 x += trigger_level_title->get_w() + plugin->get_theme()->widget_border;
406 add_subwindow(trigger_level = new AudioScopeTriggerLevel(plugin, x, y));
409 x += trigger_level->get_w() + plugin->get_theme()->widget_border;
411 add_subwindow(probe_sample = new BC_Title(x, y, _("Sample: 0")));
412 y += probe_sample->get_h() + plugin->get_theme()->widget_border;
413 add_subwindow(probe_level0 = new BC_Title(x, y, _("Level 0: 0"), MEDIUMFONT, CHANNEL0_COLOR));
414 y += probe_level0->get_h() + plugin->get_theme()->widget_border;
415 add_subwindow(probe_level1 = new BC_Title(x, y, _("Level 1: 0"), MEDIUMFONT, CHANNEL1_COLOR));
416 y += probe_level1->get_h() + plugin->get_theme()->widget_border;
423 int AudioScopeWindow::resize_event(int w, int h)
425 int y_diff = h - get_h();
427 int canvas_factor = get_h() - canvas->get_h();
428 canvas->reposition_window(0,
432 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
437 // Remove all columns which may be a different size.
438 plugin->frame_buffer.remove_all_objects();
440 window_size_title->reposition_window(window_size_title->get_x(),
441 window_size_title->get_y() + y_diff);
442 window_size->reposition_window(window_size->get_x(),
443 window_size->get_y() + y_diff);
444 window_size_tumbler->reposition_window(window_size_tumbler->get_x(),
445 window_size_tumbler->get_y() + y_diff);
449 history_size_title->reposition_window(history_size_title->get_x(),
450 history_size_title->get_y() + y_diff);
451 history_size->reposition_window(history_size->get_x(),
452 history_size->get_y() + y_diff);
454 mode_title->reposition_window(mode_title->get_x(),
455 mode_title->get_y() + y_diff);
456 mode->reposition_window(mode->get_x(),
457 mode->get_y() + y_diff);
460 trigger_level_title->reposition_window(trigger_level_title->get_x(),
461 trigger_level_title->get_y() + y_diff);
462 trigger_level->reposition_window(trigger_level->get_x(),
463 trigger_level->get_y() + y_diff);
466 probe_sample->reposition_window(probe_sample->get_x(),
467 probe_sample->get_y() + y_diff);
468 probe_level0->reposition_window(probe_level0->get_x(),
469 probe_level0->get_y() + y_diff);
470 probe_level1->reposition_window(probe_level1->get_x(),
471 probe_level1->get_y() + y_diff);
480 void AudioScopeWindow::draw_overlay()
482 canvas->set_color(GREEN);
487 canvas->get_h() / 2);
488 if(plugin->config.mode == XY_MODE)
490 canvas->draw_line(canvas->get_w() / 2,
498 //printf("AudioScopeWindow::draw_overlay %d\n", __LINE__);
501 void AudioScopeWindow::draw_trigger()
503 if(plugin->config.mode == WAVEFORM_RISING_TRIGGER ||
504 plugin->config.mode == WAVEFORM_FALLING_TRIGGER)
506 int y = (int)(-plugin->config.trigger_level *
507 canvas->get_h() / 2 +
508 canvas->get_h() / 2);
509 CLAMP(y, 0, canvas->get_h() - 1);
510 canvas->set_inverse();
511 canvas->set_color(RED);
512 canvas->draw_line(0, y, canvas->get_w(), y);
513 canvas->set_opaque();
517 void AudioScopeWindow::draw_probe()
519 if(probe_x >= 0 || probe_y >= 0)
521 canvas->set_color(GREEN);
522 canvas->set_inverse();
524 if(plugin->config.mode == XY_MODE)
526 canvas->draw_line(0, probe_y, get_w(), probe_y);
527 canvas->draw_line(probe_x, 0, probe_x, get_h());
531 canvas->draw_line(probe_x, 0, probe_x, get_h());
534 canvas->set_opaque();
541 void AudioScopeWindow::calculate_probe(int x, int y, int do_overlay)
543 if(x < 0 && y < 0) return;
545 // Clear previous overlay
546 if(do_overlay) draw_probe();
548 // New probe position
555 if(plugin->config.mode == XY_MODE)
557 channel0 = (float)(probe_x - canvas->get_w() / 2) / (canvas->get_w() / 2);
558 channel1 = (float)(canvas->get_h() / 2 - probe_y) / (canvas->get_h() / 2);
561 if(plugin->current_frame)
563 sample = probe_x * plugin->current_frame->size / canvas->get_w();
564 CLAMP(sample, 0, plugin->current_frame->size - 1);
565 channel0 = plugin->current_frame->data[0][sample];
566 channel1 = plugin->current_frame->data[1][sample];
570 char string[BCTEXTLEN];
571 sprintf(string, _("Sample: %d"), sample);
572 probe_sample->update(string);
574 sprintf(string, _("Level 0: %.2f"), channel0);
575 probe_level0->update(string);
577 sprintf(string, _("Level 1: %.2f"), channel1);
578 probe_level1->update(string);
592 void AudioScopeWindow::update_gui()
594 char string[BCTEXTLEN];
595 sprintf(string, "%d", plugin->config.window_size);
596 window_size->set_text(string);
597 history_size->update(plugin->config.history_size);
624 AudioScope::AudioScope(PluginServer *server)
625 : PluginAClient(server)
633 AudioScope::~AudioScope()
636 for(int i = 0; i < CHANNELS; i++)
637 delete audio_buffer[i];
639 frame_buffer.remove_all_objects();
640 frame_history.remove_all_objects();
644 void AudioScope::reset()
648 for(int i = 0; i < CHANNELS; i++)
653 bzero(&header, sizeof(data_header_t));
658 const char* AudioScope::plugin_title() { return N_("AudioScope"); }
659 int AudioScope::is_realtime() { return 1; }
660 int AudioScope::is_multichannel() { return 1; }
662 int AudioScope::process_buffer(int64_t size,
664 int64_t start_position,
667 int channels = MIN(get_total_buffers(), CHANNELS);
670 for(int i = 0; i < get_total_buffers(); i++)
672 read_samples(buffer[i],
679 load_configuration();
681 // Reset audio buffer
682 if(window_size != config.window_size)
685 window_size = config.window_size;
690 data = new unsigned char[sizeof(data_header_t)];
696 for(int i = 0; i < CHANNELS; i++)
698 audio_buffer[i] = new Samples(MAX_WINDOW);
703 int needed = buffer_size + size;
704 if(audio_buffer[0]->get_allocated() < needed)
706 for(int i = 0; i < CHANNELS; i++)
708 Samples *new_samples = new Samples(needed);
709 memcpy(new_samples->get_data(),
710 audio_buffer[i]->get_data(),
711 sizeof(double) * buffer_size);
712 delete audio_buffer[i];
713 audio_buffer[i] = new_samples;
717 for(int i = 0; i < CHANNELS; i++)
719 memcpy(audio_buffer[i]->get_data() + buffer_size,
720 buffer[MIN(i, channels - 1)]->get_data(),
721 sizeof(double) * size);
726 // Append a windows to end of GUI buffer
728 while(buffer_size >= window_size)
730 if(allocated_data < (total_windows + 1) * window_size * CHANNELS)
732 int new_allocation = (total_windows + 1) *
735 unsigned char *new_data = new unsigned char[sizeof(data_header_t) +
736 sizeof(float) * new_allocation];
737 data_header_t *new_header = (data_header_t*)new_data;
738 data_header_t *old_header = (data_header_t*)data;
739 memcpy(new_header->samples,
741 sizeof(float) * allocated_data);
744 allocated_data = new_allocation;
747 // Search for trigger
748 int need_trigger = 0;
750 int trigger_sample = 0;
751 //printf("AudioScope::process_buffer %d\n", __LINE__);
752 if(config.mode == WAVEFORM_RISING_TRIGGER)
755 double *trigger_data = audio_buffer[0]->get_data();
756 for(int i = 1; i < buffer_size - window_size; i++)
758 if(trigger_data[i - 1] < config.trigger_level &&
759 trigger_data[i] >= config.trigger_level)
768 if(config.mode == WAVEFORM_FALLING_TRIGGER)
771 double *trigger_data = audio_buffer[0]->get_data();
772 for(int i = 1; i < buffer_size - window_size; i++)
774 if(trigger_data[i - 1] > config.trigger_level &&
775 trigger_data[i] <= config.trigger_level)
784 //printf("AudioScope::process_buffer %d\n", __LINE__);
786 if(need_trigger && !got_trigger)
788 //printf("AudioScope::process_buffer %d\n", __LINE__);
789 for(int j = 0; j < CHANNELS; j++)
791 double *sample_input = audio_buffer[j]->get_data();
793 sample_input + buffer_size - window_size,
794 sizeof(double) * window_size);
797 buffer_size = window_size;
798 if(buffer_size == window_size) break;
799 //printf("AudioScope::process_buffer %d\n", __LINE__);
803 data_header_t *header = (data_header_t*)data;
804 //printf("AudioScope::process_buffer %d\n", __LINE__);
805 for(int j = 0; j < CHANNELS; j++)
807 float *sample_output = header->samples +
808 total_windows * CHANNELS * window_size +
810 double *sample_input = audio_buffer[j]->get_data();
811 for(int i = 0; i < window_size; i++)
813 sample_output[i] = sample_input[i + trigger_sample];
816 // Shift accumulation buffer
817 //printf("AudioScope::process_buffer %d\n", __LINE__);
819 sample_input + trigger_sample + window_size,
820 sizeof(double) * (buffer_size - trigger_sample - window_size));
821 //printf("AudioScope::process_buffer %d\n", __LINE__);
824 //printf("AudioScope::process_buffer %d\n", __LINE__);
827 buffer_size -= window_size + trigger_sample;
828 //printf("AudioScope::process_buffer %d\n", __LINE__);
832 data_header_t *header = (data_header_t*)data;
833 header->window_size = window_size;
834 header->sample_rate = sample_rate;
835 header->channels = channels;
836 header->total_windows = total_windows;
838 send_render_gui(data,
839 sizeof(data_header_t) +
840 sizeof(float) * total_windows * window_size * CHANNELS);
845 void AudioScope::render_stop()
848 frame_buffer.remove_all_objects();
854 NEW_WINDOW_MACRO(AudioScope, AudioScopeWindow)
856 void AudioScope::update_gui()
860 int result = load_configuration();
861 AudioScopeWindow *window = (AudioScopeWindow*)thread->get_window();
862 window->lock_window("AudioScope::update_gui");
863 if(result) window->update_gui();
865 // Shift in accumulated frames
866 if(frame_buffer.size())
868 BC_SubWindow *canvas = window->canvas;
869 // Frames to draw in this iteration
870 int total_frames = timer->get_difference() *
874 if(total_frames) timer->subtract(total_frames *
879 // Add forced frame drawing
880 for(int i = 0; i < frame_buffer.size(); i++)
881 if(frame_buffer.get(i)->force) total_frames++;
882 total_frames = MIN(frame_buffer.size(), total_frames);
883 //printf("AudioScope::update_gui %d %d\n", __LINE__, total_frames);
886 // expire old history frames
887 int new_frames = frame_history.size() + total_frames;
888 int expired = new_frames - config.history_size;
890 frame_history.remove_object_block(0, expired);
891 // Shift frames into history
892 for(int frame = 0; frame < total_frames; frame++)
893 frame_history.append(frame_buffer.get(frame));
894 frame_buffer.remove_block(0, total_frames);
896 // Point probe data at history
897 current_frame = frame_history.get(frame_history.size() - 1);
899 // Draw frames from history
900 canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
901 for(int frame = 0; frame < frame_history.size(); frame++)
903 AudioScopeFrame *ptr = frame_history.get(frame);
905 int luma = (frame + 1) * 0x80 / frame_history.size();
906 if(frame == frame_history.size() - 1)
908 canvas->set_color(WHITE);
909 canvas->set_line_width(2);
913 canvas->set_color((luma << 16) |
920 int w = canvas->get_w();
921 int h = canvas->get_h();
922 float *channel0 = ptr->data[0];
923 float *channel1 = ptr->data[1];
925 if(config.mode == XY_MODE)
929 for(int point = 0; point < ptr->size; point++)
931 int x2 = (int)(channel0[point] * w / 2 + w / 2);
932 int y2 = (int)(-channel1[point] * h / 2 + h / 2);
938 canvas->draw_line(x1, y1, x2, y2);
951 for(int channel = ptr->channels - 1; channel >= 0; channel--)
955 if(frame == frame_history.size() - 1)
957 canvas->set_color(PINK);
958 canvas->set_line_width(2);
961 canvas->set_color(((luma * 0xff / 0xff) << 16) |
962 ((luma * 0x80 / 0xff) << 8) |
963 ((luma * 0x80 / 0xff)));
967 if(frame == frame_history.size() - 1)
968 canvas->set_color(WHITE);
970 canvas->set_color((luma << 16) |
977 for(int point = 0; point < ptr->size; point++)
979 int x2 = point * w / ptr->size;
980 int y2 = (int)(-ptr->data[channel][point] * h / 2 + h / 2);
984 canvas->draw_line(x1, y1, x2, y2);
993 for(int x2 = 0; x2 < w; x2++)
995 int sample1 = x2 * ptr->size / w;
996 int sample2 = (x2 + 1) * ptr->size / w;
997 double min = ptr->data[channel][sample1];
998 double max = ptr->data[channel][sample1];
999 for(int i = sample1 + 1; i < sample2; i++)
1001 double value = ptr->data[channel][i];
1002 if(value < min) min = value;
1003 if(value > max) max = value;
1006 int min2 = (int)(-min * h / 2 + h / 2);
1007 int max2 = (int)(-max * h / 2 + h / 2);
1008 CLAMP(min2, 0, h - 1);
1009 CLAMP(max2, 0, h - 1);
1010 int y2 = (min2 + max2) / 2;
1011 canvas->draw_line(x2, min2, x2, max2);
1014 canvas->draw_line(x2, y1, x2, y2);
1023 canvas->set_line_width(1);
1026 // Recompute probe level
1027 window->calculate_probe(window->probe_x, window->probe_y, 0);
1031 window->draw_overlay();
1037 while(frame_buffer.size() > MAX_COLUMNS)
1038 frame_buffer.remove_object_number(0);
1040 thread->get_window()->unlock_window();
1044 void AudioScope::render_gui(void *data, int size)
1048 thread->get_window()->lock_window("AudioScope::render_gui");
1049 data_header_t *header = (data_header_t*)data;
1050 memcpy(&this->header, header, sizeof(data_header_t));
1051 //BC_SubWindow *canvas = ((AudioScopeWindow*)thread->get_window())->canvas;
1052 //int h = canvas->get_h();
1054 // Set all previous frames to draw immediately
1055 for(int i = 0; i < frame_buffer.size(); i++)
1056 frame_buffer.get(i)->force = 1;
1058 for(int current_fragment = 0;
1059 current_fragment < header->total_windows;
1062 float *in_frame = header->samples +
1063 current_fragment * header->window_size * CHANNELS;
1064 AudioScopeFrame *out_frame = new AudioScopeFrame(
1065 header->window_size,
1068 // Copy the window to the frame
1069 for(int j = 0; j < CHANNELS; j++)
1071 for(int i = 0; i < header->window_size; i++)
1073 out_frame->data[j][i] = in_frame[header->window_size * j + i];
1077 frame_buffer.append(out_frame);
1082 thread->get_window()->unlock_window();
1093 LOAD_CONFIGURATION_MACRO(AudioScope, AudioScopeConfig)
1095 void AudioScope::read_data(KeyFrame *keyframe)
1098 input.set_shared_input(keyframe->xbuf);
1103 result = input.read_tag();
1107 if(input.tag.title_is("AUDIOSCOPE"))
1111 w = input.tag.get_property("W", w);
1112 h = input.tag.get_property("H", h);
1115 config.history_size = input.tag.get_property("HISTORY_SIZE", config.history_size);
1116 config.window_size = input.tag.get_property("WINDOW_SIZE", config.window_size);
1117 config.mode = input.tag.get_property("MODE", config.mode);
1118 config.trigger_level = input.tag.get_property("TRIGGER_LEVEL", config.trigger_level);
1124 void AudioScope::save_data(KeyFrame *keyframe)
1127 output.set_shared_output(keyframe->xbuf);
1129 //printf("AudioScope::save_data %d %d %d\n", __LINE__, config.w, config.h);
1130 output.tag.set_title("AUDIOSCOPE");
1131 output.tag.set_property("W", w);
1132 output.tag.set_property("H", h);
1133 output.tag.set_property("HISTORY_SIZE", config.history_size);
1134 output.tag.set_property("WINDOW_SIZE", (int)config.window_size);
1135 output.tag.set_property("MODE", (int)config.mode);
1136 output.tag.set_property("TRIGGER_LEVEL", (float)config.trigger_level);
1137 output.append_tag();
1138 output.tag.set_title("/AUDIOSCOPE");
1139 output.append_tag();
1140 output.append_newline();
1141 output.terminate_string();