scanu2

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

Description

Plugin opcode in scansyn.

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

Syntax

scanu2 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. If init is not an integer the initial state is white noise with the fractional part being a scaling..

irate -- the amount of time between successive updates of the mass state. Kind of like the sample period of the system. If the number is big, the string will update at a slow rate showing little timbral variability; otherwise it will change rapidly resulting in a more dynamic sound.

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 -- 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.

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 positive pluck in the range 0 to 1.

iright -- If init < 0, the position of the negative pluck in the range 0 to 1.

If ileft is the same as iright a single positive pluck is used as initial state.

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. Note that larger numbers slow the evolution of the vibration, which is the reciprocal of the coresponding parameter in scanu.

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 scanu2 matrix format is a binary list of connections. There is no weight given to the link; it is assumed to be unity.

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

0
1
0
0
1
0
1
0
0
1
0
1
0
0
1
0
        

Note: to avoid confusion with other matrix formats, it is best to save this matrix format file using the extension file.matrxB.

Examples

Here is an example of the scanu2 opcode. It uses the files Play scanu2.csd

Example 938. Example of the scanu2 opcode.

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

<CsoundSynthesizer>

<CsOptions>

</CsOptions>

<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 1

instr scan
a0 init 0

irate = .01

kpos line 0, p3, 128
;kpos randh abs(128), 3

; scanu init, irate, ifndisplace, ifnmass, ifnmatrix, ifncentr, ifndamp, kmass,
;       kmtrxstiff, kcentr, kdamp, ileft, iright, kpos, kdisplace, ain, idisp, id
scanu2 1, irate, 6, 2, 3, 4, 5, 2, 9, .01, .01, .1, .9, 0, 0, a0, 1, 2

;ar scans kamp, kfreq, ifntraj, id
a1 scans ampdb(p4), cpspch(p5), 7, 2
out a1
endin

</CsInstruments>
<CsScore>
; Initial displacement condition
;f1 0 128 -7 0 64 1 64 0 ; ramp
f1 0 128 10 1 ; sine hammer
;f1 0 128 -7 0 28 0 2 1 2 0 96 0 ; a pluck that is 10 points wide on the surface

; Masses
f2 0 128 -7 1 128 1

; Spring matrices
f3 0 16384 -23 "string-128.matrxB"

; Centering force
f4 0 128 -7 1 128 1 ; uniform initial centering
;f4 0 128 -7 .001 128 1 ; ramped centering

; Damping
f5 0 128 -7 1 128 1 ; uniform damping
;f5 0 128 -7 .1 128 1 ; ramped damping

; Initial velocity - (displacement, vel, and acceleration
; Acceleration is from stiffness matrix pos effect - increases acceleration
;

f6 0 128 -7 .01 128 .01 ; uniform initial velocity

; Trajectories
f7 0 128 -5 .001 128 128

i"scan" 2 12 86 7.00
i"scan" 14 2 86 5.00
i"scan" 16 2 86 6.00
i"scan" 18 2 86 8.00
i"scan" 20 2 98 10.00

e

</CsScore>
</CsoundSynthesizer>

See Also

scanu

Credits

Author: John ffitch
May 2021

New in Csound version 6.16