aboutsummaryrefslogtreecommitdiff
path: root/sonics/bussing.udo
blob: 83993f66ba404c09b07c76c80cd8f3e25d093c98 (plain)
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
#ifndef UDO_BUSSING
#define UDO_BUSSING ##
/*
	Bus handling
	Slim excerpt for Partial Emergence

	This file is part of the SONICS UDO collection by Richard Knight 2021
		License: GPL-2.0-or-later
		http://1bpm.net
*/

gkmastervolume init 1


/*
	Get the stereo L and R names for a singular bus name
	
	SnameL, SnameR bus_name Sbus

	SnameL		left bus identifier
	SnameR		right bus identifier

	Sbus		bus name
*/
opcode bus_name, SS, S
	Sbus xin
	xout sprintf("%sL", Sbus), sprintf("%sR", Sbus)
endop


/*
	Read from a stereo bus, but do not clear it

	aL, aR bus_tap Sbus

	aL	left channel
	aR	right channel

	Sbus	bus name
*/
opcode bus_tap, aa, S
	Sbus xin
	SbusL, SbusR bus_name Sbus
	aL chnget SbusL
	aR chnget SbusR
	xout aL, aR
endop

/*
	Read from a stereo bus, and then clear the bus
	
	aL, aR bus_read Sbus

	aL	left channel
	aR	right channel

	Sbus	bus name
*/
opcode bus_read, aa, S
	Sbus xin
	SbusL, SbusR bus_name Sbus
	aL chnget SbusL
	aR chnget SbusR
	chnclear SbusL
	chnclear SbusR
	xout aL, aR
endop


/*
	Set to a stereo bus

	bus_set Sbus, aL, aR

	Sbus	bus name
	aL	left channel
	aR	right channel
*/
opcode bus_set, 0, Saa
	Sbus, aL, aR xin
	SbusL, SbusR bus_name Sbus
	chnset aL, SbusL
	chnset aR, SbusR
endop

/*
	Mix to a stereo bus

	bus_mix Sbus, aL, aR

	Sbus	bus name
	aL	left channel
	aR	right channel
*/
opcode bus_mix, 0, Saa
	Sbus, aL, aR xin
	SbusL, SbusR bus_name Sbus
	chnmix aL, SbusL
	chnmix aR, SbusR
endop


/*
	Mix to master bus

	bus_masterout aL, aR

	aL 	left channel
	aR	right channel
*/
opcode bus_masterout, 0, aa
	aL, aR xin
	chnmix aL, "mainL"
	chnmix aR, "mainR"
endop


instr _mainmixer
	aL, aR bus_read "main"
	aL = aL*gkmastervolume
	aR = aR*gkmastervolume
	outs aL, aR
endin
alwayson "_mainmixer"

#end