1 /* 2 * oscilloscope.h 3 * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath 4 * DIN Is Noise is released under GNU Public License 2.0 5 * For more information, please visit https://dinisnoise.org/ 6 */ 7 8 #ifndef __oscilloscope 9 #define __oscilloscope 10 11 #define MAX_SAMPLES 1024 12 13 #include "box.h" 14 #include "ui.h" 15 #include "arrow_button.h" 16 #include "widget.h" 17 #include <string> 18 #include <vector> 19 20 struct oscilloscope_params_t { 21 int left, base, height; 22 int num_samples; 23 int visible; 24 int folded; 25 oscilloscope_params_t (int l, int b, int h, int ns, int v, int f); 26 }; 27 28 struct oscilloscope : ui, click_listener, widget { 29 30 struct sample_t { 31 static float lmin, lmax; // current min/max of left channel 32 static float rmin, rmax; // current min/max of right channel 33 float left, right; // stereo sample_toscilloscope::sample_t34 sample_t () {left = right = 0;} 35 } samples [MAX_SAMPLES]; 36 37 std::vector<oscilloscope_params_t> params; // for each instrument 38 39 int left, base, height; 40 int num_samples; 41 int folded; 42 43 void set_folded (int f); 44 45 int viewr; 46 int addr; 47 void add_samples (float* outl, float* outr, int n); 48 49 std::string settingsf; 50 51 int limit; 52 53 oscilloscope (const std::string& _settingsf); 54 ~oscilloscope (); 55 56 int load (); 57 int save (); 58 void load_current_instrument (); 59 void save_current_instrument (); 60 61 // gl 62 int* vertex_array; 63 float* color_array; 64 65 // ui 66 // 67 arrow_button fld; 68 float lr, lg, lb; // left channel color 69 float rr, rg, rb; // right channel color 70 71 box<int> win, pick_win; 72 int leftx, rightx, endx; 73 74 int ndraw; 75 int label_counter; 76 77 int lly, lry, lh; 78 static const int buf_size = 256; 79 char lbuf1 [buf_size], rbuf1 [buf_size]; 80 81 void set_height (int h); 82 void set_num_samples (int n); 83 84 void calc_draw_params (); 85 void draw (); 86 87 int lmb_clicked; 88 int px, py; 89 int move, stop_move; 90 int handle_input (); 91 void clicked (button& b); 92 93 }; 94 #endif 95 96 97 98