hvs2

hvs2 — Allows two-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.

Description

hvs2 allows two-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.

Syntax

hvs2 kx, ky, inumParms, inumPointsX, inumPointsY, iOutTab, iPositionsTab, iSnapTab [, iConfigTab]

Initialization

inumParms - number of parameters controlled by the HVS. Each HVS snapshot is made up of inumParms elements.

inumPointsX, inumPointsY - number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.

iOutTab - number of the table receiving the set of output-parameter instant values of the HVS. The total amount of parameters is defined by the inumParms argument.

iPositionsTab – a table filled with the individual positions of snapshots in the HVS matrix (see below for more information).

iSnapTab – a table filled with all the snapshots. Each snapshot is made up of a set of parameter values. The amount of elements contained in each snapshots is specified by the inumParms argument. The set of elements of each snapshot follows (and is adjacent) to the previous one in this table. So the total size of this table should be >= to inumParms multiplied the number of snapshots you intend to store for the HVS.

iConfigTab – (optional) a table containing the behavior of the HVS for each parameter. If the value of iConfigTab is zero (default), this argument is ignored, meaning that each parameter is treated with linear interpolation by the HVS. If iConfigTab is different than zero, then it must refer to an existing table whose contents are in its turn referring to a particolar kind of interpolation. In this table, a value of -1 indicates that corresponding parameter is leaved unchanged (ignored) by the HVS; a value of zero indicates that corresponding parameter is treated with linear-interpolation; each other values must be integer numbers indicating an existing table filled with a shape which will determine the kind of special interpolation to be used (table-based interpolation).

Performance

kx, ky - these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.

Hyper Vectorial Synthesis is a technique that allows control of a huge set of parameters by using a simple and global approach. The key concepts of the HVS are:

The set of HVS parameters, whose amount is fixed and defined by the inumParms argument. During the HVS performance, all these parameters are variant and can be applied to any sound synthesis technique, as well as to any global control for algorithmic composition and any other kind of level. The user must previously define several sets of fixed values for each HVS parameter, each set corresponding to a determinate synthesis configuration. Each set of values is called snapshot, and can be considered as the coordinates of a bound of a multi-dimensional space. The HVS consists on moving a point in this multi-dimensional space (by using a special motion pointer, see below), according and inside the bounds defined by the snapshots. You can fix any amount of HVS parameters (each parameter being a dimension of the multi-dimensional space), even a huge number, the limit only depends on the processing power (and the memory) of your computer and on the complexity of the sound-synthesis you will use.

The HVS cube (or square or line). This is the matrix (of 3, 2 or 1 dimensions, according to the hvs opcode you intend to use) of “mainstays” (or pivot) points of HVS. The total amount of pivot-points depends on the value of the inumPointsX, inumPointsY and inumPointsZ arguments. In the case of a 3-dimensional HVS matrix you can define, for instance, 3 points for the X dimension, 5 for the Y dimension and 2 for the Z dimension. In this case, the total number of pivot-points is 3 * 5 * 2 = 30. With this set of pivot points, the cube Is divided into smaller cubed zones each one bounded by eight nearby points. Each point is numbered. The numeral order of these points is enstabilished in the following way: number zero is the first point, number 1 the second and so on. Assuming you are using a 3-dimensional HVS cube having the number of points above mentioned (i.e. 3, 5 and 2 respectively for the X, Y and Z axis), the first point (point zero) is the upper-left-front vertex of the cube, by facing the XY plane of the cube. The second point is the middle point of the upper front edge of the cube and so on. You can refer to the figure below in order to understand how the numeral order of the pivot-points proceeds:

For the 2-dimensional HVS, it is the same, by only omitting the rear cube face, so each zone is bounded by 4 pivot-points instead of 8. For the 1-dimensional HVS, the whole thing is even simpler because it is a line with the pivot-points proceeding from left to right. Each point is coupled with a snapshot.

Snapshot order, as stored into the iSnapTab, can or cannot follow the order of the pivot-points numbers. In fact it is possible to alter this order by means the iPositionsTab, a table that remaps the position of each snapshot in relation to the pivot points. The iPositionsTab is made up of the positions of the snapshots (contained in the iSnapTab) in the two-dimensional grid. Each subsequent element is actually a pointer representing the position in the iSnapTab. For example, in a 2-dimensional HVS matrix such as the following (in this case having inumPointsX = 3 and inumPointsY = 5:

Table 10. 

5 7 1
3 4 9
6 2 0
4 1 3
8 2 7

These numbers (to be stored in the iSnapTab table by using, for instance, the GEN02 function generator) represents the snapshot position within the grid (in this case a 3x5 matrix). So, the first element 5, has index zero and represents the 6th (element zero is the first) snapshot contained in the iSnapTab, the second element 7 represents the 8th element of iSnapTab and so on. Summing up, the vertices of each zone (a cubed zone is delimited by 8 vertices; a squared zone by 4 vertices and a linear zone by 2 points) are coupled with a determinate snapshot, whose number is remapped by the iSnapTab.

Output values of the HVS are influenced by the motion pointer, a point whose position, in the HVS cube (or square or segment) is determined by the kx, ky and kz arguments. The values of these arguments, which must be in the 0 to 1 range, are externally set by the user. The output values, whose amount is equal to the inumParms argument, are stored in the iOutTab, a table that must be already allocated by the user, and must be at least inumParms size. In what way the motion pointer influences the output? Well, when the motion pointer falls in a determinate cubed zone, delimited, for instance, by 8 vertices (or pivot points), we assume that each vertex has associated a different snapshot (i.e. a set of inumParms values), well, the output will be the weighted average value of the 8 vertices, calculated according on the distance of the motion pointer from each of the 8 vertices. In the case of a default behavior, when the iConfigTab argument is not set, the exact output is calculated by using linear interpolation which is applied to each different parameter of the HVS. Anyway, it is possible to influence this behavior by setting the iConfigTab argument to a number of a table whose contents can affect one or more HVS parameters. The iConfigTab table elements are associated to each HVS parameter and their values affect the HVS output in the following way:

  • If iConfigTab is equal to -1, corresponding output is skipped, i.e. the element is not calculated, leaving corresponding element value in the iOutTab unchanged;

  • If iConfigTab is equal to zero, then the normal HVS output is calculated (by using weighted average of the nearest vertex of current zone where it falls the motion pointer);

  • If iConfigTab element is equal to an integer number > zero, then the contents of a table having that number is used as a shape of a table-based interpolation.

Examples

Here is an example of the hvs2 opcode. It uses the file hvs2.csd.

Example 453. Example of the hvs2 opcode.

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

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac     ;      -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o hvs2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; updated example by Stefano Cucchi and Menno Knevel (original creators unknown)

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

instr	1

inumLinesX init	4 ; number of LINES - matrix -  16 POINTS
inumLinesY init	4 ; numeber of COLOUMNS
inumParms	init	3 ; 3 PARAMETERS  every ponint of the matrix - take a look at iSnapTab
iOutTab	ftgen	5,0,8, -2,      0 ; 
iPosTab	ftgen	6,0,32, -2,     3,2,1,0,4,5,6,7,8,9,10, 11, 15, 14, 13, 12
iSnapTab	ftgen	8,0,64, -2,       1,1,1,     2,0,0,    3,2,0,    2,2,2,    5,2,1,    2,3,4,    6,1,7,      0,0,0, \
                                          1,3,5,     1,4,4,    1,5,8,    1,1,5,    4,3,2,    3,4,5,    7,6,5,      7,8,9

kx linseg 0, p3*0.3, 1, p3*0.3, 0, p3*0.4, 1
ky linseg 1, p3, 0


;     kx,  ky, inumParms,  inumlinesX,  inumlinesY,  iOutTab,  iPosTab,  iSnapTab 
hvs2  kx,  ky, inumParms,  inumLinesX,  inumLinesY,  iOutTab,  iPosTab,  iSnapTab  

k0  tab    0, 5 ; init first value of 3 of iSnapTab
k1  tab    1, 5 ; init  second value of 3 of iSnapTab
k2  tab    2, 5 ; init third value of 3 of iSnapTab

printk2 k0, 10
printk2 k1, 10
printk2 k2, 10

; Make parameters of synthesis depend on the table values produced by hvs
; k0 = first value of group of three in iSnapTab
; k1 = second value of group of three in iSnapTab
; k2 = first value of group of three in iSnapTab

ares1 fof 0.2, k0*100 + 50, k1*100 + 200, 0, k2 * 10 + 50, 0.003, 0.02, 0.007, 20, \
      1, 2, p3
ares2 fof 0.2, k1*100 + 50, k2*100 + 200, 0, k0 * 10 + 50, 0.003, 0.02, 0.007, 20, \
      1, 2, p3
kdeclik linseg 0, 0.3, 1, p3-0.6, 1, 0.3, 0
outs ares1*kdeclik, ares2*kdeclik
	endin

</CsInstruments>
<CsScore>

f 1 0 1024 10 1  ;Sine wave
f 2 0 1024 19 0.5 0.5 270 0.5  ;Grain envelope table

i1 0 10
e
</CsScore>
</CsoundSynthesizer>


Here is second example of the hvs2 opcode. It uses the file hvs2-2.csd.

Example 454. Second example of the hvs2 opcode.

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

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac           -iadc    ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o hvs2.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr=48000
ksmps=100
nchnls=2

; Example by James Hearon 2008
; Edited by Andres Cabrera

ginumPointsX init       16
ginumPointsY init       16
ginumParms  init        3

;Generate 9 tables with arbitrary points
gitmp ftgen 100, 0, 16, -2, 70, 260, 390, 180, 200, 300, 980, 126, \
                330, 860, 580, 467, 220, 399, 1026, 1500
gitmp ftgen 200, 0, 16, -2, 100, 200, 300, 140, 600, 700, 880, 126, \
                330, 560, 780, 167, 220, 999, 1026, 1500
gitmp ftgen 300, 0, 16, -2, 400, 200, 300, 540, 600, 700, 880, 126, \
                330, 160, 780, 167, 820, 999, 1026, 1500
gitmp ftgen 400, 0, 16, -2, 100, 200, 800, 640, 600, 300, 880, 126, \
                330, 660, 780, 167, 220, 999, 1026, 1500
gitmp ftgen 500, 0, 16, -2, 200, 200, 360, 440, 600, 700, 880, 126, \
                330, 560, 380, 167, 220, 499, 1026, 1500
gitmp ftgen 600, 0, 16, -2, 100, 600, 300, 840, 600, 700, 880, 126, \
                330, 260, 980, 367, 120, 399, 1026, 1500
gitmp ftgen 700, 0, 16, -2, 100, 200, 300, 340, 200, 500, 380, 126, \
                330, 860, 780, 867, 120, 999, 1026, 1500
gitmp ftgen 800, 0, 16, -2, 100, 600, 300, 240, 200, 700, 880, 126, \
                130, 560, 980, 167, 220, 499, 1026, 1500
gitmp ftgen 900, 0, 16, -2, 100, 800, 200, 140, 600, 700, 680, 126, \
                330, 560, 780, 167, 120, 299, 1026, 1500

giOutTab ftgen   5,0,8, -2,      0
giPosTab ftgen   6,0,32, -2, 0,1,2,3,4,5,6,7,8,9,10, 11, 15, 14, 13, 12
giSnapTab ftgen   8,0,64, -2,  1,1,1,   2,0,0,  3,2,0,  2,2,2,  \
        5,2,1,  2,3,4,  6,1,7,  0,0,0,  1,3,5,  3,4,4,  1,5,8,  1,1,5,  \
        4,3,2,  3,4,5,  7,6,5,  7,8,9

tb0_init        giOutTab

        FLpanel "hsv2",440,100,10,10,0
gk1,ih1 FLslider "X", 0,1, 0, 5, -1, 400,20, 20,10
gk2, ih2 FLslider "Y", 0, 1, 0, 5, -1, 400, 20, 20, 50
        FLpanel_end

        FLpanel "hvsBox",280,280,500,1000,0
;ihandle FLhvsBox inumlinesX, inumlinesY, iwidth, iheight, ix, iy [, image]
gih1  FLhvsBox  16, 16, 250, 250, 10, 1
        FLpanel_end
        FLrun


        instr   1
FLhvsBoxSetValue gk1, gk2, gih1

hvs2    gk1,gk2,  ginumParms, ginumPointsX, ginumPointsY, giOutTab, giPosTab, giSnapTab  ;, iConfigTab

k0      init    0
k1      init    1
k2      init    2
kspeed  init    0

kspeed = int((tb0(k2)) + 1)*.10

kenv  oscil   25000, kspeed*16, 10 

k1    phasor kspeed ;slow phasor: 200 sec.
kpch  tableikt k1 * 16, int((tb0(k1)) +1)*100 ;scale phasor * length
a1    oscilikt kenv, kpch, int(tb0(k0)) +1000;scale pitch slightly
ahp butterlp a1, 2500
outs ahp, ahp

        endin


</CsInstruments>
<CsScore>

f 10  0  1024 20  5 ;use of windowing function
f1000 0 1024 10 .33 .25 .5
f1001 0 1024 10 1
f1002 0 1024 10 .5  .25  .05
f1003 0 1024 10 .05  .10  .3  .5  1
f1004 0 1024 10 1 .5  .25  .125  .625
f1005 0 1024 10 .33  .44  .55  .66
f1006 0 1024 10 1 1 1 1 1
f1007 0 1024 10 .05 .25 .05 .25 .05 1

f0 3600
i1 0 3600

</CsScore>
</CsoundSynthesizer>


See also

Hyper Vectorial Synthesis

Credits

Author: Gabriel Maldonado

New in version 5.06