Changeset 470
- Timestamp:
- 01/16/07 19:06:49 (5 years ago)
- Files:
-
- sweep/branches/sweep-info-panel/ChangeLog (modified) (2 diffs)
- sweep/branches/sweep-info-panel/plugins/byenergy/byenergy.c (modified) (6 diffs)
- sweep/branches/sweep-info-panel/plugins/echo/echo.c (modified) (6 diffs)
- sweep/branches/sweep-info-panel/plugins/example/example.c (modified) (5 diffs)
- sweep/branches/sweep-info-panel/plugins/fade/fade.c (modified) (7 diffs)
- sweep/branches/sweep-info-panel/plugins/ladspa/ladspameta.c (modified) (24 diffs)
- sweep/branches/sweep-info-panel/plugins/normalise/normalise.c (modified) (4 diffs)
- sweep/branches/sweep-info-panel/plugins/reverse/reverse.c (modified) (8 diffs)
- sweep/branches/sweep-info-panel/src/about_dialog.c (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/about_dialog.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/callbacks.c (modified) (72 diffs)
- sweep/branches/sweep-info-panel/src/callbacks.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/channelops.c (modified) (27 diffs)
- sweep/branches/sweep-info-panel/src/channelops.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/cursors.c (modified) (9 diffs)
- sweep/branches/sweep-info-panel/src/cursors.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/db_ruler.c (modified) (26 diffs)
- sweep/branches/sweep-info-panel/src/db_ruler.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/db_slider.c (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/db_slider.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/driver.c (modified) (21 diffs)
- sweep/branches/sweep-info-panel/src/driver.h (modified) (5 diffs)
- sweep/branches/sweep-info-panel/src/driver_alsa.c (modified) (18 diffs)
- sweep/branches/sweep-info-panel/src/driver_oss.c (modified) (18 diffs)
- sweep/branches/sweep-info-panel/src/driver_solaris.c (modified) (7 diffs)
- sweep/branches/sweep-info-panel/src/edit.c (modified) (75 diffs)
- sweep/branches/sweep-info-panel/src/edit.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/file_dialogs.c (modified) (29 diffs)
- sweep/branches/sweep-info-panel/src/file_dialogs.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/file_mad.c (modified) (16 diffs)
- sweep/branches/sweep-info-panel/src/file_sndfile.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/file_sndfile1.c (modified) (30 diffs)
- sweep/branches/sweep-info-panel/src/file_speex.c (modified) (69 diffs)
- sweep/branches/sweep-info-panel/src/file_vorbis.c (modified) (46 diffs)
- sweep/branches/sweep-info-panel/src/format.c (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/format.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/head.c (modified) (45 diffs)
- sweep/branches/sweep-info-panel/src/head.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/info-panel.c (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/info-panel.h (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/interface.c (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/interface.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/levelmeter.c (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/levelmeter.h (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/main.c (modified) (5 diffs)
- sweep/branches/sweep-info-panel/src/notes.c (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/notes.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/param.c (modified) (23 diffs)
- sweep/branches/sweep-info-panel/src/param.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/paste_dialogs.c (modified) (10 diffs)
- sweep/branches/sweep-info-panel/src/paste_dialogs.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/pcmio.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/pixmaps.h (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/play.c (modified) (29 diffs)
- sweep/branches/sweep-info-panel/src/play.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/plugin.c (modified) (4 diffs)
- sweep/branches/sweep-info-panel/src/plugin.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/preferences.c (modified) (15 diffs)
- sweep/branches/sweep-info-panel/src/preferences.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/print.c (modified) (5 diffs)
- sweep/branches/sweep-info-panel/src/print.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/question_dialogs.c (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/question_dialogs.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/record.c (modified) (20 diffs)
- sweep/branches/sweep-info-panel/src/record.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/sample-display.c (modified) (74 diffs)
- sweep/branches/sweep-info-panel/src/sample-display.h (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/sample.h (modified) (3 diffs)
- sweep/branches/sweep-info-panel/src/samplerate.c (modified) (26 diffs)
- sweep/branches/sweep-info-panel/src/sw_chooser.c (modified) (14 diffs)
- sweep/branches/sweep-info-panel/src/sw_chooser.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/sweep_app.h (modified) (12 diffs)
- sweep/branches/sweep-info-panel/src/sweep_filter.c (modified) (7 diffs)
- sweep/branches/sweep-info-panel/src/sweep_marker.c (modified) (19 diffs)
- sweep/branches/sweep-info-panel/src/sweep_sample.c (modified) (91 diffs)
- sweep/branches/sweep-info-panel/src/sweep_selection.c (modified) (14 diffs)
- sweep/branches/sweep-info-panel/src/sweep_sounddata.c (modified) (14 diffs)
- sweep/branches/sweep-info-panel/src/sweep_typeconvert.c (modified) (4 diffs)
- sweep/branches/sweep-info-panel/src/sweep_undo.c (modified) (34 diffs)
- sweep/branches/sweep-info-panel/src/time_ruler.c (modified) (17 diffs)
- sweep/branches/sweep-info-panel/src/time_ruler.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/timeouts.c (modified) (6 diffs)
- sweep/branches/sweep-info-panel/src/undo_dialog.c (modified) (15 diffs)
- sweep/branches/sweep-info-panel/src/undo_dialog.h (modified) (1 diff)
- sweep/branches/sweep-info-panel/src/view.c (modified) (136 diffs)
- sweep/branches/sweep-info-panel/src/view.h (modified) (2 diffs)
- sweep/branches/sweep-info-panel/src/view_pixmaps.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sweep/branches/sweep-info-panel/ChangeLog
r341 r470 1 Tue Jan 16 10:53:31 CET 2007 Radoslaw Korzeniewski <radoslaw@korzeniewski.net> 2 3 * implementing Information Panel 4 * add Time markers 5 * indenting in GNU Style all code 6 1 7 Mon Jan 30 23:58:00 GMT 2006 Peter Shorthose <kickback@users.sourceforge.net> 2 8 … … 11 17 * a new SVG icon for sweep (Alex Kloss) 12 18 * an updated spanish translation (Waldo Ramirez Montano) 13 * an updated Polish translation (Radoslaw Korzeniewski)14 * more minor tweaks and improvements.19 * an updated Polish translation (Radoslaw Korzeniewski) 20 * more minor tweaks and improvements. 15 21 * released 0.9.0 16 22 sweep/branches/sweep-info-panel/plugins/byenergy/byenergy.c
r464 r470 30 30 31 31 static sw_param_range resolution_range = { 32 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,33 lower: {f:0.001},34 step: {f:0.001}32 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 33 lower: {f:0.001}, 34 step: {f:0.001} 35 35 }; 36 36 37 37 static sw_param_range threshold_range = { 38 38 SW_RANGE_ALL_VALID, 39 lower: {f:0.0},40 upper: {f:1.0},41 step: {f:0.01}39 lower: {f:0.0}, 40 upper: {f:1.0}, 41 step: {f:0.01} 42 42 }; 43 43 44 44 static sw_param_range min_duration_range = { 45 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,46 lower: {f:0.0},47 step: {f:0.01}45 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 46 lower: {f:0.0}, 47 step: {f:0.01} 48 48 }; 49 49 50 50 static sw_param_range max_interruption_range = { 51 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,52 lower: {f:0.0},53 step: {f:0.01}51 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 52 lower: {f:0.0}, 53 step: {f:0.01} 54 54 }; 55 55 56 56 static sw_param_spec param_specs[] = { 57 57 { 58 N_("Select regions above threshold"),59 N_("Whether to select those regions lying above a given threshold "60 "or below it."),61 SWEEP_TYPE_BOOL,62 SW_PARAM_CONSTRAINED_NOT,63 {NULL},64 },65 { 66 N_("Resolution"),67 N_("Width of energy detection window (s)"),68 SWEEP_TYPE_FLOAT,69 SW_PARAM_CONSTRAINED_RANGE,70 {range:&resolution_range}71 },72 { 73 N_("Threshold"),74 N_("Energy level to detect [0.0 - 1.0]"),75 SWEEP_TYPE_FLOAT,76 SW_PARAM_CONSTRAINED_RANGE,77 {range:&threshold_range},78 },79 { 80 N_("Minimum duration"),81 N_("Shortest region of selection to detect (s)"),82 SWEEP_TYPE_FLOAT,83 SW_PARAM_CONSTRAINED_RANGE,84 {range:&min_duration_range}85 },86 { 87 N_("Maximum interruption"),88 N_("Longest length of sound above threshold to allow (s)"),89 SWEEP_TYPE_FLOAT,90 SW_PARAM_CONSTRAINED_RANGE,91 {range:&max_interruption_range}92 }58 N_("Select regions above threshold"), 59 N_("Whether to select those regions lying above a given threshold " 60 "or below it."), 61 SWEEP_TYPE_BOOL, 62 SW_PARAM_CONSTRAINED_NOT, 63 {NULL}, 64 }, 65 { 66 N_("Resolution"), 67 N_("Width of energy detection window (s)"), 68 SWEEP_TYPE_FLOAT, 69 SW_PARAM_CONSTRAINED_RANGE, 70 {range:&resolution_range} 71 }, 72 { 73 N_("Threshold"), 74 N_("Energy level to detect [0.0 - 1.0]"), 75 SWEEP_TYPE_FLOAT, 76 SW_PARAM_CONSTRAINED_RANGE, 77 {range:&threshold_range}, 78 }, 79 { 80 N_("Minimum duration"), 81 N_("Shortest region of selection to detect (s)"), 82 SWEEP_TYPE_FLOAT, 83 SW_PARAM_CONSTRAINED_RANGE, 84 {range:&min_duration_range} 85 }, 86 { 87 N_("Maximum interruption"), 88 N_("Longest length of sound above threshold to allow (s)"), 89 SWEEP_TYPE_FLOAT, 90 SW_PARAM_CONSTRAINED_RANGE, 91 {range:&max_interruption_range} 92 } 93 93 }; 94 94 95 95 static void 96 by_energy_suggest (sw_sample * sample, sw_param_set pset, gpointer custom_data) 96 by_energy_suggest (sw_sample * sample, sw_param_set pset, 97 gpointer custom_data) 97 98 { 98 99 pset[0].b = FALSE; … … 112 113 gfloat max_interruption_f = pset[4].f; 113 114 114 sw_sounddata * sounddata;115 sw_audio_t * d;115 sw_sounddata *sounddata; 116 sw_audio_t *d; 116 117 glong window, win_s; 117 118 gint i, doff; 118 119 glong min_duration, max_interruption; 119 glong length, loc =0;120 glong start =-1, end=-1;121 sw_audio_intermediate_t di, energy, max_energy =0, factor=1.0;120 glong length, loc = 0; 121 glong start = -1, end = -1; 122 sw_audio_intermediate_t di, energy, max_energy = 0, factor = 1.0; 122 123 123 124 sounddata = sample_get_sounddata (s); 124 125 125 window = (glong) (resolution * (gfloat)sounddata->format->rate);126 window = (glong) (resolution * (gfloat) sounddata->format->rate); 126 127 length = sounddata->nr_frames; 127 min_duration = (glong) (min_duration_f * (gfloat)sounddata->format->rate);128 min_duration = (glong) (min_duration_f * (gfloat) sounddata->format->rate); 128 129 129 130 /* check (end-1 - (start+1)) > 0 */ 130 min_duration = MAX(2*window, min_duration); 131 max_interruption = (glong)(max_interruption_f * (gfloat)sounddata->format->rate); 132 133 d = (sw_audio_t *)sounddata->data; 131 min_duration = MAX (2 * window, min_duration); 132 max_interruption = 133 (glong) (max_interruption_f * (gfloat) sounddata->format->rate); 134 135 d = (sw_audio_t *) sounddata->data; 134 136 135 137 sounddata_lock_selection (sounddata); … … 141 143 length = sounddata->nr_frames; 142 144 doff = 0; 143 while (length > 0) { 144 energy = 0; 145 146 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 147 148 /* calculate avg. for this window */ 149 for (i=0; i<win_s; i++) { 150 di = (sw_audio_intermediate_t)(d[doff+i] * factor); 151 energy += fabs(di); 145 while (length > 0) 146 { 147 energy = 0; 148 149 win_s = frames_to_samples (sounddata->format, MIN (length, window)); 150 151 /* calculate avg. for this window */ 152 for (i = 0; i < win_s; i++) 153 { 154 di = (sw_audio_intermediate_t) (d[doff + i] * factor); 155 energy += fabs (di); 156 } 157 doff += win_s; 158 159 energy /= (sw_audio_intermediate_t) win_s; 160 energy = sqrt (energy); 161 162 max_energy = MAX (energy, max_energy); 163 164 length -= window; 152 165 } 153 doff += win_s;154 155 energy /= (sw_audio_intermediate_t)win_s;156 energy = sqrt(energy);157 158 max_energy = MAX(energy, max_energy);159 160 length -= window;161 }162 166 163 167 factor = SW_AUDIO_T_MAX / max_energy; … … 167 171 #endif 168 172 169 threshold *= (gfloat) max_energy;173 threshold *= (gfloat) max_energy; 170 174 171 175 length = sounddata->nr_frames; 172 176 doff = 0; 173 while (length > 0) { 174 energy = 0; 175 176 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 177 178 /* calculate RMS energy for this window */ 179 for (i=0; i<win_s; i++) { 180 di = (sw_audio_intermediate_t)(d[doff+i]); 181 energy += fabs(di); 177 while (length > 0) 178 { 179 energy = 0; 180 181 win_s = frames_to_samples (sounddata->format, MIN (length, window)); 182 183 /* calculate RMS energy for this window */ 184 for (i = 0; i < win_s; i++) 185 { 186 di = (sw_audio_intermediate_t) (d[doff + i]); 187 energy += fabs (di); 188 } 189 doff += win_s; 190 191 energy /= (sw_audio_intermediate_t) win_s; 192 energy = sqrt (energy); 193 194 #ifdef DEBUG 195 g_print ("%ld\tenergy: %f\tthreshold: %f\n", loc, energy, threshold); 196 #endif 197 198 /* Check if threshold condition is met */ 199 if (select_above ? (energy >= threshold) : (energy <= threshold)) 200 { 201 if (start == -1) 202 { 203 /* Not in possible selection; initialise start,end */ 204 end = start = loc; 205 } 206 else 207 { 208 end = loc; 209 } 210 } 211 else if (end != -1) 212 { 213 if (loc - end > max_interruption) 214 { 215 if (end - start > min_duration) 216 { 217 sounddata_add_selection_1 (sounddata, start + 1, end - 1, 218 NULL); 219 } 220 end = start = -1; 221 } 222 /* else do nothing: keep start, end where they are */ 223 } 224 225 loc += window; 226 length -= window; 182 227 } 183 doff += win_s; 184 185 energy /= (sw_audio_intermediate_t)win_s; 186 energy = sqrt(energy); 187 188 #ifdef DEBUG 189 g_print ("%ld\tenergy: %f\tthreshold: %f\n", loc, energy, threshold); 190 #endif 191 192 /* Check if threshold condition is met */ 193 if (select_above ? (energy >= threshold) : (energy <= threshold)) { 194 if (start == -1) { 195 /* Not in possible selection; initialise start,end */ 196 end = start = loc; 197 } else { 198 end = loc; 199 } 200 } else if (end != -1) { 201 if (loc - end > max_interruption) { 202 if (end - start > min_duration) { 203 sounddata_add_selection_1 (sounddata, start + 1, end - 1, NULL); 204 } 205 end = start = -1; 206 } 207 /* else do nothing: keep start, end where they are */ 228 229 if (start != -1) 230 { 231 if (end - start > min_duration) 232 { 233 sounddata_add_selection_1 (sounddata, start, end, NULL); 234 } 208 235 } 209 236 210 loc += window;211 length -= window;212 }213 214 if (start != -1) {215 if (end - start > min_duration) {216 sounddata_add_selection_1 (sounddata, start, end, NULL);217 }218 }219 220 237 sounddata_unlock_selection (sounddata); 221 238 } 222 239 223 240 static sw_op_instance * 224 apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data)241 apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data) 225 242 { 226 243 return 227 244 perform_selection_op (sample, _("Select by energy"), 228 (SweepFilter) select_by_energy, pset, NULL);245 (SweepFilter) select_by_energy, pset, NULL); 229 246 } 230 247 … … 235 252 "Copyright (C) 2000 CSIRO Australia", 236 253 "http://sweep.sourceforge.net/plugins/byenergy", 237 "Filters/Select by energy", /* identifier */238 0, /* accel_key */239 0, /* accel_mods */240 NR_PARAMS, /* nr_params */241 param_specs, /* param_specs */242 by_energy_suggest, /* suggests() */254 "Filters/Select by energy", /* identifier */ 255 0, /* accel_key */ 256 0, /* accel_mods */ 257 NR_PARAMS, /* nr_params */ 258 param_specs, /* param_specs */ 259 by_energy_suggest, /* suggests() */ 243 260 apply_by_energy, 244 NULL, /* custom data */261 NULL, /* custom data */ 245 262 }; 246 263 … … 248 265 by_energy_init (void) 249 266 { 250 return g_list_append ((GList *) NULL, &proc_by_energy);267 return g_list_append ((GList *) NULL, &proc_by_energy); 251 268 } 252 269 253 270 254 271 sw_plugin plugin = { 255 by_energy_init, /* plugin_init */256 NULL, /* plugin_cleanup */257 }; 272 by_energy_init, /* plugin_init */ 273 NULL, /* plugin_cleanup */ 274 }; sweep/branches/sweep-info-panel/plugins/echo/echo.c
r80 r470 36 36 37 37 static sw_param_range delay_range = { 38 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,39 lower: {f:0.0},40 step: {f:0.001}38 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 39 lower: {f:0.0}, 40 step: {f:0.001} 41 41 }; 42 42 43 43 static sw_param_range gain_range = { 44 44 SW_RANGE_ALL_VALID, 45 lower: {f:0.0},46 upper: {f:1.0},47 step: {f:0.01}45 lower: {f:0.0}, 46 upper: {f:1.0}, 47 step: {f:0.01} 48 48 }; 49 49 … … 51 51 static sw_param_spec param_specs[] = { 52 52 { 53 N_("Delay"), 54 N_("Time to delay by"), 55 SWEEP_TYPE_FLOAT, 56 SW_PARAM_CONSTRAINED_RANGE, 57 {range: &delay_range}, 58 SW_PARAM_HINT_TIME 59 }, 53 N_("Delay"), 54 N_("Time to delay by"), 55 SWEEP_TYPE_FLOAT, 56 SW_PARAM_CONSTRAINED_RANGE, 57 {range:&delay_range}, 58 SW_PARAM_HINT_TIME}, 60 59 { 61 N_("Gain"), 62 N_("Gain with which to mix in delayed signal"), 63 SWEEP_TYPE_FLOAT, 64 SW_PARAM_CONSTRAINED_RANGE, 65 {range: &gain_range}, 66 SW_PARAM_HINT_DEFAULT 67 }, 60 N_("Gain"), 61 N_("Gain with which to mix in delayed signal"), 62 SWEEP_TYPE_FLOAT, 63 SW_PARAM_CONSTRAINED_RANGE, 64 {range:&gain_range}, 65 SW_PARAM_HINT_DEFAULT}, 68 66 }; 69 67 … … 83 81 84 82 sw_framecount_t i, delay_f, dlen_s; 85 sw_audio_t * d, *e;83 sw_audio_t *d, *e; 86 84 gpointer ep; 87 85 88 86 delay_f = time_to_frames (format, delay); 89 87 90 d = (sw_audio_t *) data;88 d = (sw_audio_t *) data; 91 89 ep = data + frames_to_bytes (format, delay_f); 92 e = (sw_audio_t *) ep;90 e = (sw_audio_t *) ep; 93 91 94 if (delay > nr_frames) return; 92 if (delay > nr_frames) 93 return; 95 94 96 95 dlen_s = frames_to_samples (format, nr_frames - delay_f); 97 96 98 for (i = 0; i < dlen_s; i++) { 99 e[i] += (sw_audio_t)((gfloat)(d[i]) * gain); 100 } 97 for (i = 0; i < dlen_s; i++) 98 { 99 e[i] += (sw_audio_t) ((gfloat) (d[i]) * gain); 100 } 101 101 } 102 102 … … 106 106 return 107 107 perform_filter_region_op (sample, _("Echo"), 108 (SweepFilterRegion) region_echo, pset, NULL);108 (SweepFilterRegion) region_echo, pset, NULL); 109 109 } 110 110 … … 116 116 "Copyright (C) 2000", 117 117 "http://sweep.sourceforge.net/plugins/echo", 118 "Filters/Echo", /* identifier */119 GDK_e, /* accel_key */120 GDK_SHIFT_MASK, /* accel_mods */121 NR_PARAMS, /* nr_params */122 param_specs, /* param_specs */123 echo_suggest, /* suggests() */118 "Filters/Echo", /* identifier */ 119 GDK_e, /* accel_key */ 120 GDK_SHIFT_MASK, /* accel_mods */ 121 NR_PARAMS, /* nr_params */ 122 param_specs, /* param_specs */ 123 echo_suggest, /* suggests() */ 124 124 echo_apply, 125 NULL, /* custom_data */125 NULL, /* custom_data */ 126 126 }; 127 127 … … 129 129 echo_init (void) 130 130 { 131 return g_list_append ((GList *) NULL, &proc_echo);131 return g_list_append ((GList *) NULL, &proc_echo); 132 132 } 133 133 134 134 135 135 sw_plugin plugin = { 136 echo_init, /* plugin_init */137 NULL, /* plugin_cleanup */136 echo_init, /* plugin_init */ 137 NULL, /* plugin_cleanup */ 138 138 }; sweep/branches/sweep-info-panel/plugins/example/example.c
r75 r470 34 34 35 35 static sw_param stix_list[] = { 36 {i:4},37 {s:N_("With a fork")},38 {s:N_("With a spoon")},39 {s:N_("With false teeth")},40 {s:N_("With Nigel's bum")}36 {i:4}, 37 {s:N_("With a fork")}, 38 {s:N_("With a spoon")}, 39 {s:N_("With false teeth")}, 40 {s:N_("With Nigel's bum")} 41 41 }; 42 42 43 43 static sw_param pants_list[] = { 44 {i:7},45 {i:0},46 {i:1},47 {i:2},48 {i:7},49 {i:42},50 {i:44100},51 {i:1000000}44 {i:7}, 45 {i:0}, 46 {i:1}, 47 {i:2}, 48 {i:7}, 49 {i:42}, 50 {i:44100}, 51 {i:1000000} 52 52 }; 53 53 54 54 static sw_param_spec example_filter_region_param_specs[] = { 55 55 { 56 N_("Flim"), 57 N_("Should you manage your flim?"), 58 SWEEP_TYPE_BOOL, 59 SW_PARAM_CONSTRAINED_NOT, 60 {NULL}, 61 SW_PARAM_HINT_DEFAULT 62 }, 56 N_("Flim"), 57 N_("Should you manage your flim?"), 58 SWEEP_TYPE_BOOL, 59 SW_PARAM_CONSTRAINED_NOT, 60 {NULL}, 61 SW_PARAM_HINT_DEFAULT}, 63 62 { 64 N_("Beans"), 65 N_("Method of eating beans"), 66 SWEEP_TYPE_STRING, 67 SW_PARAM_CONSTRAINED_LIST, 68 {list: (sw_param *)&stix_list}, 69 SW_PARAM_HINT_DEFAULT 70 }, 63 N_("Beans"), 64 N_("Method of eating beans"), 65 SWEEP_TYPE_STRING, 66 SW_PARAM_CONSTRAINED_LIST, 67 {list:(sw_param *) & stix_list}, 68 SW_PARAM_HINT_DEFAULT}, 71 69 { 72 N_("Pants methodology"), 73 N_("How many pants should you wear per day?"), 74 SWEEP_TYPE_INT, 75 SW_PARAM_CONSTRAINED_LIST, 76 {list: (sw_param *)&pants_list}, 77 SW_PARAM_HINT_DEFAULT 78 } 70 N_("Pants methodology"), 71 N_("How many pants should you wear per day?"), 72 SWEEP_TYPE_INT, 73 SW_PARAM_CONSTRAINED_LIST, 74 {list:(sw_param *) & pants_list}, 75 SW_PARAM_HINT_DEFAULT} 79 76 }; 80 77 … … 93 90 { 94 91 gboolean flim = pset[0].b; 95 gchar * beans = pset[1].s;92 gchar *beans = pset[1].s; 96 93 gint nr_pants = pset[2].i; 97 94 98 if (flim) { 99 /* manage flim */ 100 } 95 if (flim) 96 { 97 /* manage flim */ 98 } 101 99 102 if (!strcmp(beans, "With a spoon")) { 103 /* eat beans with a spoon */ 104 } else { 105 /* spill beans everywhere */ 106 } 100 if (!strcmp (beans, "With a spoon")) 101 { 102 /* eat beans with a spoon */ 103 } 104 else 105 { 106 /* spill beans everywhere */ 107 } 107 108 108 if (nr_pants > 1000) { 109 /* We're wearing too many pants! */ 110 return; 111 } 109 if (nr_pants > 1000) 110 { 111 /* We're wearing too many pants! */ 112 return; 113 } 112 114 113 115 /* Do filtering stuff */ … … 121 123 return 122 124 perform_filter_region_op (sample, _("Example Filter Region"), 123 (SweepFilterRegion) example_filter_region_func,125 (SweepFilterRegion) example_filter_region_func, 124 126 pset, NULL); 125 127 } … … 132 134 "Copyright (C) 2000", 133 135 "http://sweep.sourceforge.net/plugins/example", 134 "Example", /* identifier */135 0, /* accel_key */136 0, /* accel_mods */137 3, /* nr_params */138 example_filter_region_param_specs, /* param_specs */139 example_filter_region_suggest, /* suggests() */136 "Example", /* identifier */ 137 0, /* accel_key */ 138 0, /* accel_mods */ 139 3, /* nr_params */ 140 example_filter_region_param_specs, /* param_specs */ 141 example_filter_region_suggest, /* suggests() */ 140 142 example_filter_region_apply, 141 NULL, /* custom_data */143 NULL, /* custom_data */ 142 144 }; 143 145 … … 145 147 example_init (void) 146 148 { 147 return g_list_append ((GList *) NULL, &proc_example_filter_region);149 return g_list_append ((GList *) NULL, &proc_example_filter_region); 148 150 } 149 151 150 152 151 153 sw_plugin plugin = { 152 example_init, /* plugin_init */153 NULL, /* plugin_cleanup */154 example_init, /* plugin_init */ 155 NULL, /* plugin_cleanup */ 154 156 }; sweep/branches/sweep-info-panel/plugins/fade/fade.c
r124 r470 26 26 #include <sweep/sweep.h> 27 27 28 #include <../src/sweep_app.h> /* XXX */28 #include <../src/sweep_app.h> /* XXX */ 29 29 30 30 static sw_sample * 31 31 fade (sw_sample * sample, gfloat start, gfloat end) 32 32 { 33 sw_sounddata * sounddata;34 sw_format * f;35 GList * gl;36 sw_sel * sel;37 sw_audio_t * d;33 sw_sounddata *sounddata; 34 sw_format *f; 35 GList *gl; 36 sw_sel *sel; 37 sw_audio_t *d; 38 38 gfloat factor = start; 39 39 sw_framecount_t op_total, run_total; … … 47 47 48 48 op_total = sounddata_selection_nr_frames (sounddata) / 100; 49 if (op_total == 0) op_total = 1; 49 if (op_total == 0) 50 op_total = 1; 50 51 run_total = 0; 51 52 52 53 #if 0 53 54 /* Find max */ 54 for (gl = sounddata->sels; active && gl; gl = gl->next) { 55 sel = (sw_sel *)gl->data; 56 57 offset = 0; 58 remaining = sel->sel_end - sel->sel_start; 59 60 while (active && remaining > 0) { 61 g_mutex_lock (sample->ops_mutex); 62 63 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 64 active = FALSE; 65 } else { 66 67 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 68 69 n = MIN(remaining, 1024); 70 71 for (i=0; i < n * f->channels; i++) { 72 if(d[i]>=0) max = MAX(max, d[i]); 73 else max = MAX(max, -d[i]); 55 for (gl = sounddata->sels; active && gl; gl = gl->next) 56 { 57 sel = (sw_sel *) gl->data; 58 59 offset = 0; 60 remaining = sel->sel_end - sel->sel_start; 61 62 while (active && remaining > 0) 63 { 64 g_mutex_lock (sample->ops_mutex); 65 66 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 67 { 68 active = FALSE; 69 } 70 else 71 { 72 73 d = 74 sounddata->data + frames_to_bytes (f, 75 sel->sel_start + offset); 76 77 n = MIN (remaining, 1024); 78 79 for (i = 0; i < n * f->channels; i++) 80 { 81 if (d[i] >= 0) 82 max = MAX (max, d[i]); 83 else 84 max = MAX (max, -d[i]); 85 } 86 87 remaining -= n; 88 offset += n; 89 90 run_total += n; 91 sample_set_progress_percent (sample, run_total / op_total); 92 } 93 94 g_mutex_unlock (sample->ops_mutex); 74 95 } 75 76 remaining -= n;77 offset += n;78 79 run_total += n;80 sample_set_progress_percent (sample, run_total / op_total);81 }82 83 g_mutex_unlock (sample->ops_mutex);84 96 } 85 } 86 87 if (max != 0) factor = SW_AUDIO_T_MAX / (gfloat)max;97 98 if (max != 0) 99 factor = SW_AUDIO_T_MAX / (gfloat) max; 88 100 #endif 89 101 90 102 /* Fade */ 91 for (gl = sounddata->sels; active && gl; gl = gl->next) { 92 sel = (sw_sel *)gl->data; 93 94 offset = 0; 95 remaining = sel->sel_end - sel->sel_start; 96 97 while (active && remaining > 0) { 98 g_mutex_lock (sample->ops_mutex); 99 100 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 101 active = FALSE; 102 } else { 103 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 104 105 n = MIN(remaining, 1024); 106 107 factor = start + (end - start) * 0.01 * 108 (gfloat)run_total / (gfloat)op_total; 109 110 for (i=0; i < n * f->channels; i++) { 111 d[i] = (sw_audio_t)((gfloat)d[i] * factor); 103 for (gl = sounddata->sels; active && gl; gl = gl->next) 104 { 105 sel = (sw_sel *) gl->data; 106 107 offset = 0; 108 remaining = sel->sel_end - sel->sel_start; 109 110 while (active && remaining > 0) 111 { 112 g_mutex_lock (sample->ops_mutex); 113 114 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 115 { 116 active = FALSE; 117 } 118 else 119 { 120 d = 121 sounddata->data + frames_to_bytes (f, 122 sel->sel_start + offset); 123 124 n = MIN (remaining, 1024); 125 126 factor = start + (end - start) * 0.01 * 127 (gfloat) run_total / (gfloat) op_total; 128 129 for (i = 0; i < n * f->channels; i++) 130 { 131 d[i] = (sw_audio_t) ((gfloat) d[i] * factor); 132 } 133 134 remaining -= n; 135 offset += n; 136 137 run_total += n; 138 sample_set_progress_percent (sample, 139 run_total * 100 / op_total); 140 } 141 142 g_mutex_unlock (sample->ops_mutex); 112 143 } 113 114 remaining -= n;115 offset += n;116 117 run_total += n;118 sample_set_progress_percent (sample, run_total * 100 / op_total);119 }120 121 g_mutex_unlock (sample->ops_mutex);122 144 } 123 }124 145 125 146 return sample; … … 142 163 { 143 164 return 144 perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in,165 perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in, 145 166 pset, NULL); 146 167 } … … 150 171 { 151 172 return 152 perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out,173 perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out, 153 174 pset, NULL); 154 175 } … … 160 181 "Copyright (C) 2002", 161 182 "http://sweep.sourceforge.net/plugins/fade", 162 "Filters/Fade_In", /* identifier */163 0, /* accel_key */164 0, /* accel_mods */165 0, /* nr_params */166 NULL, /* param_specs */167 NULL, /* suggests() */183 "Filters/Fade_In", /* identifier */ 184 0, /* accel_key */ 185 0, /* accel_mods */ 186 0, /* nr_params */ 187 NULL, /* param_specs */ 188 NULL, /* suggests() */ 168 189 apply_fade_in, 169 NULL, /* custom_data */190 NULL, /* custom_data */ 170 191 }; 171 192 … … 176 197 "Copyright (C) 2002", 177 198 "http://sweep.sourceforge.net/plugins/fade", 178 "Filters/Fade_In", /* identifier */179 0, /* accel_key */180 0, /* accel_mods */181 0, /* nr_params */182 NULL, /* param_specs */183 NULL, /* suggests() */199 "Filters/Fade_In", /* identifier */ 200 0, /* accel_key */ 201 0, /* accel_mods */ 202 0, /* nr_params */ 203 NULL, /* param_specs */ 204 NULL, /* suggests() */ 184 205 apply_fade_out, 185 NULL, /* custom_data */206 NULL, /* custom_data */ 186 207 }; 187 208 188 209 static GList * 189 210 fade_init (void) 190 211 { 191 GList * gl = NULL;212 GList *gl = NULL; 192 213 193 214 gl = g_list_append (gl, &proc_fade_in); … … 199 220 200 221 sw_plugin plugin = { 201 fade_init, /* plugin_init */202 NULL, /* plugin_cleanup */222 fade_init, /* plugin_init */ 223 NULL, /* plugin_cleanup */ 203 224 }; sweep/branches/sweep-info-panel/plugins/ladspa/ladspameta.c
r130 r470 30 30 #include <dirent.h> 31 31 #include <string.h> 32 #include <math.h> /* for ceil() */32 #include <math.h> /* for ceil() */ 33 33 34 34 #include <glib.h> … … 59 59 #define LADSPA_frames_to_bytes(f) (f * sizeof(LADSPA_Data)) 60 60 61 static char * default_ladspa_path = "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 62 63 static GList * modules_list = NULL; 61 static char *default_ladspa_path = 62 "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 63 64 static GList *modules_list = NULL; 64 65 static gboolean ladspa_meta_initialised = FALSE; 65 66 … … 73 74 */ 74 75 static gboolean 75 is_usable (const LADSPA_Descriptor * d)76 is_usable (const LADSPA_Descriptor * d) 76 77 { 77 78 LADSPA_PortDescriptor pd; 78 79 gint i; 79 gint 80 nr_ai=0, /* audio inputs */ 81 nr_ao=0; /* audio outputs */ 82 83 for (i=0; i < d->PortCount; i++) { 84 pd = d->PortDescriptors[i]; 85 if (LADSPA_IS_AUDIO_INPUT(pd)) 86 nr_ai++; 87 if (LADSPA_IS_AUDIO_OUTPUT(pd)) 88 nr_ao++; 89 } 90 91 if (nr_ao == 0) return FALSE; 80 gint nr_ai = 0, /* audio inputs */ 81 nr_ao = 0; /* audio outputs */ 82 83 for (i = 0; i < d->PortCount; i++) 84 { 85 pd = d->PortDescriptors[i]; 86 if (LADSPA_IS_AUDIO_INPUT (pd)) 87 nr_ai++; 88 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 89 nr_ao++; 90 } 91 92 if (nr_ao == 0) 93 return FALSE; 92 94 93 95 /* Sanity checks */ 94 if (! d->run) return FALSE; /* plugin does nothing! */ 95 if (! d->instantiate) return FALSE; /* plugin cannot be instantiated */ 96 if (! d->connect_port) return FALSE; /* plugin cannot be wired up */ 96 if (!d->run) 97 return FALSE; /* plugin does nothing! */ 98 if (!d->instantiate) 99 return FALSE; /* plugin cannot be instantiated */ 100 if (!d->connect_port) 101 return FALSE; /* plugin cannot be wired up */ 97 102 98 103 return (nr_ai == nr_ao); … … 102 107 convert_type (const LADSPA_PortRangeHintDescriptor prhd) 103 108 { 104 if (LADSPA_IS_HINT_TOGGLED (prhd))109 if (LADSPA_IS_HINT_TOGGLED (prhd)) 105 110 return SWEEP_TYPE_BOOL; 106 else if (LADSPA_IS_HINT_INTEGER (prhd))111 else if (LADSPA_IS_HINT_INTEGER (prhd)) 107 112 return SWEEP_TYPE_INT; 108 113 else … … 113 118 get_valid_mask (const LADSPA_PortRangeHintDescriptor prhd) 114 119 { 115 int ret =0;116 117 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd))120 int ret = 0; 121 122 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 118 123 ret |= SW_RANGE_LOWER_BOUND_VALID; 119 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd))124 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 120 125 ret |= SW_RANGE_UPPER_BOUND_VALID; 121 126 … … 124 129 125 130 static sw_param_range * 126 convert_constraint ( /* sw_format * format, */127 const LADSPA_PortRangeHint * prh)128 { 129 sw_param_range * pr;131 convert_constraint ( /* sw_format * format, */ 132 const LADSPA_PortRangeHint * prh) 133 { 134 sw_param_range *pr; 130 135 LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 131 136 LADSPA_Data lower, upper; 132 137 133 if (LADSPA_IS_HINT_TOGGLED (prhd))138 if (LADSPA_IS_HINT_TOGGLED (prhd)) 134 139 return NULL; 135 140 … … 141 146 upper = prh->UpperBound; 142 147 143 if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 148 if LADSPA_IS_HINT_SAMPLE_RATE 149 (prhd) 150 { 144 151 #if 0 145 lower *= format->rate;146 upper *= format->rate;152 lower *= format->rate; 153 upper *= format->rate; 147 154 #else 148 lower *= 44100;149 upper *= 44100;155 lower *= 44100; 156 upper *= 44100; 150 157 #endif 151 } 152 153 if (LADSPA_IS_HINT_INTEGER(prhd)) { 154 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 155 pr->lower.i = (sw_int)lower; 156 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 157 pr->upper.i = (sw_int)upper; 158 } else { 159 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 160 pr->lower.f = (sw_float)lower; 161 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 162 pr->upper.f = (sw_float)upper; 163 } 158 } 159 160 if (LADSPA_IS_HINT_INTEGER (prhd)) 161 { 162 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 163 pr->lower.i = (sw_int) lower; 164 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 165 pr->upper.i = (sw_int) upper; 166 } 167 else 168 { 169 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 170 pr->lower.f = (sw_float) lower; 171 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 172 pr->upper.f = (sw_float) upper; 173 } 164 174 165 175 return pr; … … 168 178 typedef struct _lm_custom lm_custom; 169 179 170 struct _lm_custom { 171 const LADSPA_Descriptor * d; 172 sw_param_spec * param_specs; 180 struct _lm_custom 181 { 182 const LADSPA_Descriptor *d; 183 sw_param_spec *param_specs; 173 184 }; 174 185 … … 176 187 lm_custom_new (const LADSPA_Descriptor * d, sw_param_spec * param_specs) 177 188 { 178 lm_custom * lmc;189 lm_custom *lmc; 179 190 180 191 lmc = g_malloc (sizeof (*lmc)); 181 if (lmc) { 182 lmc->d = d; 183 lmc->param_specs = param_specs; 184 } 192 if (lmc) 193 { 194 lmc->d = d; 195 lmc->param_specs = param_specs; 196 } 185 197 186 198 return lmc; … … 203 215 upper = prh->UpperBound; 204 216 205 if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 206 lower *= format->rate; 207 upper *= format->rate; 208 } 217 if LADSPA_IS_HINT_SAMPLE_RATE 218 (prhd) 219 { 220 lower *= format->rate; 221 upper *= format->rate; 222 } 209 223 210 224 /* Determine default value, as sw_float */ 211 225 212 if (!LADSPA_IS_HINT_HAS_DEFAULT (prhd)) { 213 def = 0.0; 214 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (prhd)) { 215 def = prh->LowerBound; 216 } else if (bounded && LADSPA_IS_HINT_DEFAULT_LOW (prhd)) { 217 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 218 def = exp(log(lower) * 0.75 + log(upper) * 0.25); 219 } else { 220 def = lower * 0.75 + upper * 0.25; 221 } 222 } else if (bounded && LADSPA_IS_HINT_DEFAULT_MIDDLE (prhd)) { 223 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 224 exp(log(lower) * 0.5 + log(upper) * 0.5); 225 } else { 226 def = lower * 0.5 + upper * 0.5; 227 } 228 } else if (bounded && LADSPA_IS_HINT_DEFAULT_HIGH (prhd)) { 229 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 230 exp(log(lower) * 0.25 + log(upper) * 0.75); 231 } else { 232 def = lower * 0.25 + upper * 0.75; 233 } 234 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (prhd)) { 235 def = prh->UpperBound; 236 } else if (LADSPA_IS_HINT_DEFAULT_0 (prhd)) { 237 def = 0.0; 238 } else if (LADSPA_IS_HINT_DEFAULT_1 (prhd)) { 239 def = 1.0; 240 } else if (LADSPA_IS_HINT_DEFAULT_100 (prhd)) { 241 def = 100.0; 242 } else if (LADSPA_IS_HINT_DEFAULT_440 (prhd)) { 243 def = 440.0; 244 } else { 245 def = 0.0; 246 } 226 if (!LADSPA_IS_HINT_HAS_DEFAULT (prhd)) 227 { 228 def = 0.0; 229 } 230 else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (prhd)) 231 { 232 def = prh->LowerBound; 233 } 234 else if (bounded && LADSPA_IS_HINT_DEFAULT_LOW (prhd)) 235 { 236 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 237 { 238 def = exp (log (lower) * 0.75 + log (upper) * 0.25); 239 } 240 else 241 { 242 def = lower * 0.75 + upper * 0.25; 243 } 244 } 245 else if (bounded && LADSPA_IS_HINT_DEFAULT_MIDDLE (prhd)) 246 { 247 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 248 { 249 exp (log (lower) * 0.5 + log (upper) * 0.5); 250 } 251 else 252 { 253 def = lower * 0.5 + upper * 0.5; 254 } 255 } 256 else if (bounded && LADSPA_IS_HINT_DEFAULT_HIGH (prhd)) 257 { 258 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 259 { 260 exp (log (lower) * 0.25 + log (upper) * 0.75); 261 } 262 else 263 { 264 def = lower * 0.25 + upper * 0.75; 265 } 266 } 267 else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (prhd)) 268 { 269 def = prh->UpperBound; 270 } 271 else if (LADSPA_IS_HINT_DEFAULT_0 (prhd)) 272 { 273 def = 0.0; 274 } 275 else if (LADSPA_IS_HINT_DEFAULT_1 (prhd)) 276 { 277 def = 1.0; 278 } 279 else if (LADSPA_IS_HINT_DEFAULT_100 (prhd)) 280 { 281 def = 100.0; 282 } 283 else if (LADSPA_IS_HINT_DEFAULT_440 (prhd)) 284 { 285 def = 440.0; 286 } 287 else 288 { 289 def = 0.0; 290 } 247 291 248 292 /* Convert to sw_param type */ 249 293 250 if (LADSPA_IS_HINT_TOGGLED (prhd)) { 251 param.b = (sw_bool)def; 252 } else if (LADSPA_IS_HINT_INTEGER (prhd)) { 253 param.i = (sw_int)def; 254 } else { 255 param.f = (sw_float)def; 256 } 294 if (LADSPA_IS_HINT_TOGGLED (prhd)) 295 { 296 param.b = (sw_bool) def; 297 } 298 else if (LADSPA_IS_HINT_INTEGER (prhd)) 299 { 300 param.i = (sw_int) def; 301 } 302 else 303 { 304 param.f = (sw_float) def; 305 } 257 306 258 307 return param; … … 263 312 gpointer custom_data) 264 313 { 265 sw_sounddata * sounddata;266 lm_custom * lm = (lm_custom *)custom_data;267 const LADSPA_Descriptor * d = lm->d;314 sw_sounddata *sounddata; 315 lm_custom *lm = (lm_custom *) custom_data; 316 const LADSPA_Descriptor *d = lm->d; 268 317 269 318 LADSPA_PortDescriptor pd; … … 272 321 sounddata = sample_get_sounddata (sample); 273 322 274 for (i=0; i < d->PortCount; i++) { 275 pd = d->PortDescriptors[i]; 276 if (LADSPA_IS_CONTROL_INPUT(pd)) { 277 pset[pset_i] = convert_default (sounddata->format, 278 &d->PortRangeHints[i]); 279 pset_i++; 280 } 281 } 323 for (i = 0; i < d->PortCount; i++) 324 { 325 pd = d->PortDescriptors[i]; 326 if (LADSPA_IS_CONTROL_INPUT (pd)) 327 { 328 pset[pset_i] = convert_default (sounddata->format, 329 &d->PortRangeHints[i]); 330 pset_i++; 331 } 332 } 282 333 283 334 } … … 289 340 gpointer custom_data) 290 341 { 291 lm_custom * lm = (lm_custom *)custom_data;292 const LADSPA_Descriptor * d = lm->d;293 sw_param_spec * param_specs = lm->param_specs;294 295 sw_sounddata * sounddata;296 sw_format * format;342 lm_custom *lm = (lm_custom *) custom_data; 343 const LADSPA_Descriptor *d = lm->d; 344 sw_param_spec *param_specs = lm->param_specs; 345 346 sw_sounddata *sounddata; 347 sw_format *format; 297 348 sw_framecount_t op_total, run_total; 298 349 sw_framecount_t offset, remaining, n; 299 350 300 GList * gl;301 sw_sel * sel;351 GList *gl; 352 sw_sel *sel; 302 353 303 354 gpointer pcmdata; … … 310 361 gint nr_handles; 311 362 312 LADSPA_Handle ** handles;313 LADSPA_Data ** input_buffers, **output_buffers;314 LADSPA_Data * mono_input_buffers[1], *mono_output_buffers[1];315 LADSPA_Data * p;316 LADSPA_Data * control_inputs;363 LADSPA_Handle **handles; 364 LADSPA_Data **input_buffers, **output_buffers; 365 LADSPA_Data *mono_input_buffers[1], *mono_output_buffers[1]; 366 LADSPA_Data *p; 367 LADSPA_Data *control_inputs; 317 368 LADSPA_Data dummy_control_output; 318 369 LADSPA_PortDescriptor pd; 319 370 glong length_b; 320 gulong port_i; /* counter for iterating over ports */371 gulong port_i; /* counter for iterating over ports */ 321 372 gint h, i, j, c; 322 373 323 374 /* Enumerate the numbers of each type of port on the ladspa plugin */ 324 gint 325 nr_ci=0, /* control inputs */ 326 nr_ai=0, /* audio inputs */ 327 nr_co=0, /* control outputs */ 328 nr_ao=0; /* audio outputs */ 375 gint nr_ci = 0, /* control inputs */ 376 nr_ai = 0, /* audio inputs */ 377 nr_co = 0, /* control outputs */ 378 nr_ao = 0; /* audio outputs */ 329 379 330 380 /* The number of audio channels to be processed */ … … 332 382 333 383 /* The number of input and output buffers to use */ 334 gint nr_i =0, nr_o=0;384 gint nr_i = 0, nr_o = 0; 335 385 336 386 /* Counters for allocating input and output buffers */ 337 gint ibi =0, obi=0;387 gint ibi = 0, obi = 0; 338 388 339 389 gboolean active = TRUE; … … 346 396 347 397 op_total = sounddata_selection_nr_frames (sounddata) / 100; 348 if (op_total == 0) op_total = 1; 398 if (op_total == 0) 399 op_total = 1; 349 400 run_total = 0; 350 401 351 402 /* Cache how many of each type of port this ladspa plugin has */ 352 for (port_i=0; port_i < d->PortCount; port_i++) { 353 pd = d->PortDescriptors[(int)port_i]; 354 if (LADSPA_IS_CONTROL_INPUT(pd)) 355 nr_ci++; 356 if (LADSPA_IS_AUDIO_INPUT(pd)) 357 nr_ai++; 358 if (LADSPA_IS_CONTROL_OUTPUT(pd)) 359 nr_co++; 360 if (LADSPA_IS_AUDIO_OUTPUT(pd)) 361 nr_ao++; 362 } 403 for (port_i = 0; port_i < d->PortCount; port_i++) 404 { 405 pd = d->PortDescriptors[(int) port_i]; 406 if (LADSPA_IS_CONTROL_INPUT (pd)) 407 nr_ci++; 408 if (LADSPA_IS_AUDIO_INPUT (pd)) 409 nr_ai++; 410 if (LADSPA_IS_CONTROL_OUTPUT (pd)) 411 nr_co++; 412 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 413 nr_ao++; 414 } 363 415 364 416 /* Basic assumption of this meta plugin, which was … … 374 426 g_assert (nr_ao > 0); 375 427 376 nr_handles = (gint) ceil (((double)nr_channels) / ((double)nr_ao));428 nr_handles = (gint) ceil (((double) nr_channels) / ((double) nr_ao)); 377 429 378 430 /* Numbers of input and output buffers: ensure … … 384 436 /* Create all input and output buffers */ 385 437 386 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 387 /* 388 * Processing a mono sample with a mono filter. 389 * Attempt to do this in place. 390 */ 391 392 /* Create an input buffer if this ladspa plugin cannot work inplace */ 393 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 394 length_b = frames_to_bytes (format, BLOCK_SIZE); 395 mono_input_buffers[0] = g_malloc (length_b); 396 } else { 397 /* Input directly from sample data; mark as NULL */ 398 mono_input_buffers[0] = NULL; 399 } 400 input_buffers = mono_input_buffers; 401 402 /* Always output directly into the sample data; mark as NULL */ 403 mono_output_buffers[0] = NULL; 404 output_buffers = mono_output_buffers; 405 406 } else { 407 length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 408 409 /* Allocate zeroed input buffers; these will remain zeroed 410 * if there aren't enough channels in the input pcmdata 411 * to use them. 412 */ 413 input_buffers = g_malloc (sizeof(LADSPA_Data *) * nr_i); 414 for (i=0; i < nr_i; i++) { 415 input_buffers[i] = g_malloc0 (length_b); 416 } 417 418 output_buffers = g_malloc(sizeof(LADSPA_Data *) * nr_o); 419 420 /* Create separate output buffers if this ladspa plugin cannot 421 * work inplace */ 422 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 423 for (i=0; i < nr_o; i++) { 424 output_buffers[i] = g_malloc (length_b); 425 } 426 } else { 427 /* Re-use the input buffers, directly mapping them to 428 * corresponding output buffers 438 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) 439 { 440 /* 441 * Processing a mono sample with a mono filter. 442 * Attempt to do this in place. 429 443 */ 430 for (i=0; i < MIN(nr_i, nr_o); i++) { 431 output_buffers[i] = input_buffers[i]; 432 } 433 /* Create some extra output buffers if nr_o > nr_i */ 434 for (; i < nr_o; i++) { 435 output_buffers[i] = g_malloc (length_b); 436 } 437 } 438 } 444 445 /* Create an input buffer if this ladspa plugin cannot work inplace */ 446 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 447 { 448 length_b = frames_to_bytes (format, BLOCK_SIZE); 449 mono_input_buffers[0] = g_malloc (length_b); 450 } 451 else 452 { 453 /* Input directly from sample data; mark as NULL */ 454 mono_input_buffers[0] = NULL; 455 } 456 input_buffers = mono_input_buffers; 457 458 /* Always output directly into the sample data; mark as NULL */ 459 mono_output_buffers[0] = NULL; 460 output_buffers = mono_output_buffers; 461 462 } 463 else 464 { 465 length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 466 467 /* Allocate zeroed input buffers; these will remain zeroed 468 * if there aren't enough channels in the input pcmdata 469 * to use them. 470 */ 471 input_buffers = g_malloc (sizeof (LADSPA_Data *) * nr_i); 472 for (i = 0; i < nr_i; i++) 473 { 474 input_buffers[i] = g_malloc0 (length_b); 475 } 476 477 output_buffers = g_malloc (sizeof (LADSPA_Data *) * nr_o); 478 479 /* Create separate output buffers if this ladspa plugin cannot 480 * work inplace */ 481 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 482 { 483 for (i = 0; i < nr_o; i++) 484 { 485 output_buffers[i] = g_malloc (length_b); 486 } 487 } 488 else 489 { 490 /* Re-use the input buffers, directly mapping them to 491 * corresponding output buffers 492 */ 493 for (i = 0; i < MIN (nr_i, nr_o); i++) 494 { 495 output_buffers[i] = input_buffers[i]; 496 } 497 /* Create some extra output buffers if nr_o > nr_i */ 498 for (; i < nr_o; i++) 499 { 500 output_buffers[i] = g_malloc (length_b); 501 } 502 } 503 } 439 504 440 505 /* instantiate the ladspa plugin */ 441 506 handles = g_malloc (sizeof (LADSPA_Handle *) * nr_handles); 442 for (h = 0; h < nr_handles; h++) { 443 handles[h] = d->instantiate (d, (long)format->rate); 444 } 507 for (h = 0; h < nr_handles; h++) 508 { 509 handles[h] = d->instantiate (d, (long) format->rate); 510 } 445 511 446 512 /* connect control ports */ 447 control_inputs = g_malloc (nr_ci * sizeof(LADSPA_Data)); 448 j=0; 449 for (port_i=0; port_i < d->PortCount; port_i++) { 450 pd = d->PortDescriptors[(int)port_i]; 451 if (LADSPA_IS_CONTROL_INPUT(pd)) { 452 /* do something with pset! */ 453 switch (param_specs[j].type) { 454 case SWEEP_TYPE_BOOL: 455 /* from ladspa.h: 456 * Data less than or equal to zero should be considered 457 * `off' or `false,' 458 * and data above zero should be considered `on' or `true.' 459 */ 460 control_inputs[j] = pset[j].b ? 1.0 : 0.0; 461 break; 462 case SWEEP_TYPE_INT: 463 control_inputs[j] = (LADSPA_Data)pset[j].i; 464 break; 465 case SWEEP_TYPE_FLOAT: 466 control_inputs[j] = pset[j].f; 467 break; 468 default: 469 /* This plugin should produce no other types */ 470 g_assert_not_reached (); 471 break; 472 } 473 474 for (h = 0; h < nr_handles; h++) { 475 d->connect_port (handles[h], port_i, &control_inputs[j]); 476 } 477 478 j++; 479 } 480 if (LADSPA_IS_CONTROL_OUTPUT(pd)) { 481 for (h = 0; h < nr_handles; h++) { 482 d->connect_port (handles[h], port_i, &dummy_control_output); 483 } 484 } 485 } 513 control_inputs = g_malloc (nr_ci * sizeof (LADSPA_Data)); 514 j = 0; 515 for (port_i = 0; port_i < d->PortCount; port_i++) 516 { 517 pd = d->PortDescriptors[(int) port_i]; 518 if (LADSPA_IS_CONTROL_INPUT (pd)) 519 { 520 /* do something with pset! */ 521 switch (param_specs[j].type) 522 { 523 case SWEEP_TYPE_BOOL: 524 /* from ladspa.h: 525 * Data less than or equal to zero should be considered 526 * `off' or `false,' 527 * and data above zero should be considered `on' or `true.' 528 */ 529 control_inputs[j] = pset[j].b ? 1.0 : 0.0; 530 break; 531 case SWEEP_TYPE_INT: 532 control_inputs[j] = (LADSPA_Data) pset[j].i; 533 break; 534 case SWEEP_TYPE_FLOAT: 535 control_inputs[j] = pset[j].f; 536 break; 537 default: 538 /* This plugin should produce no other types */ 539 g_assert_not_reached (); 540 break; 541 } 542 543 for (h = 0; h < nr_handles; h++) 544 { 545 d->connect_port (handles[h], port_i, &control_inputs[j]); 546 } 547 548 j++; 549 } 550 if (LADSPA_IS_CONTROL_OUTPUT (pd)) 551 { 552 for (h = 0; h < nr_handles; h++) 553 { 554 d->connect_port (handles[h], port_i, &dummy_control_output); 555 } 556 } 557 } 486 558 487 559 /* activate the ladspa plugin */ 488 if (d->activate) { 489 for (h = 0; h < nr_handles; h++) { 490 d->activate (handles[h]); 491 } 492 } 560 if (d->activate) 561 { 562 for (h = 0; h < nr_handles; h++) 563 { 564 d->activate (handles[h]); 565 } 566 } 493 567 494 568 /* run the plugin on selection regions */ 495 for (gl = sounddata->sels; active && gl; gl = gl->next) { 496 sel = (sw_sel *)gl->data; 497 498 offset = 0; 499 remaining = sel->sel_end - sel->sel_start; 500 501 while (active && remaining > 0) { 502 g_mutex_lock (sample->ops_mutex); 503 504 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 505 active = FALSE; 506 } else { /* cancel */ 507 pcmdata = sounddata->data + 508 frames_to_bytes (format, sel->sel_start + offset); 509 510 n = MIN(remaining, BLOCK_SIZE); 511 512 /* Copy data into input buffers */ 513 if (nr_channels == 1) { 514 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 515 length_b = frames_to_bytes (format, n); 516 memcpy (input_buffers[0], pcmdata, length_b); 517 } else { 518 /* we're processing in-place, so we haven't needed to set 519 * up a separate input buffer; input_buffers[0] actually 520 * points to pcmdata hence we don't do any copying here. 521 */ 522 input_buffers[0] = (LADSPA_Data *)pcmdata; 523 } 524 525 output_buffers[0] = (LADSPA_Data *)pcmdata; 526 527 } else { 528 /* de-interleave multichannel data */ 529 530 p = (LADSPA_Data *)pcmdata; 531 532 for (i=0; i < n; i++) { 533 for (c=0; c < nr_channels; c++) { 534 input_buffers[c][i] = *p++; 535 } 536 } 537 } 538 539 g_assert (input_buffers[0] != NULL); 540 g_assert (output_buffers[0] != NULL); 541 542 /* connect input and output audio buffers to the 543 * audio ports of the ladspa plugin */ 544 ibi = 0; obi = 0; 545 for (h = 0; h < nr_handles; h++) { 546 for (port_i=0; port_i < d->PortCount; port_i++) { 547 pd = d->PortDescriptors[(int)port_i]; 548 if (LADSPA_IS_AUDIO_INPUT(pd)) { 549 d->connect_port (handles[h], port_i, input_buffers[ibi++]); 550 } 551 if (LADSPA_IS_AUDIO_OUTPUT(pd)) { 552 d->connect_port (handles[h], port_i, output_buffers[obi++]); 553 } 554 } 555 } 556 557 /* run the ladspa plugin */ 558 for (h = 0; h < nr_handles; h++) { 559 d->run (handles[h], n); 560 } 561 562 /* re-interleave data */ 563 if (nr_channels > 1) { 564 p = (LADSPA_Data *)pcmdata; 565 566 for (i=0; i < n; i++) { 567 for (c=0; c < nr_channels; c++) { 568 *p++ = output_buffers[c][i]; 569 } 570 } 571 } 572 573 remaining -= n; 574 offset += n; 575 576 run_total += n; 577 sample_set_progress_percent (sample, run_total / op_total); 578 } 579 580 g_mutex_unlock (sample->ops_mutex); 581 } 582 } 569 for (gl = sounddata->sels; active && gl; gl = gl->next) 570 { 571 sel = (sw_sel *) gl->data; 572 573 offset = 0; 574 remaining = sel->sel_end - sel->sel_start; 575 576 while (active && remaining > 0) 577 { 578 g_mutex_lock (sample->ops_mutex); 579 580 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 581 { 582 active = FALSE; 583 } 584 else 585 { /* cancel */ 586 pcmdata = sounddata->data + 587 frames_to_bytes (format, sel->sel_start + offset); 588 589 n = MIN (remaining, BLOCK_SIZE); 590 591 /* Copy data into input buffers */ 592 if (nr_channels == 1) 593 { 594 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 595 { 596 length_b = frames_to_bytes (format, n); 597 memcpy (input_buffers[0], pcmdata, length_b); 598 } 599 else 600 { 601 /* we're processing in-place, so we haven't needed to set 602 * up a separate input buffer; input_buffers[0] actually 603 * points to pcmdata hence we don't do any copying here. 604 */ 605 input_buffers[0] = (LADSPA_Data *) pcmdata; 606 } 607 608 output_buffers[0] = (LADSPA_Data *) pcmdata; 609 610 } 611 else 612 { 613 /* de-interleave multichannel data */ 614 615 p = (LADSPA_Data *) pcmdata; 616 617 for (i = 0; i < n; i++) 618 { 619 for (c = 0; c < nr_channels; c++) 620 { 621 input_buffers[c][i] = *p++; 622 } 623 } 624 } 625 626 g_assert (input_buffers[0] != NULL); 627 g_assert (output_buffers[0] != NULL); 628 629 /* connect input and output audio buffers to the 630 * audio ports of the ladspa plugin */ 631 ibi = 0; 632 obi = 0; 633 for (h = 0; h < nr_handles; h++) 634 { 635 for (port_i = 0; port_i < d->PortCount; port_i++) 636 { 637 pd = d->PortDescriptors[(int) port_i]; 638 if (LADSPA_IS_AUDIO_INPUT (pd)) 639 { 640 d->connect_port (handles[h], port_i, 641 input_buffers[ibi++]); 642 } 643 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 644 { 645 d->connect_port (handles[h], port_i, 646 output_buffers[obi++]); 647 } 648 } 649 } 650 651 /* run the ladspa plugin */ 652 for (h = 0; h < nr_handles; h++) 653 { 654 d->run (handles[h], n); 655 } 656 657 /* re-interleave data */ 658 if (nr_channels > 1) 659 { 660 p = (LADSPA_Data *) pcmdata; 661 662 for (i = 0; i < n; i++) 663 { 664 for (c = 0; c < nr_channels; c++) 665 { 666 *p++ = output_buffers[c][i]; 667 } 668 } 669 } 670 671 remaining -= n; 672 offset += n; 673 674 run_total += n; 675 sample_set_progress_percent (sample, run_total / op_total); 676 } 677 678 g_mutex_unlock (sample->ops_mutex); 679 } 680 } 583 681 584 682 /* deactivate the ladspa plugin */ 585 if (d->deactivate) { 586 for (h = 0; h < nr_handles; h++) { 587 d->deactivate (handles[h]); 588 } 589 } 683 if (d->deactivate) 684 { 685 for (h = 0; h < nr_handles; h++) 686 { 687 d->deactivate (handles[h]); 688 } 689 } 590 690 591 691 /* let the ladspa plugin clean up after itself */ 592 if (d->cleanup) { 593 for (h = 0; h < nr_handles; h++) { 594 d->cleanup (handles[h]); 595 } 596 } 692 if (d->cleanup) 693 { 694 for (h = 0; h < nr_handles; h++) 695 { 696 d->cleanup (handles[h]); 697 } 698 } 597 699 598 700 /* free the array of handles */ 599 701 g_free (handles); 600 702 601 703 /* free the input and output buffers */ 602 if (control_inputs) g_free (control_inputs); 603 604 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 605 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 606 g_free (mono_input_buffers[0]); 607 } 608 } else { 609 610 /* free the output buffers */ 611 for (i=0; i < nr_o; i++) { 612 g_free (output_buffers[i]); 613 } 614 g_free (output_buffers); 615 616 /* free the input buffers, if we created some */ 617 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 618 for (i=0; i < nr_i; i++) { 619 g_free (input_buffers[i]); 620 } 621 } else { 622 /* inplace worked, but if (nr_i > nr_o), then 623 * we still need to free the last input buffers 624 **/ 625 for (i=nr_o; i < nr_i; i++) { 626 g_free (input_buffers[i]); 627 } 628 } 629 g_free (input_buffers); 630 } 704 if (control_inputs) 705 g_free (control_inputs); 706 707 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) 708 { 709 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 710 { 711 g_free (mono_input_buffers[0]); 712 } 713 } 714 else 715 { 716 717 /* free the output buffers */ 718 for (i = 0; i < nr_o; i++) 719 { 720 g_free (output_buffers[i]); 721 } 722 g_free (output_buffers); 723 724 /* free the input buffers, if we created some */ 725 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 726 { 727 for (i = 0; i < nr_i; i++) 728 { 729 g_free (input_buffers[i]); 730 } 731 } 732 else 733 { 734 /* inplace worked, but if (nr_i > nr_o), then 735 * we still need to free the last input buffers 736 **/ 737 for (i = nr_o; i < nr_i; i++) 738 { 739 g_free (input_buffers[i]); 740 } 741 } 742 g_free (input_buffers); 743 } 631 744 632 745 return sample; … … 637 750 sw_param_set pset, gpointer custom_data) 638 751 { 639 lm_custom * lm = (lm_custom *)custom_data;640 const LADSPA_Descriptor * d = lm->d;752 lm_custom *lm = (lm_custom *) custom_data; 753 const LADSPA_Descriptor *d = lm->d; 641 754 642 755 return 643 perform_filter_op (sample, (char *) d->Name,644 (SweepFilter) ladspa_meta_apply_filter,756 perform_filter_op (sample, (char *) d->Name, 757 (SweepFilter) ladspa_meta_apply_filter, 645 758 pset, custom_data); 646 759 } … … 658 771 #define PATH_LEN 256 659 772 gchar path[PATH_LEN]; 660 void * module;773 void *module; 661 774 LADSPA_Descriptor_Function desc_func; 662 const LADSPA_Descriptor * d;775 const LADSPA_Descriptor *d; 663 776 LADSPA_PortDescriptor pd; 664 777 gint i, j, k, nr_params; 665 778 int valid_mask; 666 sw_procedure * proc;779 sw_procedure *proc; 667 780 668 781 snprintf (path, PATH_LEN, "%s/%s", dir, name); 669 782 670 783 module = dlopen (path, RTLD_NOW); 671 if (!module) return; 784 if (!module) 785 return; 672 786 673 787 modules_list = g_list_append (modules_list, module); 674 788 675 if ((desc_func = dlsym (module, "ladspa_descriptor"))) { 676 for (i=0; (d = desc_func (i)) != NULL; i++) { 677 678 if (!is_usable(d)) 679 continue; 680 681 proc = g_malloc0 (sizeof (*proc)); 682 proc->name = (gchar *)d->Name; 683 proc->author = (gchar *)d->Maker; 684 proc->copyright = (gchar *)d->Copyright; 685 686 nr_params=0; 687 for (j=0; j < d->PortCount; j++) { 688 pd = d->PortDescriptors[j]; 689 if (LADSPA_IS_CONTROL_INPUT(pd)) { 690 nr_params++; 691 } 692 } 693 694 proc->nr_params = nr_params; 695 proc->param_specs = 696 (sw_param_spec *)g_malloc0 (nr_params * sizeof (sw_param_spec)); 697 698 k=0; 699 for (j=0; j < d->PortCount; j++) { 700 pd = d->PortDescriptors[j]; 701 if (LADSPA_IS_CONTROL_INPUT(pd)) { 702 proc->param_specs[k].name = (gchar *)d->PortNames[j]; 703 proc->param_specs[k].desc = (gchar *)d->PortNames[j]; 704 proc->param_specs[k].type = 705 convert_type (d->PortRangeHints[j].HintDescriptor); 706 valid_mask = get_valid_mask (d->PortRangeHints[j].HintDescriptor); 707 if (valid_mask == 0) { 708 proc->param_specs[k].constraint_type = SW_PARAM_CONSTRAINED_NOT; 709 } else { 710 proc->param_specs[k].constraint_type = SW_PARAM_CONSTRAINED_RANGE; 711 proc->param_specs[k].constraint.range = 712 convert_constraint (&d->PortRangeHints[j]); 713 } 714 k++; 715 } 716 } 717 718 proc->suggest = ladspa_meta_suggest; 719 720 proc->apply = ladspa_meta_apply; 721 722 proc->custom_data = lm_custom_new (d, proc->param_specs); 723 724 *gl = g_list_append (*gl, proc); 725 } 726 } 789 if ((desc_func = dlsym (module, "ladspa_descriptor"))) 790 { 791 for (i = 0; (d = desc_func (i)) != NULL; i++) 792 { 793 794 if (!is_usable (d)) 795 continue; 796 797 proc = g_malloc0 (sizeof (*proc)); 798 proc->name = (gchar *) d->Name; 799 proc->author = (gchar *) d->Maker; 800 proc->copyright = (gchar *) d->Copyright; 801 802 nr_params = 0; 803 for (j = 0; j < d->PortCount; j++) 804 { 805 pd = d->PortDescriptors[j]; 806 if (LADSPA_IS_CONTROL_INPUT (pd)) 807 { 808 nr_params++; 809 } 810 } 811 812 proc->nr_params = nr_params; 813 proc->param_specs = 814 (sw_param_spec *) g_malloc0 (nr_params * sizeof (sw_param_spec)); 815 816 k = 0; 817 for (j = 0; j < d->PortCount; j++) 818 { 819 pd = d->PortDescriptors[j]; 820 if (LADSPA_IS_CONTROL_INPUT (pd)) 821 { 822 proc->param_specs[k].name = (gchar *) d->PortNames[j]; 823 proc->param_specs[k].desc = (gchar *) d->PortNames[j]; 824 proc->param_specs[k].type = 825 convert_type (d->PortRangeHints[j].HintDescriptor); 826 valid_mask = 827 get_valid_mask (d->PortRangeHints[j].HintDescriptor); 828 if (valid_mask == 0) 829 { 830 proc->param_specs[k].constraint_type = 831 SW_PARAM_CONSTRAINED_NOT; 832 } 833 else 834 { 835 proc->param_specs[k].constraint_type = 836 SW_PARAM_CONSTRAINED_RANGE; 837 proc->param_specs[k].constraint.range = 838 convert_constraint (&d->PortRangeHints[j]); 839 } 840 k++; 841 } 842 } 843 844 proc->suggest = ladspa_meta_suggest; 845 846 proc->apply = ladspa_meta_apply; 847 848 proc->custom_data = lm_custom_new (d, proc->param_specs); 849 850 *gl = g_list_append (*gl, proc); 851 } 852 } 727 853 } 728 854 … … 736 862 ladspa_meta_init_dir (gchar * dirname, GList ** gl) 737 863 { 738 DIR * dir; 739 struct dirent * dirent; 740 char * name; 741 742 if (!dirname) return; 864 DIR *dir; 865 struct dirent *dirent; 866 char *name; 867 868 if (!dirname) 869 return; 743 870 744 871 dir = opendir (dirname); 745 if (!dir) { 746 return; 747 } 748 749 while ((dirent = readdir (dir)) != NULL) { 750 name = dirent->d_name; 751 if (strcmp (name, ".") && strcmp (name, "..")) 752 ladspa_meta_add_procs (dirname, dirent->d_name, gl); 753 } 872 if (!dir) 873 { 874 return; 875 } 876 877 while ((dirent = readdir (dir)) != NULL) 878 { 879 name = dirent->d_name; 880 if (strcmp (name, ".") && strcmp (name, "..")) 881 ladspa_meta_add_procs (dirname, dirent->d_name, gl); 882 } 754 883 } 755 884 … … 757 886 ladspa_meta_init (void) 758 887 { 759 GList * gl = NULL;760 char * ladspa_path=NULL;761 char * next_sep=NULL;762 char * saved_lp=NULL;888 GList *gl = NULL; 889 char *ladspa_path = NULL; 890 char *next_sep = NULL; 891 char *saved_lp = NULL; 763 892 764 893 /* If this ladspa_meta module has already been initialised, don't … … 770 899 ladspa_path = getenv ("LADSPA_PATH"); 771 900 if (!ladspa_path) 772 ladspa_path = saved_lp = strdup(default_ladspa_path); 773 774 do { 775 next_sep = strchr (ladspa_path, ':'); 776 if (next_sep != NULL) *next_sep = '\0'; 777 778 ladspa_meta_init_dir (ladspa_path, &gl); 779 780 if (next_sep != NULL) ladspa_path = ++next_sep; 781 782 } while ((next_sep != NULL) && (*next_sep != '\0')); 901 ladspa_path = saved_lp = strdup (default_ladspa_path); 902 903 do 904 { 905 next_sep = strchr (ladspa_path, ':'); 906 if (next_sep != NULL) 907 *next_sep = '\0'; 908 909 ladspa_meta_init_dir (ladspa_path, &gl); 910 911 if (next_sep != NULL) 912 ladspa_path = ++next_sep; 913 914 } 915 while ((next_sep != NULL) && (*next_sep != '\0')); 783 916 784 917 ladspa_meta_initialised = TRUE; 785 918 786 919 /* free string if dup'd for ladspa_path */ 787 if (saved_lp != NULL) free(saved_lp); 920 if (saved_lp != NULL) 921 free (saved_lp); 788 922 789 923 return gl; … … 793 927 ladspa_meta_cleanup (void) 794 928 { 795 GList * gl; 796 797 if (!ladspa_meta_initialised) return; 798 799 for (gl = modules_list; gl; gl = gl->next) { 800 dlclose(gl->data); 801 } 929 GList *gl; 930 931 if (!ladspa_meta_initialised) 932 return; 933 934 for (gl = modules_list; gl; gl = gl->next) 935 { 936 dlclose (gl->data); 937 } 802 938 } 803 939 804 940 sw_plugin plugin = { 805 ladspa_meta_init, /* plugin_init */806 ladspa_meta_cleanup, /* plugin_cleanup */941 ladspa_meta_init, /* plugin_init */ 942 ladspa_meta_cleanup, /* plugin_cleanup */ 807 943 }; sweep/branches/sweep-info-panel/plugins/normalise/normalise.c
r125 r470 26 26 #include <sweep/sweep.h> 27 27 28 #include <../src/sweep_app.h> /* XXX */28 #include <../src/sweep_app.h> /* XXX */ 29 29 30 30 static sw_sample * 31 31 normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 32 32 { 33 sw_sounddata * sounddata;34 sw_format * f;35 GList * gl;36 sw_sel * sel;37 sw_audio_t * d;33 sw_sounddata *sounddata; 34 sw_format *f; 35 GList *gl; 36 sw_sel *sel; 37 sw_audio_t *d; 38 38 sw_audio_t max = 0; 39 39 gfloat factor = 1.0; … … 47 47 f = sounddata->format; 48 48 49 op_total = sounddata_selection_nr_frames (sounddata) * 2 / 100;/* 2 passes */ 50 if (op_total == 0) op_total = 1; 49 op_total = sounddata_selection_nr_frames (sounddata) * 2 / 100; /* 2 passes */ 50 if (op_total == 0) 51 op_total = 1; 51 52 run_total = 0; 52 53 53 54 /* Find max */ 54 for (gl = sounddata->sels; active && gl; gl = gl->next) { 55 sel = (sw_sel *)gl->data; 55 for (gl = sounddata->sels; active && gl; gl = gl->next) 56 { 57 sel = (sw_sel *) gl->data; 56 58 57 offset = 0;58 remaining = sel->sel_end - sel->sel_start;59 offset = 0; 60 remaining = sel->sel_end - sel->sel_start; 59 61 60 while (active && remaining > 0) { 61 g_mutex_lock (sample->ops_mutex); 62 while (active && remaining > 0) 63 { 64 g_mutex_lock (sample->ops_mutex); 62 65 63 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 64 active = FALSE; 65 } else { 66 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 67 { 68 active = FALSE; 69 } 70 else 71 { 66 72 67 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 73 d = 74 sounddata->data + frames_to_bytes (f, 75 sel->sel_start + offset); 68 76 69 n = MIN(remaining, 1024);77 n = MIN (remaining, 1024); 70 78 71 for (i=0; i < n * f->channels; i++) { 72 if(d[i]>=0) max = MAX(max, d[i]); 73 else max = MAX(max, -d[i]); 79 for (i = 0; i < n * f->channels; i++) 80 { 81 if (d[i] >= 0) 82 max = MAX (max, d[i]); 83 else 84 max = MAX (max, -d[i]); 85 } 86 87 remaining -= n; 88 offset += n; 89 90 run_total += n; 91 sample_set_progress_percent (sample, run_total / op_total); 92 } 93 94 g_mutex_unlock (sample->ops_mutex); 74 95 } 96 } 75 97 76 remaining -= n; 77 offset += n; 78 79 run_total += n; 80 sample_set_progress_percent (sample, run_total / op_total); 81 } 82 83 g_mutex_unlock (sample->ops_mutex); 84 } 85 } 86 87 if (max != 0) factor = SW_AUDIO_T_MAX / (gfloat)max; 98 if (max != 0) 99 factor = SW_AUDIO_T_MAX / (gfloat) max; 88 100 89 101 /* Scale */ 90 for (gl = sounddata->sels; active && gl; gl = gl->next) { 91 sel = (sw_sel *)gl->data; 102 for (gl = sounddata->sels; active && gl; gl = gl->next) 103 { 104 sel = (sw_sel *) gl->data; 92 105 93 offset = 0;94 remaining = sel->sel_end - sel->sel_start;106 offset = 0; 107 remaining = sel->sel_end - sel->sel_start; 95 108 96 while (active && remaining > 0) { 97 g_mutex_lock (sample->ops_mutex); 109 while (active && remaining > 0) 110 { 111 g_mutex_lock (sample->ops_mutex); 98 112 99 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 100 active = FALSE; 101 } else { 102 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 113 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 114 { 115 active = FALSE; 116 } 117 else 118 { 119 d = 120 sounddata->data + frames_to_bytes (f, 121 sel->sel_start + offset); 103 122 104 n = MIN(remaining, 1024);123 n = MIN (remaining, 1024); 105 124 106 for (i=0; i < n * f->channels; i++) { 107 d[i] = (sw_audio_t)((gfloat)d[i] * factor); 125 for (i = 0; i < n * f->channels; i++) 126 { 127 d[i] = (sw_audio_t) ((gfloat) d[i] * factor); 128 } 129 130 remaining -= n; 131 offset += n; 132 133 run_total += n; 134 sample_set_progress_percent (sample, 135 run_total * 100 / op_total); 136 } 137 138 g_mutex_unlock (sample->ops_mutex); 108 139 } 109 110 remaining -= n;111 offset += n;112 113 run_total += n;114 sample_set_progress_percent (sample, run_total * 100 / op_total);115 }116 117 g_mutex_unlock (sample->ops_mutex);118 140 } 119 }120 141 121 142 return sample; … … 123 144 124 145 static sw_op_instance * 125 apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data)146 apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 126 147 { 127 148 return 128 perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise,149 perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise, 129 150 pset, NULL); 130 151 } … … 136 157 "Copyright (C) 2000", 137 158 "http://sweep.sourceforge.net/plugins/normalise", 138 "Filters/Normalise", /* identifier */139 GDK_n, /* accel_key */140 GDK_SHIFT_MASK, /* accel_mods */141 0, /* nr_params */142 NULL, /* param_specs */143 NULL, /* suggests() */159 "Filters/Normalise", /* identifier */ 160 GDK_n, /* accel_key */ 161 GDK_SHIFT_MASK, /* accel_mods */ 162 0, /* nr_params */ 163 NULL, /* param_specs */ 164 NULL, /* suggests() */ 144 165 apply_normalise, 145 NULL, /* custom_data */166 NULL, /* custom_data */ 146 167 }; 147 168 148 169 static GList * 149 170 normalise_init (void) 150 171 { 151 return g_list_append ((GList *) NULL, &proc_normalise);172 return g_list_append ((GList *) NULL, &proc_normalise); 152 173 } 153 174 154 175 155 176 sw_plugin plugin = { 156 normalise_init, /* plugin_init */157 NULL, /* plugin_cleanup */177 normalise_init, /* plugin_init */ 178 NULL, /* plugin_cleanup */ 158 179 }; sweep/branches/sweep-info-panel/plugins/reverse/reverse.c
r125 r470 26 26 #include <sweep/sweep.h> 27 27 28 #include "../src/sweep_app.h" /* XXX */28 #include "../src/sweep_app.h" /* XXX */ 29 29 30 30 #if 0 … … 42 42 e = d + frames_to_bytes (format, nr_frames); 43 43 44 for (i = 0; i <= nr_frames/2; i++) { 45 memcpy (t, d, sw); 46 memcpy (d, e, sw); 47 memcpy (e, t, sw); 48 49 d += sw; 50 e -= sw; 51 } 44 for (i = 0; i <= nr_frames / 2; i++) 45 { 46 memcpy (t, d, sw); 47 memcpy (d, e, sw); 48 memcpy (e, t, sw); 49 50 d += sw; 51 e -= sw; 52 } 52 53 53 54 g_free (t); … … 59 60 gpointer custom_data) 60 61 { 61 GList * gl;62 sw_sel * sel;62 GList *gl; 63 sw_sel *sel; 63 64 glong i, sw; 64 sw_sounddata * sounddata;65 sw_format * format;65 sw_sounddata *sounddata; 66 sw_format *format; 66 67 sw_framecount_t nr_frames; 67 68 gpointer d, e, t; … … 76 77 77 78 op_total = sounddata_selection_nr_frames (sounddata) / 200; 78 if (op_total == 0) op_total = 1; 79 if (op_total == 0) 80 op_total = 1; 79 81 run_total = 0; 80 82 … … 82 84 t = alloca (sw); 83 85 84 for (gl = sounddata->sels; active && gl; gl = gl->next) { 85 sel = (sw_sel *)gl->data; 86 for (gl = sounddata->sels; active && gl; gl = gl->next) 87 { 88 sel = (sw_sel *) gl->data; 86 89 87 d = sounddata->data + frames_to_bytes (format, sel->sel_start);88 nr_frames = sel->sel_end - sel->sel_start;90 d = sounddata->data + frames_to_bytes (format, sel->sel_start); 91 nr_frames = sel->sel_end - sel->sel_start; 89 92 90 e = d + frames_to_bytes (format, nr_frames); 91 92 remaining = nr_frames/2; 93 e = d + frames_to_bytes (format, nr_frames); 93 94 94 while (active && remaining > 0) { 95 g_mutex_lock (sample->ops_mutex); 95 remaining = nr_frames / 2; 96 96 97 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 98 active = FALSE; 99 } else { 100 n = MIN (remaining, 1024); 97 while (active && remaining > 0) 98 { 99 g_mutex_lock (sample->ops_mutex); 101 100 102 for (i = 0; i <= n; i++) { 103 memcpy (t, d, sw); 104 memcpy (d, e, sw); 105 memcpy (e, t, sw); 106 107 d += sw; 108 e -= sw; 101 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 102 { 103 active = FALSE; 104 } 105 else 106 { 107 n = MIN (remaining, 1024); 108 109 for (i = 0; i <= n; i++) 110 { 111 memcpy (t, d, sw); 112 memcpy (d, e, sw); 113 memcpy (e, t, sw); 114 115 d += sw; 116 e -= sw; 117 } 118 119 remaining -= n; 120 121 run_total += n; 122 sample_set_progress_percent (sample, run_total / op_total); 123 } 124 125 g_mutex_unlock (sample->ops_mutex); 109 126 } 110 111 remaining -= n;112 113 run_total += n;114 sample_set_progress_percent (sample, run_total / op_total);115 }116 117 g_mutex_unlock (sample->ops_mutex);118 127 } 119 }120 128 121 129 return sample; … … 128 136 return 129 137 perform_filter_region_op (sample, _("Reverse"), 130 (SweepFilterRegion)region_reverse, pset, NULL);138 (SweepFilterRegion) region_reverse, pset, NULL); 131 139 #endif 132 140 133 141 return 134 142 perform_filter_op (sample, _("Reverse"), 135 (SweepFilter) sounddata_reverse, pset, NULL);143 (SweepFilter) sounddata_reverse, pset, NULL); 136 144 } 137 145 … … 143 151 "Copyright (C) 2000", 144 152 "http://sweep.sourceforge.net/plugins/reverse", 145 "Filters/Reverse", /* identifier */146 GDK_f, /* accel_key */147 GDK_SHIFT_MASK, /* accel_mods */148 0, /* nr_params */149 NULL, /* param_specs */150 NULL, /* suggests() */153 "Filters/Reverse", /* identifier */ 154 GDK_f, /* accel_key */ 155 GDK_SHIFT_MASK, /* accel_mods */ 156 0, /* nr_params */ 157 NULL, /* param_specs */ 158 NULL, /* suggests() */ 151 159 apply_reverse, 152 NULL, /* custom_data */160 NULL, /* custom_data */ 153 161 }; 154 162 … … 156 164 reverse_init (void) 157 165 { 158 return g_list_append ((GList *) NULL, &proc_reverse);166 return g_list_append ((GList *) NULL, &proc_reverse); 159 167 } 160 168 161 169 162 170 sw_plugin plugin = { 163 reverse_init, /* plugin_init */164 NULL, /* plugin_cleanup */171 reverse_init, /* plugin_init */ 172 NULL, /* plugin_cleanup */ 165 173 }; sweep/branches/sweep-info-panel/src/about_dialog.c
r409 r470 36 36 37 37 38 static void about_dialog_destroy(void); 39 static int about_dialog_button(GtkWidget * widget, 40 GdkEventButton * event); 38 static void about_dialog_destroy (void); 39 static int about_dialog_button (GtkWidget * widget, GdkEventButton * event); 41 40 42 41 static GtkWidget *about_dialog = NULL; … … 49 48 50 49 void 51 about_dialog_create ()50 about_dialog_create () 52 51 { 53 /* FIXME: for unused about box font style, reimplement?) 54 * GtkStyle *style; 55 */ 52 /* 53 * FIXME: for unused about box font style, reimplement?) GtkStyle 54 * *style; 55 */ 56 56 GtkWidget *vbox; 57 57 GtkWidget *label; 58 58 #define BUF_LEN 64 59 59 gchar buf[BUF_LEN]; 60 GtkWidget * button;61 GtkWidget * about_image;62 GtkWidget * about_ebox;60 GtkWidget *button; 61 GtkWidget *about_image; 62 GtkWidget *about_ebox; 63 63 gchar buf2[1024]; 64 64 65 if (!about_dialog) { 66 about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); 67 gtk_window_set_type_hint (GTK_WINDOW(about_dialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); 68 gtk_window_set_decorated ( GTK_WINDOW (about_dialog), FALSE); 69 gtk_window_set_wmclass(GTK_WINDOW(about_dialog), "about_dialog", "Sweep"); 70 gtk_window_set_resizable (GTK_WINDOW(about_dialog), FALSE); 71 gtk_window_set_position (GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); 72 g_signal_connect(GTK_OBJECT(about_dialog), "destroy", 73 G_CALLBACK(about_dialog_destroy), NULL); 74 g_signal_connect(GTK_OBJECT(about_dialog), "button_press_event", 75 G_CALLBACK(about_dialog_button), NULL); 76 gtk_widget_set_events(about_dialog, GDK_BUTTON_PRESS_MASK); 65 if (!about_dialog) 66 { 67 about_dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); 68 gtk_window_set_type_hint (GTK_WINDOW (about_dialog), 69 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); 70 gtk_window_set_decorated (GTK_WINDOW (about_dialog), FALSE); 71 gtk_window_set_wmclass (GTK_WINDOW (about_dialog), "about_dialog", 72 "Sweep"); 73 gtk_window_set_resizable (GTK_WINDOW (about_dialog), FALSE); 74 gtk_window_set_position (GTK_WINDOW (about_dialog), GTK_WIN_POS_CENTER); 75 g_signal_connect (GTK_OBJECT (about_dialog), "destroy", 76 G_CALLBACK (about_dialog_destroy), NULL); 77 g_signal_connect (GTK_OBJECT (about_dialog), "button_press_event", 78 G_CALLBACK (about_dialog_button), NULL); 79 gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK); 77 80 78 81 79 82 80 vbox = gtk_vbox_new(FALSE, 1);81 gtk_container_add(GTK_CONTAINER(about_dialog), vbox);82 gtk_widget_show(vbox);83 vbox = gtk_vbox_new (FALSE, 1); 84 gtk_container_add (GTK_CONTAINER (about_dialog), vbox); 85 gtk_widget_show (vbox); 83 86 84 about_ebox = gtk_event_box_new();85 gtk_box_pack_start(GTK_BOX(vbox), about_ebox, TRUE, TRUE, 0);86 gtk_widget_show(about_ebox);87 snprintf(buf2, sizeof (buf2), "%s/sweep_splash.png", PACKAGE_DATA_DIR);88 about_image = gtk_image_new_from_file (buf2);89 gtk_container_add(GTK_CONTAINER(about_ebox), about_image);90 gtk_widget_show(about_ebox);91 gtk_widget_show(about_image);87 about_ebox = gtk_event_box_new (); 88 gtk_box_pack_start (GTK_BOX (vbox), about_ebox, TRUE, TRUE, 0); 89 gtk_widget_show (about_ebox); 90 snprintf (buf2, sizeof (buf2), "%s/sweep_splash.png", PACKAGE_DATA_DIR); 91 about_image = gtk_image_new_from_file (buf2); 92 gtk_container_add (GTK_CONTAINER (about_ebox), about_image); 93 gtk_widget_show (about_ebox); 94 gtk_widget_show (about_image); 92 95 93 /* FIXME: old gtk font code. reimplement?94 * style = gtk_style_new();95 * gdk_font_unref(style->font);96 * style->font = gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*");97 * gtk_widget_push_style(style);98 */99 snprintf (buf, BUF_LEN, "%s %s", _("This is Sweep version"), VERSION);100 label = gtk_label_new(buf);101 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);102 gtk_widget_show(label);96 /* 97 * FIXME: old gtk font code. reimplement? style = gtk_style_new(); 98 * gdk_font_unref(style->font); style->font = 99 * gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); 100 * gtk_widget_push_style(style); 101 */ 102 snprintf (buf, BUF_LEN, "%s %s", _("This is Sweep version"), VERSION); 103 label = gtk_label_new (buf); 104 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 105 gtk_widget_show (label); 103 106 104 107 #if 0 105 label = gtk_label_new("Copyright (c) 2000 Conrad Parker, conrad@vergenet.net"); 106 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); 107 gtk_widget_show(label); 108 label = 109 gtk_label_new 110 ("Copyright (c) 2000 Conrad Parker, conrad@vergenet.net"); 111 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 112 gtk_widget_show (label); 108 113 #endif 109 114 110 /* FIXME: old style code111 * gtk_widget_pop_style();112 */115 /* 116 * FIXME: old style code gtk_widget_pop_style(); 117 */ 113 118 114 119 #if 0 115 alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);116 gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);117 gtk_widget_show(alignment);120 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); 121 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, TRUE, 0); 122 gtk_widget_show (alignment); 118 123 119 label = gtk_label_new(_("http://sweep.sourceforge.net/"));120 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);121 gtk_widget_show(label);124 label = gtk_label_new (_("http://sweep.sourceforge.net/")); 125 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 126 gtk_widget_show (label); 122 127 #endif 123 128 124 button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); 125 gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, TRUE, 0); 126 gtk_widget_show (button); 127 g_signal_connect (GTK_OBJECT(button), "clicked", 128 G_CALLBACK(sweep_homepage), NULL); 129 } 130 if (!GTK_WIDGET_VISIBLE(about_dialog)) { 131 gtk_widget_show(about_dialog); 132 } else { 133 gdk_window_raise(about_dialog->window); 134 } 129 button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); 130 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0); 131 gtk_widget_show (button); 132 g_signal_connect (GTK_OBJECT (button), "clicked", 133 G_CALLBACK (sweep_homepage), NULL); 134 } 135 if (!GTK_WIDGET_VISIBLE (about_dialog)) 136 { 137 gtk_widget_show (about_dialog); 138 } 139 else 140 { 141 gdk_window_raise (about_dialog->window); 142 } 135 143 } 136 144 137 145 static void 138 about_dialog_destroy ()146 about_dialog_destroy () 139 147 { 140 148 about_dialog = NULL; … … 142 150 143 151 static int 144 about_dialog_button(GtkWidget * widget, 145 GdkEventButton * event) 152 about_dialog_button (GtkWidget * widget, GdkEventButton * event) 146 153 { 147 gtk_widget_hide (about_dialog);154 gtk_widget_hide (about_dialog); 148 155 149 156 return FALSE; sweep/branches/sweep-info-panel/src/about_dialog.h
r7 r470 22 22 #define __ABOUT_DIALOG_H__ 23 23 24 void about_dialog_create (void);24 void about_dialog_create (void); 25 25 26 26 #endif /* __ABOUT_DIALOG_H__ */ sweep/branches/sweep-info-panel/src/callbacks.c
r465 r470 68 68 #define ZOOM_FRAMERATE 10 69 69 70 /* Sample creation */ 70 /* 71 * Sample creation 72 */ 71 73 72 74 void 73 75 sample_new_empty_cb (GtkWidget * widget, gpointer data) 74 76 { 75 sw_view * view = (sw_view *)data; 76 77 if (view == NULL) { 78 create_sample_new_dialog_defaults (NULL); 79 } else { 80 create_sample_new_dialog_like (view->sample); 81 } 77 sw_view *view = (sw_view *) data; 78 79 if (view == NULL) 80 { 81 create_sample_new_dialog_defaults (NULL); 82 } 83 else 84 { 85 create_sample_new_dialog_like (view->sample); 86 } 82 87 } 83 88 … … 85 90 sample_new_copy_cb (GtkWidget * widget, gpointer data) 86 91 { 87 sw_sample * ns;88 SampleDisplay * sd = SAMPLE_DISPLAY(data);89 sw_sample * s;90 sw_view * v;92 sw_sample *ns; 93 SampleDisplay *sd = SAMPLE_DISPLAY (data); 94 sw_sample *s; 95 sw_view *v; 91 96 92 97 s = sd->view->sample; 93 98 94 if(!s) return; 95 96 ns = sample_new_copy(s); 97 98 while (ns->color == s->color) { 99 ns->color = (random()) % VIEW_COLOR_MAX; 100 } 99 if (!s) 100 return; 101 102 ns = sample_new_copy (s); 103 104 while (ns->color == s->color) 105 { 106 ns->color = (random ()) % VIEW_COLOR_MAX; 107 } 101 108 102 109 v = view_new_all (ns, 1.0); 103 110 sample_add_view (ns, v); 104 111 105 sample_bank_add(ns); 106 } 107 108 /* Generic repeater */ 112 sample_bank_add (ns); 113 } 114 115 /* 116 * Generic repeater 117 */ 109 118 110 119 static void … … 112 121 { 113 122 function (data); 114 if (view->repeater_tag <= 0) { 115 view->repeater_tag = g_timeout_add ((guint32)1000/ZOOM_FRAMERATE, 123 if (view->repeater_tag <= 0) 124 { 125 view->repeater_tag = g_timeout_add ((guint32) 1000 / ZOOM_FRAMERATE, 116 126 (GSourceFunc) function, data); 117 }127 } 118 128 } 119 129 … … 121 131 repeater_released_cb (GtkWidget * widget, gpointer data) 122 132 { 123 sw_view * view = (sw_view *)data; 124 125 if (view->repeater_tag > 0) { 126 g_source_remove(view->repeater_tag); 127 view->repeater_tag = 0; 128 } 129 } 130 131 /* View */ 133 sw_view *view = (sw_view *) data; 134 135 if (view->repeater_tag > 0) 136 { 137 g_source_remove (view->repeater_tag); 138 view->repeater_tag = 0; 139 } 140 } 141 142 /* 143 * View 144 */ 132 145 133 146 void 134 147 view_new_all_cb (GtkWidget * widget, gpointer data) 135 148 { 136 SampleDisplay * sd = SAMPLE_DISPLAY(data);137 sw_sample * s;138 sw_view * v;149 SampleDisplay *sd = SAMPLE_DISPLAY (data); 150 sw_sample *s; 151 sw_view *v; 139 152 140 153 s = sd->view->sample; 141 v = view_new_all (s, 1.0);154 v = view_new_all (s, 1.0); 142 155 143 156 sample_add_view (s, v); … … 147 160 view_new_cb (GtkWidget * widget, gpointer data) 148 161 { 149 SampleDisplay * sd = SAMPLE_DISPLAY(data);150 sw_sample * s;151 sw_view * view, *v;162 SampleDisplay *sd = SAMPLE_DISPLAY (data); 163 sw_sample *s; 164 sw_view *view, *v; 152 165 153 166 v = sd->view; … … 162 175 view_close_cb (GtkWidget * widget, gpointer data) 163 176 { 164 SampleDisplay * sd = SAMPLE_DISPLAY(data);165 sw_view * v;177 SampleDisplay *sd = SAMPLE_DISPLAY (data); 178 sw_view *v; 166 179 167 180 v = sd->view; 168 181 169 view_close (v);182 view_close (v); 170 183 } 171 184 … … 176 189 } 177 190 178 /* Tools */ 191 /* 192 * Tools 193 */ 179 194 void 180 195 set_tool_cb (GtkWidget * widget, gpointer data) 181 196 { 182 197 #if 0 183 gint tool = (gint)data; 184 185 /* current_tool = tool;*/ 198 gint tool = (gint) data; 199 200 /* 201 * current_tool = tool; 202 */ 186 203 #endif 187 204 g_print ("NOOOOOOOOOOOOOO global current_tool\n"); … … 191 208 view_set_tool_cb (GtkWidget * widget, gpointer data) 192 209 { 193 sw_view * view = (sw_view *)data;210 sw_view *view = (sw_view *) data; 194 211 sw_tool_t tool; 195 212 196 213 tool = (sw_tool_t) 197 GPOINTER_TO_INT (g_object_get_data (G_OBJECT(widget), "default"));214 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "default")); 198 215 199 216 view->current_tool = tool; … … 202 219 } 203 220 204 /* Zooming */ 221 /* 222 * Zooming 223 */ 205 224 206 225 static gboolean 207 226 zoom_in_step (gpointer data) 208 227 { 209 sw_view * view = (sw_view *)data;228 sw_view *view = (sw_view *) data; 210 229 211 230 view_zoom_in (view, DEFAULT_ZOOM); … … 217 236 zoom_in_cb (GtkWidget * widget, gpointer data) 218 237 { 219 sw_view * view = (sw_view *)data;238 sw_view *view = (sw_view *) data; 220 239 view_zoom_in (view, DEFAULT_ZOOM); 221 240 } … … 224 243 zoom_out_step (gpointer data) 225 244 { 226 sw_view * view = (sw_view *)data;245 sw_view *view = (sw_view *) data; 227 246 228 247 view_zoom_out (view, DEFAULT_ZOOM); … … 234 253 zoom_out_cb (GtkWidget * widget, gpointer data) 235 254 { 236 sw_view * view = (sw_view *)data;255 sw_view *view = (sw_view *) data; 237 256 view_zoom_out (view, DEFAULT_ZOOM); 238 257 } … … 242 261 zoom_in_pressed_cb (GtkWidget * widget, gpointer data) 243 262 { 244 sw_view * view = (sw_view *)data;263 sw_view *view = (sw_view *) data; 245 264 246 265 view_zoom_in (view, DEFAULT_ZOOM); 247 view_init_repeater (view, (GtkFunction) zoom_in_step, data);266 view_init_repeater (view, (GtkFunction) zoom_in_step, data); 248 267 } 249 268 … … 251 270 zoom_out_pressed_cb (GtkWidget * widget, gpointer data) 252 271 { 253 sw_view * view = (sw_view *)data;272 sw_view *view = (sw_view *) data; 254 273 255 274 view_zoom_out (view, DEFAULT_ZOOM); 256 view_init_repeater (view, (GtkFunction) zoom_out_step, data);275 view_init_repeater (view, (GtkFunction) zoom_out_step, data); 257 276 } 258 277 … … 260 279 zoom_to_sel_cb (GtkWidget * widget, gpointer data) 261 280 { 262 SampleDisplay * sd = SAMPLE_DISPLAY(data);263 sw_view * v = sd->view;281 SampleDisplay *sd = SAMPLE_DISPLAY (data); 282 sw_view *v = sd->view; 264 283 265 284 view_zoom_to_sel (v); … … 269 288 zoom_left_cb (GtkWidget * widget, gpointer data) 270 289 { 271 SampleDisplay * sd = SAMPLE_DISPLAY(data);272 sw_view * v = sd->view;290 SampleDisplay *sd = SAMPLE_DISPLAY (data); 291 sw_view *v = sd->view; 273 292 274 293 view_zoom_left (v); … … 278 297 zoom_right_cb (GtkWidget * widget, gpointer data) 279 298 { 280 SampleDisplay * sd = SAMPLE_DISPLAY(data);281 sw_view * v = sd->view;299 SampleDisplay *sd = SAMPLE_DISPLAY (data); 300 sw_view *v = sd->view; 282 301 283 302 view_zoom_right (v); … … 287 306 zoom_all_cb (GtkWidget * widget, gpointer data) 288 307 { 289 sw_view * v = (sw_view *)data;308 sw_view *v = (sw_view *) data; 290 309 291 310 view_zoom_all (v); 292 311 } 293 312 294 /* XXX: dump this ?? */ 313 /* 314 * XXX: dump this ?? 315 */ 295 316 void 296 317 zoom_2_1_cb (GtkWidget * widget, gpointer data) 297 318 { 298 SampleDisplay * sd = SAMPLE_DISPLAY(data);299 sw_sample * s;319 SampleDisplay *sd = SAMPLE_DISPLAY (data); 320 sw_sample *s; 300 321 301 322 s = sd->view->sample; 302 323 303 view_set_ends (sd->view,304 s->sounddata->nr_frames / 4,305 3 * s->sounddata->nr_frames / 4);324 view_set_ends (sd->view, 325 s->sounddata->nr_frames / 4, 326 3 * s->sounddata->nr_frames / 4); 306 327 } 307 328 … … 309 330 zoom_norm_cb (GtkWidget * widget, gpointer data) 310 331 { 311 SampleDisplay * sd = SAMPLE_DISPLAY(data);312 sw_view * view = sd->view;332 SampleDisplay *sd = SAMPLE_DISPLAY (data); 333 sw_view *view = sd->view; 313 334 314 335 view_zoom_normal (view); … … 318 339 zoom_1to1_cb (GtkWidget * widget, gpointer data) 319 340 { 320 SampleDisplay * sd = SAMPLE_DISPLAY(data);341 SampleDisplay *sd = SAMPLE_DISPLAY (data); 321 342 322 343 view_zoom_length (sd->view, sd->width); … … 327 348 zoom_center_cb (GtkWidget * widget, gpointer data) 328 349 { 329 SampleDisplay * sd = SAMPLE_DISPLAY(data);350 SampleDisplay *sd = SAMPLE_DISPLAY (data); 330 351 331 352 view_center_on (sd->view, sd->view->sample->user_offset); … … 335 356 zoom_combo_changed_cb (GtkWidget * widget, gpointer data) 336 357 { 337 sw_view * view = (sw_view *)data;338 gchar * text;358 sw_view *view = (sw_view *) data; 359 gchar *text; 339 360 sw_time_t zoom_time; 340 361 sw_framecount_t zoom_length; 341 362 342 text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget)); 343 344 if (!strcmp (text, "All")) { 345 view_zoom_all (view); 346 } else { 347 zoom_time = (sw_time_t)strtime_to_seconds (text); 348 if (zoom_time != -1.0) { 349 zoom_length = 350 time_to_frames (view->sample->sounddata->format, zoom_time); 351 352 view_zoom_length (view, zoom_length); 353 354 /* Work around a bug, probably in gtkcombo, whereby all the other 355 * widgets sometimes lost input after choosing a zoom */ 356 gtk_widget_grab_focus (view->display); 357 } 358 } 359 } 360 361 /* Device config */ 363 text = (gchar *) gtk_entry_get_text (GTK_ENTRY (widget)); 364 365 if (!strcmp (text, "All")) 366 { 367 view_zoom_all (view); 368 } 369 else 370 { 371 zoom_time = (sw_time_t) strtime_to_seconds (text); 372 if (zoom_time != -1.0) 373 { 374 zoom_length = 375 time_to_frames (view->sample->sounddata->format, zoom_time); 376 377 view_zoom_length (view, zoom_length); 378 379 /* 380 * Work around a bug, probably in gtkcombo, whereby all the 381 * other widgets sometimes lost input after choosing a zoom 382 */ 383 gtk_widget_grab_focus (view->display); 384 } 385 } 386 } 387 388 /* 389 * Device config 390 */ 362 391 363 392 void … … 367 396 } 368 397 369 /* Sample */ 398 /* 399 * Sample 400 */ 370 401 371 402 void 372 403 sample_set_color_cb (GtkWidget * widget, gpointer data) 373 404 { 374 sw_view * view = (sw_view *) data;405 sw_view *view = (sw_view *) data; 375 406 gint color; 376 407 377 color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(widget), "default"));408 color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "default")); 378 409 sample_set_color (view->sample, color); 379 410 } 380 411 381 /* Playback */ 412 /* 413 * Playback 414 */ 382 415 383 416 void 384 417 follow_toggled_cb (GtkWidget * widget, gpointer data) 385 418 { 386 sw_view * view = (sw_view *) data;419 sw_view *view = (sw_view *) data; 387 420 gboolean active; 388 421 389 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));422 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 390 423 view_set_following (view, active); 391 424 } … … 394 427 follow_toggle_cb (GtkWidget * widget, gpointer data) 395 428 { 396 sw_view * view = (sw_view *)data;429 sw_view *view = (sw_view *) data; 397 430 view_set_following (view, !view->following); 398 431 } … … 401 434 loop_toggled_cb (GtkWidget * widget, gpointer data) 402 435 { 403 sw_view * view = (sw_view *) data;436 sw_view *view = (sw_view *) data; 404 437 gboolean active; 405 438 406 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));439 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 407 440 sample_set_looping (view->sample, active); 408 441 } … … 411 444 loop_toggle_cb (GtkWidget * widget, gpointer data) 412 445 { 413 sw_view * view = (sw_view *)data;446 sw_view *view = (sw_view *) data; 414 447 sample_set_looping (view->sample, !view->sample->play_head->looping); 415 448 } … … 418 451 playrev_toggled_cb (GtkWidget * widget, gpointer data) 419 452 { 420 sw_view * view = (sw_view *) data;453 sw_view *view = (sw_view *) data; 421 454 gboolean active; 422 455 423 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));456 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 424 457 sample_set_playrev (view->sample, active); 425 458 } … … 428 461 playrev_toggle_cb (GtkWidget * widget, gpointer data) 429 462 { 430 sw_view * view = (sw_view *)data;463 sw_view *view = (sw_view *) data; 431 464 sample_set_playrev (view->sample, !view->sample->play_head->reverse); 432 465 } … … 435 468 mute_toggled_cb (GtkWidget * widget, gpointer data) 436 469 { 437 sw_view * view = (sw_view *) data;470 sw_view *view = (sw_view *) data; 438 471 gboolean active; 439 472 440 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));473 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 441 474 sample_set_mute (view->sample, active); 442 475 } … … 445 478 mute_toggle_cb (GtkWidget * widget, gpointer data) 446 479 { 447 sw_view * view = (sw_view *)data;480 sw_view *view = (sw_view *) data; 448 481 sample_set_mute (view->sample, !view->sample->play_head->mute); 449 482 } … … 452 485 monitor_toggled_cb (GtkWidget * widget, gpointer data) 453 486 { 454 sw_view * view = (sw_view *) data;487 sw_view *view = (sw_view *) data; 455 488 gboolean active; 456 489 457 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));490 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 458 491 sample_set_monitor (view->sample, active); 459 492 } … … 462 495 monitor_toggle_cb (GtkWidget * widget, gpointer data) 463 496 { 464 sw_view * view = (sw_view *)data;497 sw_view *view = (sw_view *) data; 465 498 sample_set_monitor (view->sample, !view->sample->play_head->monitor); 466 499 } … … 469 502 play_view_button_cb (GtkWidget * widget, gpointer data) 470 503 { 471 sw_view * view = (sw_view *) data;472 sw_head * head = view->sample->play_head;504 sw_view *view = (sw_view *) data; 505 sw_head *head = view->sample->play_head; 473 506 gboolean was_restricted = head->restricted; 474 507 475 508 head_set_rate (head, 1.0); 476 /* head_set_restricted (head, FALSE);*/ 477 478 if (head->going && (head->scrubbing || !was_restricted)) { 479 pause_playback_cb (widget, data); 480 } else { 481 play_view_all (view); 482 } 509 /* 510 * head_set_restricted (head, FALSE); 511 */ 512 513 if (head->going && (head->scrubbing || !was_restricted)) 514 { 515 pause_playback_cb (widget, data); 516 } 517 else 518 { 519 play_view_all (view); 520 } 483 521 } 484 522 … … 486 524 play_view_cb (GtkWidget * widget, gpointer data) 487 525 { 488 sw_view * view = (sw_view *) data;489 sw_head * head = view->sample->play_head;526 sw_view *view = (sw_view *) data; 527 sw_head *head = view->sample->play_head; 490 528 491 529 head_set_rate (head, 1.0); 492 /* head_set_restricted (head, FALSE);*/ 493 494 if (head->going) { 495 pause_playback_cb (widget, data); 496 } else { 497 play_view_all (view); 498 } 530 /* 531 * head_set_restricted (head, FALSE); 532 */ 533 534 if (head->going) 535 { 536 pause_playback_cb (widget, data); 537 } 538 else 539 { 540 play_view_all (view); 541 } 499 542 } 500 543 … … 502 545 play_view_sel_button_cb (GtkWidget * widget, gpointer data) 503 546 { 504 sw_view * view = (sw_view *) data;505 sw_head * head = view->sample->play_head;547 sw_view *view = (sw_view *) data; 548 sw_head *head = view->sample->play_head; 506 549 gboolean was_restricted = head->restricted; 507 550 508 if (view->sample->sounddata->sels == NULL) { 509 play_view_cb (widget, data); 510 return; 511 } 551 if (view->sample->sounddata->sels == NULL) 552 { 553 play_view_cb (widget, data); 554 return; 555 } 512 556 513 557 head_set_rate (head, 1.0); 514 /* head_set_restricted (head, TRUE);*/ 515 516 if (head->going && (head->scrubbing || was_restricted)) { 517 pause_playback_cb (widget, data); 518 } else { 519 play_view_sel (view); 520 } 558 /* 559 * head_set_restricted (head, TRUE); 560 */ 561 562 if (head->going && (head->scrubbing || was_restricted)) 563 { 564 pause_playback_cb (widget, data); 565 } 566 else 567 { 568 play_view_sel (view); 569 } 521 570 } 522 571 … … 524 573 play_view_sel_cb (GtkWidget * widget, gpointer data) 525 574 { 526 sw_view * view = (sw_view *) data; 527 sw_head * head = view->sample->play_head; 528 529 if (view->sample->sounddata->sels == NULL) { 530 play_view_cb (widget, data); 531 return; 532 } 575 sw_view *view = (sw_view *) data; 576 sw_head *head = view->sample->play_head; 577 578 if (view->sample->sounddata->sels == NULL) 579 { 580 play_view_cb (widget, data); 581 return; 582 } 533 583 534 584 head_set_rate (head, 1.0); 535 /* head_set_restricted (head, TRUE);*/ 536 537 if (head->going) { 538 pause_playback_cb (widget, data); 539 } else { 540 play_view_sel (view); 541 } 585 /* 586 * head_set_restricted (head, TRUE); 587 */ 588 589 if (head->going) 590 { 591 pause_playback_cb (widget, data); 592 } 593 else 594 { 595 play_view_sel (view); 596 } 542 597 } 543 598 … … 545 600 pause_playback_cb (GtkWidget * widget, gpointer data) 546 601 { 547 sw_view * view = (sw_view *)data;602 sw_view *view = (sw_view *) data; 548 603 549 604 pause_playback (view->sample); … … 553 608 stop_playback_cb (GtkWidget * widget, gpointer data) 554 609 { 555 sw_view * view = (sw_view *)data;610 sw_view *view = (sw_view *) data; 556 611 557 612 stop_playback (view->sample); … … 561 616 preview_cut_cb (GtkWidget * widget, gpointer data) 562 617 { 563 sw_view * view = (sw_view *) data;618 sw_view *view = (sw_view *) data; 564 619 565 620 sample_refresh_playmode (view->sample); 566 621 567 if (view->sample->sounddata->sels != NULL) { 568 play_preview_cut (view); 569 } else { 570 play_preroll (view); 571 } 622 if (view->sample->sounddata->sels != NULL) 623 { 624 play_preview_cut (view); 625 } 626 else 627 { 628 play_preroll (view); 629 } 572 630 } 573 631 … … 575 633 preroll_cb (GtkWidget * widget, gpointer data) 576 634 { 577 sw_view * view = (sw_view *) data;635 sw_view *view = (sw_view *) data; 578 636 579 637 sample_refresh_playmode (view->sample); 580 638 581 639 play_preroll (view); 582 640 } 583 641 584 /* Record */ 642 /* 643 * Record 644 */ 585 645 586 646 void 587 647 show_rec_dialog_cb (GtkWidget * widget, gpointer data) 588 648 { 589 sw_view * view = (sw_view *)data;649 sw_view *view = (sw_view *) data; 590 650 591 651 rec_dialog_create (view->sample); 592 652 } 593 653 594 /* Transport */ 654 /* 655 * Transport 656 */ 595 657 596 658 static gboolean 597 659 rewind_step (gpointer data) 598 660 { 599 sw_sample * sample = (sw_sample *)data;661 sw_sample *sample = (sw_sample *) data; 600 662 gint step; 601 663 602 step = sample->sounddata->format->rate; /* 1 second */664 step = sample->sounddata->format->rate; /* 1 second */ 603 665 sample_set_playmarker (sample, sample->user_offset - step, TRUE); 604 666 … … 609 671 ffwd_step (gpointer data) 610 672 { 611 sw_sample * sample = (sw_sample *)data;673 sw_sample *sample = (sw_sample *) data; 612 674 gint step; 613 675 614 step = sample->sounddata->format->rate; /* 1 second */676 step = sample->sounddata->format->rate; /* 1 second */ 615 677 sample_set_playmarker (sample, sample->user_offset + step, TRUE); 616 678 … … 621 683 page_back_cb (GtkWidget * widget, gpointer data) 622 684 { 623 sw_view * view = (sw_view *)data;624 sw_sample * sample = view->sample;685 sw_view *view = (sw_view *) data; 686 sw_sample *sample = view->sample; 625 687 gint step; 626 688 627 step = MIN (sample->sounddata->format->rate, (view->end - view->start));689 step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 628 690 sample_set_playmarker (sample, sample->user_offset - step, TRUE); 629 691 } … … 632 694 page_fwd_cb (GtkWidget * widget, gpointer data) 633 695 { 634 sw_view * view = (sw_view *)data;635 sw_sample * sample = view->sample;696 sw_view *view = (sw_view *) data; 697 sw_sample *sample = view->sample; 636 698 gint step; 637 699 638 step = MIN (sample->sounddata->format->rate, (view->end - view->start));700 step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 639 701 sample_set_playmarker (sample, sample->user_offset + step, TRUE); 640 702 } … … 643 705 rewind_pressed_cb (GtkWidget * widget, gpointer data) 644 706 { 645 sw_view * view = (sw_view *)data;646 sw_sample * sample = view->sample;647 648 view_init_repeater (view, (GtkFunction) rewind_step, sample);707 sw_view *view = (sw_view *) data; 708 sw_sample *sample = view->sample; 709 710 view_init_repeater (view, (GtkFunction) rewind_step, sample); 649 711 } 650 712 … … 652 714 ffwd_pressed_cb (GtkWidget * widget, gpointer data) 653 715 { 654 sw_view * view = (sw_view *)data;655 sw_sample * sample = view->sample;656 657 view_init_repeater (view, (GtkFunction) ffwd_step, sample);716 sw_view *view = (sw_view *) data; 717 sw_sample *sample = view->sample; 718 719 view_init_repeater (view, (GtkFunction) ffwd_step, sample); 658 720 } 659 721 … … 661 723 goto_start_cb (GtkWidget * widget, gpointer data) 662 724 { 663 sw_view * view = (sw_view *)data;664 sw_sample * sample = view->sample;665 GList * gl;666 sw_mark * mark;725 sw_view *view = (sw_view *) data; 726 sw_sample *sample = view->sample; 727 GList *gl; 728 sw_mark *mark; 667 729 gint delta = sample->sounddata->nr_frames; 668 sw_mark * mark_delta = NULL; 669 670 if (sample->sounddata->marks){ 671 g_mutex_lock (sample->sounddata->marks_mutex); 672 673 for (gl = sample->sounddata->marks; gl; gl = gl->next){ 674 675 mark = (sw_mark*)gl->data; 676 677 if ((sample->user_offset > mark->frame) && 678 (sample->user_offset - mark->frame) < delta){ 679 680 delta = sample->user_offset - mark->frame; 681 682 mark_delta = mark; 683 } 730 sw_mark *mark_delta = NULL; 731 732 if (sample->sounddata->marks) 733 { 734 g_mutex_lock (sample->sounddata->marks_mutex); 735 736 for (gl = sample->sounddata->marks; gl; gl = gl->next) 737 { 738 739 mark = (sw_mark *) gl->data; 740 741 if ((sample->user_offset > mark->frame) && 742 (sample->user_offset - mark->frame) < delta) 743 { 744 745 delta = sample->user_offset - mark->frame; 746 747 mark_delta = mark; 748 } 684 749 } 685 750 686 g_mutex_unlock (sample->sounddata->marks_mutex); 687 688 if (mark_delta) 689 sample_set_playmarker (sample, mark_delta->frame, TRUE); 690 else 691 sample_set_playmarker (sample, 0, TRUE); 692 } else { 693 694 sample_set_scrubbing (sample, FALSE); 695 sample_set_playmarker (sample, 0, TRUE); 696 } 751 g_mutex_unlock (sample->sounddata->marks_mutex); 752 753 if (mark_delta) 754 sample_set_playmarker (sample, mark_delta->frame, TRUE); 755 else 756 sample_set_playmarker (sample, 0, TRUE); 757 } 758 else 759 { 760 761 sample_set_scrubbing (sample, FALSE); 762 sample_set_playmarker (sample, 0, TRUE); 763 } 697 764 } 698 765 … … 700 767 goto_start_of_view_cb (GtkWidget * widget, gpointer data) 701 768 { 702 sw_view * view = (sw_view *)data;703 sw_sample * sample = view->sample;769 sw_view *view = (sw_view *) data; 770 sw_sample *sample = view->sample; 704 771 705 772 sample_set_scrubbing (sample, FALSE); … … 710 777 goto_end_of_view_cb (GtkWidget * widget, gpointer data) 711 778 { 712 sw_view * view = (sw_view *)data;713 sw_sample * sample = view->sample;779 sw_view *view = (sw_view *) data; 780 sw_sample *sample = view->sample; 714 781 715 782 sample_set_scrubbing (sample, FALSE); … … 720 787 goto_end_cb (GtkWidget * widget, gpointer data) 721 788 { 722 sw_view * view = (sw_view *)data;723 sw_sample * sample = view->sample;724 GList * gl;725 sw_mark * mark;789 sw_view *view = (sw_view *) data; 790 sw_sample *sample = view->sample; 791 GList *gl; 792 sw_mark *mark; 726 793 gint delta = sample->sounddata->nr_frames; 727 sw_mark * mark_delta = NULL; 728 729 if (sample->sounddata->marks){ 730 g_mutex_lock (sample->sounddata->marks_mutex); 731 732 for (gl = sample->sounddata->marks; gl; gl = gl->next){ 733 734 mark = (sw_mark*)gl->data; 735 736 if ((sample->user_offset < mark->frame) && 737 (mark->frame - sample->user_offset) < delta){ 738 739 delta = mark->frame - sample->user_offset; 740 741 mark_delta = mark; 742 } 794 sw_mark *mark_delta = NULL; 795 796 if (sample->sounddata->marks) 797 { 798 g_mutex_lock (sample->sounddata->marks_mutex); 799 800 for (gl = sample->sounddata->marks; gl; gl = gl->next) 801 { 802 803 mark = (sw_mark *) gl->data; 804 805 if ((sample->user_offset < mark->frame) && 806 (mark->frame - sample->user_offset) < delta) 807 { 808 809 delta = mark->frame - sample->user_offset; 810 811 mark_delta = mark; 812 } 743 813 } 744 814 745 g_mutex_unlock (sample->sounddata->marks_mutex); 746 747 if (mark_delta) 748 sample_set_playmarker (sample, mark_delta->frame, TRUE); 749 else 750 sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); 751 } else { 752 753 sample_set_scrubbing (sample, FALSE); 754 sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); 755 } 756 } 757 758 /* Interface elements: sample display, scrollbars etc. */ 815 g_mutex_unlock (sample->sounddata->marks_mutex); 816 817 if (mark_delta) 818 sample_set_playmarker (sample, mark_delta->frame, TRUE); 819 else 820 sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); 821 } 822 else 823 { 824 825 sample_set_scrubbing (sample, FALSE); 826 sample_set_playmarker (sample, sample->sounddata->nr_frames, TRUE); 827 } 828 } 829 830 /* 831 * Interface elements: sample display, scrollbars etc. 832 */ 759 833 760 834 void 761 835 sd_sel_changed_cb (GtkWidget * widget) 762 836 { 763 SampleDisplay * sd = SAMPLE_DISPLAY(widget);837 SampleDisplay *sd = SAMPLE_DISPLAY (widget); 764 838 765 839 sample_refresh_views (sd->view->sample); … … 769 843 sd_win_changed_cb (GtkWidget * widget) 770 844 { 771 SampleDisplay * sd = SAMPLE_DISPLAY(widget);772 sw_view * v = sd->view;773 774 g_signal_handlers_block_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 0,775 0, 0, 0, v);845 SampleDisplay *sd = SAMPLE_DISPLAY (widget); 846 sw_view *v = sd->view; 847 848 g_signal_handlers_block_matched (GTK_OBJECT (v->adj), 849 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 776 850 view_fix_adjustment (sd->view); 777 778 g_signal_handlers_unblock_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 0,779 0, 0, 0, v);851 852 g_signal_handlers_unblock_matched (GTK_OBJECT (v->adj), 853 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 780 854 view_refresh_hruler (v); 781 855 } … … 784 858 adj_changed_cb (GtkWidget * widget, gpointer data) 785 859 { 786 sw_view * v = (sw_view *)data; 787 SampleDisplay * sd = SAMPLE_DISPLAY(v->display); 788 GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); 789 790 g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 791 0, 0, 0, v); 792 sample_display_set_window(sd, 793 (gint)adj->value, 794 (gint)(adj->value + adj->page_size)); 795 796 g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 797 0, 0, 0, v); 860 sw_view *v = (sw_view *) data; 861 SampleDisplay *sd = SAMPLE_DISPLAY (v->display); 862 GtkAdjustment *adj = GTK_ADJUSTMENT (v->adj); 863 864 g_signal_handlers_block_matched (GTK_OBJECT (GTK_OBJECT (sd)), 865 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 866 sample_display_set_window (sd, (gint) adj->value, 867 (gint) (adj->value + adj->page_size)); 868 869 g_signal_handlers_unblock_matched (GTK_OBJECT (GTK_OBJECT (sd)), 870 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 798 871 view_refresh_hruler (v); 799 872 } … … 802 875 adj_value_changed_cb (GtkWidget * widget, gpointer data) 803 876 { 804 sw_view * v = (sw_view *)data; 805 SampleDisplay * sd = SAMPLE_DISPLAY(v->display); 806 GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); 807 808 if (!v->sample->play_head->going || !v->following) { 809 810 g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 811 0, 0, 0, v); 812 sample_display_set_window(sd, 813 (gint)adj->value, 814 (gint)(adj->value + adj->page_size)); 815 g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 816 0, 0, 0, v); 817 } 818 819 if (v->following) { 820 if (v->sample->user_offset < adj->value || 821 v->sample->user_offset > adj->value + adj->page_size) 822 sample_set_playmarker (v->sample, adj->value + adj->page_size/2, TRUE); 823 } 824 825 view_refresh_hruler (v); 826 } 827 828 /* Selection */ 877 sw_view *v = (sw_view *) data; 878 SampleDisplay *sd = SAMPLE_DISPLAY (v->display); 879 GtkAdjustment *adj = GTK_ADJUSTMENT (v->adj); 880 881 if (!v->sample->play_head->going || !v->following) 882 { 883 884 g_signal_handlers_block_matched (GTK_OBJECT (GTK_OBJECT (sd)), 885 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 886 sample_display_set_window (sd, (gint) adj->value, 887 (gint) (adj->value + adj->page_size)); 888 g_signal_handlers_unblock_matched (GTK_OBJECT (GTK_OBJECT (sd)), 889 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 890 } 891 892 if (v->following) 893 { 894 if (v->sample->user_offset < adj->value || 895 v->sample->user_offset > adj->value + adj->page_size) 896 sample_set_playmarker (v->sample, 897 adj->value + adj->page_size / 2, TRUE); 898 } 899 900 view_refresh_hruler (v); 901 } 902 903 /* 904 * Selection 905 */ 829 906 830 907 void 831 908 select_invert_cb (GtkWidget * widget, gpointer data) 832 909 { 833 SampleDisplay * sd = SAMPLE_DISPLAY(data);910 SampleDisplay *sd = SAMPLE_DISPLAY (data); 834 911 835 912 sample_selection_invert (sd->view->sample); … … 839 916 select_all_cb (GtkWidget * widget, gpointer data) 840 917 { 841 SampleDisplay * sd = SAMPLE_DISPLAY(data);918 SampleDisplay *sd = SAMPLE_DISPLAY (data); 842 919 843 920 sample_selection_select_all (sd->view->sample); … … 847 924 select_none_cb (GtkWidget * widget, gpointer data) 848 925 { 849 SampleDisplay * sd = SAMPLE_DISPLAY(data);926 SampleDisplay *sd = SAMPLE_DISPLAY (data); 850 927 851 928 sample_selection_select_none (sd->view->sample); … … 855 932 selection_halve_cb (GtkWidget * widget, gpointer data) 856 933 { 857 SampleDisplay * sd = SAMPLE_DISPLAY(data);934 SampleDisplay *sd = SAMPLE_DISPLAY (data); 858 935 859 936 sample_selection_halve (sd->view->sample); … … 863 940 selection_double_cb (GtkWidget * widget, gpointer data) 864 941 { 865 SampleDisplay * sd = SAMPLE_DISPLAY(data);942 SampleDisplay *sd = SAMPLE_DISPLAY (data); 866 943 867 944 sample_selection_double (sd->view->sample); … … 871 948 select_shift_left_cb (GtkWidget * widget, gpointer data) 872 949 { 873 SampleDisplay * sd = SAMPLE_DISPLAY(data);950 SampleDisplay *sd = SAMPLE_DISPLAY (data); 874 951 875 952 sample_selection_shift_left (sd->view->sample); … … 879 956 select_shift_right_cb (GtkWidget * widget, gpointer data) 880 957 { 881 SampleDisplay * sd = SAMPLE_DISPLAY(data);958 SampleDisplay *sd = SAMPLE_DISPLAY (data); 882 959 883 960 sample_selection_shift_right (sd->view->sample); 884 961 } 885 962 886 /* Undo / Redo */ 963 /* 964 * Undo / Redo 965 */ 887 966 888 967 void 889 968 show_undo_dialog_cb (GtkWidget * widget, gpointer data) 890 969 { 891 sw_view * view = (sw_view *)data;970 sw_view *view = (sw_view *) data; 892 971 893 972 undo_dialog_create (view->sample); … … 897 976 undo_cb (GtkWidget * widget, gpointer data) 898 977 { 899 sw_view * view = (sw_view *)data;978 sw_view *view = (sw_view *) data; 900 979 901 980 undo_current (view->sample); … … 905 984 redo_cb (GtkWidget * widget, gpointer data) 906 985 { 907 sw_view * view = (sw_view *)data;986 sw_view *view = (sw_view *) data; 908 987 909 988 redo_current (view->sample); … … 913 992 cancel_cb (GtkWidget * widget, gpointer data) 914 993 { 915 sw_view * view = (sw_view *)data;994 sw_view *view = (sw_view *) data; 916 995 917 996 cancel_active_op (view->sample); 918 997 } 919 998 920 /* Edit */ 999 /* 1000 * Edit 1001 */ 921 1002 922 1003 void 923 1004 copy_cb (GtkWidget * widget, gpointer data) 924 1005 { 925 sw_view * view = (sw_view *)data;926 sw_sample * s = view->sample;1006 sw_view *view = (sw_view *) data; 1007 sw_sample *s = view->sample; 927 1008 928 1009 do_copy (s); … … 932 1013 cut_cb (GtkWidget * widget, gpointer data) 933 1014 { 934 sw_view * view = (sw_view *)data;935 sw_sample * s = view->sample;1015 sw_view *view = (sw_view *) data; 1016 sw_sample *s = view->sample; 936 1017 937 1018 do_cut (s); … … 941 1022 clear_cb (GtkWidget * widget, gpointer data) 942 1023 { 943 sw_view * view = (sw_view *)data;944 sw_sample * s = view->sample;1024 sw_view *view = (sw_view *) data; 1025 sw_sample *s = view->sample; 945 1026 946 1027 do_clear (s); … … 950 1031 delete_cb (GtkWidget * widget, gpointer data) 951 1032 { 952 sw_view * view = (sw_view *)data;953 sw_sample * s = view->sample;1033 sw_view *view = (sw_view *) data; 1034 sw_sample *s = view->sample; 954 1035 955 1036 do_delete (s); … … 959 1040 crop_cb (GtkWidget * widget, gpointer data) 960 1041 { 961 sw_view * view = (sw_view *)data;962 sw_sample * s = view->sample;1042 sw_view *view = (sw_view *) data; 1043 sw_sample *s = view->sample; 963 1044 964 1045 do_crop (s); … … 968 1049 paste_cb (GtkWidget * widget, gpointer data) 969 1050 { 970 sw_view * view = (sw_view *)data;971 sw_sample * s = view->sample;1051 sw_view *view = (sw_view *) data; 1052 sw_sample *s = view->sample; 972 1053 973 1054 do_paste_insert (s); … … 977 1058 paste_mix_cb (GtkWidget * widget, gpointer data) 978 1059 { 979 sw_view * view = (sw_view *)data; 980 sw_sample * s = view->sample; 981 982 if (clipboard_width() > 0) { 983 create_paste_mix_dialog (s); 984 } else { 985 sample_set_tmp_message (s, _("Clipboard empty")); 986 } 1060 sw_view *view = (sw_view *) data; 1061 sw_sample *s = view->sample; 1062 1063 if (clipboard_width () > 0) 1064 { 1065 create_paste_mix_dialog (s); 1066 } 1067 else 1068 { 1069 sample_set_tmp_message (s, _("Clipboard empty")); 1070 } 987 1071 } 988 1072 … … 990 1074 paste_xfade_cb (GtkWidget * widget, gpointer data) 991 1075 { 992 sw_view * view = (sw_view *)data; 993 sw_sample * s = view->sample; 994 995 if (clipboard_width() > 0) { 996 create_paste_xfade_dialog (s); 997 } else { 998 sample_set_tmp_message (s, _("Clipboard empty")); 999 } 1076 sw_view *view = (sw_view *) data; 1077 sw_sample *s = view->sample; 1078 1079 if (clipboard_width () > 0) 1080 { 1081 create_paste_xfade_dialog (s); 1082 } 1083 else 1084 { 1085 sample_set_tmp_message (s, _("Clipboard empty")); 1086 } 1000 1087 } 1001 1088 … … 1003 1090 paste_as_new_cb (GtkWidget * widget, gpointer data) 1004 1091 { 1005 sw_sample * s;1006 sw_view * v;1092 sw_sample *s; 1093 sw_view *v; 1007 1094 1008 1095 s = do_paste_as_new (); 1009 1010 if (s) { 1011 v = view_new_all (s, 1.0); 1012 sample_add_view (s, v); 1013 sample_bank_add (s); 1014 } 1096 1097 if (s) 1098 { 1099 v = view_new_all (s, 1.0); 1100 sample_add_view (s, v); 1101 sample_bank_add (s); 1102 } 1015 1103 } 1016 1104 … … 1018 1106 show_info_dialog_cb (GtkWidget * widget, gpointer data) 1019 1107 { 1020 sw_view * view = (sw_view *)data;1108 sw_view *view = (sw_view *) data; 1021 1109 1022 1110 sample_show_info_dialog (view->sample); … … 1024 1112 1025 1113 void 1026 hide_window_cb (GtkAccelGroup *accel_group, 1027 GObject *acceleratable, 1028 guint keyval, 1029 GdkModifierType modifier) 1030 { 1031 if (GTK_IS_WINDOW(acceleratable)) 1032 g_signal_emit_by_name(G_OBJECT(acceleratable), "hide"); 1033 } 1034 1035 void 1036 close_window_cb (GtkAccelGroup *accel_group, 1037 GObject *acceleratable, 1038 guint keyval, 1039 GdkModifierType modifier) 1040 { 1041 if (GTK_IS_WINDOW(acceleratable)) 1042 g_signal_emit_by_name(G_OBJECT(acceleratable), "destroy"); 1043 } 1044 1114 hide_window_cb (GtkAccelGroup * accel_group, 1115 GObject * acceleratable, 1116 guint keyval, GdkModifierType modifier) 1117 { 1118 if (GTK_IS_WINDOW (acceleratable)) 1119 g_signal_emit_by_name (G_OBJECT (acceleratable), "hide"); 1120 } 1121 1122 void 1123 close_window_cb (GtkAccelGroup * accel_group, 1124 GObject * acceleratable, 1125 guint keyval, GdkModifierType modifier) 1126 { 1127 if (GTK_IS_WINDOW (acceleratable)) 1128 g_signal_emit_by_name (G_OBJECT (acceleratable), "destroy"); 1129 } 1130 1045 1131 /* 1046 1132 * Prime the label with the largest string then fetch the width. … … 1050 1136 * don't try this at home kids, karma will get you. (oh well.. it works.) 1051 1137 */ 1052 void 1053 hack_max_label_width_cb (GtkWidget *widget, 1054 GtkStyle *previous_style, 1055 gpointer user_data) 1138 void 1139 hack_max_label_width_cb (GtkWidget * widget, 1140 GtkStyle * previous_style, gpointer user_data) 1056 1141 { 1057 1142 PangoRectangle logical_rect, ink_rect; 1058 1143 const gchar *saved; 1059 1060 if (!GTK_IS_LABEL(widget)) 1061 return; 1062 saved = strdup(gtk_label_get_text(GTK_LABEL(widget))); 1063 gtk_label_set_text(GTK_LABEL(widget), "00:00:00.0000"); 1064 pango_layout_get_extents (gtk_label_get_layout (GTK_LABEL(widget)), &ink_rect, &logical_rect); 1065 gtk_label_set_text(GTK_LABEL(widget), saved); 1066 1067 if(saved != NULL) 1068 g_free((gpointer)saved); 1069 gtk_widget_set_usize(GTK_WIDGET(widget), PANGO_PIXELS (ink_rect.width), -1); 1070 } 1071 1072 void 1073 hack_max_combo_width_cb (GtkWidget *widget, 1074 GtkStyle *previous_style, 1075 gpointer user_data) 1144 1145 if (!GTK_IS_LABEL (widget)) 1146 return; 1147 saved = strdup (gtk_label_get_text (GTK_LABEL (widget))); 1148 gtk_label_set_text (GTK_LABEL (widget), "00:00:00.0000"); 1149 pango_layout_get_extents (gtk_label_get_layout (GTK_LABEL (widget)), 1150 &ink_rect, &logical_rect); 1151 gtk_label_set_text (GTK_LABEL (widget), saved); 1152 1153 if (saved != NULL) 1154 g_free ((gpointer) saved); 1155 gtk_widget_set_usize (GTK_WIDGET (widget), PANGO_PIXELS (ink_rect.width), 1156 -1); 1157 } 1158 1159 void 1160 hack_max_combo_width_cb (GtkWidget * widget, 1161 GtkStyle * previous_style, gpointer user_data) 1076 1162 { 1077 1163 PangoRectangle logical_rect, ink_rect; 1078 1164 GtkWidget *tmp_entry; 1079 1080 if (!GTK_IS_ENTRY(widget)) 1081 return; 1082 tmp_entry = gtk_entry_new(); 1083 gtk_widget_set_style(tmp_entry, gtk_style_copy(widget->style)); 1084 gtk_entry_set_text(GTK_ENTRY(tmp_entry), "00:00:00.0000."); 1085 1086 pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY(tmp_entry)), &ink_rect, &logical_rect); 1087 gtk_widget_destroy(tmp_entry); 1088 1089 gtk_widget_set_usize(GTK_WIDGET(GTK_ENTRY(widget)), PANGO_PIXELS (ink_rect.width), -1); 1090 } 1165 1166 if (!GTK_IS_ENTRY (widget)) 1167 return; 1168 tmp_entry = gtk_entry_new (); 1169 gtk_widget_set_style (tmp_entry, gtk_style_copy (widget->style)); 1170 gtk_entry_set_text (GTK_ENTRY (tmp_entry), "00:00:00.0000."); 1171 1172 pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY (tmp_entry)), 1173 &ink_rect, &logical_rect); 1174 gtk_widget_destroy (tmp_entry); 1175 1176 gtk_widget_set_usize (GTK_WIDGET (GTK_ENTRY (widget)), 1177 PANGO_PIXELS (ink_rect.width), -1); 1178 } sweep/branches/sweep-info-panel/src/callbacks.h
r285 r470 24 24 #include <gtk/gtk.h> 25 25 26 void 27 sample_new_empty_cb (GtkWidget * widget, gpointer data); 28 29 void 30 sample_new_copy_cb (GtkWidget * widget, gpointer data); 31 32 void 33 view_new_all_cb (GtkWidget * widget, gpointer data); 34 35 void 36 view_new_cb (GtkWidget * widget, gpointer data); 37 38 void 39 view_close_cb (GtkWidget * widget, gpointer data); 40 41 void 42 exit_cb (GtkWidget * widget, gpointer data); 43 44 void 45 set_tool_cb (GtkWidget * widget, gpointer data); 46 47 void 48 view_set_tool_cb (GtkWidget * widget, gpointer data); 49 50 void 51 repeater_released_cb (GtkWidget * widget, gpointer data); 52 53 void 54 zoom_in_cb (GtkWidget * widget, gpointer data); 55 56 void 57 zoom_out_cb (GtkWidget * widget, gpointer data); 58 59 void 60 zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 61 62 void 63 zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 64 65 void 66 zoom_to_sel_cb (GtkWidget * widget, gpointer data); 67 68 void 69 zoom_left_cb (GtkWidget * widget, gpointer data); 70 71 void 72 zoom_right_cb (GtkWidget * widget, gpointer data); 73 74 void 75 zoom_all_cb (GtkWidget * widget, gpointer data); 76 77 void 78 zoom_2_1_cb (GtkWidget * widget, gpointer data); 79 80 void 81 zoom_norm_cb (GtkWidget * widget, gpointer data); 82 83 void 84 zoom_1to1_cb (GtkWidget * widget, gpointer data); 85 86 void 87 zoom_center_cb (GtkWidget * widget, gpointer data); 88 89 void 90 zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 91 92 void 93 sample_set_color_cb (GtkWidget * widget, gpointer data); 94 95 void 96 device_config_cb (GtkWidget * widget, gpointer data); 97 98 void 99 follow_toggled_cb (GtkWidget * widget, gpointer data); 100 101 void 102 follow_toggle_cb (GtkWidget * widget, gpointer data); 103 104 void 105 loop_toggled_cb (GtkWidget * widget, gpointer data); 106 107 void 108 loop_toggle_cb (GtkWidget * widget, gpointer data); 109 110 void 111 playrev_toggled_cb (GtkWidget * widget, gpointer data); 112 113 void 114 playrev_toggle_cb (GtkWidget * widget, gpointer data); 115 116 void 117 mute_toggled_cb (GtkWidget * widget, gpointer data); 118 119 void 120 mute_toggle_cb (GtkWidget * widget, gpointer data); 121 122 void 123 monitor_toggled_cb (GtkWidget * widget, gpointer data); 124 125 void 126 monitor_toggle_cb (GtkWidget * widget, gpointer data); 127 128 void 129 play_view_button_cb (GtkWidget * widget, gpointer data); 130 131 void 132 play_view_sel_button_cb (GtkWidget * widget, gpointer data); 133 134 void 135 play_view_cb (GtkWidget * widget, gpointer data); 136 137 void 138 play_view_all_once_cb (GtkWidget * widget, gpointer data); 139 140 void 141 play_view_all_loop_cb (GtkWidget * widget, gpointer data); 142 143 void 144 play_view_sel_cb (GtkWidget * widget, gpointer data); 145 146 void 147 play_view_sel_once_cb (GtkWidget * widget, gpointer data); 148 149 void 150 play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 151 152 void 153 pause_playback_cb (GtkWidget * widget, gpointer data); 154 155 void 156 stop_playback_cb (GtkWidget * widget, gpointer data); 157 158 void 159 preview_cut_cb (GtkWidget * widget, gpointer data); 160 161 void 162 preroll_cb (GtkWidget * widget, gpointer data); 163 164 void 165 show_rec_dialog_cb (GtkWidget * widget, gpointer data); 166 167 void 168 page_back_cb (GtkWidget * widget, gpointer data); 169 170 void 171 page_fwd_cb (GtkWidget * widget, gpointer data); 172 173 void 174 rewind_pressed_cb (GtkWidget * widget, gpointer data); 175 176 void 177 ffwd_pressed_cb (GtkWidget * widget, gpointer data); 178 179 void 180 goto_start_cb (GtkWidget * widget, gpointer data); 181 182 void 183 goto_start_of_view_cb (GtkWidget * widget, gpointer data); 184 185 void 186 goto_end_of_view_cb (GtkWidget * widget, gpointer data); 187 188 void 189 goto_end_cb (GtkWidget * widget, gpointer data); 190 191 void 192 sd_sel_changed_cb (GtkWidget * widget); 193 194 void 195 sd_win_changed_cb (GtkWidget * widget); 196 197 void 198 adj_changed_cb (GtkWidget * widget, gpointer data); 199 200 void 201 adj_value_changed_cb (GtkWidget * widget, gpointer data); 202 203 void 204 select_invert_cb (GtkWidget * widget, gpointer data); 205 206 void 207 select_all_cb (GtkWidget * widget, gpointer data); 208 209 void 210 select_none_cb (GtkWidget * widget, gpointer data); 211 212 void 213 selection_halve_cb (GtkWidget * widget, gpointer data); 214 215 void 216 selection_double_cb (GtkWidget * widget, gpointer data); 217 218 void 219 select_shift_left_cb (GtkWidget * widget, gpointer data); 220 221 void 222 select_shift_right_cb (GtkWidget * widget, gpointer data); 223 224 void 225 show_undo_dialog_cb (GtkWidget * widget, gpointer data); 226 227 void 228 undo_cb (GtkWidget * widget, gpointer data); 229 230 void 231 redo_cb (GtkWidget * widget, gpointer data); 232 233 void 234 cancel_cb (GtkWidget * widget, gpointer data); 235 236 void 237 copy_cb (GtkWidget * widget, gpointer data); 238 239 void 240 cut_cb (GtkWidget * widget, gpointer data); 241 242 void 243 clear_cb (GtkWidget * widget, gpointer data); 244 245 void 246 delete_cb (GtkWidget * widget, gpointer data); 247 248 void 249 crop_cb (GtkWidget * widget, gpointer data); 250 251 void 252 paste_cb (GtkWidget * widget, gpointer data); 253 254 void 255 paste_mix_cb (GtkWidget * widget, gpointer data); 256 257 void 258 paste_xfade_cb (GtkWidget * widget, gpointer data); 259 260 void 261 paste_as_new_cb (GtkWidget * widget, gpointer data); 262 263 void 264 reverse_cb (GtkWidget * widget, gpointer data); 265 266 void 267 normalise_cb (GtkWidget * widget, gpointer data); 268 269 void 270 show_info_dialog_cb (GtkW
