Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
bstqsampler.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BST_QSAMPLER_H__
3 #define __BST_QSAMPLER_H__
4 
5 #include "bstutils.hh"
6 
7 /* --- Gtk+ type macros --- */
8 #define BST_TYPE_QSAMPLER (bst_qsampler_get_type ())
9 #define BST_QSAMPLER(object) (GTK_CHECK_CAST ((object), BST_TYPE_QSAMPLER, BstQSampler))
10 #define BST_QSAMPLER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BST_TYPE_QSAMPLER, BstQSamplerClass))
11 #define BST_IS_QSAMPLER(object) (GTK_CHECK_TYPE ((object), BST_TYPE_QSAMPLER))
12 #define BST_IS_QSAMPLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BST_TYPE_QSAMPLER))
13 #define BST_QSAMPLER_GET_CLASS(obj) ((BstQSamplerClass*) ((GtkObject*) (obj))->klass)
14 
15 
16 
17 /* --- typedefs --- */
18 typedef struct _BstQSampler BstQSampler;
19 typedef struct _BstQSamplerClass BstQSamplerClass;
20 typedef struct _BstQSamplerPeak BstQSamplerPeak;
21 typedef struct _BstQSamplerTPeak BstQSamplerTPeak;
22 typedef struct _BstQSamplerSource BstQSamplerSource;
23 typedef struct _BstQSamplerBlock BstQSamplerBlock;
24 typedef struct _BstQSamplerMark BstQSamplerMark;
25 typedef struct _BstQSamplerRegion BstQSamplerRegion;
26 typedef guint (*BstQSamplerFill) (gpointer data,
27  guint voffset,
28  gdouble offset_scale,
29  guint block_size,
30  guint n_values,
31  BstQSamplerPeak *values,
32  BstQSampler *qsampler);
33 typedef enum
34 {
35  /* regions & marks */
36  BST_QSAMPLER_ACTIVE = 1 << 1,
37  BST_QSAMPLER_SELECTED = 1 << 2,
38  /* marks only */
39  BST_QSAMPLER_PRELIGHT = 1 << 3,
40 
41  /*< private >*/
42  BST_QSAMPLER_MARK_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE | BST_QSAMPLER_PRELIGHT),
43  BST_QSAMPLER_REGION_MASK = (BST_QSAMPLER_SELECTED | BST_QSAMPLER_ACTIVE),
44  BST_QSAMPLER_MARK = 1 << 4,
45  BST_QSAMPLER_MASK = 0x1f,
46  BST_QSAMPLER_SKIP = 1 << 5,
47  BST_QSAMPLER_NEEDS_DRAW = 1 << 6,
48  BST_QSAMPLER_DIRTY = 1 << 7
49 } BstQSamplerType;
50 #ifdef __cplusplus
51 constexpr BstQSamplerType operator& (BstQSamplerType s1, BstQSamplerType s2) { return BstQSamplerType (s1 & (long long unsigned) s2); }
52 inline BstQSamplerType& operator&= (BstQSamplerType &s1, BstQSamplerType s2) { s1 = s1 & s2; return s1; }
53 constexpr BstQSamplerType operator| (BstQSamplerType s1, BstQSamplerType s2) { return BstQSamplerType (s1 | (long long unsigned) s2); }
54 inline BstQSamplerType& operator|= (BstQSamplerType &s1, BstQSamplerType s2) { s1 = s1 | s2; return s1; }
55 constexpr BstQSamplerType operator~ (BstQSamplerType s1) { return BstQSamplerType (~(long long unsigned) s1); }
56 #endif // __cplusplus
57 
58 #define BST_QSAMPLER_RELOAD_PRIORITY (GTK_PRIORITY_REDRAW + 5)
59 
60 
61 /* --- structures --- */
63 {
64  GtkWidget parent_instance;
65 
66  guint peak_length; /* pcm length in peaks */
67  guint n_peaks; /* number of cached peaks */
68  BstQSamplerTPeak *peaks;
69  guint peak_offset; /* display offset */
70  guint n_pixels; /* <= n_peaks */
71 
72 
73  /* user settings */
74  guint n_marks;
75  BstQSamplerMark *marks;
76  guint n_regions;
77  BstQSamplerRegion *regions;
78  guint pcm_length;
79  BstQSamplerFill src_filler;
80  gpointer src_data;
81  GDestroyNotify src_destroy;
82  gdouble zoom_factor;
83 
84  GtkAdjustment *adjustment;
85  gdouble vscale_factor;
86 
87  GdkColor red, green;
88  GdkGC *red_gc, *green_gc;
89  GdkWindow *canvas;
90  Bst::QSamplerDrawMode draw_mode;
91  guint expose_frame : 1;
92  guint ignore_adjustment : 1;
93  guint refresh_queued : 1;
94  guint invalid_remains : 1; /* temporary refresh flag */
95 
96  /* user data */
97  gpointer owner;
98  guint owner_index;
99 };
101 {
102  gint16 min, max;
103  guint8 type;
104 };
106 {
107  gint16 min, max;
108 };
110 {
111  GtkWidgetClass parent_class;
112 };
114 {
115  guint index;
116  BstQSamplerType type;
117  guint offset;
118 };
120 {
121  guint index;
122  BstQSamplerType type;
123  guint offset;
124  guint length;
125 };
126 
127 
128 /* --- prototypes --- */
129 GType bst_qsampler_get_type (void);
130 void bst_qsampler_set_source (BstQSampler *qsampler,
131  guint n_total_samples,
132  BstQSamplerFill fill_func,
133  gpointer data,
134  GDestroyNotify destroy);
135 void bst_qsampler_get_bounds (BstQSampler *qsampler,
136  gint *first_offset,
137  gint *last_offset);
138 gboolean bst_qsampler_get_offset_at (BstQSampler *qsampler,
139  gint *x_coord_p);
140 void bst_qsampler_scroll_show (BstQSampler *qsampler,
141  guint offset);
142 void bst_qsampler_scroll_rbounded (BstQSampler *qsampler,
143  guint offset,
144  gfloat boundary_padding,
145  gfloat padding);
146 void bst_qsampler_scroll_lbounded (BstQSampler *qsampler,
147  guint offset,
148  gfloat boundary_padding,
149  gfloat padding);
150 void bst_qsampler_scroll_bounded (BstQSampler *qsampler,
151  guint offset,
152  gfloat boundary_padding,
153  gfloat padding);
154 void bst_qsampler_scroll_to (BstQSampler *qsampler,
155  guint offset);
156 void bst_qsampler_force_refresh (BstQSampler *qsampler);
157 void bst_qsampler_set_mark (BstQSampler *qsampler,
158  guint mark_index,
159  guint offset,
160  BstQSamplerType type);
161 gint bst_qsampler_get_mark_offset (BstQSampler *qsampler,
162  guint mark_index);
163 void bst_qsampler_set_region (BstQSampler *qsampler,
164  guint region_index,
165  guint offset,
166  guint length,
167  BstQSamplerType type);
168 void bst_qsampler_set_zoom (BstQSampler *qsampler,
169  gdouble zoom);
170 void bst_qsampler_set_vscale (BstQSampler *qsampler,
171  gdouble vscale);
172 void bst_qsampler_set_draw_mode (BstQSampler *qsampler, Bst::QSamplerDrawMode dmode);
173 void bst_qsampler_set_adjustment (BstQSampler *qsampler,
174  GtkAdjustment *adjustment);
175 
176 void bst_qsampler_set_source_from_esample (BstQSampler *qsampler,
177  SfiProxy esample,
178  guint nth_channel);
179 
180 #endif /* __BST_QSAMPLER_H__ */
Definition: bstqsampler.hh:105
Definition: bstqsampler.hh:119
Definition: bstqsampler.hh:109
Definition: bstqsampler.hh:113
Definition: bstqsampler.hh:62
Definition: bstqsampler.hh:100