xscanu
Prev | Deprecated Orchestra Opcodes and GEN Routines | Next

## xscanu

xscanu — Compute the waveform and the wavetable for use in scanned synthesis.

## Description

Plugin opcode in scansyn.

Experimental version of scanu. Allows much larger matrices and is faster and smaller but removes some (unused?) flexibility. If liked, it will replace the older opcode as it is syntax compatible but extended.

## Syntax

    xscanu init, irate, ifndisplace, ifnmass, ifnmatrix, ifncentr, ifndamp, kmass, \
          kmtrxstiff, kcentr, kdamp, ileft, iright, kpos, kdisplace, ain, idisp, id

## Initialization

init -- the initial position of the masses. If this is a negative number, then the absolute of init signifies the table to use as a hammer shape. If init > 0, the length of it should be the same as the intended mass number, otherwise it can be anything.

irate -- update rate.

ifndisplace -- the ftable that contains the initial velocity for each mass. It should have the same size as the intended mass number.

ifnmass -- ftable that contains the mass of each mass. It should have the same size as the intended mass number.

ifnmatrix --

- either an ftable that contains the spring stiffness of each connection. It should have the same size as the square of the intended mass number. The data ordering is a row after row dump of the connection matrix of the system.

- or a string giving the name of a file in the MATRIX format

ifncentr -- ftable that contains the centering force of each mass. It should have the same size as the intended mass number.

ifndamp -- the ftable that contains the damping factor of each mass. It should have the same size as the intended mass number.

ileft -- If init < 0, the position of the left hammer (ileft = 0 is hit at leftmost, ileft = 1 is hit at rightmost).

iright -- If init < 0, the position of the right hammer (iright = 0 is hit at leftmost, iright = 1 is hit at rightmost).

idisp -- If 0, no display of the masses is provided.

id -- If positive, the ID of the opcode. This will be used to point the scanning opcode to the proper waveform maker. If this value is negative, the absolute of this value is the wavetable on which to write the waveshape. That wavetable can be used later from an other opcode to generate sound. The initial contents of this table will be destroyed.

## Performance

kmass -- scales the masses

kmtrxstiff -- scales the spring stiffness

kcentr -- scales the centering force

kdamp -- scales the damping

kpos -- position of an active hammer along the string (kpos = 0 is leftmost, kpos = 1 is rightmost). The shape of the hammer is determined by init and the power it pushes with is kstrngth.

kdisplace -- power that the active hammer uses

ain -- audio input that adds to the velocity of the masses. Amplitude should not be too great.

## Matrix Format

The xscanu matrix format is a list of connections, one per line linking point x to point y. There is no weight given to the link; it is assumed to be unity. The list is preceded by the line <MATRIX> and ends with a </MATRIX> line

For example, a circular string of 8 would be coded as

    <MATRIX>
    0 1
    1 0
    1 2
    2 1
    2 3
    3 2
    3 4
    4 3
    4 5
    5 4
    5 6
    6 5
    6 7
    7 6
    0 7
    </MATRIX>

To avoid confusion with other matrix formats, it is best to save this matrix format file using the extension file.XmatrxT.

## Examples

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

Example 1343. Example of the xscanu opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac  --limiter=0.95  ;;;realtime audio out & limit loud sounds
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o xscanu.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1
    ;the matrices can be found in /manual/examples

    instr 1	; Plain scanned syntnesis
    	; Note Also that I am using quadratic interpolation on these.
      a0	=           0
    	xscanu      1, .01, 6, 2, "128,8-grid.XmatrxT", 4, 5, 2, .1, .1, -.01, .1, .5, 0, 0, a0, 0, 0
      a1	xscans      .5, cpspch(p4), 333, 0, p6			; NOTE LEFT RIGHT TRAJECTORY (f333) IS CLEAN!
      a1	dcblock a1
    	outs        a1, a1
    endin

    instr 2	; Scan synthesis with audio injection and dual scan paths

      a0  diskin2       "fox.wav",1,0,1
     ; a0,aa	    ins
      a0	=           a0/.8
    	xscanu      1, .01, 6, 2, "128,8-torus.XmatrxT", 14, 5, 2, .01, .05, -.05, .1, .5, 0, 0, a0, 0, 0
      a1	xscans      .3, cpspch(7.00), 333, 0, 2			; NOTE LEFT RIGHT TRAJECTORY (f333) IS CLEAN!
      a2	xscans      .3, cpspch(6.00), 77, 0, 2
      a1	dcblock a1
      a2	dcblock a2
    	outs        a1*.5,a2*.1
    endin

    </CsInstruments>
    <CsScore>

    ; Initial condition
    ;f1 0 16 7 0 8 1 8 0
    f1 0 128 7 0 64 1 64 0

    ; Masses
    f2 0 128 -7 1 128 1

    ; Centering force
    f4  0 128 -7 0 128 2
    f14 0 128 -7 2 64 0 64 2

    ; Damping
    f5 0 128 -7 1 128 1

    ; Initial velocity
    f6 0 128 -7 -.0 128 .0

    ; Trajectories
    f7 0 128 -5 .001 128 128
    f77 0 128 -23 "128-spiral-8,16,128,2,1over2.traj"
    f777 0 128 -23 "128,8-torus.XmatrxT"

    ; Spring matrices
    f3 0 128 -23 "128-string.XmatrxT"
    f33 0 128 -23 "128-stringcircular.XmatrxT"
    f333  0 128 -23 "128-left_right.XmatrxT"
    f3333 0 128 -23 "128,8-torus.XmatrxT"
    f33333 0 128 -23 "128,8-cylinder.XmatrxT"
    f333333 0 128 -23 "128,8-grid.XmatrxT"

    ; Sine
    f9 0 1024 10 1

    ; Pitch tables
    f100 0 1024 -7 +3 128 +3 128 -2 128 -2 128 +0 128 +0 128 -4 128 -4 128 +3
    f101 0 1024 -7 -2 128 -2 128 -2 128 -2 128 -5 128 -5 128 -4 128 -4 128 -2
    f102 0 1024 -7 +3 128 +3 128 +2 128 +2 128 +0 128 +0 128 +0 128 +0 128 +3
    f103 0 1024 -7 +7 128 +7 128 +5 128 +5 128 +3 128 +3 128 +3 128 +3 128 +7

    ; Amplitude tables
    f200 0 1024 7 1 128 0 128 0 127 0 1 1 128 0 128 0 127 0 1 1 128 0 127 0 1 1
    f201 0 1024 7 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1
    f202 0 1024 7 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1
    f203 0 1024 7 1 1024 0
    ;;f204 0 1024 7 1 512 0 511 0 1 1

    ;-----------------------

    ; Note list
    i1 0 10 6.00 1  2
    s
    i2 0 15
    e
    </CsScore>
    </CsoundSynthesizer>

For similar examples, see the documentation on scans.

## See Also

More information on Scanned Synthesis (as well as several other matrices) is available on the Scanned Synthesis page at cSounds.com.

Also an article on these opcodes: http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html , written by Steven Yi

scanu, xscans

## Credits

Written by John ffitch.

New in version 4.20

Prev | Up | Next
xscans | Home | Deprecated Gen Routines