<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!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/html; charset=UTF-8" /> <title>p5gconnect</title> <link rel="stylesheet" href="csound.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="p.html" title="p" /> <link rel="next" href="p5gdata.html" title="p5gdata" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">p5gconnect</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="p.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="p5gdata.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="p5gconnect"> <a id="p5gconnect"></a> <div class="titlepage"></div> <a id="Indexp5gconnect" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">p5gconnect</span> </h2> <p>p5gconnect — Reads data from a P5 Glove controller. </p> </div> <div class="refsect1" title="Description"> <a id="id3082643"></a> <h2>Description</h2> <p> Opens and at control-rate polls a P5 Glove controller. </p> </div> <div class="refsect1" title="Syntax"> <a id="id3082661"></a> <h2>Syntax</h2> <pre class="synopsis"> <span class="command"> <strong>p5gconnect</strong> </span> </pre> </div> <div class="refsect1" title="Initialization"> <a id="id3082677"></a> <h2>Initialization</h2> <p> The opcode locates a P5 Glove attached to the computer by USB, and starts a listener thread to poll the device. </p> </div> <div class="refsect1" title="Performance"> <a id="id3082689"></a> <h2>Performance</h2> <p> Every control cycle the glove is polled for its position, and finger and button states. These values are read by the <span class="emphasis"><em>p5gdata</em></span> opcode. </p> </div> <div class="refsect1" title="Example"> <a id="id3082705"></a> <h2>Example</h2> <p> Here is an example of the p5g opcodes. It uses the file <a class="ulink" href="examples/p5g.csd" target="_top"><em class="citetitle">p5g.csd</em></a>. </p> <div class="example"> <a id="id3082721"></a> <p class="title"> <b>Example 413. Example of the p5g opcodes.</b> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> -+rtaudio=alsa -o dac:hw:0 <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="ohdr">ksmps</span> <span class="op">=</span> 1000 <span class="omacro">#define</span> P5G_BUTTONS #0# <span class="omacro">#define</span> P5G_BUTTON_A #1# <span class="omacro">#define</span> P5G_BUTTON_B #2# <span class="omacro">#define</span> P5G_BUTTON_C #4# <span class="omacro">#define</span> P5G_JUSTPUSH #8# <span class="omacro">#define</span> P5G_JUSTPU_A #9# <span class="omacro">#define</span> P5G_JUSTPU_B #10# <span class="omacro">#define</span> P5G_JUSTPU_C #12# <span class="omacro">#define</span> P5G_RELEASED #16# <span class="omacro">#define</span> P5G_RELSED_A #17# <span class="omacro">#define</span> P5G_RELSED_B #18# <span class="omacro">#define</span> P5G_RELSED_C #20# <span class="omacro">#define</span> P5G_FINGER_INDEX #32# <span class="omacro">#define</span> P5G_FINGER_MIDDLE #33# <span class="omacro">#define</span> P5G_FINGER_RING #34# <span class="omacro">#define</span> P5G_FINGER_PINKY #35# <span class="omacro">#define</span> P5G_FINGER_THUMB #36# <span class="omacro">#define</span> P5G_DELTA_X #37# <span class="omacro">#define</span> P5G_DELTA_Y #38# <span class="omacro">#define</span> P5G_DELTA_Z #39# <span class="omacro">#define</span> P5G_DELTA_XR #40# <span class="omacro">#define</span> P5G_DELTA_YR #41# <span class="omacro">#define</span> P5G_DELTA_ZR #42# <span class="omacro">#define</span> P5G_ANGLES #43# gka <span class="opc">init</span> 0 gkp <span class="opc">init</span> 0 <span class="oblock">instr</span> 1 p5gconnect ka p5gdata $P5G_JUSTPU_A. kc p5gdata $P5G_BUTTON_C. <span class="comment">; If the A button is just pressed then activate a note</span> <span class="octrl">if</span> (ka<span class="op">==</span>0) <span class="octrl">goto</span> <span class="olabel">ee</span> <span class="opc">event</span> "i", 2, 0, 2 <span class="olabel">ee</span><span class="op">:</span> gka p5gdata $P5G_DELTA_X. gkp p5gdata $P5G_DELTA_Y. <span class="opc">printk2</span> gka <span class="opc">printk2</span> gkp <span class="octrl">if</span> (kc<span class="op">==</span>0) <span class="octrl">goto</span> <span class="olabel">ff</span> <span class="opc">printks</span> "turning off (<span class="op">%</span>d)\n", 0, kc <span class="opc">turnoff</span> <span class="olabel">ff</span><span class="op">:</span> <span class="oblock">endin</span> <span class="oblock">instr</span> 2 a1 <span class="opc">oscil</span> <span class="opc">ampdbfs</span>(gkp), 440<span class="op">+</span>100<span class="op">*</span>gka, 1 <span class="comment">;; a1 oscil 10000, 440, 1</span> <span class="opc">out</span> a1 <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span>1 0 4096 10 1 <span class="stamnt">i</span>1 0 300 <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="id3083458"></a> <h2>See Also</h2> <p> <a class="link" href="p5gdata.html" title="p5gdata"><em class="citetitle">p5gdata</em></a>, </p> </div> <div class="refsect1" title="Credits"> <a id="id3083475"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: John ffitch</td> </tr> <tr> <td>Codemist Ltd</td> </tr> <tr> <td>2009</td> </tr> </table> <p> </p> <p>New in version 5.12</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="p.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="p5gdata.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">p </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> p5gdata</td> </tr> </table> </div> </body> </html>