Changeset 470

Show
Ignore:
Timestamp:
01/16/07 19:06:49 (2 years ago)
Author:
radekk
Message:

Indenting files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/branches/sweep-info-panel/ChangeLog

    r341 r470  
     1Tue 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 
    17Mon Jan 30 23:58:00 GMT 2006 Peter Shorthose <kickback@users.sourceforge.net> 
    28 
     
    1117        * a new SVG icon for sweep (Alex Kloss) 
    1218        * 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. 
    1521        * released 0.9.0 
    1622 
  • sweep/branches/sweep-info-panel/plugins/byenergy/byenergy.c

    r464 r470  
    3030 
    3131static 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, 
     33lower: {f:0.001}, 
     34step: {f:0.001} 
    3535}; 
    3636 
    3737static sw_param_range threshold_range = { 
    3838  SW_RANGE_ALL_VALID, 
    39   lower: {f: 0.0}, 
    40   upper: {f: 1.0}, 
    41   step:  {f: 0.01} 
     39lower: {f:0.0}, 
     40upper: {f:1.0}, 
     41step: {f:0.01} 
    4242}; 
    4343 
    4444static 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, 
     46lower: {f:0.0}, 
     47step: {f:0.01} 
    4848}; 
    4949 
    5050static 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, 
     52lower: {f:0.0}, 
     53step: {f:0.01} 
    5454}; 
    5555 
    5656static sw_param_spec param_specs[] = { 
    5757  { 
    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 
    9393}; 
    9494 
    9595static void 
    96 by_energy_suggest (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     96by_energy_suggest (sw_sample * sample, sw_param_set pset, 
     97                   gpointer custom_data) 
    9798{ 
    9899  pset[0].b = FALSE; 
     
    112113  gfloat max_interruption_f = pset[4].f; 
    113114 
    114   sw_sounddata * sounddata; 
    115   sw_audio_t * d; 
     115  sw_sounddata *sounddata; 
     116  sw_audio_t *d; 
    116117  glong window, win_s; 
    117118  gint i, doff; 
    118119  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; 
    122123 
    123124  sounddata = sample_get_sounddata (s); 
    124125 
    125   window = (glong)(resolution * (gfloat)sounddata->format->rate); 
     126  window = (glong) (resolution * (gfloat) sounddata->format->rate); 
    126127  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); 
    128129 
    129130  /* 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; 
    134136 
    135137  sounddata_lock_selection (sounddata); 
     
    141143  length = sounddata->nr_frames; 
    142144  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; 
    152165    } 
    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   } 
    162166 
    163167  factor = SW_AUDIO_T_MAX / max_energy; 
     
    167171#endif 
    168172 
    169   threshold *= (gfloat)max_energy; 
     173  threshold *= (gfloat) max_energy; 
    170174 
    171175  length = sounddata->nr_frames; 
    172176  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; 
    182227    } 
    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        } 
    208235    } 
    209236 
    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  
    220237  sounddata_unlock_selection (sounddata); 
    221238} 
    222239 
    223240static sw_op_instance * 
    224 apply_by_energy(sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     241apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    225242{ 
    226243  return 
    227244    perform_selection_op (sample, _("Select by energy"), 
    228                           (SweepFilter)select_by_energy, pset, NULL); 
     245                          (SweepFilter) select_by_energy, pset, NULL); 
    229246} 
    230247 
     
    235252  "Copyright (C) 2000 CSIRO Australia", 
    236253  "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() */ 
    243260  apply_by_energy, 
    244   NULL, /* custom data */ 
     261  NULL,                                /* custom data */ 
    245262}; 
    246263 
     
    248265by_energy_init (void) 
    249266{ 
    250   return g_list_append ((GList *)NULL, &proc_by_energy); 
     267  return g_list_append ((GList *) NULL, &proc_by_energy); 
    251268} 
    252269 
    253270 
    254271sw_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  
    3636 
    3737static 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, 
     39lower: {f:0.0}, 
     40step: {f:0.001} 
    4141}; 
    4242 
    4343static sw_param_range gain_range = { 
    4444  SW_RANGE_ALL_VALID, 
    45   lower: {f: 0.0}, 
    46   upper: {f: 1.0}, 
    47   step: {f: 0.01} 
     45lower: {f:0.0}, 
     46upper: {f:1.0}, 
     47step: {f:0.01} 
    4848}; 
    4949 
     
    5151static sw_param_spec param_specs[] = { 
    5252  { 
    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}, 
    6059  { 
    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}, 
    6866}; 
    6967 
     
    8381 
    8482  sw_framecount_t i, delay_f, dlen_s; 
    85   sw_audio_t * d, * e; 
     83  sw_audio_t *d, *e; 
    8684  gpointer ep; 
    8785 
    8886  delay_f = time_to_frames (format, delay); 
    8987 
    90   d = (sw_audio_t *)data; 
     88  d = (sw_audio_t *) data; 
    9189  ep = data + frames_to_bytes (format, delay_f); 
    92   e = (sw_audio_t *)ep; 
     90  e = (sw_audio_t *) ep; 
    9391 
    94   if (delay > nr_frames) return; 
     92  if (delay > nr_frames) 
     93    return; 
    9594 
    9695  dlen_s = frames_to_samples (format, nr_frames - delay_f); 
    9796 
    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    } 
    101101} 
    102102 
     
    106106  return 
    107107    perform_filter_region_op (sample, _("Echo"), 
    108                               (SweepFilterRegion)region_echo, pset, NULL); 
     108                              (SweepFilterRegion) region_echo, pset, NULL); 
    109109} 
    110110 
     
    116116  "Copyright (C) 2000", 
    117117  "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() */ 
    124124  echo_apply, 
    125   NULL, /* custom_data */ 
     125  NULL,                                /* custom_data */ 
    126126}; 
    127127 
     
    129129echo_init (void) 
    130130{ 
    131   return g_list_append ((GList *)NULL, &proc_echo); 
     131  return g_list_append ((GList *) NULL, &proc_echo); 
    132132} 
    133133 
    134134 
    135135sw_plugin plugin = { 
    136   echo_init, /* plugin_init */ 
    137   NULL, /* plugin_cleanup */ 
     136  echo_init,                   /* plugin_init */ 
     137  NULL,                                /* plugin_cleanup */ 
    138138}; 
  • sweep/branches/sweep-info-panel/plugins/example/example.c

    r75 r470  
    3434 
    3535static 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")} 
    4141}; 
    4242 
    4343static 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} 
    5252}; 
    5353 
    5454static sw_param_spec example_filter_region_param_specs[] = { 
    5555  { 
    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}, 
    6362  { 
    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}, 
    7169  { 
    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} 
    7976}; 
    8077 
     
    9390{ 
    9491  gboolean flim = pset[0].b; 
    95   gchar * beans = pset[1].s; 
     92  gchar *beans = pset[1].s; 
    9693  gint nr_pants = pset[2].i; 
    9794 
    98   if (flim) { 
    99     /* manage flim */ 
    100   } 
     95  if (flim) 
     96    { 
     97      /* manage flim */ 
     98    } 
    10199 
    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    } 
    107108 
    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    } 
    112114 
    113115  /* Do filtering stuff */ 
     
    121123  return 
    122124    perform_filter_region_op (sample, _("Example Filter Region"), 
    123                               (SweepFilterRegion)example_filter_region_func, 
     125                              (SweepFilterRegion) example_filter_region_func, 
    124126                              pset, NULL); 
    125127} 
     
    132134  "Copyright (C) 2000", 
    133135  "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() */ 
    140142  example_filter_region_apply, 
    141   NULL, /* custom_data */ 
     143  NULL,                                /* custom_data */ 
    142144}; 
    143145 
     
    145147example_init (void) 
    146148{ 
    147   return g_list_append ((GList *)NULL, &proc_example_filter_region); 
     149  return g_list_append ((GList *) NULL, &proc_example_filter_region); 
    148150} 
    149151 
    150152 
    151153sw_plugin plugin = { 
    152   example_init, /* plugin_init */ 
    153   NULL, /* plugin_cleanup */ 
     154  example_init,                        /* plugin_init */ 
     155  NULL,                                /* plugin_cleanup */ 
    154156}; 
  • sweep/branches/sweep-info-panel/plugins/fade/fade.c

    r124 r470  
    2626#include <sweep/sweep.h> 
    2727 
    28 #include <../src/sweep_app.h> /* XXX */ 
     28#include <../src/sweep_app.h>  /* XXX */ 
    2929 
    3030static sw_sample * 
    3131fade (sw_sample * sample, gfloat start, gfloat end) 
    3232{ 
    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; 
    3838  gfloat factor = start; 
    3939  sw_framecount_t op_total, run_total; 
     
    4747 
    4848  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; 
    5051  run_total = 0; 
    5152 
    5253#if 0 
    5354  /* 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); 
    7495        } 
    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); 
    8496    } 
    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; 
    88100#endif 
    89101 
    90102  /* 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); 
    112143        } 
    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); 
    122144    } 
    123   } 
    124145 
    125146  return sample; 
     
    142163{ 
    143164  return 
    144     perform_filter_op (sample, _("Fade in"), (SweepFilter)fade_in, 
     165    perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in, 
    145166                       pset, NULL); 
    146167} 
     
    150171{ 
    151172  return 
    152     perform_filter_op (sample, _("Fade out"), (SweepFilter)fade_out, 
     173    perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out, 
    153174                       pset, NULL); 
    154175} 
     
    160181  "Copyright (C) 2002", 
    161182  "http://sweep.sourceforge.net/plugins/fade", 
    162   "Filters/Fade_In", /* identifier */ 
    163   0, /* accel_key */ 
    164   0, /* accel_mods */ 
    165   0,