| 1 |
|
| 2 |
<refentry id="readk"> |
| 3 |
<indexterm id="IndexReadk"><primary>readk</primary></indexterm> |
| 4 |
<refentryinfo><title>Signal I/O:File I/O</title></refentryinfo> |
| 5 |
<refmeta> |
| 6 |
<refentrytitle>readk</refentrytitle> |
| 7 |
</refmeta> |
| 8 |
|
| 9 |
<refnamediv> |
| 10 |
<refname>readk</refname> |
| 11 |
<refpurpose> |
| 12 |
Periodically reads an orchestra control-signal value from an external file. |
| 13 |
</refpurpose> |
| 14 |
</refnamediv> |
| 15 |
|
| 16 |
<refsect1> |
| 17 |
<title>Description</title> |
| 18 |
<para> |
| 19 |
Periodically reads an orchestra control-signal value from a named external file in a specific format. |
| 20 |
</para> |
| 21 |
</refsect1> |
| 22 |
|
| 23 |
<refsect1> |
| 24 |
<title>Syntax</title> |
| 25 |
<synopsis>kres <command>readk</command> ifilname, iformat, iprd</synopsis> |
| 26 |
</refsect1> |
| 27 |
|
| 28 |
<refsect1> |
| 29 |
<title>Initialization</title> |
| 30 |
<para> |
| 31 |
<emphasis>ifilname</emphasis> -- an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in SSDIR, and finally in SFDIR. |
| 32 |
</para> |
| 33 |
|
| 34 |
<para> |
| 35 |
<emphasis>iformat</emphasis> -- specifies the input data format: |
| 36 |
<itemizedlist> |
| 37 |
<listitem> |
| 38 |
<para>1 = 8-bit signed integers (char)</para> |
| 39 |
</listitem> |
| 40 |
|
| 41 |
<listitem> |
| 42 |
<para>4 = 16-bit short integers</para> |
| 43 |
</listitem> |
| 44 |
|
| 45 |
<listitem> |
| 46 |
<para>5 = 32-bit long integers</para> |
| 47 |
</listitem> |
| 48 |
|
| 49 |
<listitem> |
| 50 |
<para>6 = 32-bit floats</para> |
| 51 |
</listitem> |
| 52 |
|
| 53 |
<listitem> |
| 54 |
<para>7 = ASCII long integers (plain text)</para> |
| 55 |
</listitem> |
| 56 |
|
| 57 |
<listitem> |
| 58 |
<para>8 = ASCII floats (plain text)</para> |
| 59 |
</listitem> |
| 60 |
</itemizedlist> |
| 61 |
</para> |
| 62 |
|
| 63 |
<para> |
| 64 |
Note that A-law and U-law formats are not available, and that all formats except the last two are binary. The input file should be a "raw", headerless data file. |
| 65 |
</para> |
| 66 |
|
| 67 |
<para> |
| 68 |
<emphasis>iprd</emphasis> -- the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signal is read from the input file. A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate. Longer periods will cause the same values to repeat for more than one control period. |
| 69 |
|
| 70 |
</para> |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
</refsect1> |
| 80 |
|
| 81 |
<refsect1> |
| 82 |
<title>Performance</title> |
| 83 |
<para> |
| 84 |
<emphasis>kres</emphasis> -- output of the signal read from <emphasis>ifilname</emphasis>. |
| 85 |
</para> |
| 86 |
|
| 87 |
<para> |
| 88 |
This opcode allows a generated control signal value to be read from a named external file. The file should contain no header information but it should contain a regularly sampled time series of control values. For ASCII text formats, the values are assumed to be separated by at least one whitespace character. There may be any number of <emphasis>readk</emphasis> opcodes in an instrument or orchestra and they may read from the same or different files. |
| 89 |
</para> |
| 90 |
</refsect1> |
| 91 |
<refsect1> |
| 92 |
<title>Examples</title> |
| 93 |
<para> |
| 94 |
Here is an example of the readk opcode. It uses the file <ulink url="examples/readk.csd"><citetitle>readk.csd</citetitle></ulink>. |
| 95 |
<example> |
| 96 |
<title>Example of the readk opcode.</title> |
| 97 |
<para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 98 |
<xi:include href="examples-xml/readk.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 99 |
</example> |
| 100 |
</para> |
| 101 |
<para> |
| 102 |
Here is another example of the readk opcode. It uses the file <ulink url="examples/readk-2.csd"><citetitle>readk-2.csd</citetitle></ulink>. |
| 103 |
<example> |
| 104 |
<title>Example 2 of the readk opcode.</title> |
| 105 |
<xi:include href="examples-xml/readk-2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 106 |
</example> |
| 107 |
Its output should include lines like this: |
| 108 |
<screen> |
| 109 |
WARNING: Seeding from current time 683384022 |
| 110 |
|
| 111 |
i 1 time 1.00033: 463.64510 |
| 112 |
i 1 time 2.00000: 463.64510 |
| 113 |
i 1 time 3.00000: 483.14200 |
| 114 |
i 1 time 4.00000: 567.55973 |
| 115 |
i 1 time 5.00000: 576.37060 |
| 116 |
i 1 time 6.00000: 460.66550 |
| 117 |
|
| 118 |
i 2 time 6.00033: 463.64510 |
| 119 |
i 2 time 7.00000: 463.64510 |
| 120 |
i 2 time 8.00000: 483.14200 |
| 121 |
i 2 time 9.00000: 567.55970 |
| 122 |
i 2 time 10.00000: 576.37060 |
| 123 |
i 2 time 11.00000: 460.66550</screen> |
| 124 |
</para> |
| 125 |
</refsect1> |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
<refsect1> |
| 141 |
<title>See also</title> |
| 142 |
<para><link linkend="SigioFileIO"><citetitle>File Input and Output</citetitle></link></para> |
| 143 |
</refsect1> |
| 144 |
|
| 145 |
<refsect1> |
| 146 |
<title>Credits</title> |
| 147 |
<para>By: &namejohn; and &namebarry;</para> |
| 148 |
<para>1999 or earlier</para> |
| 149 |
</refsect1> |
| 150 |
</refentry> |