1 /* 2 * Sweep, a sound wave editor. 3 * 4 * Copyright (C) 2000 Conrad Parker 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 21 #ifndef __SWEEP_APP_H__ 22 #define __SWEEP_APP_H__ 23 24 #include <gtk/gtk.h> 25 #include <pthread.h> 26 27 /* #include "i18n.h" */ 28 29 typedef struct _sw_perform_data sw_perform_data; 30 31 struct _sw_perform_data { 32 SweepFunction func; 33 sw_param_set pset; 34 gpointer custom_data; 35 }; 36 37 /* Tools */ 38 typedef enum { 39 TOOL_NONE = 0, 40 TOOL_SELECT, 41 TOOL_MOVE, 42 TOOL_ZOOM, 43 TOOL_CROP, 44 TOOL_SCRUB, 45 TOOL_PENCIL, 46 TOOL_NOISE, 47 TOOL_HAND 48 } sw_tool_t; 49 50 /* View colors */ 51 enum { 52 VIEW_COLOR_BLACK, 53 VIEW_COLOR_RED, 54 VIEW_COLOR_ORANGE, 55 VIEW_COLOR_YELLOW, 56 VIEW_COLOR_BLUE, 57 VIEW_COLOR_WHITE, 58 VIEW_COLOR_RADAR, 59 VIEW_COLOR_DEFAULT_MAX=VIEW_COLOR_RADAR, 60 VIEW_COLOR_BLUESCREEN, 61 VIEW_COLOR_MAX 62 }; 63 64 typedef enum { 65 SW_TOOLBAR_BUTTON, 66 SW_TOOLBAR_TOGGLE_BUTTON, 67 SW_TOOLBAR_RADIO_BUTTON, 68 } sw_toolbar_button_type; 69 70 typedef struct { 71 sw_framecount_t start, end; 72 } sw_view_bounds; 73 74 typedef struct _sw_view sw_view; 75 76 struct _sw_view { 77 sw_sample * sample; 78 79 sw_framecount_t start, end; /* bounds of visible frames */ 80 sw_audio_t vlow, vhigh; /* bounds of vertical zoom */ 81 /* gfloat gain;*/ 82 /*gfloat rate;*/ 83 84 sw_tool_t current_tool; 85 86 gint repeater_tag; 87 88 gboolean following; /* whether or not to follow playmarker */ 89 90 gint hand_offset; 91 92 GtkWidget * window; 93 GtkWidget * time_ruler; 94 GtkWidget * scrollbar; 95 GtkWidget * display; 96 GtkWidget * pos; 97 GtkWidget * status; 98 GtkWidget * menubar; 99 GtkWidget * menu; 100 GtkWidget * zoom_combo; 101 GtkWidget * progress; 102 103 GtkWidget * follow_toggle; 104 GtkWidget * play_pos; 105 GtkWidget * loop_toggle; 106 GtkWidget * playrev_toggle; 107 GtkWidget * play_toggle; 108 GtkWidget * play_sel_toggle; 109 GtkWidget * mute_toggle; 110 GtkWidget * monitor_toggle; 111 112 GtkWidget * menu_sel; 113 GtkWidget * menu_point; 114 115 GtkWidget * channelops_menuitem; 116 GtkWidget * channelops_submenu; 117 GList * channelops_widgets; 118 119 GtkWidget * follow_checkmenu; 120 GtkWidget * color_menuitems[VIEW_COLOR_MAX]; 121 GtkWidget * loop_checkmenu; 122 GtkWidget * playrev_checkmenu; 123 GtkWidget * mute_checkmenu; 124 GtkWidget * monitor_checkmenu; 125 126 GtkObject * adj; 127 GtkObject * gain_adj; 128 GtkObject * rate_adj; 129 130 GtkWidget * db_rulers_vbox; 131 GList * db_rulers; 132 133 GList * tool_buttons; 134 135 GList * noready_widgets; /* Widgets to set insensitive on READY only */ 136 GList * nomodify_widgets; /* Widgets to set insensitive on MODIFY or ALLOC */ 137 GList * noalloc_widgets; /* Widgets to set insensitive on ALLOC only */ 138 }; 139 140 typedef struct _sw_head sw_head; 141 typedef struct _sw_head_controller sw_head_controller; 142 143 typedef enum { 144 SWEEP_HEAD_PLAY, 145 SWEEP_HEAD_RECORD 146 } sw_head_t; 147 148 struct _sw_head_controller { 149 sw_head * head; 150 151 GtkWidget * follow_toggle; 152 GtkWidget * pos_label; 153 GtkWidget * loop_toggle; 154 GtkWidget * reverse_toggle; 155 GtkWidget * go_toggle; 156 GtkWidget * go_sel_toggle; 157 GtkWidget * mute_toggle; 158 GtkObject * gain_adj; 159 }; 160 161 struct _sw_head { 162 sw_sample * sample; 163 164 GMutex * head_mutex; 165 sw_head_t type; /* SWEEP_HEAD_PLAY or SWEEP_HEAD_RECORD */ 166 /* sw_transport_type transport_mode;*/ 167 sw_framecount_t stop_offset; 168 gdouble offset; 169 sw_framecount_t realoffset; /* offset according to device */ 170 gboolean going; /* stopped or going? */ 171 gboolean restricted; /* restricted to sample->sounddata->sels ? */ 172 gboolean looping; 173 gboolean previewing; 174 gboolean reverse; 175 gboolean mute; 176 gboolean monitor; 177 gfloat delta; /* current motion delta */ 178 gfloat gain; 179 gfloat rate; 180 gfloat mix; /* record mixing level */ 181 182 sw_head * scrub_master; /* another head this is being scrubbed by */ 183 gboolean scrubbing; /* if this head is a scrub master, is it scrubbing ? */ 184 185 gint repeater_tag; 186 GList * controllers; 187 }; 188 189 typedef enum { 190 SWEEP_FILE_METHOD_BY_EXTENSION=0, /* Guess */ 191 SWEEP_FILE_METHOD_LIBSNDFILE, 192 SWEEP_FILE_METHOD_OGGVORBIS, 193 SWEEP_FILE_METHOD_SPEEX, 194 SWEEP_FILE_METHOD_MP3=1000666 /* Random high number -- unsupported */ 195 } sw_file_method_t; 196 197 /* 198 * sw_sample 199 */ 200 struct _sw_sample { 201 sw_sounddata * sounddata; 202 GList * views; 203 204 sw_view_bounds stored_views[10]; 205 206 gchar * pathname; 207 208 time_t last_mtime; 209 gboolean edit_ignore_mtime; 210 211 sw_file_method_t file_method; /* file handler; eg. libsndfile, libvorbis */ 212 int file_format; /* format within handler, eg. WAV */ 213 gpointer file_info; /* parameters of original file or last save */ 214 215 sw_sel * tmp_sel; /* Temporary selection, used while selecting */ 216 217 /* Operations; lock on scheduling */ 218 219 pthread_t ops_thread; 220 221 GMutex * ops_mutex; 222 GList * registered_ops; 223 GList * current_undo; 224 GList * current_redo; 225 sw_op_instance * active_op; 226 gint op_progress_tag; 227 228 /* Per-edit locking */ 229 230 GMutex * edit_mutex; /* Mutex for access to edit state */ 231 sw_edit_mode edit_mode; /* READY/MODIFYING/ALLOC */ 232 sw_edit_state edit_state; /* IDLE/BUSY/DONE/CANCEL */ 233 gboolean modified; /* modified since last save ? */ 234 235 GCond * pending_cond; /* held with edit_mutex */ 236 GList * pending_ops; 237 238 /* Playback, recording, scrubbing */ 239 240 sw_framecount_t user_offset; /* XXX: Actual offset of driver (frames) */ 241 gboolean by_user; /* Offset was last changed by user */ 242 243 GMutex * play_mutex; /* Mutex for access to play state */ 244 sw_head * play_head; 245 246 sw_head * rec_head; 247 248 gfloat rate; /* XXX: */ 249 250 gint color; 251 252 GtkWidget * info_clist; 253 254 gint progress_percent; /* completion percentage of current op */ 255 256 gint playmarker_tag; /* gtk_timeout tag for playmarkers */ 257 258 gboolean tmp_message_active; 259 gchar * last_tmp_message; 260 gint tmp_message_tag; 261 }; 262 263 void 264 sweep_quit (void); 265 266 guint 267 sweep_timeout_add (guint32 interval, GtkFunction function, gpointer data); 268 269 void 270 sweep_timeout_remove (guint sweep_timeout_handler_id); 271 272 #endif /* __SWEEP_APP_H__ */ 273