PageRenderTime 478ms CodeModel.GetById 101ms app.highlight 197ms RepoModel.GetById 165ms app.codeStats 2ms

/apidocs/echonest.support.midi.RawInstreamFile-pysrc.html

http://echo-nest-remix.googlecode.com/
HTML | 231 lines | 200 code | 10 blank | 21 comment | 0 complexity | 9ca209127e5d58ecf3da58b589edd972 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.RawInstreamFile</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;RawInstreamFile
 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.RawInstreamFile-pysrc.html"
 56            target="_top">no&nbsp;frames</a>]</span></td></tr>
 57      </table>
 58    </td>
 59  </tr>
 60</table>
 61<h1 class="epydoc">Source Code for <a href="echonest.support.midi.RawInstreamFile-module.html">Module echonest.support.midi.RawInstreamFile</a></h1>
 62<pre class="py-src">
 63<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment"># -*- coding: ISO-8859-1 -*-</tt>
 </tt>
 64<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line">
 </tt>
 65<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-comment"># standard library imports</tt>
 </tt>
 66<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">types</tt> <tt class="py-keyword">import</tt> <tt class="py-name">StringType</tt> </tt>
 67<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">struct</tt> <tt class="py-keyword">import</tt> <tt class="py-name">unpack</tt> </tt>
 68<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line">
 </tt>
 69<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-comment"># custom import</tt>
 </tt>
 70<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Module echonest.support.midi.DataTypeConverters=echonest.support.midi.DataTypeConverters-module.html"><a title="echonest.support.midi.DataTypeConverters" class="py-name" href="#" onclick="return doclink('link-0', 'DataTypeConverters', 'link-0');">DataTypeConverters</a></tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Function echonest.support.midi.DataTypeConverters.readBew()=echonest.support.midi.DataTypeConverters-module.html#readBew,Method echonest.support.midi.RawInstreamFile.RawInstreamFile.readBew()=echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#readBew"><a title="echonest.support.midi.DataTypeConverters.readBew
 71echonest.support.midi.RawInstreamFile.RawInstreamFile.readBew" class="py-name" href="#" onclick="return doclink('link-1', 'readBew', 'link-1');">readBew</a></tt><tt class="py-op">,</tt> <tt id="link-2" class="py-name" targets="Function echonest.support.midi.DataTypeConverters.readVar()=echonest.support.midi.DataTypeConverters-module.html#readVar"><a title="echonest.support.midi.DataTypeConverters.readVar" class="py-name" href="#" onclick="return doclink('link-2', 'readVar', 'link-2');">readVar</a></tt><tt class="py-op">,</tt> <tt id="link-3" class="py-name" targets="Function echonest.support.midi.DataTypeConverters.varLen()=echonest.support.midi.DataTypeConverters-module.html#varLen"><a title="echonest.support.midi.DataTypeConverters.varLen" class="py-name" href="#" onclick="return doclink('link-3', 'varLen', 'link-3');">varLen</a></tt> </tt>
 72<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line">
 </tt>
 73<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line">
 </tt>
 74<a name="RawInstreamFile"></a><div id="RawInstreamFile-def"><a name="L11"></a><tt class="py-lineno"> 11</tt> <a class="py-toggle" href="#" id="RawInstreamFile-toggle" onclick="return toggle('RawInstreamFile');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html">RawInstreamFile</a><tt class="py-op">:</tt> </tt>
 75</div><div id="RawInstreamFile-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="RawInstreamFile-expanded"><a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line">    
 </tt>
 76<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line">    <tt class="py-docstring">"""
</tt> </tt>
 77<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">    
</tt> </tt>
 78<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring">    It parses and reads data from an input file. It takes care of big 
</tt> </tt>
 79<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">    endianess, and keeps track of the cursor position. The midi parser 
</tt> </tt>
 80<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring">    only reads from this object. Never directly from the file.
</tt> </tt>
 81<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">    
</tt> </tt>
 82<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
 83<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line">    
 </tt>
 84<a name="RawInstreamFile.__init__"></a><div id="RawInstreamFile.__init__-def"><a name="L21"></a><tt class="py-lineno"> 21</tt> <a class="py-toggle" href="#" id="RawInstreamFile.__init__-toggle" onclick="return toggle('RawInstreamFile.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">infile</tt><tt class="py-op">=</tt><tt class="py-string">''</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
 85</div><div id="RawInstreamFile.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.__init__-expanded"><a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line">        <tt class="py-docstring">""" 
</tt> </tt>
 86<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-docstring">        If 'file' is a string we assume it is a path and read from 
</tt> </tt>
 87<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-docstring">        that file.
</tt> </tt>
 88<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-docstring">        If it is a file descriptor we read from the file, but we don't 
</tt> </tt>
 89<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-docstring">        close it.
</tt> </tt>
 90<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-docstring">        Midi files are usually pretty small, so it should be safe to 
</tt> </tt>
 91<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-docstring">        copy them into memory.
</tt> </tt>
 92<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
 93<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">infile</tt><tt class="py-op">:</tt> </tt>
 94<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">infile</tt><tt class="py-op">,</tt> <tt class="py-name">StringType</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
 95<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">                <tt class="py-name">infile</tt> <tt class="py-op">=</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt class="py-name">infile</tt><tt class="py-op">,</tt> <tt class="py-string">'rb'</tt><tt class="py-op">)</tt> </tt>
 96<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">data</tt> <tt class="py-op">=</tt> <tt class="py-name">infile</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name" targets="Method echonest.support.midi.MidiInFile.MidiInFile.read()=echonest.support.midi.MidiInFile.MidiInFile-class.html#read,Method echonest.support.midi.MidiInStream.MidiInStream.read()=echonest.support.midi.MidiInStream.MidiInStream-class.html#read"><a title="echonest.support.midi.MidiInFile.MidiInFile.read
 97echonest.support.midi.MidiInStream.MidiInStream.read" class="py-name" href="#" onclick="return doclink('link-4', 'read', 'link-4');">read</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
 98<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line">                <tt class="py-name">infile</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Method echonest.support.midi.MidiInStream.MidiInStream.close()=echonest.support.midi.MidiInStream.MidiInStream-class.html#close"><a title="echonest.support.midi.MidiInStream.MidiInStream.close" class="py-name" href="#" onclick="return doclink('link-5', 'close', 'link-5');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
 99<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
100<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">                <tt class="py-comment"># don't close the f</tt>
 </tt>
101<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">data</tt> <tt class="py-op">=</tt> <tt class="py-name">infile</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name"><a title="echonest.support.midi.MidiInFile.MidiInFile.read
102echonest.support.midi.MidiInStream.MidiInStream.read" class="py-name" href="#" onclick="return doclink('link-6', 'read', 'link-4');">read</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
103<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
104<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">data</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
105<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line">        <tt class="py-comment"># start at beginning ;-)</tt>
 </tt>
106<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cursor</tt> <tt class="py-op">=</tt> <tt class="py-number">0</tt> </tt>
107</div><a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line">
 </tt>
108<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">
 </tt>
109<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">    <tt class="py-comment"># setting up data manually</tt>
 </tt>
110<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">    
 </tt>
111<a name="RawInstreamFile.setData"></a><div id="RawInstreamFile.setData-def"><a name="L46"></a><tt class="py-lineno"> 46</tt> <a class="py-toggle" href="#" id="RawInstreamFile.setData-toggle" onclick="return toggle('RawInstreamFile.setData');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#setData">setData</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">data</tt><tt class="py-op">=</tt><tt class="py-string">''</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
112</div><div id="RawInstreamFile.setData-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.setData-expanded"><a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">        <tt class="py-docstring">"Sets the data from a string."</tt> </tt>
113<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">data</tt> <tt class="py-op">=</tt> <tt class="py-name">data</tt> </tt>
114</div><a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">    
 </tt>
115<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">    <tt class="py-comment"># cursor operations</tt>
 </tt>
116<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">
 </tt>
117<a name="RawInstreamFile.setCursor"></a><div id="RawInstreamFile.setCursor-def"><a name="L52"></a><tt class="py-lineno"> 52</tt> <a class="py-toggle" href="#" id="RawInstreamFile.setCursor-toggle" onclick="return toggle('RawInstreamFile.setCursor');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#setCursor">setCursor</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">position</tt><tt class="py-op">=</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
118</div><div id="RawInstreamFile.setCursor-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.setCursor-expanded"><a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">        <tt class="py-docstring">"Sets the absolute position if the cursor"</tt> </tt>
119<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cursor</tt> <tt class="py-op">=</tt> <tt class="py-name">position</tt> </tt>
120</div><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">
 </tt>
121<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">
 </tt>
122<a name="RawInstreamFile.getCursor"></a><div id="RawInstreamFile.getCursor-def"><a name="L57"></a><tt class="py-lineno"> 57</tt> <a class="py-toggle" href="#" id="RawInstreamFile.getCursor-toggle" onclick="return toggle('RawInstreamFile.getCursor');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#getCursor">getCursor</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
123</div><div id="RawInstreamFile.getCursor-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.getCursor-expanded"><a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">        <tt class="py-docstring">"Returns the value of the cursor"</tt> </tt>
124<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cursor</tt> </tt>
125</div><a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">        
 </tt>
126<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">        
 </tt>
127<a name="RawInstreamFile.moveCursor"></a><div id="RawInstreamFile.moveCursor-def"><a name="L62"></a><tt class="py-lineno"> 62</tt> <a class="py-toggle" href="#" id="RawInstreamFile.moveCursor-toggle" onclick="return toggle('RawInstreamFile.moveCursor');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#moveCursor">moveCursor</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">relative_position</tt><tt class="py-op">=</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
128</div><div id="RawInstreamFile.moveCursor-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.moveCursor-expanded"><a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">        <tt class="py-docstring">"Moves the cursor to a new relative position"</tt> </tt>
129<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cursor</tt> <tt class="py-op">+=</tt> <tt class="py-name">relative_position</tt> </tt>
130</div><a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">
 </tt>
131<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">    <tt class="py-comment"># native data reading functions</tt>
 </tt>
132<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line">        
 </tt>
133<a name="RawInstreamFile.nextSlice"></a><div id="RawInstreamFile.nextSlice-def"><a name="L68"></a><tt class="py-lineno"> 68</tt> <a class="py-toggle" href="#" id="RawInstreamFile.nextSlice-toggle" onclick="return toggle('RawInstreamFile.nextSlice');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#nextSlice">nextSlice</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">length</tt><tt class="py-op">,</tt> <tt class="py-param">move_cursor</tt><tt class="py-op">=</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
134</div><div id="RawInstreamFile.nextSlice-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.nextSlice-expanded"><a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">        <tt class="py-docstring">"Reads the next text slice from the raw data, with length"</tt> </tt>
135<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line">        <tt class="py-name">c</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">cursor</tt> </tt>
136<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">        <tt class="py-name">slc</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">data</tt><tt class="py-op">[</tt><tt class="py-name">c</tt><tt class="py-op">:</tt><tt class="py-name">c</tt><tt class="py-op">+</tt><tt class="py-name">length</tt><tt class="py-op">]</tt> </tt>
137<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">move_cursor</tt><tt class="py-op">:</tt> </tt>
138<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name" targets="Method echonest.support.midi.RawInstreamFile.RawInstreamFile.moveCursor()=echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#moveCursor"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.moveCursor" class="py-name" href="#" onclick="return doclink('link-7', 'moveCursor', 'link-7');">moveCursor</a></tt><tt class="py-op">(</tt><tt class="py-name">length</tt><tt class="py-op">)</tt> </tt>
139<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">slc</tt> </tt>
140</div><a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        
 </tt>
141<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        
 </tt>
142<a name="RawInstreamFile.readBew"></a><div id="RawInstreamFile.readBew-def"><a name="L77"></a><tt class="py-lineno"> 77</tt> <a class="py-toggle" href="#" id="RawInstreamFile.readBew-toggle" onclick="return toggle('RawInstreamFile.readBew');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#readBew">readBew</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">n_bytes</tt><tt class="py-op">=</tt><tt class="py-number">1</tt><tt class="py-op">,</tt> <tt class="py-param">move_cursor</tt><tt class="py-op">=</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
143</div><div id="RawInstreamFile.readBew-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.readBew-expanded"><a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">        <tt class="py-docstring">"""
</tt> </tt>
144<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">        Reads n bytes of date from the current cursor position.
</tt> </tt>
145<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">        Moves cursor if move_cursor is true
</tt> </tt>
146<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
147<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-8" class="py-name"><a title="echonest.support.midi.DataTypeConverters.readBew
148echonest.support.midi.RawInstreamFile.RawInstreamFile.readBew" class="py-name" href="#" onclick="return doclink('link-8', 'readBew', 'link-1');">readBew</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Method echonest.support.midi.RawInstreamFile.RawInstreamFile.nextSlice()=echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#nextSlice"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.nextSlice" class="py-name" href="#" onclick="return doclink('link-9', 'nextSlice', 'link-9');">nextSlice</a></tt><tt class="py-op">(</tt><tt class="py-name">n_bytes</tt><tt class="py-op">,</tt> <tt class="py-name">move_cursor</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
149</div><a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">
 </tt>
150<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">
 </tt>
151<a name="RawInstreamFile.readVarLen"></a><div id="RawInstreamFile.readVarLen-def"><a name="L85"></a><tt class="py-lineno"> 85</tt> <a class="py-toggle" href="#" id="RawInstreamFile.readVarLen-toggle" onclick="return toggle('RawInstreamFile.readVarLen');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html#readVarLen">readVarLen</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
152</div><div id="RawInstreamFile.readVarLen-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="RawInstreamFile.readVarLen-expanded"><a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">        <tt class="py-docstring">"""
</tt> </tt>
153<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-docstring">        Reads a variable length value from the current cursor position.
</tt> </tt>
154<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"><tt class="py-docstring">        Moves cursor if move_cursor is true
</tt> </tt>
155<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
156<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">        <tt class="py-name">MAX_VARLEN</tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt> <tt class="py-comment"># Max value varlen can be</tt> </tt>
157<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">        <tt class="py-name">var</tt> <tt class="py-op">=</tt> <tt id="link-10" class="py-name"><a title="echonest.support.midi.DataTypeConverters.readVar" class="py-name" href="#" onclick="return doclink('link-10', 'readVar', 'link-2');">readVar</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.nextSlice" class="py-name" href="#" onclick="return doclink('link-11', 'nextSlice', 'link-9');">nextSlice</a></tt><tt class="py-op">(</tt><tt class="py-name">MAX_VARLEN</tt><tt class="py-op">,</tt> <tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
158<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt class="py-comment"># only move cursor the actual bytes in varlen</tt>
 </tt>
159<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-12" class="py-name"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.moveCursor" class="py-name" href="#" onclick="return doclink('link-12', 'moveCursor', 'link-7');">moveCursor</a></tt><tt class="py-op">(</tt><tt id="link-13" class="py-name"><a title="echonest.support.midi.DataTypeConverters.varLen" class="py-name" href="#" onclick="return doclink('link-13', 'varLen', 'link-3');">varLen</a></tt><tt class="py-op">(</tt><tt class="py-name">var</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
160<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">var</tt> </tt>
161</div></div><a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">
 </tt>
162<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">
 </tt>
163<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">
 </tt>
164<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt> <tt class="py-op">==</tt> <tt class="py-string">'__main__'</tt><tt class="py-op">:</tt> </tt>
165<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">
 </tt>
166<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">    <tt id="link-14" class="py-name" targets="Variable echonest.support.midi.example_print_file.test_file=echonest.support.midi.example_print_file-module.html#test_file"><a title="echonest.support.midi.example_print_file.test_file" class="py-name" href="#" onclick="return doclink('link-14', 'test_file', 'link-14');">test_file</a></tt> <tt class="py-op">=</tt> <tt class="py-string">'test/midifiles/minimal.mid'</tt> </tt>
167<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">    <tt class="py-name">fis</tt> <tt class="py-op">=</tt> <tt id="link-15" class="py-name" targets="Module echonest.support.midi.RawInstreamFile=echonest.support.midi.RawInstreamFile-module.html,Class echonest.support.midi.RawInstreamFile.RawInstreamFile=echonest.support.midi.RawInstreamFile.RawInstreamFile-class.html"><a title="echonest.support.midi.RawInstreamFile
168echonest.support.midi.RawInstreamFile.RawInstreamFile" class="py-name" href="#" onclick="return doclink('link-15', 'RawInstreamFile', 'link-15');">RawInstreamFile</a></tt><tt class="py-op">(</tt><tt id="link-16" class="py-name"><a title="echonest.support.midi.example_print_file.test_file" class="py-name" href="#" onclick="return doclink('link-16', 'test_file', 'link-14');">test_file</a></tt><tt class="py-op">)</tt> </tt>
169<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-name">fis</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.nextSlice" class="py-name" href="#" onclick="return doclink('link-17', 'nextSlice', 'link-9');">nextSlice</a></tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">fis</tt><tt class="py-op">.</tt><tt class="py-name">data</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
170<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">
 </tt>
171<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">    <tt id="link-18" class="py-name"><a title="echonest.support.midi.example_print_file.test_file" class="py-name" href="#" onclick="return doclink('link-18', 'test_file', 'link-14');">test_file</a></tt> <tt class="py-op">=</tt> <tt class="py-string">'test/midifiles/cubase-minimal.mid'</tt> </tt>
172<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">    <tt class="py-name">cubase_minimal</tt> <tt class="py-op">=</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt id="link-19" class="py-name"><a title="echonest.support.midi.example_print_file.test_file" class="py-name" href="#" onclick="return doclink('link-19', 'test_file', 'link-14');">test_file</a></tt><tt class="py-op">,</tt> <tt class="py-string">'rb'</tt><tt class="py-op">)</tt> </tt>
173<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">    <tt class="py-name">fis2</tt> <tt class="py-op">=</tt> <tt id="link-20" class="py-name"><a title="echonest.support.midi.RawInstreamFile
174echonest.support.midi.RawInstreamFile.RawInstreamFile" class="py-name" href="#" onclick="return doclink('link-20', 'RawInstreamFile', 'link-15');">RawInstreamFile</a></tt><tt class="py-op">(</tt><tt class="py-name">cubase_minimal</tt><tt class="py-op">)</tt> </tt>
175<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-name">fis2</tt><tt class="py-op">.</tt><tt id="link-21" class="py-name"><a title="echonest.support.midi.RawInstreamFile.RawInstreamFile.nextSlice" class="py-name" href="#" onclick="return doclink('link-21', 'nextSlice', 'link-9');">nextSlice</a></tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">fis2</tt><tt class="py-op">.</tt><tt class="py-name">data</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
176<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">    <tt class="py-name">cubase_minimal</tt><tt class="py-op">.</tt><tt id="link-22" class="py-name"><a title="echonest.support.midi.MidiInStream.MidiInStream.close" class="py-name" href="#" onclick="return doclink('link-22', 'close', 'link-5');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
177<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line"> </tt><script type="text/javascript">
178<!--
179expandto(location.href);
180// -->
181</script>
182</pre>
183<br />
184<!-- ==================== NAVIGATION BAR ==================== -->
185<table class="navbar" border="0" width="100%" cellpadding="0"
186       bgcolor="#a0c0ff" cellspacing="0">
187  <tr valign="middle">
188
189  <!-- Tree link -->
190      <th>&nbsp;&nbsp;&nbsp;<a
191        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
192
193  <!-- Index link -->
194      <th>&nbsp;&nbsp;&nbsp;<a
195        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
196
197  <!-- Help link -->
198      <th>&nbsp;&nbsp;&nbsp;<a
199        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
200
201  <!-- Project homepage -->
202      <th class="navbar" align="right" width="100%">
203        <table border="0" cellpadding="0" cellspacing="0">
204          <tr><th class="navbar" align="center"
205            ><a class="navbar" target="_top" href="http://code.google.com/p/echo-nest-remix/">Project Homepage</a></th>
206          </tr></table></th>
207  </tr>
208</table>
209<table border="0" cellpadding="0" cellspacing="0" width="100%%">
210  <tr>
211    <td align="left" class="footer">
212    Generated by Epydoc 3.0.1 on Wed Sep  1 16:08:59 2010
213    </td>
214    <td align="right" class="footer">
215      <a target="mainFrame" href="http://epydoc.sourceforge.net"
216        >http://epydoc.sourceforge.net</a>
217    </td>
218  </tr>
219</table>
220
221<script type="text/javascript">
222  <!--
223  // Private objects are initially displayed (because if
224  // javascript is turned off then we want them to be
225  // visible); but by default, we want to hide them.  So hide
226  // them unless we have a cookie that says to show them.
227  checkCookie();
228  // -->
229</script>
230</body>
231</html>