-odac /* Graph Widget Graph Widgets can display tables, audio signals and fft analysis. The currently visible table can be changed by sending values on the widget's channel. Positive values change the table by index and negative values change the table by table number. The displayed table can also be changed using the menu on the upper left corner. Graph widgets can also show the spectrum from signals using the dispfft opcode, or time varying signals (a-rate and k-rate) using the display opcode. In spectrum mode, clicking near a peak will detect and display the frequency of the highest peak near the mouse. If @getPeak was set, this value will also be output to the given named channel Keyboard Shortcuts: C: toggle table information (only in table mode) F: freeze graph (only in spectrum mode) G: toggle grid H: help, show a dialog with this information S: toggle selector menu Z: toggle scrollbars +/-: zoom in / out String commands: @set Sets the index graph to be displayed, similar to `outvalue "graphid", index` @find fft @find audio @find table @freeze 1 - freeze the display, 0 - unfreeze @getPeak The peak frequency is output to the given named channel. The peak is output whenever the user clicks on a spectrum graph NB: see Examples/Useful/SpectrumAnalyzer for an example of this feature */ sr = 44100 ksmps = 64 nchnls = 2 0dbfs = 1 gisin1 ftgen 0, 0, 1024, 10, 1 gisin2 ftgen 0, 0, 1024, 10, 1, 0.5, 0.333 gisin3 ftgen 0, 0, 1024, 10, 1, 0, 0.333, 0, 0.25, 0, 0.166 gisqr ftgen 0, 0, 1024, 7, 1, 512, 1, 0, -1, 512, -1 gisaw ftgen 0, 0, 1024, 7, 1, 1024, -1 instr Oscil itables[] fillarray gisin1, gisin2, gisin3, gisqr, gisaw kindex init -1 kindex invalue "tabindex" kindex = limit:k(kindex, 0, lenarray(itables)-1) ktab = itables[kindex] kfreq invalue "freq" asig oscilikt 0.2, kfreq, ktab asig *= 0.1 outch 1, asig, 2, asig dispfft asig, 0.05, 4096 adisp = asig*5 display adisp, 0.01 if timeinstk() == 1 || changed(kindex) == 1 then ; A numeric value sent to the graph widget sets it to display graph ; at that index. In this case, the graph is only enabled for tables, ; so that the index corresponds to the index of the itables array ; outvalue "graph1", kindex ; Another possibility is to the the table number directly via the ; @find command: ; outvalue "graph1", sprintfk("@find table %d", ktab) ; Or, you can set the table directly as negative number: outvalue "graph1", -ktab outvalue "plot1", ktab endif endin instr SetupGraphs ; It is possible to select the desired graph through the @find string command outvalue "graph2", "@find fft asig" outvalue "graph3", "@find audio adisp" ; outvalue "plot1", gisin1 ; To select a table by number: ; outvalue "graph1", sprintf("@find table %d", itabnum) turnoff endin ; If started too early, the table display will fail schedule "Oscil", 0.3, -1 ; setup the display graphs. Notice that we need to schedule this in the ; future since audio and fft graphs start existing when the first ; display is ready, which in the case of fft graphs is after the first ; window has been filled (delay = winsize/sr) and in the case of audio ; signals is the period itself schedule "SetupGraphs", 0.5, 1 f0 3600 0 0 730 739 true 212 221 230 graph1 5 65 360 189 {ec9057d4-b17b-4c85-b694-0dec1a12500a} true 0 -3 2 1.00000000 1.00000000 1.00000000 1.00000000 lin lin true true true true true true true tabindex 90 262 50 40 {12cab531-987e-41ac-9262-d5f71c064805} true 0 0 left Liberation Sans 16 85 0 255 218 218 218 1.00000000 0 4 false 2 5 267 85 30 {d70336af-31c0-46c6-8288-9113647dfccf} true 0 -3 right top Arial 16 3 0 0 0 255 255 255 false 1 0 graph2 5 350 570 189 {23c327bd-bf0d-492b-90dd-e6536e96ae62} true 0 -3 5 4.00000000 1.00000000 1.00000000 1.00000000 lin lin true true true false false true true graph3 5 560 570 189 {43a72640-7329-4222-abdb-bbd4584d49c0} true 0 -3 6 1.00000000 1.00000000 1.00000000 1.00000000 lin lin false true true true true true true freq 210 255 55 55 {e273f498-ec83-4aa1-bc8a-5dbde9a50fcf} true 0 0 20.00000000 1000.00000000 743.73000000 lin continuous 0.01000000 false 245 124 0 #4a2600 1 #4a2600 true true false 145 267 64 30 {e0e7e340-f91d-4b1a-83f7-99afd9b06fec} true 0 -3 right top Arial 16 3 0 0 0 255 255 255 false 1 0 6 1 174 40 {9084758a-d369-4258-a038-c3887349a499} true 0 -3 left top Arial 28 3 0 0 0 255 255 255 false 1 0 plot1 370 65 360 189 {ccc0ad50-1250-4166-987c-eb32de8a9566} true 0 -3 255 193 3 0.00 5 45 247 21 {895a45e4-944d-4121-b5ed-d012a62b8893} true 0 -3 left top Arial 11 3 0 0 0 255 255 255 false 1 0 370 44 247 21 {ec8cdf60-0106-4db3-8ca6-49dc35779522} true 0 -3 left top Liberation Sans 11 3 0 0 0 255 255 255 false 1 0 4 310 303 38 {9a77618a-96c8-4a63-b6a7-74e9af0b3ee2} true 0 -3 left top Liberation Sans 11 3 0 0 0 255 255 255 false 1 0 5 540 238 23 {95516290-ec6d-42db-aea9-418260ff1003} true 0 -3 left top Arial 11 3 0 0 0 255 255 255 false 1 0