1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
psychojs/docs/module-sound.TonePlayer.html
2021-02-20 13:02:55 +01:00

1528 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: TonePlayer</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: TonePlayer</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-sound.html">sound</a>.</span>TonePlayer<span class="signature">(options)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="TonePlayer"><span class="type-signature"></span>new TonePlayer<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This class handles the playing of tones.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>psychoJS</code></td>
<td class="type">
<span class="param-type"><a href="module-core.PsychoJS.html">module:core.PsychoJS</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the PsychoJS instance</td>
</tr>
<tr>
<td class="name"><code>duration_s</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
0.5
</td>
<td class="description last">duration of the tone (in seconds). If duration_s == -1, the sound will play indefinitely.</td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'C4'
</td>
<td class="description last">note (if string) or frequency (if number)</td>
</tr>
<tr>
<td class="name"><code>volume</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
1.0
</td>
<td class="description last">volume of the tone (must be between 0 and 1.0)</td>
</tr>
<tr>
<td class="name"><code>loops</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
0
</td>
<td class="description last">how many times to repeat the tone after it has played once. If loops == -1, the tone will repeat indefinitely until stopped.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line13">line 13</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>SoundPlayer</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="._initSoundLibrary"><span class="type-signature">(protected, static) </span>_initSoundLibrary<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Initialise the sound library.
<p>Note: if TonePlayer accepts the sound but Tone.js is not available, e.g. if the browser is IE11,
we throw an exception.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line290">line 290</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".accept"><span class="type-signature">(static) </span>accept<span class="signature">(sound)</span><span class="type-signature"> &rarr; {Object|undefined}</span></h4>
<div class="description">
Determine whether this player can play the given sound.
<p>Note: if TonePlayer accepts the sound but Tone.js is not available, e.g. if the browser is IE11,
we throw an exception.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sound</code></td>
<td class="type">
<span class="param-type"><a href="module-sound.Sound.html">module:sound.Sound</a></span>
</td>
<td class="description last">the sound</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line60">line 60</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
an instance of TonePlayer that can play the given sound or undefined otherwise
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
|
<span class="param-type">undefined</span>
</dd>
</dl>
<h4 class="name" id="getDuration"><span class="type-signature"></span>getDuration<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
<div class="description">
Get the duration of the sound.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line118">line 118</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the duration of the sound, in seconds
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id="play"><span class="type-signature"></span>play<span class="signature">(loops<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Start playing the sound.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>loops</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">how many times to repeat the sound after it has played once. If loops == -1, the sound will repeat indefinitely until stopped.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line193">line 193</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setDuration"><span class="type-signature"></span>setDuration<span class="signature">(duration_s)</span><span class="type-signature"></span></h4>
<div class="description">
Set the duration of the tone.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>duration_s</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">the duration of the tone (in seconds) If duration_s == -1, the sound will play indefinitely.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line132">line 132</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setLoops"><span class="type-signature"></span>setLoops<span class="signature">(loops)</span><span class="type-signature"></span></h4>
<div class="description">
Set the number of loops.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>loops</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">how many times to repeat the track after it has played once. If loops == -1, the track will repeat indefinitely until stopped.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line146">line 146</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setVolume"><span class="type-signature"></span>setVolume<span class="signature">(volume, mute<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Set the volume of the tone.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>volume</code></td>
<td class="type">
<span class="param-type">Integer</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the volume of the tone</td>
</tr>
<tr>
<td class="name"><code>mute</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to mute the tone</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line160">line 160</a>
</li></ul></dd>
</dl>
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Stop playing the sound immediately.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sound_TonePlayer.js.html">sound/TonePlayer.js</a>, <a href="sound_TonePlayer.js.html#line262">line 262</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="module-core.BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="module-core.EventManager.html">EventManager</a></li><li><a href="module-core.GUI.html">GUI</a></li><li><a href="module-core.Keyboard.html">Keyboard</a></li><li><a href="module-core.KeyPress.html">KeyPress</a></li><li><a href="module-core.Logger.html">Logger</a></li><li><a href="module-core.MinimalStim.html">MinimalStim</a></li><li><a href="module-core.Mouse.html">Mouse</a></li><li><a href="module-core.PsychoJS.html">PsychoJS</a></li><li><a href="module-core.ServerManager.html">ServerManager</a></li><li><a href="module-core.Window.html">Window</a></li><li><a href="module-data.ExperimentHandler.html">ExperimentHandler</a></li><li><a href="module-data.TrialHandler.html">TrialHandler</a></li><li><a href="module-sound.Sound.html">Sound</a></li><li><a href="module-sound.TonePlayer.html">TonePlayer</a></li><li><a href="module-sound.TrackPlayer.html">TrackPlayer</a></li><li><a href="module-util.Clock.html">Clock</a></li><li><a href="module-util.Color.html">Color</a></li><li><a href="module-util.CountdownTimer.html">CountdownTimer</a></li><li><a href="module-util.EventEmitter.html">EventEmitter</a></li><li><a href="module-util.MixinBuilder.html">MixinBuilder</a></li><li><a href="module-util.MonotonicClock.html">MonotonicClock</a></li><li><a href="module-util.PsychObject.html">PsychObject</a></li><li><a href="module-util.Scheduler.html">Scheduler</a></li><li><a href="module-visual.Form.html">Form</a></li><li><a href="module-visual.ImageStim.html">ImageStim</a></li><li><a href="module-visual.MovieStim.html">MovieStim</a></li><li><a href="module-visual.Polygon.html">Polygon</a></li><li><a href="module-visual.Rect.html">Rect</a></li><li><a href="module-visual.ShapeStim.html">ShapeStim</a></li><li><a href="module-visual.Slider.html">Slider</a></li><li><a href="module-visual.TextBox.html">TextBox</a></li><li><a href="module-visual.TextStim.html">TextStim</a></li><li><a href="module-visual.VisualStim.html">VisualStim</a></li><li><a href="TextInput.html">TextInput</a></li></ul><h3>Interfaces</h3><ul><li><a href="module-sound.SoundPlayer.html">SoundPlayer</a></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a></li><li><a href="module-util.ColorMixin.html">ColorMixin</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Sat Feb 20 2021 13:00:58 GMT+0100 (Central European Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>