File: bsesource.proc

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 (850 lines) | stat: -rw-r--r-- 31,086 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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
/* BSE - Better Sound Engine	-*-mode: c;-*-
 * Copyright (C) 2000-2004 Tim Janik
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * A copy of the GNU Lesser General Public License should ship along
 * with this library; if not, see http://www.gnu.org/copyleft/.
 */
#include <bse/bseplugin.h>
#include <bse/bseprocedure.h>
#include <bse/bsesource.h>
#include <bse/bseundostack.h>
#include <bse/bseieee754.h>
#include <bse/bsemidievent.h>


AUTHORS	= "Tim Janik <timj@gtk.org>";
LICENSE = "GNU Lesser General Public License";

METHOD (BseSource, set-input-by-id) {
  HELP	= "Connect a module input to another module's output.";
  IN	= bse_param_spec_object ("imodule", "Input Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  IN	= bse_param_spec_object ("omodule", "Output Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("output-channel", "Output Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("error", "Error", NULL,
				BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE,
				SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource = bse_value_get_object (in_values++);
  guint ichannel     = sfi_value_get_int (in_values++);
  BseSource *osource = bse_value_get_object (in_values++);
  guint ochannel     = sfi_value_get_int (in_values++);
  BseErrorType error;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
      BSE_ITEM (isource)->parent != BSE_ITEM (osource)->parent)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* connect */
  error = bse_source_set_input (isource, ichannel, osource, ochannel);
  if (error == BSE_ERROR_NONE)
    bse_item_push_undo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);

  /* set output parameters */
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, set-input) {
  HELP	= "Connect a module input to another module's output.";
  IN	= bse_param_spec_object ("imodule", "Input Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_string ("input-channel", "Input Channel", NULL,
			    NULL, SFI_PARAM_STANDARD);
  IN	= bse_param_spec_object ("omodule", "Output Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_string ("output-channel", "Output Channel", NULL,
			    NULL, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("error", "Error", NULL,
				BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE,
				SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource   = bse_value_get_object (in_values++);
  gchar *ichannel_ident = sfi_value_get_string (in_values++);
  BseSource *osource   = bse_value_get_object (in_values++);
  gchar *ochannel_ident = sfi_value_get_string (in_values++);
  guint ichannel, ochannel;
  BseErrorType error;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
      BSE_ITEM (isource)->parent != BSE_ITEM (osource)->parent ||
      !ichannel_ident || !ochannel_ident)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* connect */
  ichannel = bse_source_find_ichannel (isource, ichannel_ident);
  ochannel = bse_source_find_ochannel (osource, ochannel_ident);
  error = bse_source_set_input (isource, ichannel, osource, ochannel);
  if (error == BSE_ERROR_NONE)
    bse_item_push_undo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);
  
  /* set output parameters */
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, unset-input-by-id) {
  HELP	= "Disconnect a module input.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  IN	= bse_param_spec_object ("omodule", "Output Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("output-channel", "Output Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("error", "Error", NULL,
				BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE,
				SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource = bse_value_get_object (in_values++);
  guint ichannel     = sfi_value_get_int (in_values++);
  BseSource *osource = bse_value_get_object (in_values++);
  guint ochannel     = sfi_value_get_int (in_values++);
  BseErrorType error = BSE_ERROR_NONE;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* disconnect */
  error = bse_source_check_input (isource, ichannel, osource, ochannel);
  if (error == BSE_ERROR_NONE)
    {
      BseUndoStack *ustack = bse_item_undo_open (isource, "unset-input-by-id");
      bse_source_input_backup_to_undo (isource, ichannel, osource, ochannel);
      bse_item_push_redo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);
      bse_item_undo_close (ustack);
      error = bse_source_unset_input (isource, ichannel, osource, ochannel);
    }

  /* set output parameters */
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, unset-input) {
  HELP	= "Disconnect a module input.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("input-channel", "Input Channel", NULL,
			    NULL, SFI_PARAM_STANDARD);
  IN	= bse_param_spec_object ("omodule", "Output Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("output-channel", "Output Channel", NULL,
			    NULL, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("error", "Error", NULL,
				BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE,
				SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource   = bse_value_get_object (in_values++);
  gchar *ichannel_ident = sfi_value_get_string (in_values++);
  BseSource *osource   = bse_value_get_object (in_values++);
  gchar *ochannel_ident = sfi_value_get_string (in_values++);
  guint ichannel, ochannel;
  BseErrorType error = BSE_ERROR_NONE;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (isource) || !BSE_IS_SOURCE (osource) ||
      !ichannel_ident || !ochannel_ident)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* disconnect */
  ichannel = bse_source_find_ichannel (isource, ichannel_ident);
  ochannel = bse_source_find_ochannel (osource, ochannel_ident);
  error = bse_source_check_input (isource, ichannel, osource, ochannel);
  if (error == BSE_ERROR_NONE)
    {
      BseUndoStack *ustack = bse_item_undo_open (isource, "unset-input-by-id");
      bse_source_input_backup_to_undo (isource, ichannel, osource, ochannel);
      bse_item_push_redo_proc (isource, "unset-input-by-id", ichannel, osource, ochannel);
      bse_item_undo_close (ustack);
      error = bse_source_unset_input (isource, ichannel, osource, ochannel);
    }
  
  /* set output parameters */
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, clear-inputs) {
  HELP	= "Disconnect all module inputs.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource = bse_value_get_object (in_values++);
  BseUndoStack *ustack;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (isource))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* disconnect */
  ustack = bse_item_undo_open (isource, "clear-inputs %s", bse_object_debug_name (isource));
  bse_source_backup_ichannels_to_undo (isource);
  bse_item_push_redo_proc (isource, "clear-inputs");
  bse_item_undo_close (ustack);
  bse_source_clear_ichannels (isource);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, clear-outputs) {
  HELP	= "Disconnect all module outputs.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *isource = bse_value_get_object (in_values++);
  BseUndoStack *ustack;

  /* check parameters */
  if (!BSE_IS_SOURCE (isource))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* disconnect */
  ustack = bse_item_undo_open (isource, "clear-outputs %s", bse_object_debug_name (isource));
  bse_source_backup_ochannels_to_undo (isource);
  bse_item_push_redo_proc (isource, "clear-outputs");
  bse_item_undo_close (ustack);
  bse_source_clear_ochannels (isource);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, has-output) {
  HELP	= "Check whether a module's output channel is connected.";
  IN	= bse_param_spec_object ("module", NULL, NULL, BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_int ("ochannel", NULL, NULL, 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_bool ("has_outputs", NULL, NULL, FALSE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ochannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_bool (out_values++, bse_source_has_output (source, ochannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, has-outputs) {
  HELP	= "Check whether a module has output channel connections.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_bool ("has_outputs", "Has Outputs", NULL,
			  FALSE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_bool (out_values++, source->outputs != NULL);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, n-ichannels) {
  HELP	= "Get the number of input channels of a module.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_int ("n_channels", "Number of Channels", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_int (out_values++, BSE_SOURCE_N_ICHANNELS (source));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-label) {
  HELP	= "Get input channel name.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_label", "Channel Name", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_LABEL (source, ichannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-ident) {
  HELP	= "Get canonical input channel name.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_ident", "Channel Name", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_IDENT (source, ichannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-blurb) {
  HELP	= "Get input channel description.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_blurb", "Channel Blurb", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_ICHANNEL_BLURB (source, ichannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, is-joint-ichannel-by-id) {
  HELP	= "Check if an input channel is a joint (multi-connect) channel.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_bool ("is_jchannel", "Is Joint Channel", NULL,
			  FALSE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_bool (out_values++, BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, is-joint-ichannel) {
  HELP	= "Check if an input channel is a joint (multi-connect) channel.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("input-channel", "Input Channel", NULL,
			    NULL, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_bool ("is_jchannel", "Is Joint Channel", NULL,
			  FALSE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  gchar *ichannel   = sfi_value_get_string (in_values++);
  guint id;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || !ichannel)
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  id = bse_source_find_ichannel (source, ichannel);
  sfi_value_set_bool (out_values++,
		      id < BSE_SOURCE_N_ICHANNELS (source) ? BSE_SOURCE_IS_JOINT_ICHANNEL (source, id) : FALSE);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-get-n-joints) {
  HELP	= "Retrieve the number of inputs connected to an input channel.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_int ("n_joints", "Number of Connections", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  BseSourceInput *input;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  input = BSE_SOURCE_INPUT (source, ichannel);
  if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel))
    sfi_value_set_int (out_values++, input->jdata.n_joints);
  else
    sfi_value_set_int (out_values++, input->idata.osource ? 1 : 0);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-get-osource) {
  HELP	= "Retrieve output module connected to a specific joint of an input channel";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-joint", "Input Joint", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_object ("osource", "Output Source", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  guint joint       = sfi_value_get_int (in_values++);
  BseSourceInput *input;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  input = BSE_SOURCE_INPUT (source, ichannel);
  if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel) && joint < input->jdata.n_joints)
    bse_value_set_object (out_values++, input->jdata.joints[joint].osource);
  else if (joint < 1)
    bse_value_set_object (out_values++, input->idata.osource);
  else
    bse_value_set_object (out_values++, NULL);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ichannel-get-ochannel) {
  HELP	= "Retrieve output channel of the module connected to a specific joint of an input channel.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("input-joint", "Input Joint", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_int ("ochannel", "Output Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ichannel    = sfi_value_get_int (in_values++);
  guint joint       = sfi_value_get_int (in_values++);
  BseSourceInput *input;
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  input = BSE_SOURCE_INPUT (source, ichannel);
  if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel) && joint < input->jdata.n_joints)
    sfi_value_set_int (out_values++, input->jdata.joints[joint].ochannel);
  else if (joint < 1)
    sfi_value_set_int (out_values++, input->idata.ochannel);
  else
    sfi_value_set_int (out_values++, G_MAXINT);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, n-ochannels) {
  HELP	= "Get the number of output channels of a module.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_int ("n_channels", "Number of Channels", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_int (out_values++, BSE_SOURCE_N_OCHANNELS (source));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ochannel-label) {
  HELP	= "Get output channel name.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("output-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_label", "Channel Name", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ochannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_LABEL (source, ochannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ochannel-ident) {
  HELP	= "Get canonical output channel name.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("output-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_ident", "Channel Name", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ochannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_IDENT (source, ochannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, ochannel-blurb) {
  HELP	= "Get output channel description.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_int ("output-channel", "Input Channel", NULL,
			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_string ("channel_blurb", "Channel Blurb", NULL,
			    NULL, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  guint ochannel    = sfi_value_get_int (in_values++);
  
  /* check parameters */
  if (!BSE_IS_SOURCE (source) || ochannel >= BSE_SOURCE_N_OCHANNELS (source))
    return BSE_ERROR_PROC_PARAM_INVAL;
  
  /* set output parameters */
  sfi_value_set_string (out_values++, BSE_SOURCE_OCHANNEL_BLURB (source, ochannel));
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, set-pos) {
  HELP	= "Set the x and y position of a module. In contrast to setting the position "
          "through ordinary object property setters, this function will not update "
          "the module position if the passed in arguments are sufficiently equal to "
          "the values already set on the object. As such, it does not record an extra "
          "undo step for setting properties to values they already have and if necessary "
          "turns setting of x and y positions into an atomic undo operation.";
  IN	= bse_param_spec_object ("module", "Module", NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_real ("x-pos", "X Position", NULL,
                          0, -SFI_MAXREAL, SFI_MAXREAL, 1, SFI_PARAM_STANDARD);
  IN	= sfi_pspec_real ("y-pos", "Y Position", NULL,
                          0, -SFI_MAXREAL, SFI_MAXREAL, 1, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source = bse_value_get_object (in_values++);
  SfiReal xpos      = sfi_value_get_real (in_values++);
  SfiReal ypos      = sfi_value_get_real (in_values++);
  SfiReal epsilon = 1e-5;

  /* check parameters */
  if (!BSE_IS_SOURCE (source) || BSE_DOUBLE_IS_NANINF (xpos) || BSE_DOUBLE_IS_NANINF (ypos))
    return BSE_ERROR_PROC_PARAM_INVAL;

  /* action */
  if (fabs (xpos - source->pos_x) > epsilon ||
      fabs (ypos - source->pos_y) > epsilon)
    {
      BseUndoStack *ustack = bse_item_undo_open (source, "set-xy-pos");
      bse_item_set (source,
                    "pos_x", xpos,
                    "pos_y", ypos,
                    NULL);
      bse_item_undo_close (ustack);
    }

  return BSE_ERROR_NONE;
}

METHOD (BseSource, set-automation) {
  HELP	= "Setup automation parameters for a property.";
  IN	= bse_param_spec_object ("source", NULL, NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("property_name", NULL, "Item property name",
                            NULL, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_int ("midi_channel", _("MIDI Channel"), _("The MIDI Channel from which automation events should be received, 0 designates the default MIDI channel"),
                         0, 0, BSE_MIDI_MAX_CHANNELS, 1, SFI_PARAM_STANDARD ":scale:unprepared");
  IN    = bse_param_spec_genum ("control_type", _("Control Type"), _("The type of control events used for automation"),
                                BSE_TYPE_MIDI_CONTROL_TYPE, BSE_MIDI_CONTROL_CONTINUOUS_16, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("error", "Error", NULL, BSE_TYPE_ERROR_TYPE, BSE_ERROR_NONE, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source       = bse_value_get_object (in_values++);
  gchar     *property     = sfi_value_get_string (in_values++);
  guint      midi_channel = sfi_value_get_int (in_values++);
  guint      control_type = g_value_get_enum (in_values++);
  BseErrorType error = BSE_ERROR_NONE;

  /* check parameters */
  if (!BSE_IS_SOURCE (source) || !property)
    return BSE_ERROR_PROC_PARAM_INVAL;

  /* connect */
  guint old_midi_channel = 0;
  guint old_control_type = 0;
  bse_source_get_automation_property (source, property, &old_midi_channel, &old_control_type);
  if (old_midi_channel != midi_channel || old_control_type != control_type)
    {
      error = bse_source_set_automation_property (source, property, midi_channel, control_type);
      if (error == BSE_ERROR_NONE)
        bse_item_push_undo_proc (source, "set-automation", property, old_midi_channel, old_control_type);
    }

  /* set output parameters */
  g_value_set_enum (out_values++, error);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, get-automation-channel) {
  HELP	= "Get MIDI channel from an automation property.";
  IN	= bse_param_spec_object ("source", NULL, NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("property_name", NULL, "Item property name",
                            NULL, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_int ("midi_channel", NULL, NULL, 0, 0, BSE_MIDI_MAX_CHANNELS, 1, SFI_PARAM_STANDARD ":scale:unprepared");
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source       = bse_value_get_object (in_values++);
  gchar     *property     = sfi_value_get_string (in_values++);

  /* check parameters */
  if (!BSE_IS_SOURCE (source) || !property)
    return BSE_ERROR_PROC_PARAM_INVAL;

  /* connect */
  guint midi_channel = 0;
  bse_source_get_automation_property (source, property, &midi_channel, NULL);
  /* set output parameters */
  g_value_set_int (out_values++, midi_channel);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, get-automation-control) {
  HELP	= "Get control type from an automation property.";
  IN	= bse_param_spec_object ("source", NULL, NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  IN    = sfi_pspec_string ("property_name", NULL, "Item property name",
                            NULL, SFI_PARAM_STANDARD);
  OUT   = bse_param_spec_genum ("control_type", NULL, NULL, BSE_TYPE_MIDI_CONTROL_TYPE, BSE_MIDI_CONTROL_CONTINUOUS_16, SFI_PARAM_STANDARD);
}
BODY (BseProcedureClass *proc,
      const GValue      *in_values,
      GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source       = bse_value_get_object (in_values++);
  gchar     *property     = sfi_value_get_string (in_values++);

  /* check parameters */
  if (!BSE_IS_SOURCE (source) || !property)
    return BSE_ERROR_PROC_PARAM_INVAL;

  /* connect */
  guint control_type = 0;
  bse_source_get_automation_property (source, property, NULL, &control_type);
  /* set output parameters */
  g_value_set_enum (out_values++, control_type);
  
  return BSE_ERROR_NONE;
}

METHOD (BseSource, is-prepared) {
  HELP  = "Check whether a source is prepared for synthesis processing.";
  IN	= bse_param_spec_object ("source", NULL, NULL,
				 BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
  OUT   = sfi_pspec_bool ("is_prepared", NULL, NULL, FALSE, SFI_PARAM_STANDARD);
} BODY (BseProcedureClass *proc,
        const GValue      *in_values,
        GValue            *out_values)
{
  /* extract parameter values */
  BseSource *source       = bse_value_get_object (in_values++);

  /* check parameters */
  if (!BSE_IS_SOURCE (source))
    return BSE_ERROR_PROC_PARAM_INVAL;

  /* set output parameters */
  sfi_value_set_bool (out_values++, BSE_SOURCE_PREPARED (source));

  return BSE_ERROR_NONE;
}