Skip to content

Commit

Permalink
Add example for tttapa/MIDI_controller#97
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Dec 10, 2019
1 parent 0cbef22 commit 61ff2df
Show file tree
Hide file tree
Showing 24 changed files with 332 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
<div class="title">1.Volume-Controlled-USB-DAC.ino</div> </div>
</div><!--header-->
<div class="contents">
<h1><a class="anchor" id="autotoc_md127"></a>
<h1><a class="anchor" id="autotoc_md128"></a>
1.Volume-Controlled-USB-DAC</h1>
<p>This is an example of the <a class="el" href="../../d4/de3/classVolumeControl.html" title="A class for controlling the volume of AudioMixer4 objects using a potentiometer.">VolumeControl</a> class of the Control Surface library. It acts as a USB Audio DAC (Digital-to-Analog Converter).</p>
<dl class="section user"><dt>Boards:</dt><dd>Teensy 3.x</dd></dl>
<h2><a class="anchor" id="autotoc_md128"></a>
<h2><a class="anchor" id="autotoc_md129"></a>
Connections</h2>
<p>This specific example uses an I²S DAC, but you can use other interfaces of the Teensy Audio library as well. For testing, I'm using a PCM5102a.</p>
<ul>
Expand All @@ -90,11 +90,11 @@ <h2><a class="anchor" id="autotoc_md128"></a>
</ul>
<p>Connect the left terminal of the potentiometer to ground, and the right one to V<sub>CC</sub>.</p>
<p>Select a USB audio option from the Tools menu in the IDE.</p>
<h2><a class="anchor" id="autotoc_md129"></a>
<h2><a class="anchor" id="autotoc_md130"></a>
Behavior</h2>
<p>Upload the sketch, and select the Control Surface as the audio output of your computer. Connect the output of the DAC to a pair of headphones or powered speakers, and play some music. <br />
You can now adjust the volume using the potentiometer.</p>
<h2><a class="anchor" id="autotoc_md130"></a>
<h2><a class="anchor" id="autotoc_md131"></a>
Mapping</h2>
<p>None.</p>
<p>Written by PieterP, 2019-08-09 <br />
Expand Down
8 changes: 4 additions & 4 deletions docs/Doxygen/d0/d32/MIDI-Input-Callback_8ino-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@
<div class="title">MIDI-Input-Callback.ino</div> </div>
</div><!--header-->
<div class="contents">
<h1><a class="anchor" id="autotoc_md123"></a>
<h1><a class="anchor" id="autotoc_md124"></a>
MIDI-Input-Callback</h1>
<p>This is an example on how to attach your own callbacks for receiving MIDI input data.</p>
<dl class="section user"><dt>Boards:</dt><dd>AVR, AVR USB, Due, Nano 33, Teensy 3.x, ESP32</dd></dl>
<h2><a class="anchor" id="autotoc_md124"></a>
<h2><a class="anchor" id="autotoc_md125"></a>
Connections</h2>
<p>None.</p>
<h2><a class="anchor" id="autotoc_md125"></a>
<h2><a class="anchor" id="autotoc_md126"></a>
Behavior</h2>
<ul>
<li>When MIDI messages are sent to the USB interface, they are printed to the Serial port.</li>
</ul>
<h2><a class="anchor" id="autotoc_md126"></a>
<h2><a class="anchor" id="autotoc_md127"></a>
Mapping</h2>
<p>None.</p>
<p>Written by PieterP, 2019-08-07 <br />
Expand Down
22 changes: 21 additions & 1 deletion docs/Doxygen/d4/dbe/namespaceMIDI__CC.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ <h2 class="memtitle"><span class="permalink"><a href="#ab0416b7ab8e6735cd0d7d5dc
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../d8/d59/1_8First-Output_8ino-example.html#a3">1.First-Output.ino</a>, <a class="el" href="../../de/de4/Control-Change-Potentiometer_8ino-example.html#a2">Control-Change-Potentiometer.ino</a>, and <a class="el" href="../../d9/d9d/MIDI-Controller-Finished-Example_8ino-example.html#a4">MIDI-Controller-Finished-Example.ino</a>.</dd>
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../d8/d59/1_8First-Output_8ino-example.html#a3">1.First-Output.ino</a>, <a class="el" href="../../de/de4/Control-Change-Potentiometer_8ino-example.html#a2">Control-Change-Potentiometer.ino</a>, <a class="el" href="../../d9/d9d/MIDI-Controller-Finished-Example_8ino-example.html#a4">MIDI-Controller-Finished-Example.ino</a>, and <a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a4">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00023">23</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>
Expand Down Expand Up @@ -495,6 +495,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a387d0b2e50ca62985339ada9
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a23">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00028">28</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -519,6 +521,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a74d40ba44bcb8038da09d9e9
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a25">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00029">29</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand Down Expand Up @@ -1223,6 +1227,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a6175cdec915c72aa878d46c0
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a7">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00070">70</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1247,6 +1253,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#ac93b5216e9ef6531ed24607e
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a9">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00071">71</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1271,6 +1279,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#ae19d57fe27a2fc0c2c7fbc18
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a11">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00072">72</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1295,6 +1305,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#af5481936386fe76e82bd87e6
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a13">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00073">73</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand Down Expand Up @@ -1561,6 +1573,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a1452ebb069eec6b6d2bd78ed
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a15">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00088">88</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1585,6 +1599,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#ab11284129427da5946423184
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a17">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00089">89</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1609,6 +1625,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#ad88eb1e442062ff26976943f
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a19">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00090">90</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand All @@ -1633,6 +1651,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#a564086cbe2e297efad355dbc
</tr>
</table>
</div><div class="memdoc">
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#a21">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html#l00091">91</a> of file <a class="el" href="../../d9/d43/Control__Change_8hpp_source.html">Control_Change.hpp</a>.</p>

Expand Down
2 changes: 2 additions & 0 deletions docs/Doxygen/d5/d2d/classIncrementDecrementSelectorLEDs.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
</table>
</dd>
</dl>
<dl class="section examples"><dt>Examples</dt><dd><a class="el" href="../../de/d26/MIDI_controller-97_8ino-example.html#_a1">MIDI_controller-97.ino</a>.</dd>
</dl>

<p class="definition">Definition at line <a class="el" href="../../d3/dce/SelectorLEDs_8hpp_source.html#l00099">99</a> of file <a class="el" href="../../d3/dce/SelectorLEDs_8hpp_source.html">SelectorLEDs.hpp</a>.</p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
Expand Down
40 changes: 20 additions & 20 deletions docs/Doxygen/d5/d7d/md_pages_Getting-Started.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#installation">Installation</a></li>
<li class="level1"><a href="#first-output">First Output: Creating a Basic MIDI Controller Sketch</a><ul><li class="level2"><a href="#autotoc_md147">1. Include the library</a></li>
<li class="level1"><a href="#first-output">First Output: Creating a Basic MIDI Controller Sketch</a><ul><li class="level2"><a href="#autotoc_md148">1. Include the library</a></li>
<li class="level2"><a href="#first-output-midi-interface">2. Instantiate a MIDI Interface</a></li>
<li class="level2"><a href="#first-output-extio">3. Add Extended Input/Output elements (optional)</a></li>
<li class="level2"><a href="#autotoc_md148">4. Add MIDI Control Elements</a></li>
<li class="level2"><a href="#autotoc_md149">4. Add MIDI Control Elements</a></li>
<li class="level2"><a href="#first-output-init">5. Initialize the Control Surface</a></li>
<li class="level2"><a href="#first-output-loop">6. Continuously Update the Control Surface</a></li>
<li class="level2"><a href="#autotoc_md149">The finished sketch</a></li>
<li class="level2"><a href="#autotoc_md150">The finished sketch</a></li>
</ul>
</li>
<li class="level1"><a href="#first-input">First Input: Getting Feedback from the MIDI Software</a><ul><li class="level2"><a href="#autotoc_md150">1. Include the library</a></li>
<li class="level2"><a href="#autotoc_md151">2. Instantiate a MIDI Interface</a></li>
<li class="level2"><a href="#autotoc_md152">3. Add Extended Input/Output elements (optional)</a></li>
<li class="level2"><a href="#autotoc_md153">4. Add MIDI Control Elements</a></li>
<li class="level2"><a href="#autotoc_md154">5. Initialize the Control Surface</a></li>
<li class="level2"><a href="#autotoc_md155">6. Continuously Update the Control Surface</a></li>
<li class="level2"><a href="#autotoc_md156">The finished sketch</a></li>
<li class="level1"><a href="#first-input">First Input: Getting Feedback from the MIDI Software</a><ul><li class="level2"><a href="#autotoc_md151">1. Include the library</a></li>
<li class="level2"><a href="#autotoc_md152">2. Instantiate a MIDI Interface</a></li>
<li class="level2"><a href="#autotoc_md153">3. Add Extended Input/Output elements (optional)</a></li>
<li class="level2"><a href="#autotoc_md154">4. Add MIDI Control Elements</a></li>
<li class="level2"><a href="#autotoc_md155">5. Initialize the Control Surface</a></li>
<li class="level2"><a href="#autotoc_md156">6. Continuously Update the Control Surface</a></li>
<li class="level2"><a href="#autotoc_md157">The finished sketch</a></li>
</ul>
</li>
</ul>
Expand All @@ -101,7 +101,7 @@
<p>Instructions on how to install the library and its dependencies can be found on the page <a class="el" href="../../d2/d2c/Installation_8md.html">Installation</a>.</p>
<h1><a class="anchor" id="first-output"></a>
First Output: Creating a Basic MIDI Controller Sketch</h1>
<h2><a class="anchor" id="autotoc_md147"></a>
<h2><a class="anchor" id="autotoc_md148"></a>
1. Include the library</h2>
<p>Include the library so that you have access to all the classes and functions.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../db/dbf/Control__Surface_8h.html">Control_Surface.h</a>&gt;</span></div>
Expand Down Expand Up @@ -135,7 +135,7 @@ <h2><a class="anchor" id="first-output-extio"></a>
<p>Each of the eight analog inputs of the multiplexer can be connected to the wiper of one potentiometer.</p>
<p>We'll connect the three address lines of the multiplexer (<code>S0</code>, <code>S1</code> and <code>S2</code>) to digital pins <code>3</code>, <code>4</code> and <code>5</code>. The output of the multiplexer goes to analog pin <code>A0</code>. Connect the enable pin (<code>Ē</code>) to ground.</p>
<div class="fragment"><div class="line"><a class="code" href="../../db/dd3/group__AH__ExtIO.html#ga61b86abe972c3205b1c165aa40632aa0">CD74HC4051</a> mux = { A0, {3, 4, 5} };</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md148"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md149"></a>
4. Add MIDI Control Elements</h2>
<p>Now, we can specify the objects that read the input of the potentiometers and send out MIDI events accordingly.</p>
<p>Again, I'll refer to the overview of MIDI Output Elements <a href="https://tttapa.github.io/Control-Surface/Doc/Doxygen/d7/dcd/group__MIDIOutputElements.html">here</a>.</p>
Expand Down Expand Up @@ -187,7 +187,7 @@ <h2><a class="anchor" id="first-output-loop"></a>
</div><!-- fragment --><blockquote class="doxtable">
<p><b>Note</b>: Using blocking code like delays will interfere with the Control Surface, so try to use <a href="https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay">Blink Without Delay</a> techniques instead. </p>
</blockquote>
<h2><a class="anchor" id="autotoc_md149"></a>
<h2><a class="anchor" id="autotoc_md150"></a>
The finished sketch</h2>
<p>That's it! <br />
Now you can just upload the sketch to your Arduino, open up your favorite audio software, map the potentiometers, and start playing!</p>
Expand Down Expand Up @@ -238,15 +238,15 @@ <h2><a class="anchor" id="autotoc_md149"></a>
allow="accelerometer; autoplay; encrypted-media; gyroscope;
picture-in-picture" allowfullscreen></iframe>
</p>
<h2><a class="anchor" id="autotoc_md150"></a>
<h2><a class="anchor" id="autotoc_md151"></a>
1. Include the library</h2>
<p>Include the library so that you have access to all the classes and functions.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../db/dbf/Control__Surface_8h.html">Control_Surface.h</a>&gt;</span></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md151"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md152"></a>
2. Instantiate a MIDI Interface</h2>
<p>See <a class="el" href="../../d5/d7d/md_pages_Getting-Started.html#first-output-midi-interface">First Output: Instantiate a MIDI Interface</a>.</p>
<div class="fragment"><div class="line"><a class="code" href="../../de/d05/classUSBMIDI__Interface.html">USBMIDI_Interface</a> midi;</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md152"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md153"></a>
3. Add Extended Input/Output elements (optional)</h2>
<p>See <a class="el" href="../../d5/d7d/md_pages_Getting-Started.html#first-output-extio">First Output: Add Extended Input/Output elements</a>.</p>
<p>In this example, we'll use a 74HC595 8-bit serial in/parallel out shift register. This allows us to drive eight LEDs using just the SPI bus and a single digital pin. You can daisy chain as many shift registers as you want, without requiring any more pins.</p>
Expand All @@ -258,7 +258,7 @@ <h2><a class="anchor" id="autotoc_md150"></a>
<div class="line">};</div>
</div><!-- fragment --><p>The <code>8</code> between angle brackets (<code>&lt;&gt;</code>) is the number of bits of the shift register. If you daisy chain two 8-bit shift registers together, you would use <code>16</code> instead of <code>8</code>, for example. <br />
The bit order determines which pin of the shift register is the first pin in the program. <code>MSBFIRST</code> means "most significant bit first". You can also use <code>LSBFIRST</code> (least significant bit first).</p>
<h2><a class="anchor" id="autotoc_md153"></a>
<h2><a class="anchor" id="autotoc_md154"></a>
4. Add MIDI Control Elements</h2>
<p>Now, we can specify the objects that listen for MIDI input, and update the status of the LEDs accordingly.</p>
<p>I'll refer to the overview of MIDI Input Elements <a href="https://tttapa.github.io/Control-Surface/Doc/Doxygen/d7/dcd/group__MIDIInputElements.html">here</a>.</p>
Expand All @@ -285,19 +285,19 @@ <h2><a class="anchor" id="autotoc_md153"></a>
<div class="line"> {sreg.pin(6), <a class="code" href="../../d7/d78/namespaceMIDI__Notes.html#a559f01ec7251fdc9c5a5bc0e26b97372">note</a>(<a class="code" href="../../d7/d78/namespaceMIDI__Notes.html#a5d3863f3260c9ccc894ed8c2827b9423">B</a>, 4)},</div>
<div class="line"> {sreg.pin(7), <a class="code" href="../../d7/d78/namespaceMIDI__Notes.html#a559f01ec7251fdc9c5a5bc0e26b97372">note</a>(<a class="code" href="../../d7/d78/namespaceMIDI__Notes.html#ac199d8a68ddb5b6aab199fc827947900">C</a>, 5)},</div>
<div class="line">};</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md154"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md155"></a>
5. Initialize the Control Surface</h2>
<p>See <a class="el" href="../../d5/d7d/md_pages_Getting-Started.html#first-output-init">First Output: Initialize the Control Surface</a>.</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> setup() {</div>
<div class="line"> <a class="code" href="../../d9/d38/Control__Surface__Class_8cpp.html#af7a5d250297d82b2b29605dd7ac250df">Control_Surface</a>.<a class="code" href="../../dc/d45/classControl__Surface__.html#a1fda63983d83a8be20302e9fef48f63e">begin</a>();</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md155"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md156"></a>
6. Continuously Update the Control Surface</h2>
<p>See <a class="el" href="../../d5/d7d/md_pages_Getting-Started.html#first-output-loop">First Output: Continuously Update the Control Surface</a>.</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> loop() {</div>
<div class="line"> <a class="code" href="../../d9/d38/Control__Surface__Class_8cpp.html#af7a5d250297d82b2b29605dd7ac250df">Control_Surface</a>.<a class="code" href="../../dc/d45/classControl__Surface__.html#a69fd0ae13604c39d6dc0da12fc94a18f">loop</a>();</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md156"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md157"></a>
The finished sketch</h2>
<p>That's it! <br />
Now you can just upload the sketch to your Arduino, open up your favorite audio software, redirect the MIDI output to the Arduino, and start playing!</p>
Expand Down
Loading

0 comments on commit 61ff2df

Please sign in to comment.