Use Non-Frames Version Previous Page No Next Page
Appendix: DirectCsound

Score Macro Arithmetic Infix Operators

  (TabNum T  TabIndex)
  (amp  R  seed)

Description

T retrieves a value from a score function table. R retrieves a pseudo random value.

Initialization

TabNum - table number

TabIndex - absolute index of table element

amp - sets the range of random values from zero to amp itself

seed - change the initial seed of the pseudo random sequence. When seed is set to a non-zero value, R operator sets the seed, while with seed = 0 it returns a normal random value. When seed is set to -1 the seed of pseudo random sequence is obtained by the current timer value of the computer, allowing a different pseudo random sequence each time Csound is run.

Performance

The unusual infix syntax can be transformed into a more familiar syntax by means of macros. In the case of T:
  #define Table(tabnum:index) # (($tabnum) T ($index)) #
So you can call the $Table( ) macro with the classic function call syntax:
  $Table(num: element)

In the case of R:

  #define RndSeed(seed) # (1 R ($seed)) #
  #define Rand(min:max) # ( ($min) + ((($max)-($min)) R 0)  ) #
In these examples $RndSeed( ) macro sets the seed, while $Rand( ) retrives a random value inside the min-max interval.


Use Non-Frames Version Previous Page No Next Page
Appendix: DirectCsound