Skip to content

Commit

Permalink
Merge pull request #750 from tjingboem/7.0
Browse files Browse the repository at this point in the history
new or improved examples
  • Loading branch information
tjingboem authored Jun 16, 2024
2 parents 33a830c + 8181d3e commit 5a4f072
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 38 deletions.
12 changes: 6 additions & 6 deletions examples/delay.csd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ilev = p4 ;level of direct sound
idelay = p5 *.001 ;Delay in ms
ifd = p6 ;feedback
ain diskin2 "fox.wav", 1, 1
ain diskin2 "Mathews.wav", 1, 1
adel delay ain + (adel*ifd), idelay;ifd = amount of feedback
asig moogvcf adel, 1500, .6, 1 ;color feedback
outs asig*ilev, ain
Expand All @@ -30,11 +30,11 @@ endin
</CsInstruments>
<CsScore>
;Delay is in ms
i 1 0 15 2 200 .95 ;with feedback
i 1 4 5 2 20 .95
i 1 + 3 2 5 .95
i 1 + 3 3 5 0 ;no feedback
i 1 0 5 1.5 200 .95 ;with feedback
i 1 + 5 1.5 20 .95
i 1 + 3 1.5 5 .95
i 1 + 7 2 5 0 ;no feedback
e
</CsScore>
</CsoundSynthesizer>
</CsoundSynthesizer>
16 changes: 9 additions & 7 deletions examples/exciter.csd
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,33 @@ ksmps=32
nchnls=2
0dbfs =1
; by Menno Knevel 2023
instr 1 ; excited sound + original sound
a1 diskin2 "fox.wav", 1
a1 diskin2 "Mathews.wav", 1, 3.5
a2 exciter a1, 3000, 20000, 10, 10 ;generate uneven harmonics at maximum setting
outs a2+a1, a2+a1
endin
instr 2 ; original sound for comparison
a1 diskin2 "fox.wav", 1
a1 diskin2 "Mathews.wav", 1, 3.5
outs a1, a1
endin
instr 3 ; the effect of the excited sound only
a1 diskin2 "fox.wav", 1
a1 diskin2 "Mathews.wav", 1, 3.5
a2 exciter a1, 3000, 20000, 10, 10 ;generate uneven harmonics at maximum setting
outs a2, a2
endin
</CsInstruments>
<CsScore>
i1 0 3
i2 3 3
i3 6 3
i1 0 5
i2 5 5
i3 10 4.5
e
</CsScore>
</CsoundSynthesizer>
</CsoundSynthesizer>
4 changes: 2 additions & 2 deletions examples/filelen.csd
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ endin
</CsInstruments>
<CsScore>
i 1 0 3 "fox.wav" ; mono signal
i 1 5 4 "drumsSlp.wav" ; stereo signal
i 1 0 8 "Mathews.wav" ; mono signal
i 1 8 4 "drumsSlp.wav" ; stereo signal
e
</CsScore>
</CsoundSynthesizer>
5 changes: 2 additions & 3 deletions examples/gen20.csd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nchnls = 2
instr 1
insnd = 10 ;"fox.wav"
insnd = 10 ;"marimba.aif"
ibasfrq = 44100 / ftlen(insnd) ;use original sample rate of insnd file
kamp expseg .001, p3/2, .7, p3/2, .8 ;envelope
Expand All @@ -35,11 +35,10 @@ endin
<CsScore>
f1 0 512 20 2 ;Hanning window
f2 0 512 20 6 1 ;Gaussian window
f10 0 16384 1 "fox.wav" 0 0 0
f10 0 16384 1 "marimba.aif" 0 0 0
i1 0 5 1 ;use Hanning window
i1 + 5 2 ;use Gaussian window
e
</CsScore>
</CsoundSynthesizer>

29 changes: 29 additions & 0 deletions examples/nchnls_hw.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
-iadc ;;;realtime audio in
</CsOptions>
<CsInstruments>
; by Menno Knevel - 2024
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
idacc,iadcc nchnls_hw
prints "\non this machine:"
prints "\nnumber of outputs = %d\n", idacc
prints "number of inputs = %d\n\n", iadcc
endin
</CsInstruments>
<CsScore>
i1 0 0
e
</CsScore>
</CsoundSynthesizer>
20 changes: 10 additions & 10 deletions examples/pvoc.csd
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ ksmps = 32
nchnls = 2
0dbfs = 1
; by Menno Knevel 2021
; by Menno Knevel 2023
gilen filelen "fox.wav" ; get length of impulse soundfile
gilen filelen "Mathews.wav" ; get length of impulse soundfile
; analyze sound file and output result to pvoc-ex file
ires system_i 1,{{ pvanal fox.wav fox1.pvx }} ; default settings
ires system_i 1,{{ pvanal Mathews.wav Mathews1.pvx }} ; default settings
instr 1 ; untreated signal
asig diskin2 "fox.wav", 1
asig diskin2 "Mathews.wav", 1
prints "\n---***YOU NOW HEAR THE UNTREATED SOUND SAMPLE***---\n"
outs asig*.8, asig*.8
endin
Expand All @@ -29,20 +29,20 @@ instr 2
prints "\n---***YOU NOW HEAR THE RESULT OF THIS ANALYZED FILE:***---\n"
ktime line 0, p3, gilen ; timepointer over the entire sample
asig pvoc ktime, p4, "fox1.pvx", 1
asig pvoc ktime, p4, "Mathews1.pvx", 1
outs asig*.6, asig*.6
endin
</CsInstruments>
<CsScore>
i1 0 2.76 ; original sample
i1 0 15.6 ; original sample
i2 5 2.76 1 ; no change so original sample is played
i2 10 2 1 ; played faster
i2 17 10 1 ; no change so original sample is played
i2 28 2 1 ; played faster
i2 15 10 1 ; slowed down, same pitch &
i2 25 10 1.2; slowed down and higher pitch
i2 31 30 1 ; slowed down, same pitch &
i2 63 10 .6 ; sped up and lower pitch
e
</CsScore>
Expand Down
10 changes: 5 additions & 5 deletions examples/syncgrain.csd
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ asig syncgrain 1, ifreq, ipitch, igrsize, ips*istr, 1, 2, iolaps
endin
</CsInstruments>
<CsScore>
f1 0 0 1 "fox.wav" 0 0 0 ;deferred table
f1 0 0 1 "Mathews.wav" 0 0 0 ;deferred table
f2 0 8192 20 2 1
i1 0 5 1
i1 + 5 4
i1 + 5 .8
i1 0 11 1
i1 + 11 4
i1 + 11 .8
e
</CsScore>
</CsoundSynthesizer>
</CsoundSynthesizer>
4 changes: 2 additions & 2 deletions opcodes/filelen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
<xi:include href="examples-xml/filelen.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</example>

The mono audio file <quote>fox.wav</quote> is about 2.8 seconds long, and the stereo file <quote>drumsSlp.wav</quote> is 4.0 seconds. So <emphasis>filelen</emphasis>'s output should include a line for the mono and the stereo file like this:
The mono audio file <quote>Mathews.wav</quote> is about 2.8 seconds long, and the stereo file <quote>drumsSlp.wav</quote> is 4.0 seconds. So <emphasis>filelen</emphasis>'s output should include a line for the mono and the stereo file like this:
<screen>
lenght of sample = 2.757 seconds
lenght of sample = 15.598 seconds
lenght of sample = 4.000 seconds
</screen>
</para>
Expand Down
19 changes: 18 additions & 1 deletion opcodes/nchnls_hw.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,24 @@
correspond to the currently selected/in-use hardware devices.
</para>
</refsect1>


<refsect1>
<title>Examples</title>
<para>
Here is an example of the nchnls_hw opcode. It uses the file <ulink url="examples/nchnls_hw.csd"><citetitle>nchnls_hw.csd</citetitle></ulink>.
<example>
<title>Example of the nchnls_hw opcode.</title>
<para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
<xi:include href="examples-xml/nchnls_hw.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</example>
The output should include lines like these:
<screen>
on this machine:
number of outputs = 32
number of inputs = 32</screen>
</para>
</refsect1>

<refsect1>
<title>See also</title>
<para><link linkend="MiscopcodesTop"><citetitle>Miscellaneous opcodes</citetitle></link></para>
Expand Down
4 changes: 2 additions & 2 deletions opcodes/wterrain2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<para>
<emphasis>kcurve=3: cornoid</emphasis>
<literallayout>
fx(t) = kx + krx * sin(t) * (cos(t) + kcurveparam);
fy(t) = ky + kry * cos(t) * (cos(t) + kcurveparam);
fx(t) = kx + krx * cos(t) * cos(2*t)
fy(t) = ky + kry * sin(t) * (kcurveparam + cos(2*t))
</literallayout>
<mediaobject>
<imageobject>
Expand Down

0 comments on commit 5a4f072

Please sign in to comment.