1 \section{Built-in Module
\sectcode{audio
}}
4 \strong{Note:
} This module is obsolete, since the hardware to which it
5 interfaces is obsolete. For audio on the Indigo or
4D/
35, see
6 built-in module
\code{al
} above.
8 This module provides rudimentary access to the audio I/O device
9 \file{/dev/audio
} on the Silicon Graphics Personal IRIS
4D/
25;
10 see
{\it audio
}(
7). It supports the following operations:
12 \renewcommand{\indexsubitem}{(in module audio)
}
13 \begin{funcdesc
}{setoutgain
}{n
}
16 \code{0 <=
\var{n
} <
256}.
18 $
0 \leq \var{n
} <
256$.
19 %%JHXXX Sets the output gain (0-255).
23 \begin{funcdesc
}{getoutgain
}{}
24 Returns the output gain.
27 \begin{funcdesc
}{setrate
}{n
}
28 Sets the sampling rate:
\code{1} =
32K/sec,
\code{2} =
16K/sec,
32 \begin{funcdesc
}{setduration
}{n
}
33 Sets the `sound duration' in units of
1/
100 seconds.
36 \begin{funcdesc
}{read
}{n
}
39 sampled bytes from the audio input (line in or microphone).
40 The chunk is returned as a string of length n.
41 Each byte encodes one sample as a signed
8-bit quantity using linear
43 This string can be converted to numbers using
\code{chr2num()
} described
47 \begin{funcdesc
}{write
}{buf
}
48 Writes a chunk of samples to the audio output (speaker).
51 These operations support asynchronous audio I/O:
53 \renewcommand{\indexsubitem}{(in module audio)
}
54 \begin{funcdesc
}{start_recording
}{n
}
55 Starts a second thread (a process with shared memory) that begins reading
57 bytes from the audio device.
58 The main thread immediately continues.
61 \begin{funcdesc
}{wait_recording
}{}
62 Waits for the second thread to finish and returns the data read.
65 \begin{funcdesc
}{stop_recording
}{}
66 Makes the second thread stop reading as soon as possible.
67 Returns the data read so far.
70 \begin{funcdesc
}{poll_recording
}{}
71 Returns true if the second thread has finished reading (so
72 \code{wait_recording()
} would return the data without delay).
75 \begin{funcdesc
}{start_playing
}{}
76 \funcline{wait_playing
}{}
77 \funcline{stop_playing
}{}
78 \funcline{poll_playing
}{}
80 Similar but for output.
82 returns a lower bound for the number of bytes actually played (not very
87 The following operations do not affect the audio device but are
88 implemented in C for efficiency:
90 \renewcommand{\indexsubitem}{(in module audio)
}
91 \begin{funcdesc
}{amplify
}{buf\, f1\, f2
}
92 Amplifies a chunk of samples by a variable factor changing from
93 \code{\var{f1
}/
256} to
\code{\var{f2
}/
256.
}
94 Negative factors are allowed.
95 Resulting values that are to large to fit in a byte are clipped.
98 \begin{funcdesc
}{reverse
}{buf
}
99 Returns a chunk of samples backwards.
102 \begin{funcdesc
}{add
}{buf1\, buf2
}
103 Bytewise adds two chunks of samples.
104 Bytes that exceed the range are clipped.
105 If one buffer is shorter, it is assumed to be padded with zeros.
108 \begin{funcdesc
}{chr2num
}{buf
}
109 Converts a string of sampled bytes as returned by
\code{read()
} into
110 a list containing the numeric values of the samples.
113 \begin{funcdesc
}{num2chr
}{list
}
115 Converts a list as returned by
117 back to a buffer acceptable by