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