--midi-key-cps=4 --midi-velocity=5 sr = 44100 ksmps = 128 nchnls = 2 0dbfs = 1 ; Make sure CsOptions are not ignored in the preferences, ; Otherwise Realtime MIDI input will not work. instr 1 ; Simple two operator FM synth ifreq = p4 ; From p4 in the score or cps from MIDI note kmodfactor invalue "modfactor" kmodindex invalue "modindex" ; Mod envelope kmodatt invalue "modatt" kmoddec invalue "moddec" kmodsus invalue "modsus" kmodrel invalue "modrel" amodenv madsr i(kmodatt), i(kmoddec), i(kmodsus), i(kmodrel) kmodfreq = kmodfactor*ifreq ; Index = Am * fc/fm kmodamp = kmodindex*kmodfactor*ifreq ; Modulator 2 amod poscil amodenv*kmodamp, kmodfreq, 1 ;Carrier amp envelope kaatt invalue "aatt" kadec invalue "adec" kasus invalue "asus" karel invalue "arel" aenv madsr i(kaatt), i(kadec), i(kasus), i(karel) ; Carrier aout poscil aenv, ifreq+amod, 1 ; Output klevel invalue "level" outvalue "index", kmodindex outs aout*klevel, aout*klevel endin instr 98 ; Trigger instrument from button kfreq invalue "freq" event "i", 1, 0, p3, kfreq turnoff endin instr 99 ;Always on instrument ; This instrument updates the modulator's frequencies ; which depend on the base frequency and the freq. ; factors. kfreq invalue "freq" kmodfactor invalue "modfactor" outvalue "mod1freq", kfreq*kmodfactor ; Display spectrum aoutl, aoutr monitor dispfft aoutl, 1/18, 4096 ;Turn on or off according to checkbox kon invalue "on" ktrig changed kon if ktrig == 1 then if kon == 1 then event "i", 1, 0, -1, kfreq elseif kon == 0 then turnoff2 1, 0, 1 endif endif endin instr setup outvalue "graph1", "@find fft aoutl" turnoff endin f 1 0 4096 10 1 i 99 0 3600 i "setup" 0.5 0 e 0 0 707 667 true 150 162 137 303 57 124 189 {d24a6567-245e-4b96-a96c-265154ea2763} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 border 1 1 aatt 317 78 20 100 {52285914-cd8e-4320-83ed-740bb6e00cc5} true 0 -3 0.00000100 1.00000000 0.05000100 lin continuous -1.00000000 false adec 344 78 20 100 {ae9a1fd4-3a2d-455e-8cf9-0bee3b33cf35} true 0 -3 0.00000100 1.00000000 0.11000100 lin continuous -1.00000000 false asus 369 78 20 100 {3f6778f4-f803-452b-8ad0-0c9d5c4cbd5d} true 0 -3 0.00000000 1.00000000 0.68000000 lin continuous -1.00000000 false arel 396 78 20 100 {ca4f7523-9201-4206-b2b6-a072148c3a2c} true 0 -3 0.00000100 1.00000000 0.46000100 lin continuous -1.00000000 false 319 177 18 24 {bcf32e26-2bf7-4ad4-8a7b-69ef032ace4a} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 347 177 18 24 {d5344ca1-d562-4dd8-a4fe-8dd5733a623e} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 372 177 18 24 {73d35ddb-baba-41e2-bf82-d6b91c90cf99} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 397 176 18 24 {a656444c-2c8f-4ec7-ba9d-28908c0c930b} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 level 367 196 56 50 {72278ecf-6354-4450-ac8e-0dd2e1ae75a8} true 0 -3 0.00000000 1.00000000 0.21212100 lin continuous 0.01000000 false 245 124 0 #512900 0 #512900 true true false 323 211 45 26 {28be316d-00c7-4ce9-aa38-795d5e410491} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 326 255 93 28 {8fd7940b-e8ae-4dcc-ad46-a1122c8304dc} true 0 -3 event 1.00000000 Note / i98 0 3 false false false 10 freq 326 288 48 49 {b570746e-7bce-4da8-8d2c-484962ef3051} true 0 -3 110.00000000 880.00000000 312.22222200 lin continuous 0.01000000 false 245 124 0 #512900 0 #512900 true true false 360 336 35 25 {440ae8a0-c22e-4bc6-90b6-b38735055e8a} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 freq 313 341 49 23 {b7c10b60-531a-4d72-9e4b-5481a69f0863} true 0 -3 right Helvetica 10 0 0 0 255 255 255 312.20000000 0.10000000 -999999999999.00000000 99999999999999.00000000 noborder 1 0 false 7 3 421 46 {7d867dcb-f254-41e1-9688-ac4493acaffa} true 0 -3 center center Bitstream Vera Sans 22 3 255 255 255 85 85 0 false 1 0 7 57 291 189 {997d3d17-6315-467b-87e9-f90019528715} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 border 1 1 modatt 18 91 20 100 {92b90402-b30e-4fe4-89cf-1d190c50ac1f} true 0 -3 0.00000100 1.00000000 0.22000100 lin continuous -1.00000000 false moddec 45 91 20 100 {154d0574-233c-4e7e-99d0-40f38e808105} true 0 -3 0.00000100 1.00000000 0.60000000 lin continuous -1.00000000 false modsus 70 91 20 100 {43b9c7cb-bb3e-4ac4-bf07-f36f2f672969} true 0 -3 0.00000000 1.00000000 0.62000000 lin continuous -1.00000000 false modrel 97 91 20 100 {bf98c730-c083-47f3-81b9-1f6c760589ab} true 0 -3 0.00000100 1.00000000 0.46000054 lin continuous -1.00000000 false 20 191 18 24 {226aa66a-4728-443b-943b-11fd61f3d619} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 48 191 18 24 {0705b2ef-d2e0-4e2f-9849-12a2e972b3a7} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 73 191 18 24 {dac7bfb6-8958-4e09-9e92-a120e30d88f0} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 98 190 18 24 {75f53fde-54c5-44de-a089-5b1a603e64ff} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 modfactor 209 71 78 25 {02d4392c-1838-481c-b42d-3fc69183fff6} true 0 0 left Noto Sans 14 0 0 0 201 221 240 0.01000000 -1e+12 1e+12 false 3.14 127 72 82 24 {85f65a4a-d052-4eb3-bb50-5e8c38687862} true 0 -3 left top Bitstream Vera Sans 10 3 0 0 0 255 255 255 noborder 1 0 127 101 82 25 {3fde78a2-f109-4353-a6cf-7cb11b6785d4} true 0 -3 left top Bitstream Vera Sans 10 3 0 0 0 255 255 255 noborder 1 0 mod1freq 207 101 81 26 {96ac1dfc-84fa-4ea8-a8c2-c9a0cf1cae9a} true 0 -3 left top Bitstream Vera Sans 10 3 0 0 0 255 255 255 noborder 1 0 modindex 136 151 52 51 {fec82d6b-f6d2-4998-b80a-aa8767afe151} true 0 -3 0.00000000 5.00000000 1.88500000 lin continuous 0.01000000 false 245 124 0 #512900 0 #512900 true true false 124 201 80 25 {5abc7fa0-6696-4ce5-a5ba-a57ab880c052} true 0 -3 center top Bitstream Vera Sans 10 3 0 0 0 255 255 255 noborder 1 0 6 254 312 107 {ac1cafe0-a2b2-40e3-9eb7-ba9181805e25} true 0 -3 1.00000000 scope 8.00000000 1.00000000 1.00000000 1.00000000 0.00000000 NoTrigger graph1 7 367 700 300 {0e18b8a6-dd3a-493d-8a28-89046c1e1d66} true 0 -3 1 2.00000000 1.00000000 1.00000000 1.00000000 lin lin false true false false false true true index 187 162 80 25 {44744181-1d69-4efd-b3f4-10bf29cbb42c} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 on 378 292 20 20 {2bd0732f-6957-498c-8422-3ef8e269f5fe} true 0 -3 false 394 291 28 24 {c76f669d-1d21-4fb7-bab3-304ad6fb12ef} true 0 -3 left top DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 0 i 1 0 1 440