mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
380 lines
24 KiB
HTML
380 lines
24 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.6"/>
|
|
<title>ArduinoLibs: Melody Class Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.6 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="annotated.html"><span>Class List</span></a></li>
|
|
<li><a href="classes.html"><span>Class Index</span></a></li>
|
|
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
|
|
<li><a href="functions.html"><span>Class Members</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Pages</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
<a href="classMelody-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">Melody Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Plays a melody on a digital output pin using tone().
|
|
<a href="classMelody.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="Melody_8h_source.html">Melody.h</a>></code></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
|
|
Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:a9edc4165a49368dd5d78eedf982c38b9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9edc4165a49368dd5d78eedf982c38b9"></a>
|
|
 </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#a9edc4165a49368dd5d78eedf982c38b9">Melody</a> (uint8_t pin)</td></tr>
|
|
<tr class="memdesc:a9edc4165a49368dd5d78eedf982c38b9"><td class="mdescLeft"> </td><td class="mdescRight">Constructs a new melody playing object for <em>pin</em>. <br/></td></tr>
|
|
<tr class="separator:a9edc4165a49368dd5d78eedf982c38b9"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ad38db3338ed87d72238c0ea9440c633c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad38db3338ed87d72238c0ea9440c633c"></a>
|
|
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#ad38db3338ed87d72238c0ea9440c633c">isPlaying</a> () const </td></tr>
|
|
<tr class="memdesc:ad38db3338ed87d72238c0ea9440c633c"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if the melody is currently playing; false if not. <br/></td></tr>
|
|
<tr class="separator:ad38db3338ed87d72238c0ea9440c633c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab78253ae9abc8478b05f415f5d878a60"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#ab78253ae9abc8478b05f415f5d878a60">loopCount</a> () const </td></tr>
|
|
<tr class="memdesc:ab78253ae9abc8478b05f415f5d878a60"><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of times the melody should loop before stopping. <a href="#ab78253ae9abc8478b05f415f5d878a60">More...</a><br/></td></tr>
|
|
<tr class="separator:ab78253ae9abc8478b05f415f5d878a60"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a507097a2e8ff51a5e9157e3a320ae35b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#a507097a2e8ff51a5e9157e3a320ae35b">setLoopCount</a> (int count)</td></tr>
|
|
<tr class="memdesc:a507097a2e8ff51a5e9157e3a320ae35b"><td class="mdescLeft"> </td><td class="mdescRight">Sets the number of times the melody should loop to <em>count</em>. <a href="#a507097a2e8ff51a5e9157e3a320ae35b">More...</a><br/></td></tr>
|
|
<tr class="separator:a507097a2e8ff51a5e9157e3a320ae35b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae88ad06c2acb728f56dd213d5dad6006"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#ae88ad06c2acb728f56dd213d5dad6006">setLoopDuration</a> (unsigned long ms)</td></tr>
|
|
<tr class="memdesc:ae88ad06c2acb728f56dd213d5dad6006"><td class="mdescLeft"> </td><td class="mdescRight">Sets the maximum number of loops to last no longer than <em>ms</em> milliseconds. <a href="#ae88ad06c2acb728f56dd213d5dad6006">More...</a><br/></td></tr>
|
|
<tr class="separator:ae88ad06c2acb728f56dd213d5dad6006"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a9fd8e0d48833d8da3cd3b3b58408b0b5"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#a9fd8e0d48833d8da3cd3b3b58408b0b5">play</a> ()</td></tr>
|
|
<tr class="memdesc:a9fd8e0d48833d8da3cd3b3b58408b0b5"><td class="mdescLeft"> </td><td class="mdescRight">Starts playing the melody, or restarts it if already playing. <a href="#a9fd8e0d48833d8da3cd3b3b58408b0b5">More...</a><br/></td></tr>
|
|
<tr class="separator:a9fd8e0d48833d8da3cd3b3b58408b0b5"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aecc9185c9cb1246e8a55521b17d72932"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#aecc9185c9cb1246e8a55521b17d72932">playOnce</a> ()</td></tr>
|
|
<tr class="memdesc:aecc9185c9cb1246e8a55521b17d72932"><td class="mdescLeft"> </td><td class="mdescRight">Plays the melody once and then stops. <a href="#aecc9185c9cb1246e8a55521b17d72932">More...</a><br/></td></tr>
|
|
<tr class="separator:aecc9185c9cb1246e8a55521b17d72932"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ac0c552233c41d85f2766d2e4df376b2b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#ac0c552233c41d85f2766d2e4df376b2b">stop</a> ()</td></tr>
|
|
<tr class="memdesc:ac0c552233c41d85f2766d2e4df376b2b"><td class="mdescLeft"> </td><td class="mdescRight">Stops playing the melody. <a href="#ac0c552233c41d85f2766d2e4df376b2b">More...</a><br/></td></tr>
|
|
<tr class="separator:ac0c552233c41d85f2766d2e4df376b2b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:adb6ad8e8cfe8c9a137e470f4e85c7254"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#adb6ad8e8cfe8c9a137e470f4e85c7254">setMelody</a> (const int *notes, const uint8_t *lengths, unsigned int size)</td></tr>
|
|
<tr class="memdesc:adb6ad8e8cfe8c9a137e470f4e85c7254"><td class="mdescLeft"> </td><td class="mdescRight">Sets the melody to the <em>size</em> elements of <em>notes</em> and <em>lengths</em>. <a href="#adb6ad8e8cfe8c9a137e470f4e85c7254">More...</a><br/></td></tr>
|
|
<tr class="separator:adb6ad8e8cfe8c9a137e470f4e85c7254"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ad1103b970be1f59058cc7d927be68955"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classMelody.html#ad1103b970be1f59058cc7d927be68955">run</a> ()</td></tr>
|
|
<tr class="memdesc:ad1103b970be1f59058cc7d927be68955"><td class="mdescLeft"> </td><td class="mdescRight">Runs the melody control loop. <a href="#ad1103b970be1f59058cc7d927be68955">More...</a><br/></td></tr>
|
|
<tr class="separator:ad1103b970be1f59058cc7d927be68955"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>Plays a melody on a digital output pin using tone(). </p>
|
|
<p>The following example plays a simple tone three times on digital pin 8:</p>
|
|
<div class="fragment"><div class="line"><span class="preprocessor">#include <Melody.h></span></div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">int</span> notes[] = {</div>
|
|
<div class="line"> NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3,</div>
|
|
<div class="line"> NOTE_REST, NOTE_B3, NOTE_C4, NOTE_REST</div>
|
|
<div class="line">};</div>
|
|
<div class="line">byte lengths[] = {4, 8, 8, 4, 4, 4, 4, 4, 2};</div>
|
|
<div class="line"></div>
|
|
<div class="line"><a class="code" href="classMelody.html">Melody</a> melody(8);</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">void</span> setup() {</div>
|
|
<div class="line"> melody.setMelody(notes, lengths, <span class="keyword">sizeof</span>(lengths));</div>
|
|
<div class="line"> melody.setLoopCount(3);</div>
|
|
<div class="line"> melody.play();</div>
|
|
<div class="line">}</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="keywordtype">void</span> loop() {</div>
|
|
<div class="line"> melody.run();</div>
|
|
<div class="line">}</div>
|
|
</div><!-- fragment --><p>The <code>notes</code> array contains the frequency of the notes to be played, with the special value <code>NOTE_REST</code> indicating a rest where no notes are playing. The <code>lengths</code> array contains the lengths of each of the notes; a value of 4 indicates a quarter note, a value of 8 indicates an eighth note, etc.</p>
|
|
<p>The <a class="el" href="classMelody.html#ad1103b970be1f59058cc7d927be68955" title="Runs the melody control loop. ">run()</a> method must be called from the application's main <code>loop()</code> method to ensure that the melody advances from one note to the next. It will not block the application while notes are playing.</p>
|
|
<p>The number of loops can also be specified with <a class="el" href="classMelody.html#ae88ad06c2acb728f56dd213d5dad6006" title="Sets the maximum number of loops to last no longer than ms milliseconds. ">setLoopDuration()</a> which sets a maximum amount of time that the melody will play before stopping. The following example plays the melody for no more than 60 seconds:</p>
|
|
<div class="fragment"><div class="line"><span class="keywordtype">void</span> setup() {</div>
|
|
<div class="line"> melody.setMelody(notes, lengths, <span class="keyword">sizeof</span>(lengths));</div>
|
|
<div class="line"> melody.setLoopDuration(60000UL);</div>
|
|
<div class="line"> melody.play();</div>
|
|
<div class="line">}</div>
|
|
</div><!-- fragment -->
|
|
<p>Definition at line <a class="el" href="Melody_8h_source.html#l00122">122</a> of file <a class="el" href="Melody_8h_source.html">Melody.h</a>.</p>
|
|
</div><h2 class="groupheader">Member Function Documentation</h2>
|
|
<a class="anchor" id="ab78253ae9abc8478b05f415f5d878a60"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">int Melody::loopCount </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td> const</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the number of times the melody should loop before stopping. </p>
|
|
<p>The default value is zero, indicating that the melody will loop indefinitely.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#a507097a2e8ff51a5e9157e3a320ae35b" title="Sets the number of times the melody should loop to count. ">setLoopCount()</a>, <a class="el" href="classMelody.html#ae88ad06c2acb728f56dd213d5dad6006" title="Sets the maximum number of loops to last no longer than ms milliseconds. ">setLoopDuration()</a>, <a class="el" href="classMelody.html#a9fd8e0d48833d8da3cd3b3b58408b0b5" title="Starts playing the melody, or restarts it if already playing. ">play()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8h_source.html#l00128">128</a> of file <a class="el" href="Melody_8h_source.html">Melody.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a9fd8e0d48833d8da3cd3b3b58408b0b5"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::play </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Starts playing the melody, or restarts it if already playing. </p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#aecc9185c9cb1246e8a55521b17d72932" title="Plays the melody once and then stops. ">playOnce()</a>, <a class="el" href="classMelody.html#adb6ad8e8cfe8c9a137e470f4e85c7254" title="Sets the melody to the size elements of notes and lengths. ">setMelody()</a>, <a class="el" href="classMelody.html#ac0c552233c41d85f2766d2e4df376b2b" title="Stops playing the melody. ">stop()</a>, <a class="el" href="classMelody.html#ab78253ae9abc8478b05f415f5d878a60" title="Returns the number of times the melody should loop before stopping. ">loopCount()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00146">146</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="aecc9185c9cb1246e8a55521b17d72932"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::playOnce </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Plays the melody once and then stops. </p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#a9fd8e0d48833d8da3cd3b3b58408b0b5" title="Starts playing the melody, or restarts it if already playing. ">play()</a>, <a class="el" href="classMelody.html#ac0c552233c41d85f2766d2e4df376b2b" title="Stops playing the melody. ">stop()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00162">162</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ad1103b970be1f59058cc7d927be68955"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::run </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Runs the melody control loop. </p>
|
|
<p>This function must be called by the application's main <code>loop()</code> function to cause the melody to advance from note to note. It will not block the application while notes are playing. </p>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00214">214</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a507097a2e8ff51a5e9157e3a320ae35b"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::setLoopCount </td>
|
|
<td>(</td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>count</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Sets the number of times the melody should loop to <em>count</em>. </p>
|
|
<p>If <em>count</em> is zero, then the melody will loop indefinitely.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#ab78253ae9abc8478b05f415f5d878a60" title="Returns the number of times the melody should loop before stopping. ">loopCount()</a>, <a class="el" href="classMelody.html#ae88ad06c2acb728f56dd213d5dad6006" title="Sets the maximum number of loops to last no longer than ms milliseconds. ">setLoopDuration()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8h_source.html#l00129">129</a> of file <a class="el" href="Melody_8h_source.html">Melody.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ae88ad06c2acb728f56dd213d5dad6006"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::setLoopDuration </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned long </td>
|
|
<td class="paramname"><em>ms</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Sets the maximum number of loops to last no longer than <em>ms</em> milliseconds. </p>
|
|
<p>This function must be called after the melody is specified with <a class="el" href="classMelody.html#adb6ad8e8cfe8c9a137e470f4e85c7254" title="Sets the melody to the size elements of notes and lengths. ">setMelody()</a> as it uses the length of the melody and <em>ms</em> to determine the <a class="el" href="classMelody.html#ab78253ae9abc8478b05f415f5d878a60" title="Returns the number of times the melody should loop before stopping. ">loopCount()</a>.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#ab78253ae9abc8478b05f415f5d878a60" title="Returns the number of times the melody should loop before stopping. ">loopCount()</a>, <a class="el" href="classMelody.html#a507097a2e8ff51a5e9157e3a320ae35b" title="Sets the number of times the melody should loop to count. ">setLoopCount()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00131">131</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="adb6ad8e8cfe8c9a137e470f4e85c7254"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::setMelody </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const int * </td>
|
|
<td class="paramname"><em>notes</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t * </td>
|
|
<td class="paramname"><em>lengths</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"><em>size</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Sets the melody to the <em>size</em> elements of <em>notes</em> and <em>lengths</em>. </p>
|
|
<p>If a melody is currently playing, then this function will stop playback.</p>
|
|
<p>The <em>notes</em> array contains the frequency of the notes to be played, with the special value <code>NOTE_REST</code> indicating a rest where no notes are playing. The <em>lengths</em> array contains the lengths of each of the notes; a value of 4 indicates a quarter note, a value of 8 indicates an eighth note, etc.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#a9fd8e0d48833d8da3cd3b3b58408b0b5" title="Starts playing the melody, or restarts it if already playing. ">play()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00199">199</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ac0c552233c41d85f2766d2e4df376b2b"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Melody::stop </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Stops playing the melody. </p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classMelody.html#a9fd8e0d48833d8da3cd3b3b58408b0b5" title="Starts playing the melody, or restarts it if already playing. ">play()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Melody_8cpp_source.html#l00178">178</a> of file <a class="el" href="Melody_8cpp_source.html">Melody.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following files:<ul>
|
|
<li><a class="el" href="Melody_8h_source.html">Melody.h</a></li>
|
|
<li><a class="el" href="Melody_8cpp_source.html">Melody.cpp</a></li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sun Mar 29 2015 08:30:13 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.6
|
|
</small></address>
|
|
</body>
|
|
</html>
|