<?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>Computational Artwork &#187; Midi</title>
	<atom:link href="http://matthewbrown.net.au/tag/midi/feed/" rel="self" type="application/rss+xml" />
	<link>http://matthewbrown.net.au</link>
	<description>by Matthew Brown</description>
	<lastBuildDate>Sun, 20 Jun 2010 02:37:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Making A Drum Machine Using Scheme and Impromptu</title>
		<link>http://matthewbrown.net.au/programming/making-a-drum-machine-using-scheme-and-impromptu/</link>
		<comments>http://matthewbrown.net.au/programming/making-a-drum-machine-using-scheme-and-impromptu/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 02:36:50 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[computational arts]]></category>
		<category><![CDATA[drum machine]]></category>
		<category><![CDATA[Impromptu]]></category>
		<category><![CDATA[kkb210]]></category>
		<category><![CDATA[Midi]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[synthesizer]]></category>

		<guid isPermaLink="false">http://matthewbrown.net.au/programming/making-a-drum-machine-using-scheme-and-impromptu/</guid>
		<description><![CDATA[Following on from the MIDI-based piano idea that I outlined earlier, today we will be going through writing a drum machione in Impromptu as was done in the KKB210 Computational Arts 1 week 3 tutorial. You may have noticed that it is a bit of a pain to have to evaluate each note each time [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from the <a href="http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/" title="Making a MIDI piano with Scheme and Impromptu">MIDI-based piano</a> idea that I outlined earlier, today we will be going through writing a drum machione in Impromptu as was done in the KKB210 Computational Arts 1 week 3 tutorial.</p>
<p>You may have noticed that it is a bit of a pain to have to evaluate each note each time you want to play it. There is an easy way around this that we have used in the drum machine tutorial that can be applied to pretty much anything that needs to repeat in Impromptu.</p>
<p><span id="more-6"></span><br />
First up, we disconnect everything.</p>
<pre class="brush: java;">
; Make sure that everything is disconnected
(au:clear-graph)
</pre>
<p>Then we define the library and connect it.</p>
<pre class="brush: java;">
(define dls (au:make-node &quot;aumu&quot; &quot;dls &quot; &quot;appl&quot;))
(au:connect-node dls 0 *au:output-node* 0)
(au:update-graph)
</pre>
<p>You should recognise most of this so far from the <a href="http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/" title="Making a MIDI piano with Scheme and Impromptu">piano tutorial</a>. We can play a drum the same way. Have a look at the <a href="http://www.midi.org/about-midi/gm/gm1sound.shtml#Percussion" title="General MIDI Level 1 Sound Set">General MIDI Level 1 Sound Set</a> for more information on what numbers equate to what drums.</p>
<pre class="brush: java;">
; Playing a drum beat the same way as we played
; notes in the piano tutorial.
(play-note (now) dls 36 80 20000 9)
</pre>
<p>Now to simplify the playing of each note or beat, we want to create a function. In this case we will be calling it drum-machine.</p>
<pre class="brush: java;">
; Define the drum-machine function.
(define drum-machine

; Tell Impromptu to move forward in steps.
(lambda (time step)
(print step)
(case step

; For steps 0 and 8 do this:
((0 8 )
(play-note (now) dls 42 80 20000 9)
(play-note (now) dls 36 80 20000 9))

; For steps 4 and 12 do this:
((4 12)
(play-note (now) dls 42 80 20000 9)
(play-note (now) dls 38 80 20000 9))

; For step 15 do this:
((15)
(play-note (now) dls 46 80 20000 9))

; For any other steps do this:
(else (play-note (now) dls 44 80 20000 9)))
</pre>
<p>That&#8217;s fairly straight forward right? It uses exactly the same play-note commands and parameters that we have used before, however it puts them within a step function that tells impromptu to play through the notes in steps and to play certain notes at certain steps.</p>
<p>This doesn&#8217;t repeat though. In order to make it repeat, we tell Impromptu to run a callback to the drum-machine function. This sends it back to drum-machine. and so it goes through the steps again and will continue to do so until something gets changed that doesn&#8217;t work, such as a close bracket immediately after (define drum-machine.</p>
<pre class="brush: java;">
(callback (+ time 10000) drum-machine (+ time 9000) (modulo (+ step 1) 16))))
</pre>
<p>Now, of course just having this setup doesn&#8217;t mean it will run when you evaluate it. You have to create a function call. This is specified below along with when to run it (now).</p>
<pre class="brush: java;">
(drum-machine (now) 0)
</pre>
<p>Once you have evaluated all of the components of the program you should be able to evaluate the function call and it will run the drum-machine function, a constantly looping drum machine that you can change on the fly.</p>
<p>Thats right, if you want to change one of the drum sounds, when it&#8217;s playing, or anything like that, all you have to do is edit it and then re-evaluate that single line and it will be played from then on as part of the constant loop. You can also add more steps, remove steps, change what is played for certain steps, re-evaluate it and it becomes part of the loop. Easy as that.</p>
]]></content:encoded>
			<wfw:commentRss>http://matthewbrown.net.au/programming/making-a-drum-machine-using-scheme-and-impromptu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making A MIDI Based Piano Using Scheme and Impromptu</title>
		<link>http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/</link>
		<comments>http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 14:23:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[computational arts]]></category>
		<category><![CDATA[Impromptu]]></category>
		<category><![CDATA[kkb210]]></category>
		<category><![CDATA[Midi]]></category>
		<category><![CDATA[piano]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[synthesizer]]></category>

		<guid isPermaLink="false">http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/</guid>
		<description><![CDATA[As part of the tutorial in week 3 of KKB210, Computational Arts 1, we were introduced to the Scheme programming language through the Impromptu environment. We were looking at creating audio based on the Apple Sound Bank Synthesizer using the MIDI specifications. As an introduction to this topic we started off simply by writing the [...]]]></description>
			<content:encoded><![CDATA[<p>As part of the tutorial in week 3 of KKB210, Computational Arts 1, we were introduced to the Scheme programming language through the Impromptu environment.</p>
<p>We were looking at creating audio based on the Apple Sound Bank Synthesizer using the <a href="http://www.midi.org/about-midi/gm/gm1sound.shtml" title="MIDI Specification">MIDI specifications</a>.</p>
<p>As an introduction to this topic we started off simply by writing the code to play a single note on a piano.</p>
<p><span id="more-5"></span><br />
To start with, we clear everything from the au graph.</p>
<pre class="brush: java;">
; Make sure that everything is disconnected
(au:clear-graph)
</pre>
<p>Next we define the piano and create a basic au graph that connects the piano library to the output.</p>
<pre class="brush: java;">
; setup simple au graph
; piano -&gt; output
(define piano (au:make-node &quot;aumu&quot; &quot;dls &quot; &quot;appl&quot;))
(au:connect-node piano 0 *au:output-node* 0)
(au:update-graph)
</pre>
<p>Now we tell it to play a note. It is formatted as follows:</p>
<p>(play-note time instrument pitch volume duration)</p>
<p>Time is of course, when the note is to be played and duration is how long for. In the example below, we have defined that the note will be played immediately, it will be from the piano library we defined earlier, the pitch is set at 60 with a volume of 80, and it is held for 1 second. To add more notes, simply copy the line and paste it before or after and change the parameters to meet your needs.</p>
<pre class="brush: java;">
; play note on piano
(play-note (now) piano 60 80 (* 1.0 *second*))
</pre>
<p>The following are not required. The first line just prints out information about the device in the log view.</p>
<p>The second line opens the Apple Sound Bank Synthesizer properties and parameters which allow you to adjust settings such as the tuning, volume, reverb volume, audio streaming, render quality, and CPU load restriction.</p>
<pre class="brush: java;">
(au:print-audiounits &quot;aumu&quot;)
(au:open-view piano)
</pre>
<p>Now this is all well and good, but how do you make it play?</p>
<p>The easiest way is to press Option &gt; E on your keyboard to tell it to evaluate. Alternatively you can press the evaluate button in the top right of the Impromptu editor. Now, this won&#8217;t evaluate the entire program, you will have to do each line individually starting from the beginning. So in some cases, it may be best to evaluate as you are going.</p>
<p>Click near the start of a line and ensure that the entire line and anything on seperate lines that are within the series of commands are highlighted and then  hit evaluate.</p>
<p>Work your way through and once you reach play-note, it should play the note with the parameters that you specified.</p>
<p>If you try to evaluate the note first, it won&#8217;t play. This is because the MIDI library hasn&#8217;t been connected yet.</p>
<p>If you have put in multiple notes than you will have noticed that you have to evaluate each note whenever you want to hear it. This is a pain and it will be addressed in my next post where we will be <a href="http://matthewbrown.net.au/programming/making-a-drum-machine-using-scheme-and-impromptu/" title="Making a drum machine using Impromptu and Scheme.">making a drum machine in Impromptu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://matthewbrown.net.au/programming/making-a-midi-based-piano-using-scheme-and-impromptu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction To Impromptu</title>
		<link>http://matthewbrown.net.au/software/introduction-to-impromptu/</link>
		<comments>http://matthewbrown.net.au/software/introduction-to-impromptu/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 12:49:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[computational arts]]></category>
		<category><![CDATA[Impromptu]]></category>
		<category><![CDATA[kkb210]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Midi]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[QUT]]></category>
		<category><![CDATA[vector drawing]]></category>

		<guid isPermaLink="false">http://matthewbrown.net.au/software/impromptu/introduction-to-impromptu/</guid>
		<description><![CDATA[Impromptu is a programming environment that is intended to assist in the creation of computational arts of all varieties and is completely new to me. It is designed for OS X, and this is probably part of the reason I have not come across it before since it was only November that I seriously started [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://impromptu.moso.com.au" title="Impromptu Scheme Programming Environment">Impromptu</a> is a programming environment that is intended to assist in the creation of computational arts of all varieties and is completely new to me.</p>
<p>It is designed for OS X, and this is probably part of the reason I have not come across it before since it was only November that I seriously started using a Mac.</p>
<p>Impromptu uses the Scheme programming language and is particularly suited to live programming, however in using it myself, it is obvious that the features built into it to assist live programming make regular programming much easier as well since changes can be made on the fly.</p>
<p><span id="more-7"></span></p>
<p>Impromptu is  developed by Andrew Sorenson from QUT. As I am studying computational arts at QUT, it would be almost impossible to not come across Impromptu sooner or later.</p>
<p>My tutor and lecturer have both commented that as far as generating computational audio, Impromptu is one of the best development environments as it is oriented strongly around time and timing so that things can be scheduled accurately. Apparently other environments over periods of time can start to get slightly out of time, where Impromptu doesn&#8217;t.</p>
<p>It also supports a whole heap of graphic generating options, such as  OpenGL rendering and vector drawing, along with many more, which is quite nice.</p>
<p>I haven&#8217;t used it in depth, but my experience with it thus far is that it is very straight forward and simple to use. I have never written anything in Scheme before, but it seems easy to learn and the Impromptu environment helps make it even easier.</p>
<p>The audio that is used is MIDI generated and follows the standard outlined on the <a href="http://www.midi.org/about-midi/gm/gm1sound.shtml" title="MIDI Numbers">MIDI Manufacturers Association website</a>.</p>
<p>Thus far I have seen examples of and written my own drum kit, bass line, and I have been experimenting with an entire musical piece as well, slowly. I&#8217;ll be going through these things a bit later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://matthewbrown.net.au/software/introduction-to-impromptu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

