|
| 1 | +# chuap |
| 2 | + |
| 3 | +## Abstract |
| 4 | + |
| 5 | +Simulates Chua's oscillator |
| 6 | + |
| 7 | +## Description |
| 8 | + |
| 9 | +`chuap` Simulates Chua's oscillator, an LRC oscillator with an active resistor, proved |
| 10 | +capable of bifurcation and chaotic attractors, with k-rate control of circuit elements. |
| 11 | + |
| 12 | +The oscillator can be driven into period bifurcation, and thus to chaos, because of the |
| 13 | +nonlinear response of the active resistor. |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +The circuit is described by a set of three ordinary differential equations called Chua's equations: |
| 18 | + |
| 19 | + |
| 20 | + dI3 R0 1 |
| 21 | + --- = - -- I3 - - V2 |
| 22 | + dt L L |
| 23 | + |
| 24 | + dV2 1 G |
| 25 | + --- = -- I3 - -- (V2 - V1) |
| 26 | + dt C2 C2 |
| 27 | + |
| 28 | + dV1 G 1 |
| 29 | + --- = -- (V2 - V1) - -- f(V1) |
| 30 | + dt C1 C1 |
| 31 | + |
| 32 | + |
| 33 | + where f() is a piecewise discontinuity simulating the active resistor: |
| 34 | + |
| 35 | + |
| 36 | + f(V1) = Gb V1 + - (Ga - Gb)(|V1 + E| - |V1 - E|) |
| 37 | + |
| 38 | + |
| 39 | +A solution of these equations `(I3,V2,V1)(t)` starting from an initial state `(I3,V2,V1)(0)` is called a |
| 40 | +trajectory of Chua's oscillator. The Csound implementation is a difference equation simulation of |
| 41 | +Chua's oscillator with Runge-Kutta integration. |
| 42 | + |
| 43 | + |
| 44 | +!!! note |
| 45 | + |
| 46 | + This algorithm uses internal non linear feedback loops which causes audio result to depend on |
| 47 | + the orchestra sampling rate. For example, if you develop a project with sr=48000Hz and if you |
| 48 | + want to produce an audio CD from it, you should record a file with sr=48000Hz and then downsample |
| 49 | + the file to 44100Hz |
| 50 | + |
| 51 | +!!! warning |
| 52 | + |
| 53 | + Be careful! Some sets of parameters will produce amplitude spikes or positive feedback that could |
| 54 | + damage your speakers. |
| 55 | + |
| 56 | + |
| 57 | +--------------------------- |
| 58 | + |
| 59 | +## Syntax |
| 60 | + |
| 61 | + |
| 62 | +```csound |
| 63 | +aI3, aV2, aV1 chuap kL, kR0, kC2, kG, kGa, kGb, kE, kC1, iI3, iV2, iV1, ktime_step |
| 64 | +``` |
| 65 | + |
| 66 | +## Arguments |
| 67 | + |
| 68 | + |
| 69 | +* **iI3**: Initial current at G |
| 70 | +* **iV2**: Initial voltage at C2 |
| 71 | +* **iV1**: Initial voltage at C1 |
| 72 | +* **kR0**: Resistor R0 (R0 in the diagram) |
| 73 | +* **kC1**: Capacitor C1 |
| 74 | +* **kL**: Inductor L (L1 in the diagram) |
| 75 | +* **kC2**: Capacitor C2 |
| 76 | +* **kG**: Resistor G (part of the active resistor, R1 in the diagram). The G parameter |
| 77 | + is the time step, which is needed to get the same slope of the piecewise discontinuity |
| 78 | + from Ga and Gb for all sampling rates. |
| 79 | +* **kGa**: Resistor V (nonlinearity term of the active resistor, one of the R2's in the diagram) |
| 80 | +* **kGb**: Resistor V (nonlinearity term of the active resistor, one of the R2's in the diagram) |
| 81 | +* **kE**: Size of the piecewise discontinuity simulating the active resistor |
| 82 | +* **ktime_step** Delta time in the difference equation, can be used to more or less control pitch. |
| 83 | + |
| 84 | +## Output |
| 85 | + |
| 86 | +* **aI3**: ?? |
| 87 | +* **aV2**: ?? |
| 88 | +* **aV1**: ?? |
| 89 | + |
| 90 | + |
| 91 | +## Execution Time |
| 92 | + |
| 93 | +* Performance |
| 94 | + |
| 95 | +## Examples |
| 96 | + |
| 97 | + |
| 98 | +```csound |
| 99 | +<CsoundSynthesizer> |
| 100 | +<CsOptions> |
| 101 | +; Select audio/midi flags here according to platform |
| 102 | +-odac ;;;RT audio out |
| 103 | +;-iadc ;;;uncomment -iadc if RT audio input is needed too |
| 104 | +; For Non-realtime ouput leave only the line below: |
| 105 | +; -o chuap.wav -W ;;; for file output any platform |
| 106 | +</CsOptions> |
| 107 | +<CsInstruments> |
| 108 | +
|
| 109 | +sr = 44100 |
| 110 | +ksmps = 32 |
| 111 | +nchnls = 2 |
| 112 | +0dbfs = 1 |
| 113 | +
|
| 114 | +gibuzztable ftgen 1, 0, 16384, 10, 1 |
| 115 | +
|
| 116 | +instr 1 |
| 117 | + |
| 118 | + istep_size = p4 |
| 119 | + iL = p5 |
| 120 | + iR0 = p6 |
| 121 | + iC2 = p7 |
| 122 | + iG = p8 |
| 123 | + iGa = p9 |
| 124 | + iGb = p10 |
| 125 | + iE = p11 |
| 126 | + iC1 = p12 |
| 127 | + iI3 = p13 |
| 128 | + iV2 = p14 |
| 129 | + iV1 = p15 |
| 130 | +
|
| 131 | + iattack = 0.02 |
| 132 | + isustain = p3 |
| 133 | + irelease = 0.02 |
| 134 | + p3 = iattack + isustain + irelease |
| 135 | + iscale = 1.0 |
| 136 | + adamping linseg 0.0, iattack, iscale, isustain, iscale, irelease, 0.0 |
| 137 | + aguide buzz 0.5, 440, sr/440, gibuzztable |
| 138 | + aI3, aV2, aV1 chuap iL, iR0, iC2, iG, iGa, iGb, iE, iC1, iI3, iV2, iV1, istep_size |
| 139 | + asignal balance aV2, aguide |
| 140 | +
|
| 141 | + outs asignal*adamping, asignal*adamping |
| 142 | +endin |
| 143 | +
|
| 144 | +</CsInstruments> |
| 145 | +<CsScore> |
| 146 | +; Adapted from ABC++ MATLAB example data. |
| 147 | +// time_step kL kR0 kC2 kG kGa kGb kE kC1 iI3 iV2 iV1 |
| 148 | +; torus attractor ( gallery of attractors ) |
| 149 | +i 1 0 20 .1 -0.00707925 0.00001647 100 1 -.99955324 -1.00028375 1 -.00222159 -2.36201596260071 3.08917625807226e-03 3.87075614929199 |
| 150 | +; heteroclinic orbit |
| 151 | +i 1 + 20 .425 1.3506168 0 -4.50746268737 -1 2.4924 .93 1 1 -22.28662665 .009506608 -22.2861576 |
| 152 | +; periodic attractor (torus breakdown route) |
| 153 | +i 1 + 20 .05 0.00667 0.000651 10 -1 .856 1.1 1 .06 -20.200590133667 .172539323568344 -4.07686233520508 |
| 154 | +; torus attractor (torus breakdown route)' |
| 155 | +i 1 + 20 0.05 0.00667 0.000651 10 -1 0.856 1.1 1 0.1 21.12496758 0.03001749 0.515828669 |
| 156 | +
|
| 157 | +</CsScore> |
| 158 | +</CsoundSynthesizer> |
| 159 | +``` |
| 160 | + |
| 161 | +## See also |
| 162 | + |
| 163 | +* [crackle](crackle.md) |
| 164 | +* [standardchaos](standardchaos.md) |
| 165 | +* [durst2](https://csound.com/docs/manual/dust2.html) |
| 166 | + |
| 167 | + |
| 168 | +## Credits |
| 169 | + |
| 170 | +* Author of MATLAB simulation: James Patrick McEvoy MATLAB Adventures in Bifurcations and Chaos (ABC++) |
| 171 | +* Author of Csound port: Michael Gogins, michael dot gogins at gmail dot com |
| 172 | +* New in Csound version 5.09 |
0 commit comments