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. Ignored when init > 0.
iright -- If init < 0, the position of the negative pluck in the range 0 to 1. Ignored when init > 0.
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 kdisplace.
kdisplace -- power that the active hammer uses.
ain -- audio input that adds to the velocity of the masses. Amplitude should not be too great.
Note
Both scanu and scanu2 are capable of reading the binary (.matrxB) and text (.matrxT) matrix format. However, using scanu2 is to be preferred because of its accuracy and better sound quality.
Examples
Here is an example of the scanu2 opcode. It uses the file scanu2.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac --limiter=0.95 ;;;realtime audio out & and limit loud sounds;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o scanu2.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1; by Menno Knevel 2024instr1a0init0; no audio injectionirate=.01kenvadsr.0001,1,.7,.1; envelopeif(p6==1)thenprints"\ninitial displacement condition = ramp"elseif(p6==11)thenprints"\ninitial displacement condition = sine (hammer???)"elseprints"\ninitial displacement condition = a pluck that is 10 points wide on the surface"endifif(p7==3)thenprints"\n (binary matrix)\n\n"elseprints"\n (text matrix)\n\n"endif; scanu init, irate, ifndisplace, ifnmass, ifnmatrix, ifncentr, ifndamp, kmass,; kmtrxstiff, kcentr, kdamp, ileft, iright, kpos, kdisplace, ain, idisp, idscanu2p6,irate,6,2,p7,4,5,2,9,.01,.01,.1,.9,0,0,a0,1,2;ar scans kamp, kfreq, ifntraj, idasigscansampdb(p4)*kenv,cpspch(p5),7,2outsasig*.00004,asig*.00004; lower volume due to 0dbfs=1endin</CsInstruments><CsScore>; Initial displacement conditionf10128-70641640; rampf110128101; sine hammerf1110128-702802120960; a pluck that is 10 points wide on the surface; Massesf20128-711281; Spring matricesf3016384-23"string-128.matrxB"f33016384-44"cylinder_128.matrxT"; Centering forcef40128-711281; uniform initial centering; 0 128 -7 .001 128 1 ; ramped centering; Dampingf50128-711281; uniform damping; Initial velocity - (displacement, vel, and acceleration; Acceleration is from stiffness matrix pos effect - increases accelerationf60128-7.01128.01; uniform initial velocity; exponential Trajectoryf70128-5.001128128i106887.0013i172885.0013i192886.0013i1126867.00113i1192865.00113i1212866.00113i1246907.001113i1312905.001113i1332906.001113i1376887.00133i1442885.00133i1462886.00133i1496857.001133i1562855.001133i1582856.001133i1616927.0011133i1682925.0011133i1702926.0011133e</CsScore></CsoundSynthesizer>
Here is another example of the scanu2 opcode. It uses the file scanu2-2.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac --limiter=0.95 ;;;realtime audio out & and limit loud sounds;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o scanu2-2.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1; by Menno Knevel 2024instr1; play with k-rate parametersa0init0irate=.2kmassline10,p3,1kstiffline.30,p3,.7kcenterline.3,p3,.01kdampline-.01,p3,-.1kdisplaceline0,p3,1scanu21,irate,6,2,3,4,5,kmass,kstiff,kcenter,kdamp,.1,.7,1,kdisplace,a0,1,5asigscansampdbfs(p4),cpspch(p5),7,5asigdcblock2asigasigL,asigRreverbscasig,asig,.6,10000,sr,.5,1; add some reverboutsasigL+asig,asigR+asigendin</CsInstruments><CsScore>; Initial displacement conditionf101024101; sinef201024-7110241; Masses; Spring text matrixf300-44"circularstring_1024.matrxT"; text matrix, to be found in manual/examplesf401024-7110241; uniform initial centeringf501024-7110241; uniform damping; Initial displacement - (displacement, vel, and acceleration; Acceleration is from stiffness matrix pos effect - increases accelerationf601024-7.011024.01; uniform initial velocity-displacementf701024-5.00110241024; Trajectoryi10.06.5-67.00i16.56.5-97.07; 2 notesi16.56.5-97.04e</CsScore></CsoundSynthesizer>
Yet another example of the scanu2 opcode. It uses the file scanu2-3.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac --limiter=0.95 ;;;realtime audio out & and limit loud sounds;-iadc ;;;uncomment -iadc if realtime audio input is needed too; For Non-realtime ouput leave only the line below:; -o scanu2-3.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1; by Richard Boulanger 2024instrscan; show the pluck optionsa0init0irate=.04kmassline2,p3,1kstiffline10,p3,10kcenterline5,p3,6kdampline1,p3,2kposline.4,p3,.5;scanu2 init,irate,ifndisplace,ifnmass,ifnmatrix,ifncentr,ifndamp,kmass,kmtrxstiff,; kcentr, kdamp, ileft, iright, kpos, kdisplace, ain, idisp, idscanu2p6,irate,6,2,3,4,5,kmass,kstiff,kcenter,kdamp,p7,p8,kpos,.02,a0,1,2a1scansampdbfs(p4),cpspch(p5),7,2a1dcblock2a1outsa1,a1endin</CsInstruments><CsScore>f1016101; Sine Hammerf11016101.5.3.2.1.01; Sawlike hammerf1110161010.730.530.450.170.020.002; Pulselike hammerf2016-78168; Massesf300-44"string_with_extras-16.matrxT"; Spring matrix, to be found in the examples folder of the manualf4016-7.0716.07; Centering force, uniform initial centeringf5016-7.0416.04; Damping, uniform dampingf6016-7.0116.01; uniform initial velocity-displacementf7016-515161; Trajectoryi"scan"0367.00-1.5.5; pluck in middlesi"scan"0327.00-1.1.1; pluck at leftsi"scan"0307.00-1.2-.8; 2 plucks up left and down rightsi"scan"03-67.001.2.8; sine hammer - ignore pluck positionsi"scan"03-67.0011.8.2; sawlike hammer - ignore pluck positionsi"scan"03-67.00111.1.6; pulselike hammer - ignore pluck positione</CsScore></CsoundSynthesizer>