Skip to content

Commit

Permalink
Merge pull request #745 from tjingboem/7.0
Browse files Browse the repository at this point in the history
several new examples
  • Loading branch information
tjingboem authored Jun 7, 2024
2 parents af8b414 + 0e56209 commit 97ca06b
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 67 deletions.
80 changes: 80 additions & 0 deletions examples/fluidControl-advanced.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
;Anna.mid is a midi file, a song by The Beatles and can be found on the internet
-odac -T -F Anna.mid;;;realtime audio I/O and midifile in
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o fluidControl-advanced.csd.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
; Example by Istvan Varga
; disable triggering of instruments by MIDI events
ichn = 1
lp1:
massign ichn, 0
loop_le ichn, 1, 16, lp1
pgmassign 0, 0
; initialize FluidSynth
gifld fluidEngine
gisf2 fluidLoad "sf_GMbank.sf2", gifld, 1
; k-rate version of fluidProgramSelect
opcode fluidProgramSelect_k, 0, kkkkk
keng, kchn, ksf2, kbnk, kpre xin
igoto skipInit
doInit:
fluidProgramSelect i(keng), i(kchn), i(ksf2), i(kbnk), i(kpre)
reinit doInit
rireturn
skipInit:
endop
instr 1
; initialize channels
kchn init 1
if (kchn == 1) then
lp2:
fluidControl gifld, 192, kchn - 1, 0, 0
fluidControl gifld, 176, kchn - 1, 7, 100
fluidControl gifld, 176, kchn - 1, 10, 64
loop_le kchn, 1, 16, lp2
endif
; send any MIDI events received to FluidSynth
nxt:
kst, kch, kd1, kd2 midiin
if (kst != 0) then
if (kst != 192) then
fluidControl gifld, kst, kch - 1, kd1, kd2
else
fluidProgramSelect_k gifld, kch - 1, gisf2, 0, kd1
endif
kgoto nxt
endif
; get audio output from FluidSynth
ivol init 3 ;a bit louder
aL, aR fluidOut gifld
outs aL*ivol, aR*ivol
endin
</CsInstruments>
<CsScore>
i 1 0 3600
e
</CsScore>
</CsoundSynthesizer>
60 changes: 60 additions & 0 deletions examples/musical/Poisson_Cucchi.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o Poisson_Cucchi -W ;;; for file output any platform

; By Stefano Cucchi - 2024

</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
klambda1 linseg p4, p3, p5
kindex poisson klambda1
klambda2 linseg p6, p3, p7
ktrigfreq poisson klambda2
ksig poscil 1, ktrigfreq
ktrig trigger ksig, 0, 0
schedkwhen ktrig, 0, 20, 10, 0, 0.2, kindex, 10
endin
instr 10
kcnt = p4
kpc table kcnt, p5
kcps = cpspch(kpc)
asig1 oscil 0.5, kcps, 1
kenvelope linseg 0, p3*0.5, 1, p3*0.5, 0
asig1 = asig1*kenvelope
outs asig1, asig1
endin
</CsInstruments>
<CsScore>
f 1 0 4096 10 1 0 1 0 1 0 0 1 1
f 10 0 24 -2 8.00 8.01 8.02 8.03 8.04 8.05 8.06 8.07 8.08 8.09 8.10 8.11 9.00 9.01 9.02 9.03 9.04 9.05 9.06 9.07 9.08 9.09 9.10 9.11
i1 0 30 0 23 2 17
e
</CsScore>
</CsoundSynthesizer>
42 changes: 42 additions & 0 deletions examples/musical/Signum_Welsh.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o Signum_Welsh.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
; by tgrey - 2020
instr 1
iFreq = p4
iMode = p5
; generate a sine lfo @5hz
kMod lfo 1, 5
; if p5 is non-zero, take the negative/positive sign of the lfo
; this squares off the lfo!
if(iMode!=0) then
kMod signum kMod
endif
; gerate signal with modulation included
aSig poscil kMod, iFreq
outs aSig, aSig
endin
</CsInstruments>
<CsScore>
i1 0 .5 440 0
i1 + . 550 0
i1 + . 660 1 ; this event gets "squared" modulation due to non-zero p5
</CsScore>
</CsoundSynthesizer>
17 changes: 4 additions & 13 deletions examples/poisson.csd
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,35 @@
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out Audio in
-odac -iadc ;;;RT audio I/O
-n
; For Non-realtime ouput leave only the line below:
; -o poisson.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 441 ;ksmps set deliberately high to have few k-periods per second
nchnls = 1
; Instrument #1.
instr 1
; Generates a random number in a poisson distribution.
; klambda = 1
i1 poisson 1
print i1
endin
instr 2
kres poisson p4
printk (ksmps/sr),kres ;prints every k-period
kres poisson p4
printk (ksmps/sr),kres ;prints every k-period
endin
</CsInstruments>
<CsScore>
; Play Instrument #1 for one second.
i 1 0 1
i 2 1 0.2 0.5
i 2 2 0.2 4 ;average 4 events per k-period
i 2 3 0.2 20 ;average 20 events per k-period
e
</CsScore>
</CsoundSynthesizer>
37 changes: 37 additions & 0 deletions examples/poisson2.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o poisson2.wav -W ;;; for file output any platform

; By Stefano Cucchi - 2024
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 1024
nchnls = 2
0dbfs = 1
instr 1
kpitch poisson p4
printk (ksmps/sr),kpitch ;prints every k-period
a1 oscili 0.3, kpitch, 1
outs a1, a1
endin
</CsInstruments>
<CsScore>
f1 0 4096 10 1 0.1 0 0.2 0 0.3 0 0.1
i 1 0 5 100
i 1 + 5 200
e
</CsScore>
</CsoundSynthesizer>
32 changes: 14 additions & 18 deletions examples/signum.csd
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,32 @@
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o oscil.wav -W ;;; for file output any platform
; -o signum.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
; by tgrey - 2020
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
0dbfs = 1
gaArr[] init 2
instr 1
kEnv transeg 1, p3, -3, 0
a_pi = 4 * taninv(1.0);
a1 phasor 440;
a2 = sin(2 * a_pi * 1/ksmps * a1);
a3 dcblock2 a2
asig = signum(a3)
gaArr[0] = a2 * 0.6 * kEnv
gaArr[1] = asig * 0.6 * kEnv
outs gaArr[0], gaArr[1]
iinput = p4
isignum = signum(iinput)
print iinput
print isignum
endin
</CsInstruments>
<CsScore>
i 1 0 3
i1 0 .1 100
i1 + . 50
i1 + . .25
i1 + . 0
i1 + . -.25
i1 + . -50
i1 + . -100
</CsScore>
</CsoundSynthesizer>
39 changes: 39 additions & 0 deletions examples/signum2.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o signum2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
0dbfs = 1
gaArr[] init 2
instr 1
kEnv transeg 1, p3, -3, 0
a_pi = 4 * taninv(1.0);
a1 phasor 440;
a2 = sin(2 * a_pi * 1/ksmps * a1);
a3 dcblock2 a2
asig = signum(a3)
gaArr[0] = a2 * 0.6 * kEnv
gaArr[1] = asig * 0.6 * kEnv
outs gaArr[0], gaArr[1]
endin
</CsInstruments>
<CsScore>
i 1 0 3
</CsScore>
</CsoundSynthesizer>
4 changes: 2 additions & 2 deletions opcodes/fluidControl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ fluidCCk.</para>
<refsect1>
<title>Examples</title>
<para>
Here is a more complex example of the fluidsynth opcodes written by Istvan Varga. It uses the file <ulink url="examples/fluidcomplex.csd"><citetitle>fluidcomplex.csd</citetitle></ulink>.
Here is a more complex example of the fluidsynth opcodes written by Istvan Varga. It uses the file <ulink url="examples/fluidControl-advanced.csd"><citetitle>fluidControl-advanced.csd</citetitle></ulink>.
</para>
<xi:include href="examples-xml/fluidcomplex.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="examples-xml/fluidControl-advanced.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</refsect1>

<refsect1>
Expand Down
3 changes: 2 additions & 1 deletion opcodes/instr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</para>

<para>
<emphasis>i, j</emphasis>, ... must be numbers, not expressions. Any positive integer is legal, and in any order, but excessively high numbers are best avoided.
<emphasis>i, j</emphasis>, ... must be numbers or names, not expressions. Any positive integer is legal, and in any order, but excessively high numbers are best avoided.
</para>

<note>
Expand All @@ -46,6 +46,7 @@
<para>
Instruments can be defined in any order (but they will always be both initialized and performed in ascending instrument number order, with the exception of notes triggered by real time events that are initialized in the order of being received but still performed in ascending instrument number order). Instrument blocks cannot be nested (i.e. one block cannot contain another).
</para>
<para> For more information on named instruments, see <link linkend="OrchNamedInstruments"><citetitle>Named Instruments</citetitle></link>.</para>
</refsect1>

<refsect1>
Expand Down
Loading

0 comments on commit 97ca06b

Please sign in to comment.