aboutsummaryrefslogtreecommitdiff
path: root/site/app/ocsillator/ocsillator.csd
blob: 4ad464b43dc087a06588f6143fe6f56db9be6b6b (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
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
<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 16
nchnls = 2
nchnls_i = 1
0dbfs = 2
seed 0

#include "interop.udo"
#include "bussing.udo"
#include "synth_instruments.udo"
#include "synth_drums.udo"
#include "sounddb.udo"
#include "wavetables.udo"

giocsicol_harmonics sounddb_getcollectionid "Guitar.Harmonics", 1

isize = sr * 60
giocsi_fnrecord[] fillarray ftgen(0, 0, isize, 2, 0), ftgen(0, 0, isize, 2, 0)
giosci_loopend = isize
giocsi_instrument = 0

instr ocsi_recordstart
	p3 = 99999
	aL, aR bus_tap "ocsi"
	apos lphasor 1, 0, giosci_loopend, 1
	tablew aL, apos, giocsi_fnrecord[0]
	tablew aR, apos, giocsi_fnrecord[1]
endin

instr ocsi_recordstop
	turnoff2 "ocsi_recordstart", 0, 1
	turnoff
endin

instr ocsi_recordclear
	
endin


opcode ocsi_defaultinput, kk, 0
	kamp chnget "valY"
	knote chnget "note"
	xout kamp, knote
endop

instr ocsinst_blockbass
	kamp, knote ocsi_defaultinput
	aL, aR synth_fmbass1, cpsmidinn(knote) - 12
	kenv linsegr 1, p3, 1, 0.2, 0
	aL *= kenv * kamp
	aR *= kenv * kamp
	bus_mix("ocsi", aL, aR)
endin


instr ocsinst_303
	ky, knote ocsi_defaultinput
	ifilter = (chnget:i("valY") * 50) + 50
	kdistortion = (1 - ky) + 1
	aout synth_303 cpsmidinn(knote), ifilter, kdistortion
	kenv linsegr 1, p3, 1, 0.2, 0
	aout *= kenv
	bus_mix("ocsi", aout, aout)
endin

instr ocsinst_strings
	ky, knote ocsi_defaultinput
	kfreq = cpsmidinn(knote)
	aL synth_strings1 kfreq, 0.01 * random(0.5, 1.5) * ky * 4, 6 * random(0.5, 1.5) * ky, 0.1 * random(0.5, 1.5), 0.1 * random(0.5, 1.5)
	aR synth_strings1 kfreq, 0.01 * random(0.5, 1.5) * ky * 4, 6 * random(0.5, 1.5) * ky, 0.1 * random(0.5, 1.5), 0.1 * random(0.5, 1.5)
	kenv linsegr 1, p3, 1, 0.2, 0
	aL *= kenv
	aR *= kenv
	bus_mix("ocsi", aL, aR)
endin


instr ocsinst_guitarharmonics
	ky, knote ocsi_defaultinput
	istartnote = chnget:i("note")
	knote init istartnote
	ifileid, ipitchratio sounddb_mel_nearestnote giocsicol_harmonics, chnget:i("note")
	ifn, ichannels, iduration, irmsnorm sounddb_get ifileid
	ipitchadjust = ipitchratio* (ftsr(ifn) / sr)
	kpitch = (cpsmidinn(knote) / cpsmidinn(istartnote)) * ipitchadjust
	krate = (ky * 10) + 1
	apos = a(ky) * iduration;abs:k(oscil:k(iduration * 0.5, krate)) + (iduration * 0.1) 
	aL, aR sndwarpst 1, apos, a(port(kpitch, 0.01, ipitchadjust)), ifn, 0, 4410, 441, 4, gifnHanning, 1
	kenv linsegr 0, 0.1, 1, p3 - 0.1, 1, 0.2, 0
	aL *= kenv
	aR *= kenv
	bus_mix("ocsi", aL, aR)
endin


instr ocsinst_guitarharmonicsfx
	ky, knote ocsi_defaultinput
	istartnote = chnget:i("note")
	knote init istartnote
	ifileid, ipitchratio sounddb_mel_nearestnote giocsicol_harmonics, chnget:i("note")
	ifn, ichannels, iduration, irmsnorm sounddb_get ifileid
	ipitchadjust = ipitchratio * (ftsr(ifn) / sr)
	kpitch = (cpsmidinn(knote) / cpsmidinn(istartnote)) * ipitchadjust
	krate = (ky * 10) + 1
	apos = ((a(ky) * abs:k(oscil:k(random(0.2, 1), random(2, 10)))) + 0.1) * iduration
	aL, aR sndwarpst 1, apos, a(port(kpitch * 0.5, 0.01, ipitchadjust)), ifn, 0, 4410, 441, 1, gifnHanning, 1

	ahL1, ahL2 hilbert2 aL, 1024, 256
	amL, afmL fmanal ahL1, ahL2
	aL oscil amL, afmL * 2

	ahR1, ahR2 hilbert2 aR, 1024, 256
	amR, afmR fmanal ahR1, ahL2
	aR oscil amR, afmR * 2

	aL butterhp aL, 500
	aR butterhp aR, 500
	;aL reverb aL, 2 * (ky + 2)
	;aR reverb aR, 2 * (ky + 2)
	aL tanh aL
	aR tanh aR

	kenv linsegr 1, p3 - 0.1, 1, 0.2, 0
	aL *= kenv
	aR *= kenv
	bus_mix("ocsi", aL, aR)
endin


instr osci_recordplaystart
	p3 = -1
	apos lphasor 1, 0, giosci_loopend, 1
	aL table3 apos, giocsi_fnrecord[0]
	aR table3 apos, giocsi_fnrecord[1]
	bus_mix("bufferplay", aL, aR)
endin

instr osci_recordplaystop
	turnoff2 "osci_recordplaystart", 0, 1
	turnoff
endin

instr ocsi_setinstrument
	Sinstr = strget(p4)
	turnoff2 giocsi_instrument, 0, 1
	giocsi_instrument = nstrnum(Sinstr)
	turnoff
endin

instr ocsi_play
	schedule giocsi_instrument, 0, 99999
	turnoff
endin

instr ocsi_stop
	turnoff2 giocsi_instrument, 0, 1
	turnoff
endin

instr ocsi_mixer
	aLm, aRm bus_read "ocsi"
	aLb, aRb bus_read "bufferplay"

	aL = aLm + aLb
	aR = aRm + aRb
	outs aL, aR
endin

instr osci_boot
	schedule "ocsi_mixer", 0, -1
endin

</CsInstruments>
<CsScore>
f0 z
i"osci_boot" 0 1
</CsScore>
</CsoundSynthesizer>