Changeset 470
- Timestamp:
- 01/16/07 19:06:49 (2 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,
