Debian Codegraph @

examples/sfpassign.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out, virtual midi in
5 ;-iadc ;;;uncomment -iadc if RT audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o sfpassign.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 ; By Menno Knevel - 2020
12
13 sr = 44100
14 ksmps = 32
15 nchnls = 2
16 0dbfs = 1
17
18 ;load three soundfonts
19 gisf sfload "sf_GMbank.sf2"
20 gir sfload "01hpschd.sf2"
21 giv sfload "07AcousticGuitar.sf2"
22 sfplist gisf
23 sfplist gir
24 sfplist giv
25
26 ; first, sf_GMbank.sf2 is loaded and assigned to start at 0 and counting up to 328
27 ; as there are 329 presets in sf_GMbank.sf2.
28 ; then 01hpschd.sf2 is loaded and assigned to replace the 100th preset of sf_GMbank.sf2
29 ; then 07AcousticGuitar.sf2 is loaded and assigned to replace the 20th preset of sf_GMbank.sf2
30
31 sfpassign 0, gisf
32 sfpassign 100, gir
33 sfpassign 20, giv
34
35 instr 1
36
37 inum = p4
38 ivel = p5
39 kamp linsegr 1, 1, 1, .1, 0
40 kamp = kamp/600000 * ivel ;scale amplitude and velocity dependent
41 kfreq = 1 ;do not change freq from sf
42 a1,a2 sfplay3 ivel, inum, kamp, kfreq, p6 ;preset index starts at 0, counting up
43 outs a1, a2
44
45 endin
46
47 </CsInstruments>
48 <CsScore>
49
50 i1 0 1 60 100 0 ; Piano 1 from sf_GMbank.sf2
51 i1 + 1 62 < .
52 i1 + 1 65 < .
53 i1 + 1 69 10 .
54
55 i1 5 1 60 100 100 ; harpsichord from 01hpschd.sf2
56 i1 + 1 62 < .
57 i1 + 1 65 < .
58 i1 + 1 69 10 .
59
60 i1 10 1 60 100 20 ; guitar from 07AcousticGuitar.sf2
61 i1 + 1 62 < .
62 i1 + 1 65 < .
63 i1 + 1 69 10 .
64
65 i1 15 1 60 100 101 ; Goblin from sf_GMbank.sf2
66 i1 + 1 62 < .
67 i1 + 1 65 < .
68 i1 + 1 69 10 .
69 e
70 </CsScore>
71 </CsoundSynthesizer>