Switched to use libgnomecanvas (not the C++ one).
[ardour.git] / gtk2_ardour / canvas-waveview.h
1 /* libgnomecanvas/gnome-canvas-waveview.h: GnomeCanvas item for displaying wave data
2  *
3  * Copyright (C) 2001 Paul Davis <pbd@op.net>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  */
21
22 #ifndef __GNOME_CANVAS_WAVEVIEW_H__
23 #define __GNOME_CANVAS_WAVEVIEW_H__
24
25 #include <stdint.h>
26
27 #include <libgnomecanvas/libgnomecanvas.h>
28
29 BEGIN_GNOME_CANVAS_DECLS
30
31 /* Wave viewer item for canvas.
32  */
33
34 #define GNOME_CANVAS_TYPE_CANVAS_WAVEVIEW            (gnome_canvas_waveview_get_type ())
35 #define GNOME_CANVAS_WAVEVIEW(obj)                   (GTK_CHECK_CAST ((obj), GNOME_CANVAS_TYPE_CANVAS_WAVEVIEW, GnomeCanvasWaveView))
36 #define GNOME_CANVAS_WAVEVIEW_CLASS(klass)           (GTK_CHECK_CLASS_CAST ((klass), GNOME_CANVAS_TYPE_CANVAS_WAVEVIEW, GnomeCanvasWaveViewClass))
37 #define GNOME_CANVAS_IS_CANVAS_WAVEVIEW(obj)         (GTK_CHECK_TYPE ((obj), GNOME_CANVAS_TYPE_CANVAS_WAVEVIEW))
38 #define GNOME_CANVAS_IS_CANVAS_WAVEVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_CANVAS_TYPE_CANVAS_WAVEVIEW))
39
40 typedef struct _GnomeCanvasWaveView            GnomeCanvasWaveView;
41 typedef struct _GnomeCanvasWaveViewClass       GnomeCanvasWaveViewClass;
42 typedef struct _GnomeCanvasWaveViewChannelInfo GnomeCanvasWaveViewChannelInfo;
43 typedef struct _GnomeCanvasWaveViewCacheEntry  GnomeCanvasWaveViewCacheEntry;
44 typedef struct _GnomeCanvasWaveViewCache       GnomeCanvasWaveViewCache;
45
46 /* XXX this needs to be synced with ardour/source.h PeakData */
47
48 struct _GnomeCanvasWaveViewCacheEntry
49 {
50     float  min;
51     float  max;
52 };
53
54 struct _GnomeCanvasWaveViewCache
55 {
56     GnomeCanvasWaveViewCacheEntry* data;
57     gint32                       allocated;
58     gint32                       data_size;
59     gulong                       start;
60     gulong                       end;
61 };    
62
63 GnomeCanvasWaveViewCache* gnome_canvas_waveview_cache_new ();
64 void                    gnome_canvas_waveview_cache_destroy (GnomeCanvasWaveViewCache*);
65
66 struct _GnomeCanvasWaveView
67 {
68     GnomeCanvasItem item;
69     
70     GnomeCanvasWaveViewCache *cache;
71     gboolean                cache_updater;
72     gint                    screen_width;
73
74     void *data_src;
75     guint32 channel;
76         void (*peak_function)(void*,gulong,gulong,gulong,gpointer,guint32,double);
77     gulong (*length_function)(void *);
78     gulong (*sourcefile_length_function)(void*);
79     void (*gain_curve_function)(void *arg, double start, double end, float* vector, guint32 veclen);
80     void *gain_src;
81
82     /* x-axis: samples per canvas unit. */
83     double samples_per_unit;
84     
85     /* y-axis: amplitude_above_axis.
86      * 
87      * the default is that an (scaled, normalized -1.0 ... +1.0) amplitude of 1.0
88      * corresponds to the top of the area assigned to the waveview.
89      *
90      * larger values will expand the vertical scale, cutting off the peaks/troughs.
91      * smaller values will decrease the vertical scale, moving peaks/troughs toward
92      * the middle of the area assigned to the waveview.
93      */
94
95     double amplitude_above_axis;
96     double x;
97     double y;
98     double height;
99     double half_height;
100     uint32_t wave_color;
101
102     char rectified;
103
104     /* These are updated by the update() routine
105        to optimize the render() routine, which may
106        be called several times after a single update().
107     */
108
109     int32_t bbox_ulx;
110     int32_t bbox_uly;
111     int32_t bbox_lrx;
112     int32_t bbox_lry;
113     unsigned char wave_r, wave_g, wave_b, wave_a;
114     uint32_t samples;
115     uint32_t region_start;
116     int32_t reload_cache_in_render;
117 };
118
119 struct _GnomeCanvasWaveViewClass {
120         GnomeCanvasItemClass parent_class;
121 };
122
123 GtkType gnome_canvas_waveview_get_type (void);
124
125 END_GNOME_CANVAS_DECLS
126
127 #endif /* __GNOME_CANVAS_WAVEVIEW_H__ */