Returns the number of iterations corresponding to a given point of complex plane by applying the Mandelbrot set formula.
Syntax
kiter,koutrigmandelktrig,kx,ky,kmaxIter
Performance
kiter - number of iterations
koutrig - output trigger signal
ktrig - input trigger signal
kx, ky - coordinates of a given point belonging to the complex plane
kmaxIter - maximum iterations allowed
mandel is an opcode that allows the use of the Mandelbrot set formula to generate an output that can be applied to any musical (or non-musical) parameter. It has two output arguments: kiter, that contains the iteration number of a given point, and koutrig, that generates a trigger 'bang' each time kiter changes. A new number of iterations is evaluated only when ktrig is set to a non-zero value. The coordinates of the complex plane are set in kx and ky, while kmaxIter contains the maximum number of iterations. Output values, which are integer numbers, can be mapped in any sorts of ways by the composer.
Examples
Here is an example of the mandel opcode. It uses the file mandel.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac;;;realtime audio out;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o mandel.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; By Stefano Cucchi 2021sr=44100ksmps=32nchnls=20dbfs=1instr1; FM instrumentksigoscil1,4; create a trigger signalktrigtriggerksig,0,2kxlinsegp8,p3,p9; in the range -1 1kylinsegp6,p3,p7; in the range -1 1kmaxIterlinsegp4,p3*0.5,p5,p3*0.5,p4kiter,koutrigmandelktrig,kx,ky,kmaxIterprintks2"maximum iterations = %d\n",kiter; show themasigfoscili0.3,1,440,kiter,10,1; use number of iterations to modulateoutsasig,asigendininstr2; grain instrumentksigoscil1,100; create a trigger signalktrigtriggerksig,0,2kxlinsegp8,p3,p9; in the range -1 1kylinsegp6,p3,p7; in the range -1 1kmaxIterlinsegp4,p3*0.5,p5,p3*0.5,p4kiter,koutrigmandelktrig,kx,ky,kmaxIterprintks2"maximum iterations = %d\n",kiter; show theminsnd=1ibasfrq=44100/ftlen(insnd); use original sample rate of insnd file kamp=.8kpitch=1kdens=kiterkaoffline0,p3,.1kpoff=0kgdur=.002imaxgdur=.5asiggrainkamp,kpitch,kdens,kaoff,kpoff,kgdur,insnd,1,imaxgdur,0.0outsasig,asigendin</CsInstruments><CsScore>f104096101101; sinoid wave (instr 1)f50512202; Hanning window (instr 2); start end X1 X2 Y1 Y2 i10101102000-11-11; start end X1 X2 Y1 Y2 i21110120101-10e</CsScore></CsoundSynthesizer>