Re: Orbits on 3D Surfaces
| Date | 1998-02-13 16:29 |
| From | Jon Christopher Nelson |
| Subject | Re: Orbits on 3D Surfaces |
Csounders: The following provides yet another example of a wave terrain instrument. This instrument is covered in the forthcoming MIT Press Learning Csound Book (should be out in the summer) in my tutorial on function tables and the GEN routines. With fairly simple modifications one can devise 4-D, 5-D, etc. wave terrain synthesis instruments. I have used this instrument a little in my most recent work and plan to incorporate more wave terrain synthesis in my next work. I will also be presenting a paper on this technique at the SEAMUS conference in Dartmouth this April (in case any of you plan to attend). Hope you can use this: instr 1 ;3-D wave terrain with oscils/phasors ;p4=amp p5-6=xtransi-f p7-8=xoscilampi-f p9-10=xoscilfreqi-f p11=xfn ;p12-13=ytransi-f p14-15=yoscilampi-f p16-17=yoscilfreqi-f p18=yfn ;p19=x plane fn table p20=y plane fn table kenv linseg 0,.02,p4,p3-.04,p4,.02,0 ;amp envelope ;x index values follow kxtrans line p5,p3,p6 ;transverse movement in x plane kxamp line p7,p3,p8 ;index oscillator amplitude kxamp = kxamp*.5 ;normalizes oscil amp to index table kxfreq line p9,p3,p10 ;x plane index oscil frequency kxndx oscili kxamp,kxfreq,p11 ;p11=x index function ;try sines, traingles, or ascending lines from -1 to +1 ;(phasor) etc for index function kxndx = frac(kxndx+1000.5+kxtrans) ;need fractional values ;to go from one terrain boundary to the other ;1000.5 avoids negative values and sets start point ;at table midpoint ;y index values follow kytrans line p12,p3,p13 ;transverse movement in x plane kyamp line p14,p3,p15 ;index oscillator amplitude kyamp = kyamp*.5 ;normalizes oscil amp to index table kyfreq line p16,p3,p17 ;x plane index oscil frequency kyndx oscili kyamp,kyfreq,p18 ;p11=x index function ;try sines, traingles, or ascending lines from -1 to +1 ;(phasor) etc for index function kyndx = frac(kyndx+1000.5+kytrans) ;need fractional values ;to go from one terrain boundary to the other ;1000.5 avoids negative values and sets start point ;at table midpoint ax tablei kxndx,p19,1,0,0 ;normalized (-1 to +1) audio for x plane ay tablei kyndx,p20,1,0,0 ;normalized (-1 to +1) audio for y plane az=(ax*ay)*kenv ;tracks z plane to generate terrain waveform outs az,az endin f 1 0 8192 10 1 ;sine f 2 0 8192 7 0 2048 1 4096 -1 2048 0 ;triangle f 3 0 8192 7 -1 8192 1 ;phasor from -1 to +1 f 10 0 8192 10 0 0 1 ;3 sines f 11 0 8192 10 1 .43 0 .25 .33 .11 0 .75 ;other x or y tables f 12 0 8192 9 .75 1 0 2.25 1 0 f 13 0 8192 9 1.66 1 0 3.33 1 0 f14 0 8192 9 1.25 1 0 4.25 1 180 f15 0 8192 9 1 1 0 1.5 1 0 f16 0 8192 9 3 1 0 3.5 1 0 ;p4=amp p5-6=xtransi-f p7-8=xoscilampi-f p9-10=xoscilfreqi-f p11=xfn ;p12-13=ytransi-f p14-15=yoscilampi-f p16-17=yoscilfreqi-f p18=yfn ;p19=x plane fn table p20=y plane fn table ;i1 0 .5 32000 0 0 1 1 2 2 3 0 0 1 1 40 40 3 1 10 ;i1 1 .5 32000 0 0 1 1 40 40 3 0 0 1 1 2 2 3 1 10 ;i1 0 2 32000 -.5 .5 .1 .1 440 440 3 0 0 1 1 440 440 3 1 10 ;i1 2.5 2 32000 0 0 1 1 440 440 3 -.5 .5 .1 .1 440 440 3 1 10 ;i1 0 2 32000 -.5 .5 .1 10 110 110 3 0 3 3 1 110 110 3 1 10 ;i1 2.5 2 32000 .25 -.25 3 1 110 110 3 -.5 .5 .1 10 110 110 3 1 10 ;i1 0 2 32000 -.5 .5 .1 10 110 110 3 0 3 3 1 110 110 3 13 14 ;i1 2.5 2 32000 .25 -.25 3 1 110 110 3 -.5 .5 .1 10 110 110 3 11 12 ;i1 0 2 32000 -.5 .5 .1 1 440 435 3 0 0 1 .1 440 440 3 1 10 ;i1 2.5 2 32000 0 0 1 .1 110 110 3 -.5 .5 .1 1 330 333 3 1 10 ;i1 0 2 32000 -.5 .5 .2 .4 110 110 1 0 4 .4 .2 220 220 1 15 16 ;i1 2.5 2 32000 10 0 .5 .2 110 110 3 -.5 .5 .2 .5 220 220 1 15 16 e enjoy, Jon Jon Christopher Nelson, Director CEMI (Center for Experimental Music and Intermedia) University of North Texas College of Music P.O. Box 13887 Denton, TX 76203 USA ph. (940) 369-7531 fax (940) 565-2002 jnelson@sndart.cemi.unt.edu http://www.music.unt.edu/comp/jnelson.htm |
| Date | 1998-02-13 20:29 |
| From | Hans Mikelson |
| Subject | Re: Orbits 4D Examples |
Hi,
In instrument 4 the orbit is a coiled path traced out on the surface of a
torus. This is then used to reference the 4D surface. With instrument 5
the coordinates are sent to a 4D rotation instrument so a stereo image is
created.
Bye,
Hans Mikelson
; ORCHESTRA
; Terrain Mapping
; Coded by Hans Mikelson February 13, 1998
;
sr=22050
kr=2205
ksmps=10
nchnls=2
zakinit 50, 50
; 4D
; w=sin^2*(sqrt(x^2+y^2+z^2))
instr 4
idur = p3
iamp = p4
ifqc = cpspch(p5)
kdclick linseg 0, .002, iamp, idur-.004, iamp, .002, 0
krminor linseg .5, idur/2, 5, idur/2, .5
krmajor = krminor+1
asin1 oscil krminor, ifqc, 1
acos1 oscil krminor, ifqc, 1, .25
asin2 oscil krmajor, ifqc/4, 1
acos2 oscil krmajor, ifqc/4, 1, .25
ax = asin1+acos2
ay = acos1
az = asin2
az1 = sin(sqrt(ax*ax+ay*ay+az*az)) ; Compute the surface
az = az1*az1-.5
outs az*kdclick, az*kdclick
endin
; 4D
; w=sin^2*(sqrt(x^2+y^2+z^2))
instr 5
idur = p3
iamp = p4
ifqc = cpspch(p5)
ioutch1 = p6
ioutch2 = p7
ioutch3 = p8
ioutch4 = p9
kdclick linseg 0, .002, iamp, idur-.004, iamp, .002, 0
krminor linseg .5, idur/2, 5, idur/2, .5
krmajor = krminor+1
asin1 oscil krminor, ifqc, 1
acos1 oscil krminor, ifqc, 1, .25
asin2 oscil krmajor, ifqc/4, 1
acos2 oscil krmajor, ifqc/4, 1, .25
ax = asin1+acos2
ay = acos1
az = asin2
aw1 = sin(sqrt(ax*ax+ay*ay+az*az)) ; Compute the surface
aw = aw1*aw1-.5
zaw ax*kdclick, ioutch1
zaw ay*kdclick, ioutch2
zaw az*kdclick, ioutch3
zaw aw*kdclick*10, ioutch4
endin
; 3 Space Planar Rotations
instr 50
ifqc = p4
iphase = p5
iplane = p6
inx = p7
iny = p8
inz = p9
ioutx = p10
iouty = p11
ioutz = p12
kcost oscil 1, ifqc, 1, .25+iphase
ksint oscil 1, ifqc, 1, iphase
ax zar inx
ay zar iny
az zar inz
; Rotation in X-Y plane
if (iplane!=1) goto next1
axr = ax*kcost + ay*ksint
ayr =-ax*ksint + ay*kcost
azr = az
goto next3
; Rotation in X-Z plane
next1:
if (iplane!=2) goto next2
axr = ax*kcost + az*ksint
ayr = ay
azr =-ax*ksint + az*kcost
goto next 3
; Rotation in Y-Z plane
next2:
axr = ax
ayr = ay*kcost + az*ksint
azr =-ay*ksint + az*kcost
next3:
zaw axr, ioutx
zaw ayr, iouty
zaw azr, ioutz
endin
; 4 Space Planar Rotations
instr 51
ifqc = p4
iphase = p5
iplane = p6
inx = p7
iny = p8
inz = p9
inw = p10
ioutx = p11
iouty = p12
ioutz = p13
ioutw = p14
kcost oscil 1, ifqc, 1, .25+iphase
ksint oscil 1, ifqc, 1, iphase
ax zar inx
ay zar iny
az zar inz
aw zar inw
; Rotation in X-Y plane
if (iplane!=1) goto next1
axr = ax*kcost + ay*ksint
ayr =-ax*ksint + ay*kcost
azr = az
awr = aw
goto nextend
; Rotation in X-Z plane
next1:
if (iplane!=2) goto next2
axr = ax*kcost + az*ksint
ayr = ay
azr =-ax*ksint + az*kcost
awr = aw
goto nextend
; Rotation in Y-Z plane
next2:
if (iplane!=3) goto next3
axr = ax
ayr = ay*kcost + az*ksint
azr =-ay*ksint + az*kcost
awr = aw
goto nextend
; Rotation in X-W plane
next3:
if (iplane!=4) goto next4
axr = ax*kcost + aw*ksint
ayr = ay
azr = az
awr = -ax*ksint + aw*kcost
goto nextend
; Rotation in Y-W plane
next4:
if (iplane!=5) goto next5
axr = ax
ayr = ay*kcost + az*ksint
azr = az
awr = -ay*ksint + aw*kcost
goto nextend
; Rotation in Z-W plane
next5:
if (iplane!=6) goto nextend
axr = ax
ayr = ay
azr = az*kcost + aw*ksint
awr =-az*ksint + aw*kcost
nextend:
zaw axr, ioutx
zaw ayr, iouty
zaw azr, ioutz
zaw awr, ioutw
endin
;---------------------------------------------------------------------------
; Mixer Section
;---------------------------------------------------------------------------
instr 100
idur = p3
iamp = p4
inch1 = p5
inch2 = p6
ain1 zar inch1
ain2 zar inch2
outs ain1*iamp, ain2*iamp
endin
;---------------------------------------------------------------------------
; Clear audio & control channels
;---------------------------------------------------------------------------
instr 110
zacl 0, 50 ; Clear audio channels 0 to 30
zkcl 0, 50 ; Clear control channels 0 to 30
endin
; SCORE
f1 0 8192 10 1
; Sta Dur Amp Pch
i4 0 2 20000 9.00
; Sta Dur Amp Pch OutX OutY OutZ OutW
i5 2 2 2000 9.00 1 2 3 4
; 3 Space Planar Rotation
; 1=X-Y Plane, 2=X-Z Plane, 3=Y-Z Plane
; Sta Dur Fqc Phase Plane InX InY InZ OutX OutY OutZ
;i50 0 1.6 1.5 0 2 1 2 3 4 5 6
; 4 Space Planar Rotation
; Plane: 1=X-Y, 2=X-Z, 3=Y-Z, 4=X-W, 5=Y-W, 6=Z-W
; Sta Dur Fqc Phase Plane InX InY InZ InW OutX OutY OutZ OutW
i51 2 2 1.5 0 1 1 2 3 4 5 6 7 8
i51 2 2 1.2 0 6 5 6 7 8 9 10 11 12
i51 2 2 1.0 0 5 9 10 11 12 13 14 15 16
; Mixer
; Sta Dur Amp InCh1 InCh2
i100 2 2 1 14 16
; Clear Zak
; Sta Dur
i110 2 2
|