.. _complexDoc: .. index:: single: complex ============= Complex Block ============= Declares a **complex block** or a **switch block bundle** using the keyword ``switch``. * Declaration_ * `Ports Table`_ * Description_ * `Code Examples`_ .. figure:: Images/complexBlock.png :scale: 100% :alt: Complex Block :align: center ---- Declaration =========== :: #complex block complex LABEL { default: [ 0.0, 0.0 ] rate: AudioRate reset: MasterReset meta: none } #switch block bundle complex LABEL [SIZE] { default: [ 0.0, 0.0 ] | [ [ 0.0, 0.0 ], ... ] rate: AudioRate reset: MasterReset meta: none } **LABEL** :definition: the label of the block **SIZE** :definition: the size of the block bundle :type: constant integer port (CIP) ---- Ports Table =========== Table here ---- Description =========== **DESCRIPTION** ---- Code Examples ============= A complex signal :: constant Real { value: 1 meta: 'Real part of complex block C' } constant Imag { value: 1 meta: 'Imaginary part of complex block C' } complex Complex { default: [ Real , Imag ] rate: AudioRate reset: MasterReset meta: 'A complex number in Stream' } Shorthand declaration of complex signals :: # Shorthand notation complex C {} # Shorthand setter notation # C must be declared as a complex block [ Real, Imag ] >> C; Real >> SetPort ( index: 1) >> C; Imag >> SetPort ( index: 2) >> C; C >> GetPort ( index: 1) >> Real; C >> GetPort ( index: 2) >> Imag; # Shorthand getter notation C >> CxReal () >> Real; C >> CxImag () >> Imag; # Properties C >> CxMagnitude () >> Magnitude; C >> CxPhase () >> Phase; Bundled complex signals :: # complex bundle complex ComplexBundle [2] { default: [[R1,I1], [R2,I2]] rate: AudioRate reset: MasterReset meta: 'Bundle of two complex numbers' } ComplexBundle[1] >> CxReal () >> R1; ComplexBundle[1] >> CxImag () >> I1; ComplexBundle[2] >> CxReal () >> R2; ComplexBundle[2] >> CxImag () >> I2; Arithmetic operations on complex signals: :: # Arithmetic Operations [C1,C2] >> CxAdd () >> C3; [C1,C2] >> CxMultiply () >> C3;