<?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; module</title>
	<atom:link href="http://codehop.com/tag/module/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>Custom Sequence List Generators</title>
		<link>http://codehop.com/custom-sequence-list-generators/</link>
		<comments>http://codehop.com/custom-sequence-list-generators/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 16:50:27 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[docstring]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scheduler]]></category>

		<guid isPermaLink="false">http://slipmat.noisepages.com/?p=142</guid>
		<description><![CDATA[Python&#8217;s built-in range() list generator is full of possibilities when used in conjunction with Slipmat&#8217;s @ scheduler. And that&#8217;s just one generator out of, dare I say, a million possibilities. Imagine being able to conveniently import generators from a massive &#8230; <a href="http://codehop.com/custom-sequence-list-generators/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Python&#8217;s built-in <a href="http://slipmat.noisepages.com/2010/04/auto-generating-lists/">range() list generator</a> is full of possibilities when used in conjunction with Slipmat&#8217;s <a href="http://slipmat.noisepages.com/2010/03/coding-in-time-with-the-scheduler/">@ scheduler</a>. And that&#8217;s just one generator out of, dare I say, a million possibilities.</p>
<p>Imagine being able to conveniently import generators from a massive user library of modules. This will be a reality for Slipmat for two reasons:</p>
<ul style="padding-bottom: 16px">
<li>Users can easily write their own generators</li>
<li>Users can easily <a href="http://slipmat.noisepages.com/2010/03/importing-modules-and-reusing-code/">share, import and remix</a> generators</li>
</ul>
<p>I built a list generator called range_plus(), which takes Python&#8217;s range() function a few steps farther. range() is limited to integers; range_plus() removes this restriction and allows for floats. range() supports a single increment step value; range_plus() additionally allows users to pass a list of increment step values that are chosen at random.</p>
<p>Here&#8217;s the working Python defintion for range_plus():</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
def range_plus(start, stop, random_steps=1):
    '''
    Returns a list of successive incremented values
    chosen randomly from a list.

    Input:
    start -- Starting value
    stop --  End point
    random_steps -- A list of incremental values chosen at random or a
        single numeric value
        
    Output:
    return -- A numeric list
    '''
    
    if stop < start:  # Avoid infinite loop from bad input
        return []

    if not isinstance(random_steps, list):
        random_steps = [random_steps]

    L = []

    while start < stop:
        L.append(start)
        start = start + random.choice(random_steps)

    return L
</pre>
<p>I made sure to write the <a href="http://slipmat.noisepages.com/2010/03/on-the-importance-of-docstrings/">docstrings</a>, to make life easier for anyone who may import my code later. Here's a Python interpreter session to test out some numbers:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
>>> from MyListGenerators import range_plus
>>> range_plus(0, 4, 0.5)
[0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5]
>>> range_plus(0, 4, [0.25, 0.25, 0.5, 0.75])
[0, 0.5, 1.0, 1.5, 1.75, 2.5, 3.0, 3.25, 3.75]
</pre>
<p>As applied to music, range_plus() would be a perfect fit for randomly generating rhythmic patterns, for things such as hi-hats.</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@0  @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat()
@4  @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat()
@12 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat()
@16 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat()
</pre>
<p>Here's is one scenario for what those patterns would look like in trigger notation:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
Bar 1:  x.x. x.xx ..x. xx.x
Bar 2:  xx.. x..x ..x. .xx.
Bar 3:  x..x ..x. xx.x .x..
Bar 4:  x.x. .xxx .xxx x..x
</pre>
<p>The 'x' is a 16th note trigger, the '.' is a 16th note rest, and spaces are used to distinguish between each quarter note.</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/custom-sequence-list-generators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music and Visuals</title>
		<link>http://codehop.com/music-and-visuals/</link>
		<comments>http://codehop.com/music-and-visuals/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 17:57:39 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[impromptu]]></category>
		<category><![CDATA[jitter]]></category>
		<category><![CDATA[max]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[msp]]></category>
		<category><![CDATA[visuals]]></category>

		<guid isPermaLink="false">http://slipmat.noisepages.com/?p=79</guid>
		<description><![CDATA[If slipmat at its core is a general purpose programming language augmented with advanced timing and scheduling capabilities, then slipmat would be well suited for both music and visuals. This isn&#8217;t really too much of a stretch. Audio unit generators &#8230; <a href="http://codehop.com/music-and-visuals/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If slipmat at its core is a general purpose programming language augmented with advanced timing and scheduling capabilities, then slipmat would be well suited for both music and visuals.</p>
<p>This isn&#8217;t really too much of a stretch. Audio unit generators won&#8217;t be built into the core language, but instead will be stored as separate modules and imported as needed; The same would be true for visual modules. Musical GUI elements such as sliders are already visual in nature. There are existing audio/visual systems out in the wild, such as <a href="http://cycling74.com/products/maxmspjitter/">Max/MSP/Jitter</a> and <a href="http://impromptu.moso.com.au/">Impromptu</a>. Various functions and objects designed for music could also be applied to visuals; The same envelope that controls frequency can be used to control the position of a circle:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
t = 10                          # time = 10 beats
my_circle = Circle(0, 200, 15)  # x position, y position, radius
env = line(0, t, 1)             # start value, duration, end value
sine(1.0, 440 * env)            # amp, frequency
my_circle.xpos(env * 400)       # x position over time
</pre>
<p>The example is a bit crude and omits many practical things, but the idea of syncing visuals with audio is there.</p>
<p>Beyond music and visuals, anything that is time-based would theoretically work in slipmat, providing a module is written.</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/music-and-visuals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roll Your Own Score Syntax</title>
		<link>http://codehop.com/roll-your-own-score-syntax/</link>
		<comments>http://codehop.com/roll-your-own-score-syntax/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 23:54:13 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[csound]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[notation]]></category>
		<category><![CDATA[score]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://slipmat.noisepages.com/?p=73</guid>
		<description><![CDATA[A music language that comes with a fully-loaded set of string capabilities, including regular expressions, would allow users to develop their own methods for notating music. For example, here is a horizontal representation for rhythm guitar. @0 strum('C', '/... /... &#8230; <a href="http://codehop.com/roll-your-own-score-syntax/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A music language that comes with a fully-loaded set of string capabilities, including regular expressions, would allow users to develop their own methods for notating music. For example, here is a horizontal representation for rhythm guitar.</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@0  strum('C',  '/... /... /./. /...')
@4  strum('Dm', '/... /... //// /./.')
@8  strum('G7', '/... /... ///. ../.')
@12 strum('C',  '/... /... /... ///.')
</pre>
<p>The slash triggers an event and advances time by a 16th note. The dot just advances time by a 16th note. A space does nothing.</p>
<p>These 4 lines of code represent 24 events. Not only does this shorten the score and save keystrokes, but is far more readable than if each individual event was explicitly written. In fact, I bet there are many guitar players out there that could play this as it&#8217;s written, providing he or she was given a brief explanation about the notation.</p>
<p>What about a system for triggering drums? Here&#8217;s the all-to-familiar 4-beat rock pattern with 8th note hats.</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
trigger(hat(),   'x.x. x.x. x.x. x.x.')
trigger(snare(), '.... x... .... x...')
trigger(kick(),  'x... .... x... ....')
</pre>
<p>Once again, the music is notated horizontally. Instead of 12 lines of code, there are only 3. Let&#8217;s take a look at the vertical equivalent:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@0   hat()
@0   kick()
@0.5 hat()
@1   hat()
@1   snare()
@1.5 hat()
@2   hat()
@2   kick()
@2.5 hat()
@3   hat()
@3   snare()
@3.5 hat()
</pre>
<p>In theory, people could write slipmat modules that mimic other text-based notation systems, such as the Csound score language.</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
import CsoundScore as CS
from MyLibrary import bassFM
from MyLibrary import pad

# For mapping slipmat instruments to a Csound-styled score
instrs = {"i1": bassFM(), "i2": pad()}

# A Csound-styled score
score = '''
i 1 0 2 0.5 7.00
i 1 + . .   6.05

i 2 0 8 0.333 8.09 0.77 1000
'''

CS.playScore(instrs, score)  # Play Csound-styled score
</pre>
<p>That would translate to:</p>
<pre style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 1.2em; padding-bottom: 16px">
@0 bassFM(2, 0.5, 7.00)
@2 bassFM(2, 0.5, 6.05)
@0 pad(8, 0.333, 8.09, 0.77, 1000)
</pre>
<p>Much of this can be done with some of the existing music languages out in the wild. The guitar strum and drum trigger examples can be accomplished in pure Csound code (see <a href="http://www.csounds.com/journal/issue8/dseq.html">dseq &#8212; A Drum Machine Micro-Language</a>). Even more so, Csound combined with the Python API can do some truly amazing things along these lines. Though it probably wouldn&#8217;t be nearly as fluid as a language that had this in mind when being designed from the ground up.</p>
<p>If you haven&#8217;t done so yet, take a moment to ponder the possibilities. And be sure to think about the things others will dream up that can be simply imported into your own compositions/synthesizers/sequencers/etc&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/roll-your-own-score-syntax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
