sr = 44100 ksmps = 128 nchnls = 2 0dbfs = 1 ; This table maps menu values to vco2 oscillator modes giwavemodes ftgen 0, 0, 8, -2, 0, 10, 12 instr 1 ;read widgets ; When values from sliders are to be used on the init pass, ; they must be read outside the instrument, because ; they are not read during the init pass gkwave invalue "wave" gkfreq invalue "freq" gkfreq portk gkfreq, 0.05 ;smooth frequency values endin instr 10 ktrig changed gkwave if ktrig = 1 then ; forces a new init pass from label newwaveform ; this makes waveform change even if a note is already on reinit newwaveform endif ;The envelope is outside the reinit loop, otherwise it is reinitialized kenv adsr p3/5, p3/5, 0.6, p3/2 newwaveform: prints "instr 1-init" imode tab_i i(gkwave), giwavemodes ;This line is only run every init pass aout vco2 0.2, gkfreq, imode ;This line must be within the reinit section rireturn ;End of reinit section outs aout*kenv, aout*kenv endin i 1 0 3600 f 0 3600 375 213 361 291 true 170 170 127 wave 11 8 122 23 {a391e289-ce5a-454b-9817-083317d177d8} true 0 -3 saw 0 square 1 triangle 2 1 false 137 8 205 26 {ae683ee8-7638-47e1-8b00-bb719111dd7c} true 0 -3 center Helvetica 10 3 255 255 255 32 32 32 noborder 1 1 freq 11 44 180 20 {0aada694-ff37-4a9b-a312-5e9fec7b6e6a} true 0 -3 200.00000000 800.00000000 520.00000000 lin continuous -1.00000000 false 207 39 130 25 {f4ca4244-ba74-4152-940e-d6b763ed5666} true 0 -3 left Bitstream Vera Sans 10 3 255 255 255 255 255 255 noborder 1 1 button1 11 71 180 40 {eb1f02f6-2cb9-419c-8ae6-ee9b3a8aa079} true 0 -3 event 1.00000000 Generate note / i10 0 5 false false 196 69 148 44 {72a619e9-5162-49f8-bc95-498c21af9846} true 0 -3 center Bitstream Vera Sans 10 3 255 255 255 255 255 255 noborder 1 1 10 117 332 131 {58f8a5b4-2172-4465-bd99-c96814d417d8} true 0 -3 121 130 91 26 {f2f1ffb7-e499-450f-ac22-a2d9d7c3cae7} true 0 -3 left Bitstream Vera Sans 16 3 131 65 48 255 255 255 noborder 1 1 18 160 313 73 {94d46c4e-b4b7-4c46-85c5-cb2ac3d2d94b} true 0 -3 center Bitstream Vera Sans 10 3 255 255 255 255 255 255 noborder 1 1 Version: 3 Render: Real Ask: Yes Functions: ioObject Listing: Window WindowBounds: 375 213 361 291 CurrentView: io IOViewEdit: On Options: -b128 -A -s -m167 -R ioView background {43690, 43690, 32639} ioMenu {11, 8} {122, 23} 1 303 "saw,square,triangle" wave ioText {137, 8} {205, 26} label 0.000000 0.00100 "" center "Helvetica" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder <--Select waveform from this menu ioSlider {11, 44} {180, 20} 200.000000 800.000000 520.000000 freq ioText {207, 39} {130, 25} label 0.000000 0.00100 "" left "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Frequency ioButton {11, 71} {180, 40} event 1.000000 "button1" "Generate note" "/" i10 0 5 ioText {196, 69} {148, 44} label 0.000000 0.00100 "" center "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Push this button to generate notes ioText {10, 117} {332, 131} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {0, 0, 0} {39168, 40448, 25600} nobackground noborder ioText {121, 130} {91, 26} label 0.000000 0.00100 "" left "Bitstream Vera Sans" 16 {33536, 16640, 12288} {65280, 65280, 65280} nobackground noborder Reinit ioText {18, 160} {313, 73} label 0.000000 0.00100 "" center "Bitstream Vera Sans" 10 {65280, 65280, 65280} {65280, 65280, 65280} nobackground noborder Using a reinit pass values for vco2 waveform (which is i-rate) are changed. Values for frequency are no longer used with i() so they change whenever the slider changes