BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __BST_QSAMPLER_H__ 00003 #define __BST_QSAMPLER_H__ 00004 00005 #include "bstutils.hh" 00006 00007 G_BEGIN_DECLS 00008 00009 /* --- Gtk+ type macros --- */ 00010 #define BST_TYPE_QSAMPLER (bst_qsampler_get_type ()) 00011 #define BST_QSAMPLER(object) (GTK_CHECK_CAST ((object), BST_TYPE_QSAMPLER, BstQSampler)) 00012 #define BST_QSAMPLER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BST_TYPE_QSAMPLER, BstQSamplerClass)) 00013 #define BST_IS_QSAMPLER(object) (GTK_CHECK_TYPE ((object), BST_TYPE_QSAMPLER)) 00014 #define BST_IS_QSAMPLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_QSAMPLER)) 00015 #define BST_QSAMPLER_GET_CLASS(obj) ((BstQSamplerClass*) ((GtkObject*) (obj))->klass) 00016 00017 00018 00019 /* --- typedefs --- */ 00020 typedef struct _BstQSampler BstQSampler; 00021 typedef struct _BstQSamplerClass BstQSamplerClass; 00022 typedef struct _BstQSamplerPeak BstQSamplerPeak; 00023 typedef struct _BstQSamplerTPeak BstQSamplerTPeak; 00024 typedef struct _BstQSamplerSource BstQSamplerSource; 00025 typedef struct _BstQSamplerBlock BstQSamplerBlock; 00026 typedef struct _BstQSamplerMark BstQSamplerMark; 00027 typedef struct _BstQSamplerRegion BstQSamplerRegion; 00028 typedef guint (*BstQSamplerFill) (gpointer data, 00029 guint voffset, 00030 gdouble offset_scale, 00031 guint block_size, 00032 guint n_values, 00033 BstQSamplerPeak *values, 00034 BstQSampler *qsampler); 00035 typedef enum 00036 { 00037 /* regions & marks */ 00038 BST_QSAMPLER_ACTIVE = 1 << 1, 00039 BST_QSAMPLER_SELECTED = 1 << 2, 00040 /* marks only */ 00041 BST_QSAMPLER_PRELIGHT = 1 << 3, 00042 00043 /*< private >*/ 00044 BST_QSAMPLER_MARK_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE | BST_QSAMPLER_PRELIGHT), 00045 BST_QSAMPLER_REGION_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE), 00046 BST_QSAMPLER_MARK = 1 << 4, 00047 BST_QSAMPLER_MASK = 0x1f, 00048 BST_QSAMPLER_SKIP = 1 << 5, 00049 BST_QSAMPLER_NEEDS_DRAW = 1 << 6, 00050 BST_QSAMPLER_DIRTY = 1 << 7 00051 } BstQSamplerType; 00052 #ifdef __cplusplus 00053 constexpr BstQSamplerType operator& (BstQSamplerType s1, BstQSamplerType s2) { return BstQSamplerType (s1 & (long long unsigned) s2); } 00054 inline BstQSamplerType& operator&= (BstQSamplerType &s1, BstQSamplerType s2) { s1 = s1 & s2; return s1; } 00055 constexpr BstQSamplerType operator| (BstQSamplerType s1, BstQSamplerType s2) { return BstQSamplerType (s1 | (long long unsigned) s2); } 00056 inline BstQSamplerType& operator|= (BstQSamplerType &s1, BstQSamplerType s2) { s1 = s1 | s2; return s1; } 00057 constexpr BstQSamplerType operator~ (BstQSamplerType s1) { return BstQSamplerType (~(long long unsigned) s1); } 00058 #endif // __cplusplus 00059 00060 typedef enum 00061 { 00062 BST_QSAMPLER_DRAW_CRANGE, 00063 BST_QSAMPLER_DRAW_CSHAPE, 00064 BST_QSAMPLER_DRAW_ZERO_SHAPE, 00065 BST_QSAMPLER_DRAW_MINIMUM_LINE, 00066 BST_QSAMPLER_DRAW_MIDDLE_LINE, 00067 BST_QSAMPLER_DRAW_MAXIMUM_LINE, 00068 BST_QSAMPLER_DRAW_MINIMUM_SHAPE, 00069 BST_QSAMPLER_DRAW_MAXIMUM_SHAPE, 00070 BST_QSAMPLER_DRAW_MODE_LAST /*< skip >*/ 00071 } BstQSamplerDrawMode; 00072 #define BST_QSAMPLER_RELOAD_PRIORITY (GTK_PRIORITY_REDRAW + 5) 00073 00074 00075 /* --- structures --- */ 00076 struct _BstQSampler 00077 { 00078 GtkWidget parent_instance; 00079 00080 guint peak_length; /* pcm length in peaks */ 00081 guint n_peaks; /* number of cached peaks */ 00082 BstQSamplerTPeak *peaks; 00083 guint peak_offset; /* display offset */ 00084 guint n_pixels; /* <= n_peaks */ 00085 00086 00087 /* user settings */ 00088 guint n_marks; 00089 BstQSamplerMark *marks; 00090 guint n_regions; 00091 BstQSamplerRegion *regions; 00092 guint pcm_length; 00093 BstQSamplerFill src_filler; 00094 gpointer src_data; 00095 GDestroyNotify src_destroy; 00096 gdouble zoom_factor; 00097 00098 GtkAdjustment *adjustment; 00099 gdouble vscale_factor; 00100 00101 GdkColor red, green; 00102 GdkGC *red_gc, *green_gc; 00103 GdkWindow *canvas; 00104 guint draw_mode : 16; 00105 guint expose_frame : 1; 00106 guint ignore_adjustment : 1; 00107 guint refresh_queued : 1; 00108 guint invalid_remains : 1; /* temporary refresh flag */ 00109 00110 /* user data */ 00111 gpointer owner; 00112 guint owner_index; 00113 }; 00114 struct _BstQSamplerTPeak 00115 { 00116 gint16 min, max; 00117 guint8 type; 00118 }; 00119 struct _BstQSamplerPeak 00120 { 00121 gint16 min, max; 00122 }; 00123 struct _BstQSamplerClass 00124 { 00125 GtkWidgetClass parent_class; 00126 }; 00127 struct _BstQSamplerMark 00128 { 00129 guint index; 00130 BstQSamplerType type; 00131 guint offset; 00132 }; 00133 struct _BstQSamplerRegion 00134 { 00135 guint index; 00136 BstQSamplerType type; 00137 guint offset; 00138 guint length; 00139 }; 00140 00141 00142 /* --- prototypes --- */ 00143 GType bst_qsampler_get_type (void); 00144 void bst_qsampler_set_source (BstQSampler *qsampler, 00145 guint n_total_samples, 00146 BstQSamplerFill fill_func, 00147 gpointer data, 00148 GDestroyNotify destroy); 00149 void bst_qsampler_get_bounds (BstQSampler *qsampler, 00150 gint *first_offset, 00151 gint *last_offset); 00152 gboolean bst_qsampler_get_offset_at (BstQSampler *qsampler, 00153 gint *x_coord_p); 00154 void bst_qsampler_scroll_show (BstQSampler *qsampler, 00155 guint offset); 00156 void bst_qsampler_scroll_rbounded (BstQSampler *qsampler, 00157 guint offset, 00158 gfloat boundary_padding, 00159 gfloat padding); 00160 void bst_qsampler_scroll_lbounded (BstQSampler *qsampler, 00161 guint offset, 00162 gfloat boundary_padding, 00163 gfloat padding); 00164 void bst_qsampler_scroll_bounded (BstQSampler *qsampler, 00165 guint offset, 00166 gfloat boundary_padding, 00167 gfloat padding); 00168 void bst_qsampler_scroll_to (BstQSampler *qsampler, 00169 guint offset); 00170 void bst_qsampler_force_refresh (BstQSampler *qsampler); 00171 void bst_qsampler_set_mark (BstQSampler *qsampler, 00172 guint mark_index, 00173 guint offset, 00174 BstQSamplerType type); 00175 gint bst_qsampler_get_mark_offset (BstQSampler *qsampler, 00176 guint mark_index); 00177 void bst_qsampler_set_region (BstQSampler *qsampler, 00178 guint region_index, 00179 guint offset, 00180 guint length, 00181 BstQSamplerType type); 00182 void bst_qsampler_set_zoom (BstQSampler *qsampler, 00183 gdouble zoom); 00184 void bst_qsampler_set_vscale (BstQSampler *qsampler, 00185 gdouble vscale); 00186 void bst_qsampler_set_draw_mode (BstQSampler *qsampler, 00187 BstQSamplerDrawMode dmode); 00188 void bst_qsampler_set_adjustment (BstQSampler *qsampler, 00189 GtkAdjustment *adjustment); 00190 00191 void bst_qsampler_set_source_from_esample (BstQSampler *qsampler, 00192 SfiProxy esample, 00193 guint nth_channel); 00194 00195 G_END_DECLS 00196 00197 #endif /* __BST_QSAMPLER_H__ */