Steven Yi 44100 1 2 true 1 44100 1 2 true 1 false false false false true true true true false false true true true true false false 0 false Re:Mode Re:Mode Description: Recursive Mode instrument Author: Steven Yi [HISTORY] v1.0 - Initial Release ;[once]{ gi_sine ftgen 0, 0, 65537, 10, 1 ;} ipcount pcount kpcount init ipcount idur = abs(p3) iskip tival kQ = <baseQ> if (kpcount == 5) then ; MIDI-Style Note ipch getFrequency p4 ipch2 = ipch kpchline line ipch, idur, ipch iamp = ampdbfs(p5) kspace = <space> else ; SYi Orch Note ipch getFrequency p4 ipch2 getFrequency p5 kpchline line ipch, idur, ipch2 iamp = ampdbfs(p6) kspace init p7 ienvType = p8 endif ktmp linsegr 0, .1, 0, i(kQ) / ipch, 0 ;if (kpcount == 5) then ; ;kenv yi_envelope 0, i(<attack>), i(<decay>), i(<sustain>), i(<release>) ; ;else ; ;kenv yiEnvelope ienvType, i(<attack>), i(<decay>), i(<sustain>), i(<release>) ;;kenv yiEnvelope ienvType, .05, .05, .95, .1 ; ;endif imaxdel = (1/ipch > 1/ipch2) ? 1/ipch : 1/ipch2 ;INSERT SOUND GENERATION CODE HERE adel init 0 ;aexc1 vco2 kenv* .001, kpchline ; anoise pinkish kenv ;knoiseenv linseg 0, .005, .1, .02, 0, .1, 0 ;aexc = kenv * anoise * .005 ;+ adel ;+ aexc1 ;aexc = aexc1 + adel + anoise ;aexc = adel + anoise ;inummodes = <modeOn0> + <modeOn1> + <modeOn2> + <modeOn3> + <modeOn4> + <modeOn5> ;aexc2 mpulse 1 / inummodes, 0 aexc mpulse 1, 0 ;aexc2 stickslip kpchline ;aexc = aexc2 ;+ aexc ;aexc = aexc2 + aexc ;+ adel ;+ aexc + adel ;aexc = aexc2 + adel ;+ aexc1 ;aexc wgbow .05, kpchline, 3, 0.127236, 0, 0, gi_sine ;aout = 0 kfreqmultiplier = <freqMultiplier> aout mode2 aexc, kpchline, kfreqmultiplier, kQ, <multiplier>, <multiplier1> ;aout = aout aout dcblock2 aout ;adel vdelay3 aout * <feedback>, 1000/kpchline, imaxdel * 1000 ;adel = -adel aout = aout * iamp ;* kenv aout limit aout, -.5, .5 ;END SOUND GENERATION CODE aLeft, aRight pan2 aout, kspace blueMixerOut aLeft, aRight 11 11 31 95 baseQ 98 71 true 0.0 500.0 401.9232 60 true decay 153 262 true 0.0 1.0 0.014572331 50 true sustain 206 262 true 0.0 1.0 0.89667374 50 true release 259 262 true 0.0 10.0 0.1461223 50 true attack 100 262 true 0.0 10.0 0.099999994 50 true 107 243 161 243 211 243 262 243 13 274 8 174 feedback 100 148 true 0.0 1.0 0.04407313 60 true space 174 64 true 0.0 1.0 0.69474804 60 true 189 39 multiplier 297 70 true 0.0 1.0 0.6874153 60 true 312 48 multiplier1 380 80 true 0.0 1.0 0.65212685 60 true 385 51 freqMultiplier 431 234 true 0.5 4.0 1.7130874 60 true 424 205 ver2:0.099999994 ver2:401.9231872559 ver2:0.0145723308 ver2:0.0440731309 ver2:1.5926321745 ver2:0.4348204434 ver2:0.9025782943 ver2:0.1461223066 ver2:0.694748044 ver2:0.896673739 tie_status i 0 itie tival if (itie == 0 && p3 < 0) ithen ; this is an initial note within a group of tied notes itiestatus = 0 elseif (p3 < 0 && itie == 1) ithen ; this is a middle note within a group of tied notes itiestatus = 1 elseif (p3 > 0 && itie == 1) ithen ; this is an end note out of a group of tied notes itiestatus = 2 elseif (p3 > 0 && itie == 0) ithen ; this note is a standalone note itiestatus = -1 endif xout itiestatus getFrequency i i ipch xin iout = (ipch < 15 ? cpspch(ipch) : ipch) xout iout yiEnvelope k ioooooo ienvType, iattack, idecay, isus, irel, iOldAmp, iNewAmp xin itie tival idur = abs(p3) iEndAmp = iNewAmp / iOldAmp if (ienvType == 0) then ;kenv adsr iattack, idecay, isus, irel kenv linsegr 0, iattack, 1, idecay, isus, irel, 0 elseif (ienvType == 1) then kenv linsegr 0, idur * .5, 1, idur * .5, 0 kenv logcurve kenv, 1.5 elseif (ienvType == 2) then kenv linsegr 0, idur - .1, 1, .1, 0 elseif (ienvType == 3) then if (itie == 0 && p3 < 0) then ; this is an initial note within a group of tied notes kenv linseg 0, .2, 1, .2, 1 elseif (p3 > 0 && itie == 1) then ; this is an end note out of a group of tied notes kenv linsegr 1, .01, 1, irel, 0 elseif (p3 > 0 && itie == 0) then ; this is a stand alone note kenv adsr iattack, idecay, isus, irel else ; this is a middle note within a group of tied notes (p3 < 0 && itie == 1) kenv = 1 endif endif xout kenv mode2 a akkkkko ain, kfreq, kfreqmultiplier, kq, kampmultiplier, kqmultiplier, icounter xin ;kcurrentfreq = kfreq * (icounter + 1) itie tival aout mode ain, kfreq, kq, itie ;printk 1, kcurrentfreq if (icounter < 64) then kfreqnext = kfreq + (kfreq * kfreqmultiplier) if (kfreqnext < (sr * .2) && icounter < 64) then aout2 mode2 ain * kampmultiplier, kfreqnext, kfreqmultiplier, kq * kqmultiplier, kampmultiplier, kqmultiplier, icounter + 1 aout sum aout, aout2 endif endif xout aout stickslip a k kfreq xin kdamp = 2 / sr ; damping of model/srate kmu_static = 5 ; static friction coeff. kmu_dynamic = 5 ; dynamic friction coeff. kv_crit = 5 ; critical velocity where static friction kicks in/srate kqt1 = 0 ; last state kqt2 = 0 ; last state kv = 1 /sr ; external slidevelocity in m/s / srate kfn = 30 /sr ; external; normal force/srate ktmp = 0 ; ; /** Set stick-slip model parameters (all in S.I. units). ; @param k_damp damping of spring system ; @param dummy not used ; @param mu_static static friction coeff ; @param mu_dynamic dynamic friction coeff ; @param v_crit critical velocity for transition from dyn. to static friction ; */ ;; public void setStickSlipParameters(float k_damp,float dummy,float mu_static,float mu_dynamic,float v_crit) { ;; this.k_damp = k_damp/srate; ;; this.mu_static = mu_static; ;; this.mu_dynamic = mu_dynamic; ;; this.v_crit = v_crit/srate; ;; } ; ; /** Set normal force magnitude. ; @param val normal force in Newton ; */ ;; public void setNormalForce(float val) { ;; fn = val/srate; ;; } /** Set velocity. @param v velocity in m/s */ ; public void setSpeed(float v) { ; this.v = v/srate; ; } aout = 0 kcounter = 0 kfactor = 1 - kdamp loopStart: ktmp = kv - kqt1 + kqt2 ksign = (ktmp >= 0) ? 1 : -1 if (abs(ktmp) > kv_crit) then kf_mu_sign = kfn * kmu_dynamic * ksign else kf_mu_sign = kfn * kmu_static * ksign endif kval = kfactor * kqt1 * kf_mu_sign vaset .3, kcounter, aout kqt2 = kqt1 kqt1 = kval ;kcounter = kcounter + 1 loop_lt kcounter, 1, ksmps, loopStart /** Compute the next buffer. q(t+1) = (1-k_damp)q(t)+fn mu[(v - (q(t)-q(t-1)))] * sign(v - (q(t)-q(t-1)) */ ; public void computeBuffer() { ; float factor = (1-k_damp); ; int bufsz = getBufferSize(); ; for(int k=0;k<bufsz;k++) { ; float f_mu_sign; ; float tmp = v - qt_1 + qt_2; ; int signOf = (tmp >= 0 ? 1 : -1); ; if((float)(Math.abs(tmp)) > v_crit) { ; f_mu_sign = fn * mu_dynamic * signOf; ; } else { ; f_mu_sign = fn * mu_static * signOf; ; } ; buf[k] = factor * qt_1 + f_mu_sign; ; qt_2 = qt_1; ; qt_1 = buf[k]; ; } ; } xout aout stk_bowtable a akk ;offset default 0.0 ;kslope default 0.1 ain, koffset, kslope xin kndx init 0 aout init 0 loopStart: ktemp vaget kndx, ain ksample = ktemp + koffset ksample = ksample * kslope ksample = abs(ksample) + 0.75 ksample pow ksample, -4.0 if(ksample > 1.0) then ksample = 1.0 endif vaset ksample, kndx, aout loop_lt kndx, 1, ksmps, loopStart xout aout true 0.0 1 Master -3.0 false false Master Master 0.0 false false ReverbSC true 2 2 aout1, aout2 reverbsc ain1, ain2, <feedback>, <cutoff> aout1 = (ain1 * <wetdry>) + (aout1 * (1 - <wetdry>)) aout2 = (ain2 * <wetdry>) + (aout2 * (1 - <wetdry>)) 7 7 feedback 8 55 true 0.0 1.0 0.65062463 60 true 11 36 cutoff 72 55 true 20.0 20000.0 3615.6218 60 true 80 36 wetdry 136 55 true 0.0 1.0 0.6195983 60 true 139 36 csound -Wdo devaudio -L stdin false false 2.0 0.0 root -10066279 0 true 64 0 false 1.0 0 5 true 0.0 -1.0 false false false PCH MIDI 12TET 261.62558 2.0 1.0 1.0594631 1.122462 1.1892071 1.2599211 1.3348398 1.4142135 1.4983071 1.587401 1.6817929 1.7817974 1.8877486