summaryrefslogtreecommitdiff
path: root/devdocs/elisp/sound-output.html
blob: df5ab403d0d7934ac3177a9a9d21889c6764868b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 <h3 class="section">Sound Output</h3>  <p>To play sound using Emacs, use the function <code>play-sound</code>. Only certain systems are supported; if you call <code>play-sound</code> on a system which cannot really do the job, it gives an error. </p> <p>The sound must be stored as a file in RIFF-WAVE format (‘<samp>.wav</samp>’) or Sun Audio format (‘<samp>.au</samp>’). </p> <dl> <dt id="play-sound">Function: <strong>play-sound</strong> <em>sound</em>
</dt> <dd>
<p>This function plays a specified sound. The argument, <var>sound</var>, has the form <code>(sound <var>properties</var>...)</code>, where the <var>properties</var> consist of alternating keywords (particular symbols recognized specially) and values corresponding to them. </p> <p>Here is a table of the keywords that are currently meaningful in <var>sound</var>, and their meanings: </p> <dl compact> <dt><code>:file <var>file</var></code></dt> <dd>
<p>This specifies the file containing the sound to play. If the file name is not absolute, it is expanded against the directory <code>data-directory</code>. </p> </dd> <dt><code>:data <var>data</var></code></dt> <dd>
<p>This specifies the sound to play without need to refer to a file. The value, <var>data</var>, should be a string containing the same bytes as a sound file. We recommend using a unibyte string. </p> </dd> <dt><code>:volume <var>volume</var></code></dt> <dd>
<p>This specifies how loud to play the sound. It should be a number in the range of 0 to 1. The default is to use whatever volume has been specified before. </p> </dd> <dt><code>:device <var>device</var></code></dt> <dd><p>This specifies the system device on which to play the sound, as a string. The default device is system-dependent. </p></dd> </dl> <p>Before actually playing the sound, <code>play-sound</code> calls the functions in the list <code>play-sound-functions</code>. Each function is called with one argument, <var>sound</var>. </p>
</dd>
</dl> <dl> <dt id="play-sound-file">Command: <strong>play-sound-file</strong> <em>file &amp;optional volume device</em>
</dt> <dd><p>This function is an alternative interface to playing a sound <var>file</var> specifying an optional <var>volume</var> and <var>device</var>. </p></dd>
</dl> <dl> <dt id="play-sound-functions">Variable: <strong>play-sound-functions</strong>
</dt> <dd><p>A list of functions to be called before playing a sound. Each function is called with one argument, a property list that describes the sound. </p></dd>
</dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Sound-Output.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Sound-Output.html</a>
  </p>
</div>