-odac sr = 44100 ;96000? kr = 22050 ;24000? nchnls = 2 0dbfs = 1 gkBPM init 120 gkNote init 64 gkGate init 0 zakinit 9, 9 massign 1,0 massign 2,0 massign 3,0 massign 4,0 ; Function tables for rectifier giHalfPos ftgen 10, 0, 32768, 7, 0, 16384, 0, 16384, 1 giHalfNeg ftgen 11, 0, 32768, 7, -1, 16384, 0 giFullPos ftgen 12, 0, 32768, 7, 1, 16384, 0, 16384, 1 giFullNeg ftgen 13, 0, 32768, 7, -1, 16384, 0, 16384, -1 ;--------------------------------- ; Function table generation block giSin ftgen 1, 0, 16384, 10, 1 giTri ftgen 2, 0, 16384, 7, 0, 4096, 1, 8192, -1, 4096, 0 giSaw ftgen 3, 0, 16384, 7, 1, 16384, -1 giSqr50 ftgen 4, 0, 16384, 7, 1, 8192, 1, 0, -1, 8192, -1 giSqr25 ftgen 5, 0, 16384, 7, 1, 4096, 1, 0, -0.25, 12288, -0.25 giSqr10 ftgen 6, 0, 16384, 7, 1, 1024, 1, 0, -0.0625, 15360, -0.0625 ;--------------------------------- giSq400 ftgen 21, 0, 16384, 7,1,41,1,0,0,16343,0 ; Sync_Wave Table CLKGEN giSq96 ftgen 22, 0, 16384, 7,1,1366,1,0,0,15018,0 ; 1/96_Wave Table CLKGEN giSq16 ftgen 23, 0, 16384, 7,1,910,1,0,0,15474,0 ; 1/16_Wave Table CLKGEN ;--------------------------------- opcode A2K, 0, ii izaIn, izkOut xin aIn zar izaIn zkw k(aIn), izkOut endop opcode EnvAHD, 0, kiikikkkkkkk kShape,iAtt,iHold,kReset,iDec,kSW,kKBT, kTrigI,kAMI,kInI, kEnvO,kOut xin ; NOT FORGET ABOUT KEYBOARD KB aIn zar kInI kAM zkr kAMI kTrig zkr kTrigI ; 0 1 2 3 4 5 k1[] fillarray 0.5, 0.5, 0.5, 0.5, 1, 1 k2[] fillarray 0.5, -0.5, -0.5, 0.5, 0, 0 k3[] fillarray 1, -1, 1, -1, 1, -1 kEnv, kCount, kOn init 0 iTotal = iAtt+iHold+iDec if kTrig > .5 && kOn==0 then kOn = 1 endif env: if kOn == 1 then ;kEnv linseg 0, 1, 0.9, .5, 0.9, 1, 0 if kShape==0 then ; LogExp kEnv transeg 0, iTotal/iAtt, -iAtt, 0.9, iTotal/iHold, 0, 0.9, iTotal/iDec, -iDec, 0 elseif kShape==3 then ; LinLin kEnv linseg 0, iTotal/iAtt, 0.9, iTotal/iHold, 0.9, iTotal/iDec, 0 endif kCount += 1 endif if kCount>=100 && kEnv==0 then ; basically waits till the end of the env, kOn = 0 ; when kEnv has become 0 again kCount = 0 reinit env endif printk2 kOn ;xout kEnv, aIn*kEnv zkw kEnvO, kEnv zaw aIn*kEnv, kOut ;outs aIn*kEnv, aIn*kEnv endop opcode K2A, 0, ii izkIn, izaOut xin kIn zkr izkIn zaw a(kIn), izaOut endop opcode LfoA, 0, kkkkkkkkkk ; only 4 first waves implemented - sin,tri,saw,quad ; Modulation not implemented ; kMod - blue - -64..+64 ; 0 1 2 3 4 5 k1[] fillarray 0.5, 0.5, 0.5, 0.5, 1, 1 k2[] fillarray 0.5, -0.5, -0.5, 0.5, 0, 0 k3[] fillarray 1, -1, 1, -1, 1, -1 ; kRateMode? kRate,kMode,kKBT,kModLev,kWave,kON,kOutType,kRange, kRateIn,kOut xin kRate_ zkr kRateIn if kKBT != 1 goto NoKBT kNote = gkNote goto KBT NoKBT: kNote = 0 ; freq in Hz KBT: kPitch init 0 if kRateIn == 0 goto Run kPitch zkr kRateIn Run: kM_ = kPitch + kModLev*kRate_ + kNote printk2 kM_ kout oscilikt 1, kM_ + kRate, kWave+1 ; problems with kwave? kout = (kout*k1[kOutType]+k2[kOutType])*k3[kOutType] zkw kout*kON*64, kOut endop opcode OscA, 0, kkkkkkkkkk ; kModLev - 0...1 ; kMod - blue - -64..+64 ; FREQ SEMI FAC - ALL THE SAME! ; PART MODE = 3 kCoarse,kFine,kKBT,kModLev,kWave,kON,kTuneMode,kPitchIn,kModIn,kOut xin kMod zkr kModIn if kKBT != 1 goto NoKBT kNote = gkNote goto KBT NoKBT: kNote = 64 KBT: kPitch init 64 if kPitchIn == 0 goto Run kPitch zkr kPitchIn Run: kM_ = kPitch+kModLev*kMod+kNote+kFine*0.01 if kTuneMode==3 goto Part kFreq = cpsmidinn(kM_+kCoarse) goto Out Part: kFreq = cpsmidinn(kM_)*kCoarse Out: aout oscilikt 1, kFreq, kWave+1 zaw aout*kON, kOut endop opcode Out2, 0, kkkkk ksource, kMute, kPad, kL, kR xin kpad = kPad + 1 aL zar kL aR zar kR outs aL,aR ; no sound! aL limit aL, -4, 4 ; +12 dB overhead limitation aR limit aR, -4, 4 aL *= .25 ; back to 0dbfs = 1 aR *= .25 outs aL*kMute*kpad,aR*kMute*kpad endop ; -------------------- ; VOICE AREA instr 1 ; Module Parameters Modes Inlets Outlets A2K 7, 7 LfoA 0.64,0,0,0.0,0,1,4,1, 1, 8 K2A 9, 9 OscA 0.0,0.0,1,0.0,2,1,1, 1,1, 7 Out2 0,1,0, 8,9 EnvAHD 0,0.508,0.234,0,0.25,0,1, 8,1,7, 0,9 K2A 9, 8 endin ; -------------------- ; FX AREA instr 2 ; Module Parameters Modes Inlets Outlets endin ; GLOBAL MIDI instr 3 kstat, kchan, kdata1, kdata2 midiin if kstat!=144 goto Next gkGate = 1 gkNote = kdata1 Next: if kstat!=128 goto Over gkGate = 0 Over: endin ; FOR OFFLINE RENDERING instr 4 xtratim 0.1 gkGate linsegr 1, p3, 1, 0, 0 gkNote = p4 ; in 7b MIDI format endin i1 0 [60*60*24*7] i2 0 [60*60*24*7] i3 0 [60*60*24*7] ; use i4 to emultate MIDI commands if needed ; p4 is pitch ;i4 0 1 64