diff --git a/learn/examples/fox.wav b/learn/examples/fox.wav new file mode 100644 index 0000000000..f5eed30cba Binary files /dev/null and b/learn/examples/fox.wav differ diff --git a/learn/examples/pling.csd b/learn/examples/pling.csd new file mode 100644 index 0000000000..4d9148c41b --- /dev/null +++ b/learn/examples/pling.csd @@ -0,0 +1,45 @@ + + +-odac -m128 + + +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) + + + + + + + + + 100 + 100 + 320 + 240 + true + + + 240 + 240 + 240 + + + + diff --git a/learn/examples/vibes.csd b/learn/examples/vibes.csd index 1de6d64597..3be6cd1e3d 100644 --- a/learn/examples/vibes.csd +++ b/learn/examples/vibes.csd @@ -4,48 +4,97 @@ +// 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 @@ -61,6 +110,7 @@ instr Chord endin +// create one tone with the vibes physical model instr Tone iamp = p4 @@ -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) -;; -; 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 + + diff --git a/learn/examples/vibes1.csd b/learn/examples/vibes1.csd deleted file mode 100644 index dcec25a671..0000000000 --- a/learn/examples/vibes1.csd +++ /dev/null @@ -1,128 +0,0 @@ - - --odac -m128 - - - -// version 1: more or less the same as in your original example - -sr = 44100 -ksmps = 32 -nchnls = 2 -0dbfs = 1 -seed 1 - -giStrike = ftgen(1,0,256,1,"marmstk1.wav",0,0,0) -giSine = ftgen(2,0,128,10,1) - -garev1 init 0 -garev2 init 0 - -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 - - // slight irregularity in metro ticks - kfm = randomi:k(ifm,ifm*1.05,1) - // frequency shift if ifreq1 != ifreq2 - kfreq = ifreq1 + phasor:k(1/itime) * (ifreq2-ifreq1) - // generate chord for each metro tick - schedkwhen(metro(kfm),0,0,"Chord",0,1/kfm,idb,iint1,iint2,innotes,kfreq) - -endin - - -instr Chord - - p3 *= random:i(1,3) - iamp = ampdb(p4) - iint1 = p5 - iint2 = p6 - innotes = p7 - ifreq = p8 - - indx = 0 - while (indx < innotes) do - - iint = round(random:i(iint1,iint2)) - iint = (indx > 0) ? iint : 0 - iffactor = semitone(iint) - ifreq *= iffactor - iamp = random:i(iamp,iamp*1.05) - schedule "Tone", 0, p3, iamp, ifreq*iffactor - - indx += 1 - od - -endin - -instr Tone - - iamp = p4 - ifreq = p5 - ihrd = random:i(0.1,0.9) - ipos = random:i(0,1) - - ares = vibes(iamp,ifreq,ihrd,ipos,1,6,0.05,2,0.1) - - // panning and dry output - adryl,adryr pan2 linen:a(ares,0,p3,p3/2),random:i(0,1) - out(adryl,adryr) - - // send part of it to reverb - irsend random 0.2, 0.4 - garev1 += irsend * adryl - garev2 += irsend * adryr - -endin - -instr Reverb - arev1, arev2 reverbsc garev1, garev2, 0.85, sr/2 - out(arev1,arev2) - clear(garev1,garev2) -endin -schedule("Reverb",0,-1) - - - -;; -; 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 - - - - - - - - 100 - 100 - 320 - 240 - true - - - 240 - 240 - 240 - - - - diff --git a/learn/examples/vibes2.csd b/learn/examples/vibes2.csd deleted file mode 100644 index 76680a5769..0000000000 --- a/learn/examples/vibes2.csd +++ /dev/null @@ -1,138 +0,0 @@ - - --odac -m128 - - - -// version 2: replacing score with array - -sr = 44100 -ksmps = 32 -nchnls = 2 -0dbfs = 1 -seed 1 - -giStrike = ftgen(1,0,256,1,"marmstk1.wav",0,0,0) -giSine = ftgen(2,0,128,10,1) - -garev1,garev2 init 0,0 - - -instr MakeChord - - kParams_1[] = fillarray(-15,5,1, 110,110,5,5,4) - kParams_2[] = fillarray(-15,5,1, 55,220,4,5,6) - kParams_3[] = fillarray(-15,5,10,220,220,4,4,2) - kParams_4[] = fillarray(-15,5,10,220,220,3,5,3) - kParams_5[] = fillarray(-18,5,20,220, 55,2,8,7) - kParams_6[] = fillarray(-12,2,10, 55, 55,3,5,3) - kParams_7[] = fillarray( -9,6,30,330,330,2,3,2) - kParams_8[] = fillarray(-18,6,10,330,330,1,4,5) - kParams_9[] = fillarray(-18,2,10, 30, 20,4,8,6) - - gkArr[] init 8 - - if timeinsts:k() < 10 then - gkArr = kParams_1 - else - gkArr = kParams_2 - endif - - // slight irregularity in metro ticks - ;kfm = randomi:k(ifm,ifm*1.05,1) - // frequency shift if ifreq1 != ifreq2 - kfreq = gkArr[3] + phasor:k(1/gkArr[2]) * (gkArr[4]-gkArr[3]) - // generate chord for each metro tick - schedkwhen(metro(gkArr[1]),0,0,"Chord",0,1/gkArr[1],kfreq) - -endin - - -instr Chord - - p3 *= random:i(1,3) - idb = i(gkArr,0) - iamp = ampdb(idb) - iint1 = i(gkArr,5) - iint2 = i(gkArr,6) - innotes = i(gkArr,7) - ifreq = p4 - - indx = 0 - while (indx < innotes) do - - iint = round(random:i(iint1,iint2)) - iint = (indx > 0) ? iint : 0 - iffactor = semitone(iint) - ifreq *= iffactor - iamp = random:i(iamp,iamp*1.05) - schedule "Tone", 0, p3, iamp, ifreq*iffactor - - indx += 1 - od - -endin - -instr Tone - - iamp = p4 - ifreq = p5 - ihrd = random:i(0.1,0.9) - ipos = random:i(0,1) - - ares = vibes(iamp,ifreq,ihrd,ipos,1,6,0.05,2,0.1) - - // panning and dry output - adryl,adryr pan2 linen:a(ares,0,p3,p3/2),random:i(0,1) - out(adryl,adryr) - - // send part of it to reverb - irsend random 0.2, 0.4 - garev1 += irsend * adryl - garev2 += irsend * adryr - -endin - -instr Reverb - arev1, arev2 reverbsc garev1, garev2, 0.85, sr/2 - out(arev1,arev2) - clear(garev1,garev2) -endin -schedule("Reverb",0,-1) - - - -;; -; 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 - - - - - - - - 100 - 100 - 320 - 240 - true - - - 240 - 240 - 240 - - - - diff --git a/learn/examples/vibes3.csd b/learn/examples/vibes3.csd deleted file mode 100644 index ccf8fd1332..0000000000 --- a/learn/examples/vibes3.csd +++ /dev/null @@ -1,151 +0,0 @@ - - --odac -m128 - - - -// version 3: better solution with 2dim array - -sr = 44100 -ksmps = 32 -nchnls = 2 -0dbfs = 1 -seed 0 - -giStrike = ftgen(1,0,256,1,"marmstk1.wav",0,0,0) -giSine = ftgen(2,0,128,10,1) - -garev1,garev2 init 0,0 - -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 - -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) - -instr MakeChord - - gkArr[] init 8 - kDurs[] = fillarray(20,10,10,10,20,10,30,10,10) - kTime init 0 - kCount init 0 - - if kTime <= 0 then - kIndx = (kCount < 9) ? kCount : RndInt:k(0,8) - 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(gkArr[1],gkArr[1]*1.05,1) - // frequency shift if ifreq1 != ifreq2 - 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/gkArr[1],kfreq) - - // count time - kTime -= 1/kr - -endin -schedule("MakeChord",0,-1) - - -instr Chord - - 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 - - indx = 0 - while (indx < innotes) do - - iint = round(random:i(iint1,iint2)) - iint = (indx > 0) ? iint : 0 - iffactor = semitone(iint) - ifreq *= iffactor - iamp = random:i(iamp,iamp*1.05) - schedule "Tone", 0, p3, iamp, ifreq*iffactor - - indx += 1 - od - -endin - -instr Tone - - iamp = p4 - ifreq = p5 - ihrd = random:i(0.1,0.9) - ipos = random:i(0,1) - - ares = vibes(iamp,ifreq,ihrd,ipos,1,6,0.05,2,0.1) - - // panning and dry output - adryl,adryr pan2 linen:a(ares,0,p3,p3/2),random:i(0,1) - out(adryl,adryr) - - // send part of it to reverb - irsend random 0.2, 0.4 - garev1 += irsend * adryl - garev2 += irsend * adryr - -endin - -instr Reverb - arev1, arev2 reverbsc garev1, garev2, 0.85, sr/2 - out(arev1,arev2) - clear(garev1,garev2) -endin -schedule("Reverb",0,-1) - - - - - - - - - - - 100 - 100 - 320 - 240 - true - - - 240 - 240 - 240 - - - - diff --git a/learn/examples/victor-vocoder-2.csd b/learn/examples/victor-vocoder-2.csd index fd74d6889b..279f388423 100644 --- a/learn/examples/victor-vocoder-2.csd +++ b/learn/examples/victor-vocoder-2.csd @@ -3,22 +3,47 @@ -Ma -odac +sr = 44100 +ksmps = 64 +nchnls = 2 +0dbfs = 1 -instr 1 // dispatch -schedule(3, 0, -1, p4, p5, p6, p7) -chnset(diskin:a("fox.wav",1,0,1), "input") -chnclear("excite") +// by victor lazzarini + +instr dispatch + schedule("voc_bands", 0, -1, p4, p5, p6, p7) + chnset(diskin:a("fox.wav",1,0,1), "input") + chnclear("excite") endin -schedule(1, 0, -1, 80, 8000, 8, 4) +schedule("dispatch", 0, -1, 80, 8000, 8, 4) -instr 3 // recursive vocoder bands -out(butterbp(butterbp(chnget:a("excite"), p4, p4/p6), p4, p4/p6) * +// recursive vocoder bands +instr voc_bands + print(nstrnum("voc_bands")) + out(butterbp(butterbp(chnget:a("excite"), p4, p4/p6), p4, p4/p6) * rms(butterbp(butterbp(chnget:a("input"), p4, p4/p6), p4, p4/p6))) -nxt:i = p4*2^(p7/12) -if nxt < p5 then - schedule(p1+0.001, 0, -1, nxt, p5, p6, p7) -endif + nxt:i = p4*2^(p7/12) + if nxt < p5 then + schedule(nstrnum("voc_bands")+0.001, 0, -1, nxt, p5, p6, p7) + endif endin + + + + 100 + 100 + 320 + 240 + true + + + 240 + 240 + 240 + + + + diff --git a/learn/examples/vocoder.csd b/learn/examples/vocoder.csd new file mode 100644 index 0000000000..b788eadc00 --- /dev/null +++ b/learn/examples/vocoder.csd @@ -0,0 +1,54 @@ + + +-Ma -odac + + +sr = 44100 +ksmps = 64 +nchnls = 2 +0dbfs = 1 + +// by victor lazzarini + +// umschalten zwischen +// - midi oder ein button durch den ein pitch getriggert wird +// - live oder sound file + +instr dispatch + schedule("voc_bands", 0, -1, p4, p5, p6, p7) + chnset(diskin:a("fox.wav",1,0,1), "input") + chnclear("excite") +endin +schedule("dispatch", 0, -1, 80, 8000, 8, 4) + +// recursive vocoder bands +instr voc_bands + out(butterbp(butterbp(chnget:a("excite"), p4, p4/p6), p4, p4/p6) * + rms(butterbp(butterbp(chnget:a("input"), p4, p4/p6), p4, p4/p6))) + nxt:i = p4*2^(p7/12) + if nxt < p5 then + schedule(nstrnum("voc_bands")+0.001, 0, -1, nxt, p5, p6, p7) + endif +endin + + + + + + + + + 100 + 100 + 320 + 240 + true + + + 240 + 240 + 240 + + + +