Skip to content

Commit

Permalink
more work on examples
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimheintz committed Oct 1, 2024
1 parent 28be74a commit 0bbcaf1
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 464 deletions.
Binary file added learn/examples/fox.wav
Binary file not shown.
45 changes: 45 additions & 0 deletions learn/examples/pling.csd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<CsoundSynthesizer>
<CsOptions>
-odac -m128
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1
seed 0
// by joachim heintz
instr PlingStruct
// generate one tone in a wide range between short/noisy and long/pitched
aMode = mode(mpulse(ampdb(random:i(-22,0)),p3),mtof:i(random:i(80,100)),10^(p3-1))
// distribute anywhere in the stereo field and output
aL,aR pan2 aMode,random:i(0,1)
out(aL,aR)
// call the next instance of this instrument
schedule("PlingStruct",rnd:i(1),random:i(1,4))
endin
schedule("PlingStruct",0,3)
</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>
<bsbPanel>
<label>Widgets</label>
<objectName/>
<x>100</x>
<y>100</y>
<width>320</width>
<height>240</height>
<visible>true</visible>
<uuid/>
<bgcolor mode="background">
<r>240</r>
<g>240</g>
<b>240</b>
</bgcolor>
</bsbPanel>
<bsbPresets>
</bsbPresets>
114 changes: 78 additions & 36 deletions learn/examples/vibes.csd
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,97 @@
</CsOptions>
<CsInstruments>
// by luis antunes pena, modified by joachim heintz
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
seed 1
seed 0
// load function tables
giStrike = ftgen(1,0,256,1,"marmstk1.wav",0,0,0)
giSine = ftgen(2,0,128,10,1)
garev1 init 0
garev2 init 0
// initialize globale reverb variables
garev1,garev2 init 0,0
// custom function for random integer
opcode RndInt,i,ii
iMin,iMax xin
xout int(random:i(iMin,iMax+.9999))
endop
opcode RndInt,k,kk
kMin,kMax xin
xout int(random:k(kMin,kMax+.9999))
endop
// generate a 2-dimensional global array with the parameters of each section
instr Params
gkAllParams[][] init 9,8
gkAllParams = fillarray(-15,5,1, 110,110,5,5,4,
-15,5,1, 55,220,4,5,6,
-15,5,10,220,220,4,4,2,
-15,5,10,220,220,3,5,3,
-18,5,20,220, 55,2,8,7,
-12,2,10, 55, 55,3,5,3,
-9,6,30,330,330,2,3,2,
-18,6,10,330,330,1,4,5,
-18,2,10, 30, 20,4,8,6)
turnoff
endin
schedule("Params",0,1)
// create one section
instr MakeChord
idb = p4
ifm = p5 ;repetition frequency
itime = p6 ;phasor time
ifreq1 = p7 ;base freq
ifreq2 = p8
iint1 = p9 ;interval in semitones (used for chords)
iint2 = p10
innotes = p11 ;number of notes in chord
gkArr[] init 8
kDurs[] = fillarray(20,10,10,10,20,10,30,10,10) //durations of sections
kTime init 0
kCount init 0
// for each new section
if kTime <= 0 then
// go through all rows of gkAllParams, the select one row randomly
kIndx = (kCount < 9) ? kCount : RndInt:k(0,8)
// get time and row according to the count index
kTime = kDurs[kIndx]
gkArr = getrow(gkAllParams,kIndx)
printks("Playing row %d for %d seconds\n",0,kIndx,kTime)
kCount += 1
endif
// slight irregularity in metro ticks
kfm = randomi:k(ifm,ifm*1.05,1)
kfm = randomi:k(gkArr[1],gkArr[1]*1.05,1)
// frequency shift if ifreq1 != ifreq2
kfreq = ifreq1 + phasor:k(1/itime) * (ifreq2-ifreq1)
kfreq = gkArr[3] + phasor:k(1/gkArr[2]) * (gkArr[4]-gkArr[3])
// generate chord for each metro tick
schedkwhen(metro(kfm),0,0,"Chord",0,1/kfm,idb,iint1,iint2,innotes,kfreq)
schedkwhen(metro(kfm),0,0,"Chord",0,1/gkArr[1],kfreq)
// count time (decrease like in a sandglass)
kTime -= 1/kr
endin
schedule("MakeChord",0,-1)
// create one chord
instr Chord
p3 *= random:i(1,3)
iamp = ampdb(p4)
iint1 = p5
iint2 = p6
innotes = p7
ifreq = p8
// get and adjust parameters
p3 *= random:i(2,4)
idb = i(gkArr,0)
iamp = ampdb(idb)
iint1 = i(gkArr,5)
iint2 = i(gkArr,6)
innotes = i(gkArr,7)
ifreq = p4
// loop for number of notes in chord
indx = 0
while (indx < innotes) do
Expand All @@ -61,6 +110,7 @@ instr Chord
endin
// create one tone with the vibes physical model
instr Tone
iamp = p4
Expand All @@ -81,32 +131,24 @@ instr Tone
endin
// add reverb
instr Reverb
arev1, arev2 reverbsc garev1, garev2, 0.85, sr/2
out(arev1,arev2)
out(arev1/2,arev2/2)
clear(garev1,garev2)
endin
schedule("Reverb",0,-1)
</CsInstruments>
<CsScore>
;;
; amp[dB] metro[Hz] phasor[s] freq1 freq2 int1 int2 nnotes
i1 0 20 -15 5 1 110 110 5 5 4
i1 + 10 -15 . 1 55 220 4 5 6
i1 30 10 -15 . 10 220 220 4 4 2
i1 + 10 -15 . 10 220 220 3 5 3
i1 + 20 -18 . 20 220 55 2 8 7
i1 + 10 -12 2 10 55 55 3 5 3
i1 71 30 -9 6 30 330 330 2 3 2
i1 + 10 -18 6 10 330 330 1 4 5
i1 + 9 -18 2 10 30 20 4 8 6
e
</CsScore>
</CsoundSynthesizer>



<bsbPanel>
<label>Widgets</label>
<objectName/>
Expand Down
128 changes: 0 additions & 128 deletions learn/examples/vibes1.csd

This file was deleted.

Loading

0 comments on commit 0bbcaf1

Please sign in to comment.