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.

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 and the third is a weight. If the third is omitted it is taken as value 1. The list is terminated by a </MATRIX> line or end of file.

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.

Examples

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

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


Credits

Author: John ffitch

New in Version 6.16 June 2021