<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>codehop &#187; the hub</title>
	<atom:link href="http://codehop.com/tag/the-hub/feed/" rel="self" type="application/rss+xml" />
	<link>http://codehop.com</link>
	<description>#code #art #music</description>
	<lastBuildDate>Mon, 23 Apr 2012 18:37:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Importing Modules and Reusing Code</title>
		<link>http://codehop.com/importing-modules-and-reusing-code/</link>
		<comments>http://codehop.com/importing-modules-and-reusing-code/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 14:34:23 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[csound]]></category>
		<category><![CDATA[dr. richard boulanger]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[the hub]]></category>

		<guid isPermaLink="false">http://slipmat.noisepages.com/?p=17</guid>
		<description><![CDATA[I want to begin discussing the implications of yesterday&#8217;s Python-Csound mockup code (which I&#8217;ll refer to as slipmat for the time being), starting with with imports: import Wavetable from Gen import sine from Pitch import cpspch All of Csound&#8217;s 1400+ &#8230; <a href="http://codehop.com/importing-modules-and-reusing-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I want to begin discussing the implications of yesterday&#8217;s <a href="http://slipmat.noisepages.com/2010/03/what-if-python-dna-was-injected-into-csound/">Python-Csound mockup code</a> (which I&#8217;ll refer to as slipmat for the time being), starting with with imports:</p>
<pre style="font-family: 'Courier New' monaco, courier, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">import Wavetable
from Gen import sine
from Pitch import cpspch
</pre>
<p>All of Csound&#8217;s 1400+ opcodes are available at all times. Great for convenience, perhaps not so great for organization. In contrast, the Python language starts out with only the basics, a clean slate. To extend functionality, users import <a href="http://docs.python.org/tutorial/modules.html">modules</a>. This is a cleaner approach than having it all hang out. There are some other advantages, too.</p>
<p>First, let&#8217;s look at a hypothetical import block.  Let&#8217;s say you were to design a &#8220;computer network music&#8221; ensemble inspired by <a href="http://en.wikipedia.org/wiki/The_Hub_(band)">The Hub</a>. Some communication modules you might include:</p>
<pre style="font-family: 'Courier New' monaco, courier, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">import Jack
import MIDI
import Network
import OSC
</pre>
<p>A computer network music ensemble sounds like it might be a complex piece of software. Complex enough where doing all your work in one file would be tedious. So you decide to start a new file, my_network.slip, where you store your own custom opcode/unit generator function definitions. In your main file, you write this to import:</p>
<pre style="font-family: 'Courier New' monaco, courier, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">import my_network
</pre>
<p>Not only can you use my_network for this project, but that code can be reused in any number of future projects.  Code reusability is a beautiful thing. In fact, this would apply to any properly written slipmat document. For example, a composition would double as a library of synthesizers that you could plug into your own work:</p>
<pre style="font-family: 'Courier New' monaco, courier, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">import Trapped  # Trapped in Convert by Dr. Richard Boulanger
...
signal = Trapped.blue(22.13, 4, 0, 9.01, 600, 0.5, 20, 6, 0.66)
</pre>
<p>See <a href="http://csound.cvs.sourceforge.net/*checkout*/csound/csound5/examples/trapped.csd">trapped.csd</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/importing-modules-and-reusing-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
