PageRenderTime 86ms CodeModel.GetById 40ms app.highlight 22ms RepoModel.GetById 18ms app.codeStats 0ms

/apidocs/echonest.support.midi.DataTypeConverters-module.html

http://echo-nest-remix.googlecode.com/
HTML | 439 lines | 381 code | 36 blank | 22 comment | 0 complexity | e67663f7ce22d63fcc1a243105222d31 MD5 | raw file
  1<?xml version="1.0" encoding="ascii"?>
  2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3          "DTD/xhtml1-transitional.dtd">
  4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5<head>
  6  <title>echonest.support.midi.DataTypeConverters</title>
  7  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  8  <script type="text/javascript" src="epydoc.js"></script>
  9</head>
 10
 11<body bgcolor="white" text="black" link="blue" vlink="#204080"
 12      alink="#204080">
 13<!-- ==================== NAVIGATION BAR ==================== -->
 14<table class="navbar" border="0" width="100%" cellpadding="0"
 15       bgcolor="#a0c0ff" cellspacing="0">
 16  <tr valign="middle">
 17
 18  <!-- Tree link -->
 19      <th>&nbsp;&nbsp;&nbsp;<a
 20        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
 21
 22  <!-- Index link -->
 23      <th>&nbsp;&nbsp;&nbsp;<a
 24        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
 25
 26  <!-- Help link -->
 27      <th>&nbsp;&nbsp;&nbsp;<a
 28        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
 29
 30  <!-- Project homepage -->
 31      <th class="navbar" align="right" width="100%">
 32        <table border="0" cellpadding="0" cellspacing="0">
 33          <tr><th class="navbar" align="center"
 34            ><a class="navbar" target="_top" href="http://code.google.com/p/echo-nest-remix/">Project Homepage</a></th>
 35          </tr></table></th>
 36  </tr>
 37</table>
 38<table width="100%" cellpadding="0" cellspacing="0">
 39  <tr valign="top">
 40    <td width="100%">
 41      <span class="breadcrumbs">
 42        <a href="echonest-module.html">Package&nbsp;echonest</a> ::
 43        <a href="echonest.support-module.html">Package&nbsp;support</a> ::
 44        <a href="echonest.support.midi-module.html">Package&nbsp;midi</a> ::
 45        Module&nbsp;DataTypeConverters
 46      </span>
 47    </td>
 48    <td>
 49      <table cellpadding="0" cellspacing="0">
 50        <!-- hide/show private -->
 51        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
 52    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
 53        <tr><td align="right"><span class="options"
 54            >[<a href="frames.html" target="_top">frames</a
 55            >]&nbsp;|&nbsp;<a href="echonest.support.midi.DataTypeConverters-module.html"
 56            target="_top">no&nbsp;frames</a>]</span></td></tr>
 57      </table>
 58    </td>
 59  </tr>
 60</table>
 61<!-- ==================== MODULE DESCRIPTION ==================== -->
 62<h1 class="epydoc">Module DataTypeConverters</h1><p class="nomargin-top"><span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html">source&nbsp;code</a></span></p>
 63<!-- ==================== FUNCTIONS ==================== -->
 64<a name="section-Functions"></a>
 65<table class="summary" border="1" cellpadding="3"
 66       cellspacing="0" width="100%" bgcolor="white">
 67<tr bgcolor="#70b0f0" class="table-header">
 68  <td colspan="2" class="table-header">
 69    <table border="0" cellpadding="0" cellspacing="0" width="100%">
 70      <tr valign="top">
 71        <td align="left"><span class="table-header">Functions</span></td>
 72        <td align="right" valign="top"
 73         ><span class="options">[<a href="#section-Functions"
 74         class="privatelink" onclick="toggle_private();"
 75         >hide private</a>]</span></td>
 76      </tr>
 77    </table>
 78  </td>
 79</tr>
 80<tr>
 81    <td width="15%" align="right" valign="top" class="summary">
 82      <span class="summary-type">&nbsp;</span>
 83    </td><td class="summary">
 84      <table width="100%" cellpadding="0" cellspacing="0" border="0">
 85        <tr>
 86          <td><span class="summary-sig"><a href="echonest.support.midi.DataTypeConverters-module.html#getNibbles" class="summary-sig-name">getNibbles</a>(<span class="summary-sig-arg">byte</span>)</span><br />
 87      Returns hi and lo bits in a byte as a tuple
 88&gt;&gt;&gt; getNibbles(142)
 89(8, 14)</td>
 90          <td align="right" valign="top">
 91            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#getNibbles">source&nbsp;code</a></span>
 92            
 93          </td>
 94        </tr>
 95      </table>
 96      
 97    </td>
 98  </tr>
 99<tr>
100    <td width="15%" align="right" valign="top" class="summary">
101      <span class="summary-type">&nbsp;</span>
102    </td><td class="summary">
103      <table width="100%" cellpadding="0" cellspacing="0" border="0">
104        <tr>
105          <td><span class="summary-sig"><a name="setNibbles"></a><span class="summary-sig-name">setNibbles</span>(<span class="summary-sig-arg">hiNibble</span>,
106        <span class="summary-sig-arg">loNibble</span>)</span><br />
107      Returns byte with value set according to hi and lo bits
108Asserts hiNibble and loNibble in range(16)
109&gt;&gt;&gt; setNibbles(8, 14)
110142</td>
111          <td align="right" valign="top">
112            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#setNibbles">source&nbsp;code</a></span>
113            
114          </td>
115        </tr>
116      </table>
117      
118    </td>
119  </tr>
120<tr>
121    <td width="15%" align="right" valign="top" class="summary">
122      <span class="summary-type">&nbsp;</span>
123    </td><td class="summary">
124      <table width="100%" cellpadding="0" cellspacing="0" border="0">
125        <tr>
126          <td><span class="summary-sig"><a name="readBew"></a><span class="summary-sig-name">readBew</span>(<span class="summary-sig-arg">value</span>)</span><br />
127      Reads string as big endian word, (asserts len(value) in [1,2,4])
128&gt;&gt;&gt; readBew('a&#225;&#226;&#227;')
1291642193635L
130&gt;&gt;&gt; readBew('a&#225;')
13125057</td>
132          <td align="right" valign="top">
133            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#readBew">source&nbsp;code</a></span>
134            
135          </td>
136        </tr>
137      </table>
138      
139    </td>
140  </tr>
141<tr>
142    <td width="15%" align="right" valign="top" class="summary">
143      <span class="summary-type">&nbsp;</span>
144    </td><td class="summary">
145      <table width="100%" cellpadding="0" cellspacing="0" border="0">
146        <tr>
147          <td><span class="summary-sig"><a href="echonest.support.midi.DataTypeConverters-module.html#writeBew" class="summary-sig-name">writeBew</a>(<span class="summary-sig-arg">value</span>,
148        <span class="summary-sig-arg">length</span>)</span><br />
149      Write int as big endian formatted string, (asserts length in [1,2,4])
150Difficult to print the result in doctest, so I do a simple roundabout test.</td>
151          <td align="right" valign="top">
152            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#writeBew">source&nbsp;code</a></span>
153            
154          </td>
155        </tr>
156      </table>
157      
158    </td>
159  </tr>
160<tr>
161    <td width="15%" align="right" valign="top" class="summary">
162      <span class="summary-type">&nbsp;</span>
163    </td><td class="summary">
164      <table width="100%" cellpadding="0" cellspacing="0" border="0">
165        <tr>
166          <td><span class="summary-sig"><a href="echonest.support.midi.DataTypeConverters-module.html#readVar" class="summary-sig-name">readVar</a>(<span class="summary-sig-arg">value</span>)</span><br />
167      Converts varlength format to integer.</td>
168          <td align="right" valign="top">
169            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#readVar">source&nbsp;code</a></span>
170            
171          </td>
172        </tr>
173      </table>
174      
175    </td>
176  </tr>
177<tr>
178    <td width="15%" align="right" valign="top" class="summary">
179      <span class="summary-type">&nbsp;</span>
180    </td><td class="summary">
181      <table width="100%" cellpadding="0" cellspacing="0" border="0">
182        <tr>
183          <td><span class="summary-sig"><a name="varLen"></a><span class="summary-sig-name">varLen</span>(<span class="summary-sig-arg">value</span>)</span><br />
184      Returns the the number of bytes an integer will be when
185converted to varlength</td>
186          <td align="right" valign="top">
187            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#varLen">source&nbsp;code</a></span>
188            
189          </td>
190        </tr>
191      </table>
192      
193    </td>
194  </tr>
195<tr>
196    <td width="15%" align="right" valign="top" class="summary">
197      <span class="summary-type">&nbsp;</span>
198    </td><td class="summary">
199      <table width="100%" cellpadding="0" cellspacing="0" border="0">
200        <tr>
201          <td><span class="summary-sig"><a name="writeVar"></a><span class="summary-sig-name">writeVar</span>(<span class="summary-sig-arg">value</span>)</span><br />
202      Converts an integer to varlength format</td>
203          <td align="right" valign="top">
204            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#writeVar">source&nbsp;code</a></span>
205            
206          </td>
207        </tr>
208      </table>
209      
210    </td>
211  </tr>
212<tr>
213    <td width="15%" align="right" valign="top" class="summary">
214      <span class="summary-type">&nbsp;</span>
215    </td><td class="summary">
216      <table width="100%" cellpadding="0" cellspacing="0" border="0">
217        <tr>
218          <td><span class="summary-sig"><a name="to_n_bits"></a><span class="summary-sig-name">to_n_bits</span>(<span class="summary-sig-arg">value</span>,
219        <span class="summary-sig-arg">length</span>=<span class="summary-sig-default">1</span>,
220        <span class="summary-sig-arg">nbits</span>=<span class="summary-sig-default">7</span>)</span><br />
221      returns the integer value as a sequence of nbits bytes</td>
222          <td align="right" valign="top">
223            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#to_n_bits">source&nbsp;code</a></span>
224            
225          </td>
226        </tr>
227      </table>
228      
229    </td>
230  </tr>
231<tr>
232    <td width="15%" align="right" valign="top" class="summary">
233      <span class="summary-type">&nbsp;</span>
234    </td><td class="summary">
235      <table width="100%" cellpadding="0" cellspacing="0" border="0">
236        <tr>
237          <td><span class="summary-sig"><a name="toBytes"></a><span class="summary-sig-name">toBytes</span>(<span class="summary-sig-arg">value</span>)</span><br />
238      Turns a string into a list of byte values</td>
239          <td align="right" valign="top">
240            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#toBytes">source&nbsp;code</a></span>
241            
242          </td>
243        </tr>
244      </table>
245      
246    </td>
247  </tr>
248<tr>
249    <td width="15%" align="right" valign="top" class="summary">
250      <span class="summary-type">&nbsp;</span>
251    </td><td class="summary">
252      <table width="100%" cellpadding="0" cellspacing="0" border="0">
253        <tr>
254          <td><span class="summary-sig"><a name="fromBytes"></a><span class="summary-sig-name">fromBytes</span>(<span class="summary-sig-arg">value</span>)</span><br />
255      Turns a list of bytes into a string</td>
256          <td align="right" valign="top">
257            <span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#fromBytes">source&nbsp;code</a></span>
258            
259          </td>
260        </tr>
261      </table>
262      
263    </td>
264  </tr>
265</table>
266<!-- ==================== VARIABLES ==================== -->
267<a name="section-Variables"></a>
268<table class="summary" border="1" cellpadding="3"
269       cellspacing="0" width="100%" bgcolor="white">
270<tr bgcolor="#70b0f0" class="table-header">
271  <td colspan="2" class="table-header">
272    <table border="0" cellpadding="0" cellspacing="0" width="100%">
273      <tr valign="top">
274        <td align="left"><span class="table-header">Variables</span></td>
275        <td align="right" valign="top"
276         ><span class="options">[<a href="#section-Variables"
277         class="privatelink" onclick="toggle_private();"
278         >hide private</a>]</span></td>
279      </tr>
280    </table>
281  </td>
282</tr>
283<tr>
284    <td width="15%" align="right" valign="top" class="summary">
285      <span class="summary-type">&nbsp;</span>
286    </td><td class="summary">
287        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'echonest.support.midi'"><code class="variable-quote">'</code><code class="variable-string">echonest.support.midi</code><code class="variable-quote">'</code></code>
288    </td>
289  </tr>
290</table>
291<!-- ==================== FUNCTION DETAILS ==================== -->
292<a name="section-FunctionDetails"></a>
293<table class="details" border="1" cellpadding="3"
294       cellspacing="0" width="100%" bgcolor="white">
295<tr bgcolor="#70b0f0" class="table-header">
296  <td colspan="2" class="table-header">
297    <table border="0" cellpadding="0" cellspacing="0" width="100%">
298      <tr valign="top">
299        <td align="left"><span class="table-header">Function Details</span></td>
300        <td align="right" valign="top"
301         ><span class="options">[<a href="#section-FunctionDetails"
302         class="privatelink" onclick="toggle_private();"
303         >hide private</a>]</span></td>
304      </tr>
305    </table>
306  </td>
307</tr>
308</table>
309<a name="getNibbles"></a>
310<div>
311<table class="details" border="1" cellpadding="3"
312       cellspacing="0" width="100%" bgcolor="white">
313<tr><td>
314  <table width="100%" cellpadding="0" cellspacing="0" border="0">
315  <tr valign="top"><td>
316  <h3 class="epydoc"><span class="sig"><span class="sig-name">getNibbles</span>(<span class="sig-arg">byte</span>)</span>
317  </h3>
318  </td><td align="right" valign="top"
319    ><span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#getNibbles">source&nbsp;code</a></span>&nbsp;
320    </td>
321  </tr></table>
322  
323  <pre class="literalblock">
324
325Returns hi and lo bits in a byte as a tuple
326&gt;&gt;&gt; getNibbles(142)
327(8, 14)
328
329Asserts byte value in byte range
330&gt;&gt;&gt; getNibbles(256)
331Traceback (most recent call last):
332    ...
333ValueError: Byte value out of range 0-255: 256
334
335</pre>
336  <dl class="fields">
337  </dl>
338</td></tr></table>
339</div>
340<a name="writeBew"></a>
341<div>
342<table class="details" border="1" cellpadding="3"
343       cellspacing="0" width="100%" bgcolor="white">
344<tr><td>
345  <table width="100%" cellpadding="0" cellspacing="0" border="0">
346  <tr valign="top"><td>
347  <h3 class="epydoc"><span class="sig"><span class="sig-name">writeBew</span>(<span class="sig-arg">value</span>,
348        <span class="sig-arg">length</span>)</span>
349  </h3>
350  </td><td align="right" valign="top"
351    ><span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#writeBew">source&nbsp;code</a></span>&nbsp;
352    </td>
353  </tr></table>
354  
355  Write int as big endian formatted string, (asserts length in [1,2,4])
356Difficult to print the result in doctest, so I do a simple roundabout test.
357&gt;&gt;&gt; readBew(writeBew(25057, 2))
35825057
359&gt;&gt;&gt; readBew(writeBew(1642193635L, 4))
3601642193635L
361  <dl class="fields">
362  </dl>
363</td></tr></table>
364</div>
365<a name="readVar"></a>
366<div>
367<table class="details" border="1" cellpadding="3"
368       cellspacing="0" width="100%" bgcolor="white">
369<tr><td>
370  <table width="100%" cellpadding="0" cellspacing="0" border="0">
371  <tr valign="top"><td>
372  <h3 class="epydoc"><span class="sig"><span class="sig-name">readVar</span>(<span class="sig-arg">value</span>)</span>
373  </h3>
374  </td><td align="right" valign="top"
375    ><span class="codelink"><a href="echonest.support.midi.DataTypeConverters-pysrc.html#readVar">source&nbsp;code</a></span>&nbsp;
376    </td>
377  </tr></table>
378  
379  Converts varlength format to integer. Just pass it 0 or more chars that
380might be a varlen and it will only use the relevant chars.
381use varLen(readVar(value)) to see how many bytes the integer value takes.
382asserts len(value) &gt;= 0
383&gt;&gt;&gt; readVar('&#128;&#64;')
38464
385&gt;&gt;&gt; readVar('&#225;&#226;&#227;a')
386205042145
387  <dl class="fields">
388  </dl>
389</td></tr></table>
390</div>
391<br />
392<!-- ==================== NAVIGATION BAR ==================== -->
393<table class="navbar" border="0" width="100%" cellpadding="0"
394       bgcolor="#a0c0ff" cellspacing="0">
395  <tr valign="middle">
396
397  <!-- Tree link -->
398      <th>&nbsp;&nbsp;&nbsp;<a
399        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
400
401  <!-- Index link -->
402      <th>&nbsp;&nbsp;&nbsp;<a
403        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
404
405  <!-- Help link -->
406      <th>&nbsp;&nbsp;&nbsp;<a
407        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
408
409  <!-- Project homepage -->
410      <th class="navbar" align="right" width="100%">
411        <table border="0" cellpadding="0" cellspacing="0">
412          <tr><th class="navbar" align="center"
413            ><a class="navbar" target="_top" href="http://code.google.com/p/echo-nest-remix/">Project Homepage</a></th>
414          </tr></table></th>
415  </tr>
416</table>
417<table border="0" cellpadding="0" cellspacing="0" width="100%%">
418  <tr>
419    <td align="left" class="footer">
420    Generated by Epydoc 3.0.1 on Wed Sep  1 16:08:57 2010
421    </td>
422    <td align="right" class="footer">
423      <a target="mainFrame" href="http://epydoc.sourceforge.net"
424        >http://epydoc.sourceforge.net</a>
425    </td>
426  </tr>
427</table>
428
429<script type="text/javascript">
430  <!--
431  // Private objects are initially displayed (because if
432  // javascript is turned off then we want them to be
433  // visible); but by default, we want to hide them.  So hide
434  // them unless we have a cookie that says to show them.
435  checkCookie();
436  // -->
437</script>
438</body>
439</html>