GEN44

GEN44 — Generates a stiffness (connection) matrix for use in scanu/scanu2.

Description

Generates a stiffness matrix from a text file of triples numbers.

Syntax

f # time size -44  "filename"
f # time size -44  num

Performance

The file named in version 1 or the file stiff.num in the second case is read to create the matrix.

Matrix Format

The first line of the file should be <MATRIX size=integer> and it creates a square matrix of the indicated size. This is followed by lines of two or three numbers, the first two denoting a connection from the first to the second. The third number is a weight; a weight of 2 is like having two links so more information gets distributed, while a zero weight means no link. If this third number is omitted it is taken as value 1. The list is terminated by a </MATRIX> line or end of file.

Example of this matrix format:

<MATRIX size=16>
1 2  2
2 3  1
3 4  3
4 5  1
5 6  4
6 7  1
7 8  5
8 9  6
9 10  7
10 11 6
11 12 5
12 13 4
13 14 3
14 15 2
15 16 1
16 1  9
14 13 2
10 3  6
6 4  2
2 14  7
</MATRIX>
        

can be given as zero in which case a size*size table is created. If the size in the gen statememt is too small for the matrix then space is re-allocated to the required size.

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

Examples

Here is an example of the GEN44 generator. It uses the file gen44.csd.

Example 1336. Example of the GEN44 generator.

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

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

instr scan

a0 init 0

irate = .01

kmass line 2,p3,5
kstiff line 30,p3,45
kcenter line .08,p3,.01
kdamp line .01,p3,.08
kpos line 0,p3,16
kdisplace line 0,p3,.5

;scanu2 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, kmass, kstiff, kcenter, kdamp, .2, .7, kpos,
kdisplace, a0, 1, 2

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

</CsInstruments>
<CsScore>
; Initial displacement condition
f1 0 16 10 1 ; sine hammer

; Masses
f2 0 16 -7 1 16 1

; Spring matrices
f3 0 0 -44 "string_with_extras-16.matrxT"

; Centering force
f4 0 16 -7 1 16 1 ; uniform initial centering

; Damping
f5 0 16 -7 1 16 1 ; uniform damping

; Initial displacement - (displacement, vel, and acceleration
; Acceleration is from stiffness matrix pos effect - increases acceleration
f6 0 16 -7 .01 16 .01 ; uniform initial velocity-displacement

; Trajectories
f7 0 16 -5 .001 16 16

i"scan" 0 2 -6 7.00
i"scan" 2 2 -6 5.00
i"scan" 4 2 -6 6.00
i"scan" 6 2 -6 8.00
i"scan" 8 2 -6 10.00

e

</CsScore>
</CsoundSynthesizer>


See Also

Scanned Synthesis

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

Credits

Author: John ffitch

New in Version 6.16

June 2021