-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
00730739true212221230graph1565360189{ec9057d4-b17b-4c85-b694-0dec1a12500a}true0-321.000000001.000000001.000000001.00000000linlintruetruetruetruetruetruetruetabindex902625040{12cab531-987e-41ac-9262-d5f71c064805}true00left
Liberation Sans
168502552182182181.0000000004false252678530{d70336af-31c0-46c6-8288-9113647dfccf}true0-3righttop
Arial
163000255255255false10graph25350570189{23c327bd-bf0d-492b-90dd-e6536e96ae62}true0-354.000000001.000000001.000000001.00000000linlintruetruetruefalsefalsetruetruegraph35560570189{43a72640-7329-4222-abdb-bbd4584d49c0}true0-361.000000001.000000001.000000001.00000000linlinfalsetruetruetruetruetruetruefreq2102555555{e273f498-ec83-4aa1-bc8a-5dbde9a50fcf}true0020.000000001000.00000000743.73000000lincontinuous0.01000000false2451240#4a26001#4a2600truetruefalse1452676430{e0e7e340-f91d-4b1a-83f7-99afd9b06fec}true0-3righttop
Arial
163000255255255false106117440{9084758a-d369-4258-a038-c3887349a499}true0-3lefttop
Arial
283000255255255false10plot137065360189{ccc0ad50-1250-4166-987c-eb32de8a9566}true0-325519330.0054524721{895a45e4-944d-4121-b5ed-d012a62b8893}true0-3lefttop
Arial
113000255255255false103704424721{ec8cdf60-0106-4db3-8ca6-49dc35779522}true0-3lefttop
Liberation Sans
113000255255255false10431030338{9a77618a-96c8-4a63-b6a7-74e9af0b3ee2}true0-3lefttop
Liberation Sans
113000255255255false10554023823{95516290-ec6d-42db-aea9-418260ff1003}true0-3lefttop
Arial
113000255255255false10