FLexecButton

FLexecButton —
A FLTK widget opcode that creates a button that executes a command.

Description

A FLTK widget opcode that creates a button that executes a command. Useful
for opening up HTML documentation as About text or to start a separate
program from an FLTK widget interface.

Warning

Because any command can be executed, the user is advised to be very
careful when using this opcode and when running orchestras by others
using this opcode.

Syntax

ihandle FLexecButton "command", iwidth, iheight, ix, iy

Initialization

ihandle
-- a handle value (an integer number) that unequivocally references a
corresponding widget. This is used by other opcodes that modify a widget's
properties (see
Modifying FLTK Widget Appearance). It is automatically output by FLexecButton.

“command” -- a double-quoted string containing a command to execute.

Notice that with FLexecButton, the default text for the button is "About" and it is necessary to call the FLsetText
opcode to change the text of the button.

iwidth -- width of widget.

iheight -- height of widget.

ix -- horizontal position of upper left corner of the valuator, relative to the upper left corner of corresponding window (expressed in pixels).

iy -- vertical position of upper left corner of the valuator, relative to the upper left corner of corresponding window (expressed in pixels).

Examples

Here is an example of the FLexecButton opcode. It uses the file FLexecButton.csd.

<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No display
-odac -iadc -d ;;;RT audio I/O</CsOptions><CsInstruments>sr=44100ksmps=10nchnls=1; Example by Jonathan Murphy 2007;;; reset amplitude range0dbfs=1;;; set the base colour for the panelFLcolor100,0,200;;; define the panelFLpanel"FLexecButton",250,100,0,0;;; sliders to control time stretch and pitch
gkstr, gistretchFLslider"Time",0.5,1.5,0,6,-1,10,60,150,20
gkpch, gipitchFLslider"Pitch",0.5,1.5,0,6,-1,10,60,200,20;;; set FLexecButton colourFLcolor255,255,0;;; when this button is pressed, fourier analysis is performed on the file;;; "beats.wav", producing the analysis file "beats.pvx"
gipvocFLexecButton"csound -U pvanal beats.wav beats.pvx",60,20,20,20;;; set FLexecButton textFLsetText"PVOC", gipvoc;;; when this button is pressed, instr 10000 is called, exiting;;; Csound immediately;;; cancel previous colourFLcolor-1;;; set colour for kill buttonFLcolor255,0,0
gkkill, gikillFLbutton"X",1,1,1,20,20,100,20,0,10000,0,0.1;;; cancel previous colourFLcolor-1;;; set colour for play/stop and pause buttonsFLcolor0,200,0;;; pause and play/stop buttons
gkpause, gipauseFLbutton"@||",1,0,2,40,20,20,60,-1
gkplay, giplayFLbutton"@|>",1,0,2,40,20,80,60,-1;;; end the panelFLpanelEnd;;; set initial values for time stretch and pitchFLsetVal_i1, gistretchFLsetVal_i1, gipitch;;; run the panelFLruninstr1; trigger play/stop;;; is the play/stop button on or off?;;; either way we need to trigger something,;;; so we can't just use the value of gkplay
kontrigger gkplay,0,0
kofftrigger gkplay,1,1;;; if on, start instr 2schedkwhen kon,-1,-1,2,0,-1;;; if off, stop instr 2schedkwhen koff,-1,-1,-2,0,-1endininstr2;;; paused or playing?if(gkpause==1)kgotopausekgotostartpause:;;; if the pause button is on, skip sound productionkgotoendstart:;;; get the length of the analysis file in seconds
ilenfilelen"beats.pvx";;; determine base frequency of playback
icps=1/ilen;;; create a table over the length of the file
itptftgen0,0,513,-7,0,512, ilen;;; phasor for time control
kphsphasor icps* gkstr;;; use phasor as index into table
kndx= kphs*512;;; read table
ktpttablei kndx, itpt;;; use value from table as time pointer into filefsig1pvsfread ktpt,"beats.pvx";;; change playback pitchfsig2pvscalefsig1, gkpch;;; resynthesize
aoutpvsynthfsig2;;; envelope to avoid clicks and clipping
aenvlinsegr0,0.3,0.75,0.1,0
aout= aout* aenvout aoutend:endininstr10000; killexitnowendin</CsInstruments><CsScore>i1010000e</CsScore></CsoundSynthesizer>