File: bseeditablesample.genprc.c

package info (click to toggle)
beast 0.7.4-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 33,500 kB
  • sloc: ansic: 197,348; cpp: 59,114; sh: 11,030; perl: 2,523; makefile: 2,474; xml: 1,026; lisp: 549; awk: 270; sed: 8
file content (508 lines) | stat: -rw-r--r-- 16,081 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508

/*
 * Generated data (by mkcproc.pl)
 */
#line 1 "bseeditablesample.proc"

#include        <bse/bseplugin.h>
#include        <bse/bseprocedure.h>
#include        <bse/bseeditablesample.h>
#include        <bse/gsldatahandle.h>


#line 25 "bseeditablesample.proc"


/* --- open --- */
static void
open_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 27 "bseeditablesample.proc"
 {
#line 29 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(out_pspecs++)   = bse_param_spec_genum ("error", "Error", NULL,
				BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE,
				SFI_PARAM_STANDARD);
#line 34 "bseeditablesample.proc"
}  }
static BseErrorType
#line 34 "bseeditablesample.proc"
open_exec (BseProcedureClass *proc,
	const GValue      *in_values,
	GValue            *out_values)
#line 37 "bseeditablesample.proc"
{
#line 38 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  BseErrorType error;
  
#line 42 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
#line 46 "bseeditablesample.proc"
  
  if (!esample->wchunk)
    error = BSE_ERROR_WAVE_NOT_FOUND;
  else if (esample->open_count)
    {
      esample->open_count++;
      error = BSE_ERROR_NONE;
    }
  else
    {
      error = gsl_wave_chunk_open (esample->wchunk);
      if (!error)
	esample->open_count++;
    }
  
#line 61 "bseeditablesample.proc"
  
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

/* --- close --- */
static void
close_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 67 "bseeditablesample.proc"
 {
#line 69 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
#line 71 "bseeditablesample.proc"
}  }
static BseErrorType
#line 71 "bseeditablesample.proc"
close_exec (BseProcedureClass *proc,
	const GValue      *in_values,
	GValue            *out_values)
#line 74 "bseeditablesample.proc"
{
#line 75 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  
#line 78 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample) || !esample->wchunk || !esample->open_count)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
#line 82 "bseeditablesample.proc"
  
  esample->open_count--;
  if (!esample->open_count)
    gsl_wave_chunk_close (esample->wchunk);
  
  return BSE_ERROR_NONE;
}

/* --- get-length --- */
static void
get_length_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 90 "bseeditablesample.proc"
 {
#line 92 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(out_pspecs++) = sfi_pspec_int ("length", NULL, "Number of values",
			 1, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
#line 96 "bseeditablesample.proc"
}  }
static BseErrorType
#line 96 "bseeditablesample.proc"
get_length_exec (BseProcedureClass *proc,
	const GValue      *in_values,
	GValue            *out_values)
#line 99 "bseeditablesample.proc"
{
#line 100 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  GslDataCache *dcache = NULL;
  
#line 104 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
#line 108 "bseeditablesample.proc"
  
  if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
    dcache = esample->wchunk->dcache;
  sfi_value_set_int (out_values++, dcache ? gsl_data_handle_length (dcache->dhandle) : 0);
  
  return BSE_ERROR_NONE;
}

/* --- get-n-channels --- */
static void
get_n_channels_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 116 "bseeditablesample.proc"
 {
#line 118 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(out_pspecs++) = sfi_pspec_int ("n-channels", NULL, "Number of channels",
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
#line 122 "bseeditablesample.proc"
}  }
static BseErrorType
#line 122 "bseeditablesample.proc"
get_n_channels_exec (BseProcedureClass *proc,
	const GValue      *in_values,
	GValue            *out_values)
#line 125 "bseeditablesample.proc"
{
#line 126 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  
#line 129 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
#line 133 "bseeditablesample.proc"
  
  sfi_value_set_int (out_values++, esample->wchunk ? esample->wchunk->n_channels : 1);
  
  return BSE_ERROR_NONE;
}

/* --- get-osc-freq --- */
static void
get_osc_freq_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 139 "bseeditablesample.proc"
 {
#line 141 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(out_pspecs++) = bse_param_spec_freq_simple ("osc-freq", NULL, "Oscillator Frequency",
				      SFI_PARAM_STANDARD);
#line 145 "bseeditablesample.proc"
}  }
static BseErrorType
#line 145 "bseeditablesample.proc"
get_osc_freq_exec (BseProcedureClass *proc,
	const GValue      *in_values,
	GValue            *out_values)
#line 148 "bseeditablesample.proc"
{
#line 149 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  
#line 152 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
#line 156 "bseeditablesample.proc"
  
  sfi_value_set_real (out_values++, esample->wchunk ? esample->wchunk->osc_freq : BSE_KAMMER_FREQUENCY);
  
  return BSE_ERROR_NONE;
}

/* --- read-samples --- */
static void
read_samples_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 162 "bseeditablesample.proc"
 {
#line 164 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_int ("voffset", NULL, "Value offset",
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(out_pspecs++) = sfi_pspec_fblock ("sample_block", NULL, "Block of samples", SFI_PARAM_STANDARD);
#line 169 "bseeditablesample.proc"
}  }
static BseErrorType
#line 169 "bseeditablesample.proc"
read_samples_exec (BseProcedureClass *proc,
        const GValue      *in_values,
        GValue            *out_values)
#line 172 "bseeditablesample.proc"
{
#line 173 "bseeditablesample.proc"
  
  BseEditableSample *esample = bse_value_get_object (in_values++);
  guint              voffset = sfi_value_get_int (in_values++);
  GslDataCache *dcache = NULL;
  SfiFBlock *fblock;
  
#line 179 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
    dcache = esample->wchunk->dcache;
  if (!dcache || voffset >= gsl_data_handle_length (dcache->dhandle))
    fblock = sfi_fblock_new_sized (1024);
  else
    {
      GslDataCacheNode *dnode = gsl_data_cache_ref_node (dcache, voffset, TRUE);
      guint i, l, dnode_length = dcache->node_size;
      
      l = dnode_length - (voffset - dnode->offset) + dcache->padding;
      l = MIN (l, gsl_data_handle_length (dcache->dhandle) - voffset);
      fblock = sfi_fblock_new_sized (l);
      for (i = 0; i < l; i++)
	fblock->values[i] = dnode->data[voffset - dnode->offset + i];
      gsl_data_cache_unref_node (dcache, dnode);
    }
  
#line 200 "bseeditablesample.proc"
  
  sfi_value_take_fblock (out_values++, fblock);
  
  return BSE_ERROR_NONE;
}

/* --- collect-stats --- */
static void
collect_stats_setup (BseProcedureClass *proc, GParamSpec **in_pspecs, GParamSpec **out_pspecs) {
#line 206 "bseeditablesample.proc"
 {
#line 208 "bseeditablesample.proc"
  *(in_pspecs++) = bse_param_spec_object ("esample", "Editable Sample", NULL,
				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_int ("voffset", NULL, "Offset of first stat block",
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_real ("offset_scale", NULL, "Factor to scale voffset increments with",
			  0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_int ("block_size", NULL, "Block size to compute stat pairs from",
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_int ("stepping", NULL, "Stepping within a stat block",
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(in_pspecs++) = sfi_pspec_int ("max_pairs", NULL, "Maximum number of (min, max) pairs to collect",
			 1, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  *(out_pspecs++) = sfi_pspec_fblock ("sample_block", NULL, "Block of samples", SFI_PARAM_STANDARD);
#line 221 "bseeditablesample.proc"
}  }
static BseErrorType
#line 221 "bseeditablesample.proc"
collect_stats_exec (BseProcedureClass *proc,
        const GValue      *in_values,
        GValue            *out_values)
#line 224 "bseeditablesample.proc"
{
#line 225 "bseeditablesample.proc"
  
  BseEditableSample *esample    = bse_value_get_object (in_values++);
  guint              voffset    = sfi_value_get_int (in_values++);
  double             offs_scale = g_value_get_double (in_values++);
  guint              block_size = sfi_value_get_int (in_values++);
  guint              stepping   = sfi_value_get_int (in_values++);
  guint              max_pairs  = sfi_value_get_int (in_values++);
  GslDataCache *dcache = NULL;
  SfiFBlock *fblock;
  
#line 235 "bseeditablesample.proc"
  
  if (!BSE_IS_EDITABLE_SAMPLE (esample) || stepping < 1)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
    dcache = esample->wchunk->dcache;
  if (!dcache || voffset + block_size > gsl_data_handle_length (dcache->dhandle))
    fblock = sfi_fblock_new_sized (max_pairs * 2);
  else
    {
      GslDataCacheNode *dnode = gsl_data_cache_ref_node (dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
      guint j, dnode_length = dcache->node_size;
      
      fblock = sfi_fblock_new_sized (max_pairs * 2);
      for (j = 0; j < max_pairs; j++)
	{
	  guint i, cur_offset = j * offs_scale;
	  gfloat min = +1, max = -1;
	  
#line 254 "bseeditablesample.proc"
	  
	  cur_offset /= stepping;
	  cur_offset = voffset + cur_offset * stepping;
	  
#line 258 "bseeditablesample.proc"
	  
	  for (i = cur_offset; i < cur_offset + block_size; i += stepping)
	    {
	      guint pos;
	      
	      if (i < dnode->offset || i >= dnode->offset + dnode_length)
		{
		  gsl_data_cache_unref_node (dcache, dnode);
#line 266 "bseeditablesample.proc"
		  
		  dnode = gsl_data_cache_ref_node (dcache, i, j == 0 ? GSL_DATA_CACHE_DEMAND_LOAD : GSL_DATA_CACHE_PEEK);
		  if (!dnode)
		    goto break_loops;
		}
	      pos = i - dnode->offset;
	      min = MIN (min, dnode->data[pos]);
	      max = MAX (max, dnode->data[pos]);
	    }
	  fblock->values[j * 2] = min;
	  fblock->values[j * 2 + 1] = max;
	}
      gsl_data_cache_unref_node (dcache, dnode);
    break_loops:
      sfi_fblock_resize (fblock, j * 2);
    }
  
#line 283 "bseeditablesample.proc"
  
  sfi_value_take_fblock (out_values++, fblock);
  
  return BSE_ERROR_NONE;
}

/* --- Export to BSE --- */
static void
__enode_open__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Open the sample for reading.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 28;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_open = {
  { NULL, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+open", 
    NULL,
    "/Methods/BseEditableSample/General/Open",
    NULL,
    __enode_open__fill_strings,
  },
  0, open_setup, open_exec, 
};
static void
__enode_close__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Close an opened sample.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 68;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_close = {
  { (BseExportNode*) &__enode_open, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+close", 
    NULL,
    "/Methods/BseEditableSample/General/Close",
    NULL,
    __enode_close__fill_strings,
  },
  0, close_setup, close_exec, 
};
static void
__enode_get_length__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Return the number of values in the sample.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 91;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_get_length = {
  { (BseExportNode*) &__enode_close, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+get-length", 
    NULL,
    "/Methods/BseEditableSample/General/Get Length",
    NULL,
    __enode_get_length__fill_strings,
  },
  0, get_length_setup, get_length_exec, 
};
static void
__enode_get_n_channels__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Return the number of channels in the sample.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 117;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_get_n_channels = {
  { (BseExportNode*) &__enode_get_length, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+get-n-channels", 
    NULL,
    "/Methods/BseEditableSample/General/Get N Channels",
    NULL,
    __enode_get_n_channels__fill_strings,
  },
  0, get_n_channels_setup, get_n_channels_exec, 
};
static void
__enode_get_osc_freq__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Return the oscillator frequency for the sample.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 140;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_get_osc_freq = {
  { (BseExportNode*) &__enode_get_n_channels, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+get-osc-freq", 
    NULL,
    "/Methods/BseEditableSample/General/Get Osc Freq",
    NULL,
    __enode_get_osc_freq__fill_strings,
  },
  0, get_osc_freq_setup, get_osc_freq_exec, 
};
static void
__enode_read_samples__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Read a set of samples from a specific offset.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 163;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_read_samples = {
  { (BseExportNode*) &__enode_get_osc_freq, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+read-samples", 
    NULL,
    "/Methods/BseEditableSample/General/Read Samples",
    NULL,
    __enode_read_samples__fill_strings,
  },
  0, read_samples_setup, read_samples_exec, 
};
static void
__enode_collect_stats__fill_strings (BseExportStrings *es)
{
  es->blurb = ("Collect statistics from sample blocks as (minimum, maximum) pairs.");
  es->file = "/opt/src/beast/bse/bseeditablesample.proc";
  es->line = 207;
  es->authors = "Tim Janik <timj@gtk.org>";
  es->license = "GNU Lesser General Public License";
}
static BseExportNodeProc __enode_collect_stats = {
  { (BseExportNode*) &__enode_read_samples, BSE_EXPORT_NODE_PROC,
    "BseEditableSample+collect-stats", 
    NULL,
    "/Methods/BseEditableSample/General/Collect Stats",
    NULL,
    __enode_collect_stats__fill_strings,
  },
  0, collect_stats_setup, collect_stats_exec, 
};
BseExportNode* bse__builtin_init_bseeditablesample_genprc_c (void);
BseExportNode* bse__builtin_init_bseeditablesample_genprc_c (void)
{
  return (BseExportNode*) &__enode_collect_stats;
}

/*
 * Generated data ends here
 */