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
375213361291true170170127wave11812223{a391e289-ce5a-454b-9817-083317d177d8}true0-3saw0square1triangle21false137820526{ae683ee8-7638-47e1-8b00-bb719111dd7c}true0-3center
Helvetica
103255255255323232noborder11freq114418020{0aada694-ff37-4a9b-a312-5e9fec7b6e6a}true0-3200.00000000800.00000000520.00000000lincontinuous-1.00000000false2073913025{f4ca4244-ba74-4152-940e-d6b763ed5666}true0-3left
Bitstream Vera Sans
103255255255255255255noborder11button1117118040{eb1f02f6-2cb9-419c-8ae6-ee9b3a8aa079}true0-3event1.00000000Generate note/i10 0 5falsefalse1966914844{72a619e9-5162-49f8-bc95-498c21af9846}true0-3center
Bitstream Vera Sans
103255255255255255255noborder1110117332131{58f8a5b4-2172-4465-bd99-c96814d417d8}true0-3left
DejaVu Sans
103000153158100noborder111211309126{f2f1ffb7-e499-450f-ac22-a2d9d7c3cae7}true0-3left
Bitstream Vera Sans
1631316548255255255noborder111816031373{94d46c4e-b4b7-4c46-85c5-cb2ac3d2d94b}true0-3center
Bitstream Vera Sans
103255255255255255255noborder11
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