<?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; patching</title>
	<atom:link href="http://codehop.com/tag/patching/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>Patching &#8212; An Early Mockup</title>
		<link>http://codehop.com/patching-an-early-mockup/</link>
		<comments>http://codehop.com/patching-an-early-mockup/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 19:04:48 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[patching]]></category>

		<guid isPermaLink="false">http://slipmat.noisepages.com/?p=58</guid>
		<description><![CDATA[Being able to patch together units is a fundamental principle of a modular environment. Though I&#8217;m far from figuring out what the syntax should look like in my faux music language, I have been writing some mock up code just &#8230; <a href="http://codehop.com/patching-an-early-mockup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Being able to patch together units is a fundamental principle of a modular environment. Though I&#8217;m far from figuring out what the syntax should look like in my faux music language, I have been writing some mock up code just to get a sense of it.</p>
<p>Just a warning, the following example is ignorant of i/k/a-rates, along with pass-by-reference vs pass-by-value:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
import FX
import Master
import Mixer
from Envelope import line
from TestLibrary.Instruments import SineTone

# Create instances of objects and patch together
st = SineTone()                             # Simple sine instrument
reverb = FX.Reverb(input=st.out, time=3.1)  # Reverb unit
mix = Mixer.pan(0, st.out, reverb.out)      # Dry/wet: value, sig 1, sig 2
output = Master.DAC(mix)                    # Main output

# Score
@0 turnon(reverb, mix, output)  # Turn on selected instances

@0 st.play(20, 1, 440)        # Play for 20 seconds, amp = 1, frequency = 440
@0 st.amp *= line(0, 10, 1)   # Amplitude rise
@10 st.amp *= line(1, 10, 0)  # Amplitude fall
@20 mix.pan = line(1, 20, 0)  # Dry to wet over 20 seconds

@10 reverb.time += line(0, 5, 8.1)  # Increase reverb time starting at 10
@20:
    @reverb.time turnoff(reverb, mix, output)  # Turnoff selected instances
</pre>
<p>The import section loads classes from existing instrument/unit generator libraries.</p>
<p>In the orchestra, instances are created from the imported classes, and patched together into a simple instrument graph.  There&#8217;s a simple sine instrument, which is plugged into a reverb unit. Next, there is the pan mixer, which has the dry sine instrument plugged into one side, and the wet reverb signal plugged into the other; It is initially set to 100% dry. The pan mixer is then patched into the output, which sends the audio to the DAC.</p>
<p>The first line in the score turns on three instruments: reverb, mix and output. There will be times when the duration is unknown. The ability to start and stop machines is a must.</p>
<p>The sine instrument starts with a duration of 20, an amplitude of 1 and a frequency of 440. The amplitude of the sine is modulated by two envelopes, creating a rise/fall shape. Line envelopes also modulate the dry/wet mixer and reverb time.</p>
<p>At the end, the turnoff function shuts down reverb, mix and output.</p>
<p><strong>Bonus round:</strong> Why do you suppose I wrote,</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@20:
    @reverb.time turnoff(reverb, mix, output)  # Turnoff selected instances
</pre>
<p>instead of this?</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@(20 + reverb.time) turnoff(reverb, mix, output)  # Turnoff selected instances
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/patching-an-early-mockup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
