GEN 22

NOTE: standard Bath/Montreal Csound 에서는 사용할 수 없음..

soundfile 에서 16-bit의 정수를 사용하여 데이터를 function table로 전송하여 RAM안에 저장한다.
형식은 다음과 같다.

f  #  time  size  -22  filcod  skiptime  format  channel

이 gen-function 은 거의 GEN01과 동등하다. 다른점은 GEN22 가 mono 또는 stereo로 된 16 bit integer samples를 읽고 16-bit integer format 을 유지하면서 RAM에 저장할 수 있다는 것이다. 또한 이것은 절반의 RAM 의 용량을 요구하기 때문에 긴 샘플에 유용하게 쓰인다. GEN22는 현재로서는 loscil2 opcode하고만 연계된다. 언제나 음수의 GEN넘버를 사용하여 normalization을 막아야한다. 그렇지 않으면 1, -1, 0과 정수값들의 의미없는 반복이 포함될 것이다.

주의점: GEN22에서 사용할 수 있는 function tables은 loscil2 와 fof3뿐이다. loscil 과 fof2와 같은 것으로 사용된 instruments를 업그레이드 할 때에는 반드시 loscil2 와 fof3의 출력을 rescale해야한다. 그렇지 않으면 출력의 범위를 벗어나게 된다. 다른 옵코드와의 사용은 지금으로서는 불가능하다.

By Gabriel Maldonado(?), Csound 3.49

New Csound5 opcodes: sprintf, puts

여러 옵코드 들을 선정하여 차후에 한글로 올려드리겠습니다.

Sr      sprintf     Sformat, xarg1[, xarg2[, … xarg30]]
Sr      sprintfk    Sformat, xarg1[, xarg2[, … xarg30]]

DESCRIPTION
———–

sprintf and sprintfk write formatted output to a string variable,
similarly to the C function sprintf(). sprintf runs at i-time
only, while sprintfk runs both at initialization and performance
time.

INITIALIZATION
————–

Sr – output string variable

Sformat – format string, has the same format as in printf() and
     other similar C functions, except length modifiers (l, ll, h, etc.)
     are not supported. The following conversion specifiers are
     allowed:
       d, i, o, u, x, X, e, E, f, F, g, G, c, s

xarg1, xarg2, … – input arguments for format, should be i-rate
     for all conversion specifiers except %s, which requires a
     string argument. Integer formats like %d round the input values
     to the nearest integer.

PERFORMANCE
———–

Sr – output string variable (sprintfk)

Sformat – format string for sprintfk

xarg1, xarg2, … – input arguments for format, sprintfk allows the
     use of k-rate variables, however, these should be valid at i-time
     as well

———————————————————————-

         puts Sstr, ktrig[, inonl]

DESCRIPTION
———–

puts prints a string at initialization time, and also at performance
time whenever the k-rate trigger signal is positive and is different
from the previous value. A trailing newline character is printed unless
the optional i-time argument is non-zero.

———————————————————————-

EXAMPLE
——-

iPI     =  4 * taninv(1)
SPI     strcpy “33[1mPI33[m”
S1      sprintf “%s = %f, int(%s) = %dn”, SPI, iPI, SPI, iPI
         puts S1, 1, 1

String variables added to Csound5

A string variable is defined by using ‘S’ as the type letter, and can
be either global (gSname) or local (Sname). Operations on string
variables are performed at i-time, however, some string opcodes will
also run at performance time.

By default, the maximum allowed length of string variables is 255
characters, however, this limit can be changed with the -+max_str_len
command line option; for example, -+max_str_len=1000 will set the
maximum length to 999 characters.
Note: the length of string constants is not limited.

Currently, the following opcodes can be used for manipulating strings,
but more should be available soon. Existing opcodes that expect a quoted
string constant as input argument should also work with string variables.

     strset  indx, Sstr

set string value in strset table at the specified index to Sstr.
The opcode can be used both in the orchestra header and in instruments,
and runs at i-time, dynamically extending the table if needed.

Sr  strget  indx

copies value from strset table at the specified index to Sr, or, if
the index is a string p-field from the score, then that string is
copied. If no string is defined for indx, Sr is set to empty string.

Sr  strcpy  Sstr

copies Sstr to Sr. Using the same variable for input and output is
allowed (the opcode has no effect in this case).

Sr  strcpyk Sstr

same as strcpy, but runs both at initialization and performance time.

Sr  strcat  Sstr1, Sstr2

concatenates strings, by appending Sstr2 to Sstr1, and leaves the result
in Sr. It is allowed for Sr to be the same variable as Sstr1 or Sstr2.

Sr  strcatk Sstr1, Sstr2

same as strcat, but runs both at initialization and performance time.

ir  strcmp  Sstr1, Sstr2

compares two strings, and sets ir to -1, 0, or 1 if Sstr1 is less than,
equal to, or greater than Sstr2, respectively.

kr  strcmpk Sstr1, Sstr2

same as strcmp, but runs both at initialization and performance time.

Example:

S1  strcpy “foo”
S2  strcpy “bar.wav”
S3  strcat S1, S2
a1  diskin2 S3, 1  ; reads foobar.wav