Changeset 470

Show
Ignore:
Timestamp:
01/16/07 19:06:49 (5 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, /* 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() */ 
    168189  apply_fade_in, 
    169   NULL, /* custom_data */ 
     190  NULL,                                /* custom_data */ 
    170191}; 
    171192 
     
    176197  "Copyright (C) 2002", 
    177198  "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() */ 
    184205  apply_fade_out, 
    185   NULL, /* custom_data */ 
     206  NULL,                                /* custom_data */ 
    186207}; 
    187    
     208 
    188209static GList * 
    189210fade_init (void) 
    190211{ 
    191   GList * gl = NULL; 
     212  GList *gl = NULL; 
    192213 
    193214  gl = g_list_append (gl, &proc_fade_in); 
     
    199220 
    200221sw_plugin plugin = { 
    201   fade_init, /* plugin_init */ 
    202   NULL, /* plugin_cleanup */ 
     222  fade_init,                   /* plugin_init */ 
     223  NULL,                                /* plugin_cleanup */ 
    203224}; 
  • sweep/branches/sweep-info-panel/plugins/ladspa/ladspameta.c

    r130 r470  
    3030#include <dirent.h> 
    3131#include <string.h> 
    32 #include <math.h> /* for ceil() */ 
     32#include <math.h>              /* for ceil() */ 
    3333 
    3434#include <glib.h> 
     
    5959#define LADSPA_frames_to_bytes(f) (f * sizeof(LADSPA_Data)) 
    6060 
    61 static char * default_ladspa_path = "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 
    62  
    63 static GList * modules_list = NULL; 
     61static char *default_ladspa_path = 
     62  "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 
     63 
     64static GList *modules_list = NULL; 
    6465static gboolean ladspa_meta_initialised = FALSE; 
    6566 
     
    7374 */ 
    7475static gboolean 
    75 is_usable(const LADSPA_Descriptor * d) 
     76is_usable (const LADSPA_Descriptor * d) 
    7677{ 
    7778  LADSPA_PortDescriptor pd; 
    7879  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; 
    9294 
    9395  /* 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 */ 
    97102 
    98103  return (nr_ai == nr_ao); 
     
    102107convert_type (const LADSPA_PortRangeHintDescriptor prhd) 
    103108{ 
    104   if (LADSPA_IS_HINT_TOGGLED(prhd)) 
     109  if (LADSPA_IS_HINT_TOGGLED (prhd)) 
    105110    return SWEEP_TYPE_BOOL; 
    106   else if (LADSPA_IS_HINT_INTEGER(prhd)) 
     111  else if (LADSPA_IS_HINT_INTEGER (prhd)) 
    107112    return SWEEP_TYPE_INT; 
    108113  else 
     
    113118get_valid_mask (const LADSPA_PortRangeHintDescriptor prhd) 
    114119{ 
    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)) 
    118123    ret |= SW_RANGE_LOWER_BOUND_VALID; 
    119   if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 
     124  if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 
    120125    ret |= SW_RANGE_UPPER_BOUND_VALID; 
    121126 
     
    124129 
    125130static sw_param_range * 
    126 convert_constraint ( /* sw_format * format, */ 
    127                     const LADSPA_PortRangeHint * prh) 
    128 { 
    129   sw_param_range * pr; 
     131convert_constraint (           /* sw_format * format, */ 
     132                    const LADSPA_PortRangeHint * prh) 
     133{ 
     134  sw_param_range *pr; 
    130135  LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 
    131136  LADSPA_Data lower, upper; 
    132137 
    133   if (LADSPA_IS_HINT_TOGGLED(prhd)) 
     138  if (LADSPA_IS_HINT_TOGGLED (prhd)) 
    134139    return NULL; 
    135140 
     
    141146  upper = prh->UpperBound; 
    142147 
    143   if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 
     148  if LADSPA_IS_HINT_SAMPLE_RATE 
     149    (prhd) 
     150    { 
    144151#if 0 
    145     lower *= format->rate; 
    146     upper *= format->rate; 
     152      lower *= format->rate; 
     153      upper *= format->rate; 
    147154#else 
    148     lower *= 44100; 
    149     upper *= 44100; 
     155      lower *= 44100; 
     156      upper *= 44100; 
    150157#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    } 
    164174 
    165175  return pr; 
     
    168178typedef struct _lm_custom lm_custom; 
    169179 
    170 struct _lm_custom { 
    171   const LADSPA_Descriptor * d; 
    172   sw_param_spec * param_specs; 
     180struct _lm_custom 
     181
     182  const LADSPA_Descriptor *d; 
     183  sw_param_spec *param_specs; 
    173184}; 
    174185 
     
    176187lm_custom_new (const LADSPA_Descriptor * d, sw_param_spec * param_specs) 
    177188{ 
    178   lm_custom * lmc; 
     189  lm_custom *lmc; 
    179190 
    180191  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    } 
    185197 
    186198  return lmc; 
     
    203215  upper = prh->UpperBound; 
    204216 
    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    } 
    209223 
    210224  /* Determine default value, as sw_float */ 
    211225 
    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    } 
    247291 
    248292  /* Convert to sw_param type */ 
    249293 
    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    } 
    257306 
    258307  return param; 
     
    263312                     gpointer custom_data) 
    264313{ 
    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; 
    268317 
    269318  LADSPA_PortDescriptor pd; 
     
    272321  sounddata = sample_get_sounddata (sample); 
    273322 
    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    } 
    282333 
    283334} 
     
    289340                          gpointer custom_data) 
    290341{ 
    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; 
    297348  sw_framecount_t op_total, run_total; 
    298349  sw_framecount_t offset, remaining, n; 
    299350 
    300   GList * gl; 
    301   sw_sel * sel; 
     351  GList *gl; 
     352  sw_sel *sel; 
    302353 
    303354  gpointer pcmdata; 
     
    310361  gint nr_handles; 
    311362 
    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; 
    317368  LADSPA_Data dummy_control_output; 
    318369  LADSPA_PortDescriptor pd; 
    319370  glong length_b; 
    320   gulong port_i; /* counter for iterating over ports */ 
     371  gulong port_i;               /* counter for iterating over ports */ 
    321372  gint h, i, j, c; 
    322373 
    323374  /* 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 */ 
    329379 
    330380  /* The number of audio channels to be processed */ 
     
    332382 
    333383  /* 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; 
    335385 
    336386  /* Counters for allocating input and output buffers */ 
    337   gint ibi=0, obi=0; 
     387  gint ibi = 0, obi = 0; 
    338388 
    339389  gboolean active = TRUE; 
     
    346396 
    347397  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; 
    349400  run_total = 0; 
    350401 
    351402  /* 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    } 
    363415 
    364416  /* Basic assumption of this meta plugin, which was 
     
    374426  g_assert (nr_ao > 0); 
    375427 
    376   nr_handles = (gint) ceil(((double)nr_channels) / ((double)nr_ao)); 
     428  nr_handles = (gint) ceil (((double) nr_channels) / ((double) nr_ao)); 
    377429 
    378430  /* Numbers of input and output buffers: ensure 
     
    384436  /* Create all input and output buffers */ 
    385437 
    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. 
    429443       */ 
    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    } 
    439504 
    440505  /* instantiate the ladspa plugin */ 
    441506  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    } 
    445511 
    446512  /* 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    } 
    486558 
    487559  /* 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    } 
    493567 
    494568  /* 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    } 
    583681 
    584682  /* 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    } 
    590690 
    591691  /* 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    } 
    597699 
    598700  /* free the array of handles */ 
    599701  g_free (handles); 
    600    
     702 
    601703  /* 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    } 
    631744 
    632745  return sample; 
     
    637750                   sw_param_set pset, gpointer custom_data) 
    638751{ 
    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; 
    641754 
    642755  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, 
    645758                       pset, custom_data); 
    646759} 
     
    658771#define PATH_LEN 256 
    659772  gchar path[PATH_LEN]; 
    660   void * module; 
     773  void *module; 
    661774  LADSPA_Descriptor_Function desc_func; 
    662   const LADSPA_Descriptor * d; 
     775  const LADSPA_Descriptor *d; 
    663776  LADSPA_PortDescriptor pd; 
    664777  gint i, j, k, nr_params; 
    665778  int valid_mask; 
    666   sw_procedure * proc; 
     779  sw_procedure *proc; 
    667780 
    668781  snprintf (path, PATH_LEN, "%s/%s", dir, name); 
    669782 
    670783  module = dlopen (path, RTLD_NOW); 
    671   if (!module) return; 
     784  if (!module) 
     785    return; 
    672786 
    673787  modules_list = g_list_append (modules_list, module); 
    674788 
    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    } 
    727853} 
    728854 
     
    736862ladspa_meta_init_dir (gchar * dirname, GList ** gl) 
    737863{ 
    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; 
    743870 
    744871  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    } 
    754883} 
    755884 
     
    757886ladspa_meta_init (void) 
    758887{ 
    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; 
    763892 
    764893  /* If this ladspa_meta module has already been initialised, don't 
     
    770899  ladspa_path = getenv ("LADSPA_PATH"); 
    771900  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')); 
    783916 
    784917  ladspa_meta_initialised = TRUE; 
    785918 
    786919  /* 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); 
    788922 
    789923  return gl; 
     
    793927ladspa_meta_cleanup (void) 
    794928{ 
    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    } 
    802938} 
    803939 
    804940sw_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 */ 
    807943}; 
  • sweep/branches/sweep-info-panel/plugins/normalise/normalise.c

    r125 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 * 
    3131normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    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  sw_audio_t max = 0; 
    3939  gfloat factor = 1.0; 
     
    4747  f = sounddata->format; 
    4848 
    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; 
    5152  run_total = 0; 
    5253 
    5354  /* 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; 
    5658 
    57     offset = 0; 
    58     remaining = sel->sel_end - sel->sel_start; 
     59      offset = 0; 
     60      remaining = sel->sel_end - sel->sel_start; 
    5961 
    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); 
    6265 
    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            { 
    6672 
    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); 
    6876 
    69         n = MIN(remaining, 1024); 
     77              n = MIN (remaining, 1024); 
    7078 
    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); 
    7495        } 
     96    } 
    7597 
    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; 
    88100 
    89101  /* 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; 
    92105 
    93     offset = 0; 
    94     remaining = sel->sel_end - sel->sel_start; 
     106      offset = 0; 
     107      remaining = sel->sel_end - sel->sel_start; 
    95108 
    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); 
    98112 
    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); 
    103122 
    104         n = MIN(remaining, 1024); 
     123              n = MIN (remaining, 1024); 
    105124 
    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); 
    108139        } 
    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); 
    118140    } 
    119   } 
    120141 
    121142  return sample; 
     
    123144 
    124145static sw_op_instance * 
    125 apply_normalise(sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     146apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    126147{ 
    127148  return 
    128     perform_filter_op (sample, _("Normalise"), (SweepFilter)normalise, 
     149    perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise, 
    129150                       pset, NULL); 
    130151} 
     
    136157  "Copyright (C) 2000", 
    137158  "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() */ 
    144165  apply_normalise, 
    145   NULL, /* custom_data */ 
     166  NULL,                                /* custom_data */ 
    146167}; 
    147    
     168 
    148169static GList * 
    149170normalise_init (void) 
    150171{ 
    151   return g_list_append ((GList *)NULL, &proc_normalise); 
     172  return g_list_append ((GList *) NULL, &proc_normalise); 
    152173} 
    153174 
    154175 
    155176sw_plugin plugin = { 
    156   normalise_init, /* plugin_init */ 
    157   NULL, /* plugin_cleanup */ 
     177  normalise_init,              /* plugin_init */ 
     178  NULL,                                /* plugin_cleanup */ 
    158179}; 
  • sweep/branches/sweep-info-panel/plugins/reverse/reverse.c

    r125 r470  
    2626#include <sweep/sweep.h> 
    2727 
    28 #include "../src/sweep_app.h" /* XXX */ 
     28#include "../src/sweep_app.h"  /* XXX */ 
    2929 
    3030#if 0 
     
    4242  e = d + frames_to_bytes (format, nr_frames); 
    4343 
    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    } 
    5253 
    5354  g_free (t); 
     
    5960                   gpointer custom_data) 
    6061{ 
    61   GList * gl; 
    62   sw_sel * sel; 
     62  GList *gl; 
     63  sw_sel *sel; 
    6364  glong i, sw; 
    64   sw_sounddata * sounddata; 
    65   sw_format * format; 
     65  sw_sounddata *sounddata; 
     66  sw_format *format; 
    6667  sw_framecount_t nr_frames; 
    6768  gpointer d, e, t; 
     
    7677 
    7778  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; 
    7981  run_total = 0; 
    8082 
     
    8284  t = alloca (sw); 
    8385 
    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; 
    8689 
    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; 
    8992 
    90     e = d + frames_to_bytes (format, nr_frames); 
    91      
    92     remaining = nr_frames/2; 
     93      e = d + frames_to_bytes (format, nr_frames); 
    9394 
    94     while (active && remaining > 0) { 
    95       g_mutex_lock (sample->ops_mutex); 
     95      remaining = nr_frames / 2; 
    9696 
    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); 
    101100 
    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); 
    109126        } 
    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); 
    118127    } 
    119   } 
    120128 
    121129  return sample; 
     
    128136  return 
    129137    perform_filter_region_op (sample, _("Reverse"), 
    130                               (SweepFilterRegion)region_reverse, pset, NULL); 
     138                              (SweepFilterRegion) region_reverse, pset, NULL); 
    131139#endif 
    132140 
    133141  return 
    134142    perform_filter_op (sample, _("Reverse"), 
    135                        (SweepFilter)sounddata_reverse, pset, NULL); 
     143                       (SweepFilter) sounddata_reverse, pset, NULL); 
    136144} 
    137145 
     
    143151  "Copyright (C) 2000", 
    144152  "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() */ 
    151159  apply_reverse, 
    152   NULL, /* custom_data */ 
     160  NULL,                                /* custom_data */ 
    153161}; 
    154162 
     
    156164reverse_init (void) 
    157165{ 
    158   return g_list_append ((GList *)NULL, &proc_reverse); 
     166  return g_list_append ((GList *) NULL, &proc_reverse); 
    159167} 
    160168 
    161169 
    162170sw_plugin plugin = { 
    163   reverse_init, /* plugin_init */ 
    164   NULL, /* plugin_cleanup */ 
     171  reverse_init,                        /* plugin_init */ 
     172  NULL,                                /* plugin_cleanup */ 
    165173}; 
  • sweep/branches/sweep-info-panel/src/about_dialog.c

    r409 r470  
    3636 
    3737 
    38 static void about_dialog_destroy(void); 
    39 static int about_dialog_button(GtkWidget * widget, 
    40                                GdkEventButton * event); 
     38static void about_dialog_destroy (void); 
     39static int about_dialog_button (GtkWidget * widget, GdkEventButton * event); 
    4140 
    4241static GtkWidget *about_dialog = NULL; 
     
    4948 
    5049void 
    51 about_dialog_create() 
     50about_dialog_create () 
    5251{ 
    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   */ 
    5656  GtkWidget *vbox; 
    5757  GtkWidget *label; 
    5858#define BUF_LEN 64 
    5959  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; 
    6363  gchar buf2[1024]; 
    6464 
    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); 
    7780 
    7881 
    7982 
    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); 
    8386 
    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); 
    9295 
    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); 
    103106 
    104107#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); 
    108113#endif 
    109114 
    110  /* FIXME: old style code 
    111   *   gtk_widget_pop_style(); 
    112   */ 
     115      /* 
     116       * FIXME: old style code gtk_widget_pop_style();  
     117       */ 
    113118 
    114119#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); 
    118123 
    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); 
    122127#endif 
    123128 
    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    } 
    135143} 
    136144 
    137145static void 
    138 about_dialog_destroy() 
     146about_dialog_destroy () 
    139147{ 
    140148  about_dialog = NULL; 
     
    142150 
    143151static int 
    144 about_dialog_button(GtkWidget * widget, 
    145                     GdkEventButton * event) 
     152about_dialog_button (GtkWidget * widget, GdkEventButton * event) 
    146153{ 
    147   gtk_widget_hide(about_dialog); 
     154  gtk_widget_hide (about_dialog); 
    148155 
    149156  return FALSE; 
  • sweep/branches/sweep-info-panel/src/about_dialog.h

    r7 r470  
    2222#define __ABOUT_DIALOG_H__ 
    2323 
    24 void about_dialog_create(void); 
     24void about_dialog_create (void); 
    2525 
    2626#endif /* __ABOUT_DIALOG_H__ */ 
  • sweep/branches/sweep-info-panel/src/callbacks.c

    r465 r470  
    6868#define ZOOM_FRAMERATE 10 
    6969 
    70 /* Sample creation */ 
     70/* 
     71 * Sample creation  
     72 */ 
    7173 
    7274void 
    7375sample_new_empty_cb (GtkWidget * widget, gpointer data) 
    7476{ 
    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    } 
    8287} 
    8388 
     
    8590sample_new_copy_cb (GtkWidget * widget, gpointer data) 
    8691{ 
    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; 
    9196 
    9297  s = sd->view->sample; 
    9398 
    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    } 
    101108 
    102109  v = view_new_all (ns, 1.0); 
    103110  sample_add_view (ns, v); 
    104111 
    105   sample_bank_add(ns); 
    106 
    107  
    108 /* Generic repeater */ 
     112  sample_bank_add (ns); 
     113
     114 
     115/* 
     116 * Generic repeater  
     117 */ 
    109118 
    110119static void 
     
    112121{ 
    113122  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, 
    116126                                          (GSourceFunc) function, data); 
    117  
     127   
    118128} 
    119129 
     
    121131repeater_released_cb (GtkWidget * widget, gpointer data) 
    122132{ 
    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 */ 
    132145 
    133146void 
    134147view_new_all_cb (GtkWidget * widget, gpointer data) 
    135148{ 
    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; 
    139152 
    140153  s = sd->view->sample; 
    141   v = view_new_all(s, 1.0); 
     154  v = view_new_all (s, 1.0); 
    142155 
    143156  sample_add_view (s, v); 
     
    147160view_new_cb (GtkWidget * widget, gpointer data) 
    148161{ 
    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; 
    152165 
    153166  v = sd->view; 
     
    162175view_close_cb (GtkWidget * widget, gpointer data) 
    163176{ 
    164   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    165   sw_view * v; 
     177  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     178  sw_view *v; 
    166179 
    167180  v = sd->view; 
    168181 
    169   view_close(v); 
     182  view_close (v); 
    170183} 
    171184 
     
    176189} 
    177190 
    178 /* Tools */ 
     191/* 
     192 * Tools  
     193 */ 
    179194void 
    180195set_tool_cb (GtkWidget * widget, gpointer data) 
    181196{ 
    182197#if 0 
    183   gint tool = (gint)data; 
    184  
    185   /*  current_tool = tool;*/ 
     198  gint tool = (gint) data; 
     199 
     200  /* 
     201   * current_tool = tool; 
     202   */ 
    186203#endif 
    187204  g_print ("NOOOOOOOOOOOOOO global current_tool\n"); 
     
    191208view_set_tool_cb (GtkWidget * widget, gpointer data) 
    192209{ 
    193   sw_view * view = (sw_view *)data; 
     210  sw_view *view = (sw_view *) data; 
    194211  sw_tool_t tool; 
    195212 
    196213  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")); 
    198215 
    199216  view->current_tool = tool; 
     
    202219} 
    203220 
    204 /* Zooming */ 
     221/* 
     222 * Zooming  
     223 */ 
    205224 
    206225static gboolean 
    207226zoom_in_step (gpointer data) 
    208227{ 
    209   sw_view * view = (sw_view *)data; 
     228  sw_view *view = (sw_view *) data; 
    210229 
    211230  view_zoom_in (view, DEFAULT_ZOOM); 
     
    217236zoom_in_cb (GtkWidget * widget, gpointer data) 
    218237{ 
    219   sw_view * view = (sw_view *)data; 
     238  sw_view *view = (sw_view *) data; 
    220239  view_zoom_in (view, DEFAULT_ZOOM); 
    221240} 
     
    224243zoom_out_step (gpointer data) 
    225244{ 
    226   sw_view * view = (sw_view *)data; 
     245  sw_view *view = (sw_view *) data; 
    227246 
    228247  view_zoom_out (view, DEFAULT_ZOOM); 
     
    234253zoom_out_cb (GtkWidget * widget, gpointer data) 
    235254{ 
    236   sw_view * view = (sw_view *)data; 
     255  sw_view *view = (sw_view *) data; 
    237256  view_zoom_out (view, DEFAULT_ZOOM); 
    238257} 
     
    242261zoom_in_pressed_cb (GtkWidget * widget, gpointer data) 
    243262{ 
    244   sw_view * view = (sw_view *)data; 
     263  sw_view *view = (sw_view *) data; 
    245264 
    246265  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); 
    248267} 
    249268 
     
    251270zoom_out_pressed_cb (GtkWidget * widget, gpointer data) 
    252271{ 
    253   sw_view * view = (sw_view *)data; 
     272  sw_view *view = (sw_view *) data; 
    254273 
    255274  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); 
    257276} 
    258277 
     
    260279zoom_to_sel_cb (GtkWidget * widget, gpointer data) 
    261280{ 
    262   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    263   sw_view * v = sd->view; 
     281  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     282  sw_view *v = sd->view; 
    264283 
    265284  view_zoom_to_sel (v); 
     
    269288zoom_left_cb (GtkWidget * widget, gpointer data) 
    270289{ 
    271   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    272   sw_view * v = sd->view; 
     290  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     291  sw_view *v = sd->view; 
    273292 
    274293  view_zoom_left (v); 
     
    278297zoom_right_cb (GtkWidget * widget, gpointer data) 
    279298{ 
    280   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    281   sw_view * v = sd->view; 
     299  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     300  sw_view *v = sd->view; 
    282301 
    283302  view_zoom_right (v); 
     
    287306zoom_all_cb (GtkWidget * widget, gpointer data) 
    288307{ 
    289   sw_view * v = (sw_view *)data; 
     308  sw_view *v = (sw_view *) data; 
    290309 
    291310  view_zoom_all (v); 
    292311} 
    293312 
    294 /* XXX: dump this ?? */ 
     313/* 
     314 * XXX: dump this ??  
     315 */ 
    295316void 
    296317zoom_2_1_cb (GtkWidget * widget, gpointer data) 
    297318{ 
    298   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    299   sw_sample * s; 
     319  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     320  sw_sample *s; 
    300321 
    301322  s = sd->view->sample; 
    302323 
    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); 
    306327} 
    307328 
     
    309330zoom_norm_cb (GtkWidget * widget, gpointer data) 
    310331{ 
    311   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    312   sw_view * view = sd->view; 
     332  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     333  sw_view *view = sd->view; 
    313334 
    314335  view_zoom_normal (view); 
     
    318339zoom_1to1_cb (GtkWidget * widget, gpointer data) 
    319340{ 
    320   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     341  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    321342 
    322343  view_zoom_length (sd->view, sd->width); 
     
    327348zoom_center_cb (GtkWidget * widget, gpointer data) 
    328349{ 
    329   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     350  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    330351 
    331352  view_center_on (sd->view, sd->view->sample->user_offset); 
     
    335356zoom_combo_changed_cb (GtkWidget * widget, gpointer data) 
    336357{ 
    337   sw_view * view = (sw_view *)data; 
    338   gchar * text; 
     358  sw_view *view = (sw_view *) data; 
     359  gchar *text; 
    339360  sw_time_t zoom_time; 
    340361  sw_framecount_t zoom_length; 
    341362 
    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 */ 
    362391 
    363392void 
     
    367396} 
    368397 
    369 /* Sample */ 
     398/* 
     399 * Sample  
     400 */ 
    370401 
    371402void 
    372403sample_set_color_cb (GtkWidget * widget, gpointer data) 
    373404{ 
    374   sw_view * view = (sw_view *) data; 
     405  sw_view *view = (sw_view *) data; 
    375406  gint color; 
    376407 
    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")); 
    378409  sample_set_color (view->sample, color); 
    379410} 
    380411 
    381 /* Playback */ 
     412/* 
     413 * Playback  
     414 */ 
    382415 
    383416void 
    384417follow_toggled_cb (GtkWidget * widget, gpointer data) 
    385418{ 
    386   sw_view * view = (sw_view *) data; 
     419  sw_view *view = (sw_view *) data; 
    387420  gboolean active; 
    388421 
    389   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     422  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    390423  view_set_following (view, active); 
    391424} 
     
    394427follow_toggle_cb (GtkWidget * widget, gpointer data) 
    395428{ 
    396   sw_view * view = (sw_view *)data; 
     429  sw_view *view = (sw_view *) data; 
    397430  view_set_following (view, !view->following); 
    398431} 
     
    401434loop_toggled_cb (GtkWidget * widget, gpointer data) 
    402435{ 
    403   sw_view * view = (sw_view *) data; 
     436  sw_view *view = (sw_view *) data; 
    404437  gboolean active; 
    405438 
    406   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     439  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    407440  sample_set_looping (view->sample, active); 
    408441} 
     
    411444loop_toggle_cb (GtkWidget * widget, gpointer data) 
    412445{ 
    413   sw_view * view = (sw_view *)data; 
     446  sw_view *view = (sw_view *) data; 
    414447  sample_set_looping (view->sample, !view->sample->play_head->looping); 
    415448} 
     
    418451playrev_toggled_cb (GtkWidget * widget, gpointer data) 
    419452{ 
    420   sw_view * view = (sw_view *) data; 
     453  sw_view *view = (sw_view *) data; 
    421454  gboolean active; 
    422455 
    423   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     456  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    424457  sample_set_playrev (view->sample, active); 
    425458} 
     
    428461playrev_toggle_cb (GtkWidget * widget, gpointer data) 
    429462{ 
    430   sw_view * view = (sw_view *)data; 
     463  sw_view *view = (sw_view *) data; 
    431464  sample_set_playrev (view->sample, !view->sample->play_head->reverse); 
    432465} 
     
    435468mute_toggled_cb (GtkWidget * widget, gpointer data) 
    436469{ 
    437   sw_view * view = (sw_view *) data; 
     470  sw_view *view = (sw_view *) data; 
    438471  gboolean active; 
    439472 
    440   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     473  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    441474  sample_set_mute (view->sample, active); 
    442475} 
     
    445478mute_toggle_cb (GtkWidget * widget, gpointer data) 
    446479{ 
    447   sw_view * view = (sw_view *)data; 
     480  sw_view *view = (sw_view *) data; 
    448481  sample_set_mute (view->sample, !view->sample->play_head->mute); 
    449482} 
     
    452485monitor_toggled_cb (GtkWidget * widget, gpointer data) 
    453486{ 
    454   sw_view * view = (sw_view *) data; 
     487  sw_view *view = (sw_view *) data; 
    455488  gboolean active; 
    456489 
    457   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     490  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    458491  sample_set_monitor (view->sample, active); 
    459492} 
     
    462495monitor_toggle_cb (GtkWidget * widget, gpointer data) 
    463496{ 
    464   sw_view * view = (sw_view *)data; 
     497  sw_view *view = (sw_view *) data; 
    465498  sample_set_monitor (view->sample, !view->sample->play_head->monitor); 
    466499} 
     
    469502play_view_button_cb (GtkWidget * widget, gpointer data) 
    470503{ 
    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; 
    473506  gboolean was_restricted = head->restricted; 
    474507 
    475508  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    } 
    483521} 
    484522 
     
    486524play_view_cb (GtkWidget * widget, gpointer data) 
    487525{ 
    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; 
    490528 
    491529  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    } 
    499542} 
    500543 
     
    502545play_view_sel_button_cb (GtkWidget * widget, gpointer data) 
    503546{ 
    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; 
    506549  gboolean was_restricted = head->restricted; 
    507550 
    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    } 
    512556 
    513557  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    } 
    521570} 
    522571 
     
    524573play_view_sel_cb (GtkWidget * widget, gpointer data) 
    525574{ 
    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    } 
    533583 
    534584  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    } 
    542597} 
    543598 
     
    545600pause_playback_cb (GtkWidget * widget, gpointer data) 
    546601{ 
    547   sw_view * view = (sw_view *)data; 
     602  sw_view *view = (sw_view *) data; 
    548603 
    549604  pause_playback (view->sample); 
     
    553608stop_playback_cb (GtkWidget * widget, gpointer data) 
    554609{ 
    555   sw_view * view = (sw_view *)data; 
     610  sw_view *view = (sw_view *) data; 
    556611 
    557612  stop_playback (view->sample); 
     
    561616preview_cut_cb (GtkWidget * widget, gpointer data) 
    562617{ 
    563   sw_view * view = (sw_view *) data; 
     618  sw_view *view = (sw_view *) data; 
    564619 
    565620  sample_refresh_playmode (view->sample); 
    566621 
    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    } 
    572630} 
    573631 
     
    575633preroll_cb (GtkWidget * widget, gpointer data) 
    576634{ 
    577   sw_view * view = (sw_view *) data; 
     635  sw_view *view = (sw_view *) data; 
    578636 
    579637  sample_refresh_playmode (view->sample); 
    580    
     638 
    581639  play_preroll (view); 
    582640} 
    583641 
    584 /* Record */ 
     642/* 
     643 * Record  
     644 */ 
    585645 
    586646void 
    587647show_rec_dialog_cb (GtkWidget * widget, gpointer data) 
    588648{ 
    589   sw_view * view = (sw_view *)data; 
     649  sw_view *view = (sw_view *) data; 
    590650 
    591651  rec_dialog_create (view->sample); 
    592652} 
    593653 
    594 /* Transport */ 
     654/* 
     655 * Transport  
     656 */ 
    595657 
    596658static gboolean 
    597659rewind_step (gpointer data) 
    598660{ 
    599   sw_sample * sample = (sw_sample *)data; 
     661  sw_sample *sample = (sw_sample *) data; 
    600662  gint step; 
    601663 
    602   step = sample->sounddata->format->rate; /* 1 second */ 
     664  step = sample->sounddata->format->rate;      /* 1 second */ 
    603665  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
    604666 
     
    609671ffwd_step (gpointer data) 
    610672{ 
    611   sw_sample * sample = (sw_sample *)data; 
     673  sw_sample *sample = (sw_sample *) data; 
    612674  gint step; 
    613675 
    614   step = sample->sounddata->format->rate; /* 1 second */ 
     676  step = sample->sounddata->format->rate;      /* 1 second */ 
    615677  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
    616678 
     
    621683page_back_cb (GtkWidget * widget, gpointer data) 
    622684{ 
    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; 
    625687  gint step; 
    626688 
    627   step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     689  step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 
    628690  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
    629691} 
     
    632694page_fwd_cb (GtkWidget * widget, gpointer data) 
    633695{ 
    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; 
    636698  gint step; 
    637699 
    638   step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     700  step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 
    639701  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
    640702} 
     
    643705rewind_pressed_cb (GtkWidget * widget, gpointer data) 
    644706{ 
    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); 
    649711} 
    650712 
     
    652714ffwd_pressed_cb (GtkWidget * widget, gpointer data) 
    653715{ 
    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); 
    658720} 
    659721 
     
    661723goto_start_cb (GtkWidget * widget, gpointer data) 
    662724{ 
    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; 
    667729  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            } 
    684749        } 
    685750 
    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    } 
    697764} 
    698765 
     
    700767goto_start_of_view_cb (GtkWidget * widget, gpointer data) 
    701768{ 
    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; 
    704771 
    705772  sample_set_scrubbing (sample, FALSE); 
     
    710777goto_end_of_view_cb (GtkWidget * widget, gpointer data) 
    711778{ 
    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; 
    714781 
    715782  sample_set_scrubbing (sample, FALSE); 
     
    720787goto_end_cb (GtkWidget * widget, gpointer data) 
    721788{ 
    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; 
    726793  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            } 
    743813        } 
    744814 
    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 */ 
    759833 
    760834void 
    761835sd_sel_changed_cb (GtkWidget * widget) 
    762836{ 
    763   SampleDisplay * sd = SAMPLE_DISPLAY(widget); 
     837  SampleDisplay *sd = SAMPLE_DISPLAY (widget); 
    764838 
    765839  sample_refresh_views (sd->view->sample); 
     
    769843sd_win_changed_cb (GtkWidget * widget) 
    770844{ 
    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); 
    776850  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); 
    780854  view_refresh_hruler (v); 
    781855} 
     
    784858adj_changed_cb (GtkWidget * widget, gpointer data) 
    785859{ 
    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); 
    798871  view_refresh_hruler (v); 
    799872} 
     
    802875adj_value_changed_cb (GtkWidget * widget, gpointer data) 
    803876{ 
    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 */ 
    829906 
    830907void 
    831908select_invert_cb (GtkWidget * widget, gpointer data) 
    832909{ 
    833   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     910  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    834911 
    835912  sample_selection_invert (sd->view->sample); 
     
    839916select_all_cb (GtkWidget * widget, gpointer data) 
    840917{ 
    841   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     918  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    842919 
    843920  sample_selection_select_all (sd->view->sample); 
     
    847924select_none_cb (GtkWidget * widget, gpointer data) 
    848925{ 
    849   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     926  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    850927 
    851928  sample_selection_select_none (sd->view->sample); 
     
    855932selection_halve_cb (GtkWidget * widget, gpointer data) 
    856933{ 
    857   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     934  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    858935 
    859936  sample_selection_halve (sd->view->sample); 
     
    863940selection_double_cb (GtkWidget * widget, gpointer data) 
    864941{ 
    865   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     942  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    866943 
    867944  sample_selection_double (sd->view->sample); 
     
    871948select_shift_left_cb (GtkWidget * widget, gpointer data) 
    872949{ 
    873   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     950  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    874951 
    875952  sample_selection_shift_left (sd->view->sample); 
     
    879956select_shift_right_cb (GtkWidget * widget, gpointer data) 
    880957{ 
    881   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     958  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    882959 
    883960  sample_selection_shift_right (sd->view->sample); 
    884961} 
    885962 
    886 /* Undo / Redo */ 
     963/* 
     964 * Undo / Redo  
     965 */ 
    887966 
    888967void 
    889968show_undo_dialog_cb (GtkWidget * widget, gpointer data) 
    890969{ 
    891   sw_view * view = (sw_view *)data; 
     970  sw_view *view = (sw_view *) data; 
    892971 
    893972  undo_dialog_create (view->sample); 
     
    897976undo_cb (GtkWidget * widget, gpointer data) 
    898977{ 
    899   sw_view * view = (sw_view *)data; 
     978  sw_view *view = (sw_view *) data; 
    900979 
    901980  undo_current (view->sample); 
     
    905984redo_cb (GtkWidget * widget, gpointer data) 
    906985{ 
    907   sw_view * view = (sw_view *)data; 
     986  sw_view *view = (sw_view *) data; 
    908987 
    909988  redo_current (view->sample); 
     
    913992cancel_cb (GtkWidget * widget, gpointer data) 
    914993{ 
    915   sw_view * view = (sw_view *)data; 
     994  sw_view *view = (sw_view *) data; 
    916995 
    917996  cancel_active_op (view->sample); 
    918997} 
    919998 
    920 /* Edit */ 
     999/* 
     1000 * Edit  
     1001 */ 
    9211002 
    9221003void 
    9231004copy_cb (GtkWidget * widget, gpointer data) 
    9241005{ 
    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; 
    9271008 
    9281009  do_copy (s); 
     
    9321013cut_cb (GtkWidget * widget, gpointer data) 
    9331014{ 
    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; 
    9361017 
    9371018  do_cut (s); 
     
    9411022clear_cb (GtkWidget * widget, gpointer data) 
    9421023{ 
    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; 
    9451026 
    9461027  do_clear (s); 
     
    9501031delete_cb (GtkWidget * widget, gpointer data) 
    9511032{ 
    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; 
    9541035 
    9551036  do_delete (s); 
     
    9591040crop_cb (GtkWidget * widget, gpointer data) 
    9601041{ 
    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; 
    9631044 
    9641045  do_crop (s); 
     
    9681049paste_cb (GtkWidget * widget, gpointer data) 
    9691050{ 
    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; 
    9721053 
    9731054  do_paste_insert (s); 
     
    9771058paste_mix_cb (GtkWidget * widget, gpointer data) 
    9781059{ 
    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    } 
    9871071} 
    9881072 
     
    9901074paste_xfade_cb (GtkWidget * widget, gpointer data) 
    9911075{ 
    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    } 
    10001087} 
    10011088 
     
    10031090paste_as_new_cb (GtkWidget * widget, gpointer data) 
    10041091{ 
    1005   sw_sample * s; 
    1006   sw_view * v; 
     1092  sw_sample *s; 
     1093  sw_view *v; 
    10071094 
    10081095  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    } 
    10151103} 
    10161104 
     
    10181106show_info_dialog_cb (GtkWidget * widget, gpointer data) 
    10191107{ 
    1020   sw_view * view = (sw_view *)data; 
     1108  sw_view *view = (sw_view *) data; 
    10211109 
    10221110  sample_show_info_dialog (view->sample); 
     
    10241112 
    10251113void 
    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   
     1114hide_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 
     1122void 
     1123close_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 
    10451131/* 
    10461132 * Prime the label with the largest string then fetch the width. 
     
    10501136 * don't try this at home kids, karma will get you. (oh well.. it works.)  
    10511137 */ 
    1052 void   
    1053 hack_max_label_width_cb (GtkWidget *widget, 
    1054                                                         GtkStyle *previous_style, 
    1055                             gpointer user_data) 
     1138void 
     1139hack_max_label_width_cb (GtkWidget * widget, 
     1140                         GtkStyle * previous_style, gpointer user_data) 
    10561141{ 
    10571142  PangoRectangle logical_rect, ink_rect; 
    10581143  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 
     1159void 
     1160hack_max_combo_width_cb (GtkWidget * widget, 
     1161                         GtkStyle * previous_style, gpointer user_data) 
    10761162{ 
    10771163  PangoRectangle logical_rect, ink_rect; 
    10781164  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  
    2424#include <gtk/gtk.h> 
    2525 
    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