+/* --- @AUPLAY(TAG, [FLAG])@ --- *
+ *
+ * Arguments: @TAG@ = audio sample tag to play
+ * @FLAG@ = a string to explain what to do more clearly.
+ *
+ * Returns: True if it succeeded.
+ *
+ * Use: Plays a sample. If @FLAG@ begins with `t', don't report
+ * errors if the sample can't be found.
+ */
+
+static APIRET APIENTRY rxfn_auplay(const char *fn, ULONG ac, RXSTRING *av,
+ const char *sn, RXSTRING *r)
+{
+ dstr d = DSTR_INIT;
+ int rc = 1;
+
+ if (ac < 1 || !av[0].strlength || ac > 2)
+ return (-1);
+ rxs_get(&av[0], &d);
+ if (ac > 1 && av[1].strlength >= 1 &&
+ (av[1].strptr[0] == 't' || av[1].strptr[0] == 'T'))
+ rc = au_tryplay(d.buf);
+ else
+ au_play(d.buf);
+ dstr_destroy(&d);
+ rxs_putf(r, "%d", rc);
+ return (0);
+}
+
+/* --- @AUFETCH(TAG)@ --- *
+ *
+ * Arguments: @TAG@ = audio sample tag to play
+ *
+ * Returns: True if it succeeded.
+ *
+ * Use: Prefetches a sample into the cache.
+ */
+
+static APIRET APIENTRY rxfn_aufetch(const char *fn, ULONG ac, RXSTRING *av,
+ const char *sn, RXSTRING *r)
+{
+ dstr d = DSTR_INIT;
+ int rc = 0;
+ au_sample *s;
+ au_data *a;
+
+ if (ac < 1 || !av[0].strlength || ac > 1)
+ return (-1);
+ rxs_get(&av[0], &d);
+ if ((s = au_find(d.buf)) != 0 &&
+ (a = au_fetch(s)) != 0) {
+ au_free(a);
+ rc = 1;
+ }
+ dstr_destroy(&d);
+ rxs_putf(r, "%d", rc);
+ return (0);
+}
+
+/* --- @AUNUM(TAG)@ --- *
+ *
+ * Arguments: @NUM@ = a number to be read
+ *
+ * Returns: ---
+ *
+ * Use: Reads a number aloud to the audio device.
+ */
+
+static APIRET APIENTRY rxfn_aunum(const char *fn, ULONG ac, RXSTRING *av,
+ const char *sn, RXSTRING *r)
+{
+ dstr d = DSTR_INIT;
+
+ if (ac < 1 || !av[0].strlength || ac > 1)
+ return (-1);
+ rxs_get(&av[0], &d);
+ aunum(d.buf);
+ dstr_destroy(&d);
+ return (0);
+}
+