<?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>matt.west.co.tt &#187; Music</title>
	<atom:link href="http://matt.west.co.tt/category/music/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt.west.co.tt</link>
	<description>adventures of a retro electro media hacker type person</description>
	<lastBuildDate>Mon, 25 Jul 2011 21:37:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>The Synchronizatron 3000</title>
		<link>http://matt.west.co.tt/music/synchronizatron-3000/</link>
		<comments>http://matt.west.co.tt/music/synchronizatron-3000/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 21:25:59 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=258</guid>
		<description><![CDATA[In advance of my appearance at the Ultrachip Festival in Edinburgh next month (19th-20th August! Two nights of awesomeness from the UK&#8217;s finest chiptune musicians! Free entry! W00t!), I thought this would be a good time to reveal the secret weapon at the heart of my live shows. Ladies and gentlemen, behold… the Synchronizatron 3000. [...]]]></description>
			<content:encoded><![CDATA[<p>In advance of my appearance at the <strong><a href="http://www.ultrachip.co.uk/">Ultrachip Festival</a></strong> in Edinburgh next month <em>(19th-20th August! Two nights of awesomeness from the UK&#8217;s finest chiptune musicians! Free entry! W00t!)</em>, I thought this would be a good time to reveal the secret weapon at the heart of my live shows. Ladies and gentlemen, behold… <strong>the Synchronizatron 3000</strong>.</p>
<div style="text-align: center;"><img src="http://matt.west.co.tt/images/synchronizatron_400px.jpg" alt="" width="400" height="533"></div>
<p>Out of all my projects, I like this one a lot. I like it because it brought me out of my comfort zone and into the murky world of hardware design (aided by the <a href="http://arduino.cc/">Arduino</a> project which does a fine job of making that world accessible to electronics noobs like me). I also like it because it elegantly solves a problem that, in all likelihood, nobody in the world but me has. But most of all, I like it because it has a pair of blinky LEDs on the top which serve no meaningful purpose.<br />
<span id="more-258"></span><br />
A couple of the songs in my set are played using two Spectrums together, to get an unthinkable 6 (SIX!) channels of sound. At <a href="http://ay-riders.speccy.cz">AY Riders</a> concerts in the past, we synchronised them through the low-tech method of having two of us with our fingers poised over the space bar while one of us counted us in. This method has two drawbacks: firstly, if the timing is even slightly out, it&#8217;s very noticeable. Secondly, different models of Spectrum have slightly different clock speeds, which causes them to slowly drift out of sync over the duration of the song. My two &#8216;performance&#8217; Spectrums are an original 128+ and my <a href="http://matt.west.co.tt/spectrum/speccy2010/">Speccy2010</a>, which are about as different as you can get &#8211; so that wasn&#8217;t going to cut it.</p>
<p>The job of the Synchronizatron 3000 is to provide a common external 50Hz clock signal for the two Spectrums to use, in place of their own timers. This signal gets fed in through whichever port happens to be convenient &#8211; for the Speccy2010, it&#8217;s the joystick port, which handily also provides a +5V line for powering the whole thing &#8211; and for the 128+, it&#8217;s the cassette (EAR) port. Using the cassette port adds another hurdle, because it&#8217;s designed to receive audio-frequency signals, so (presumably due to bandpass filters and other things I don&#8217;t understand) it won&#8217;t respond to simply flipping the signal high and low every 50th of a second &#8211; so instead, it rapidly alternates between generating an 8000Hz tone and silence. The code is really laughably simple:</p>
<pre>
void setup() {
  // initialize the digital pin as an output.
  pinMode(13, OUTPUT); // clock signal
  pinMode(9, INPUT);   // on/off switch
  pinMode(10, OUTPUT); // off (red) LED
  pinMode(11, OUTPUT); // on (green) LED
}

void loop() {
  if (digitalRead(9)) {  // switched on
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);
    tone(13, 8000); // burst of high frequency
    delay(5);   // play it for 5ms
    noTone(13); // set signal off
    delay(15);  // wait for 15ms
  } else {  // switched off
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
  }
}
</pre>
<p>The Z80 code on the Spectrum side to listen to those pulses goes something like this &#8211; it&#8217;s somewhat similar to what the Spectrum&#8217;s own tape loading routines do when listening for the end of a &#8216;beeeeeee&#8217; in &#8216;beeeeeee bip! beeeeeee bipipipipi…&#8217;, except that here it gets done 50 times a second:</p>
<pre>
	call init_music
loop:
wait_low:
	call get_pulse      ; check for presence of a tone
	jr nz,wait_low      ; don't proceed until the tone has stopped
wait_high:
	call get_pulse      ; now wait for the tone to start up again
	jr z,wait_high      ; - don't proceed until we detect a pulse
	call play_music     ; play the next 'frame' of music -
	                    ; - we want to do this every 1/50s
	jr loop             ; repeat ad infinitum

get_pulse:
	in a,(254)          ; read the cassette port:
	and 0x40            ; - bit 6 of port 254
	ld d,a              ; save its initial value in d
	ld b,255            ; see if it changes over the next 255 iterations over this loop:
get_pulse_loop:
	in a,(254)          ; re-read the cassette port
	and 0x40
	cp d                ; compare with initial value
	ret nz              ; return (with zero flag reset) if there's been a change
	djnz get_pulse_loop
	ret                 ; return (with zero flag set) after 255 iterations with no change
</pre>
<p>Having successfully proved the concept with the full Arduino board, accompanying breadboard and rats-nest of wires, transferring the whole thing to a standalone circuit on stripboard was dead easy &#8211; even easier than the <a href="http://arduino.cc/en/Main/Standalone">regular instructions</a> for doing that, because the Speccy2010 joystick port already gives us a regulated 5V line that saves us from having to rig one up ourselves on the board.</p>
<div style="text-align: center;"><img src="http://matt.west.co.tt/images/synchronizatron_circuit.jpg" alt="(the stripboard schematic, with obligatory coffee stain)" title="the stripboard schematic, with obligatory coffee stain" width="400" height="533"></div>
<p><em>Thanks to <a href="https://twitter.com/loleg">Oleg</a>, <a href="https://twitter.com/btscroggs">Ben</a> and the rest of the <a href="http://wiki.oxfordhackspace.org.uk/doku.php">Oxford Hack Space</a> crowd for their technical, organisational and moral support while cooking this up!</em></p>
<p>It all worked splendidly on the night <a href="http://matt.west.co.tt/music/gasman-live-at-outline-2011/">in Eersel</a>, and you&#8217;ll be able to witness it in action again if you come along to Ultrachip next month. Go on, you know you want to…<br />
<img src="http://www.cmptrllr.co.uk/wp-content/uploads/2011/07/ultrachip-2011-2x.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/synchronizatron-3000/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gasman live at Outline 2011!</title>
		<link>http://matt.west.co.tt/music/gasman-live-at-outline-2011/</link>
		<comments>http://matt.west.co.tt/music/gasman-live-at-outline-2011/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 22:14:37 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=251</guid>
		<description><![CDATA[After the triumphant AY Riders gig at the Forever demoparty back in March, I had a hankering for some more Speccy-and-keytar-and-vocoder live performance action, so I jumped at the chance to play my first EVVAR solo set at last weekend&#8217;s Outline party in the Netherlands. Outline is by no means one of the largest parties, [...]]]></description>
			<content:encoded><![CDATA[<p>After the triumphant <a href="http://ay-riders.speccy.cz/">AY Riders</a> gig at the <a href="http://forever.zeroteam.sk/">Forever</a> demoparty back in March, I had a hankering for some more Speccy-and-keytar-and-vocoder live performance action, so I jumped at the chance to play my first EVVAR solo set at last weekend&#8217;s <a href="http://outlinedemoparty.nl/">Outline</a> party in the Netherlands. Outline is by no means one of the largest parties, but there&#8217;s something magic about the atmosphere there which has made it one of the most eagerly awaited events in my calendar over the last couple of years. Most demo parties will give you the opportunity to chill outside in the sun with a beer or slave away at a hot CPU to finish off your creations, but it&#8217;s rare that the two activities flow together so smoothly as they do at Outline.</p>
<p>And with everyone&#8217;s spirits kept high, it means that when the evening activity kicks off, you have the most awesome audience you could possibly hope for. Big ups to TMC for the video, m0d for the other video which should be surfacing soon, Ziphoid for streaming the gig on <a href="http://scenesat.com/">SceneSat Radio</a>, and of course Havoc, D-Force and the rest of the Outline team for making it all happen&#8230;</p>
<p><iframe width="480" height="303" src="http://www.youtube.com/embed/C7wY4xq0psA" frameborder="0" allowfullscreen></iframe></p>
<h3>Setlist</h3>
<ul>
<li>1:51 Gasman &#8211; Out Of Neverland</li>
<li>6:18 Gasman &#8211; Torch Dragon</li>
<li>8:41 Celine Dion &#8211; My Heart Will Go On</li>
<li>10:23 Gasman &#8211; Cybernoid&#8217;s Revenge</li>
<li>14:23 Madonna (arr. TDM + Factor6) &#8211; Hung Up</li>
<li>20:17 Gasman &#8211; Oldskool Crusader</li>
<li>23:47 Michael Jackson &#8211; Thriller (featuring Okkie)</li>
<li>30:30 Purple Motion (arr. TDM + Factor6) &#8211; Satellite One</li>
</ul>
<h3>balls, touching</h3>
<p>And after all that, I still had some spare energy to do some casual hacking around with sine waves and come up with an entry for the 128 byte intro compo. As you&#8217;ll see from the video, 128 byte intros are one of those peculiarly demoscene-ish things that demand a certain frame of mind to be enjoyed properly, to the point where it gets a tad surreal for outsiders. If nothing else, you can certainly count on the Outline audience to provide a soundtrack to a silent production.</p>
<p><iframe width="480" height="303" src="http://www.youtube.com/embed/w_b2aS_ndZE" frameborder="0" allowfullscreen></iframe></p>
<p><a href="http://pouet.net/prod.php?which=57068"><i>balls, touching</i> on Pouët</a></p>
<p>(&#8230;and before you ask, the title does indeed come from an infantile demoscene in-joke about genitalia. I&#8217;d actually only planned for there to be one ball, but then one of those fortuitous coding accidents from adding or removing an odd instruction happened, and I knew I had to run with it.)</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/gasman-live-at-outline-2011/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Easterbirdie</title>
		<link>http://matt.west.co.tt/music/easterbirdie/</link>
		<comments>http://matt.west.co.tt/music/easterbirdie/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 21:22:47 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=248</guid>
		<description><![CDATA[I wrote a Speccy chiptune for the Revision party this weekend (where it was presented on the 29th anniversary of the release of the ZX Spectrum, no less). The whole thing was done live at the party in the space of about six hours, and it&#8217;s very much in my signature style. Download gasman_-_easterbirdie.mp3 Download: [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a Speccy chiptune for the <a href="http://revision-party.net/">Revision party</a> this weekend (where it was presented on the 29th anniversary of the release of the ZX Spectrum, no less). The whole thing was done live at the party in the space of about six hours, and it&#8217;s very much in my signature style.</p>
<p><a href="http://music.matt.west.co.tt/speccy/gasman_-_easterbirdie.mp3">Download gasman_-_easterbirdie.mp3</a></p>
<p>Download:</p>
<ul>
<li><a href="http://music.matt.west.co.tt/speccy/gasman_-_easterbirdie.tap.zip">Easterbirdie (ZX Spectrum .tap format)</a></li>
<li><a href="http://music.matt.west.co.tt/speccy/gasman_-_easterbirdie.mp3">Easterbirdie (MP3 format)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/easterbirdie/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://music.matt.west.co.tt/speccy/gasman_-_easterbirdie.mp3" length="3340306" type="audio/mpeg" />
		</item>
		<item>
		<title>FAWM 2011 retrospective / Geek Pop</title>
		<link>http://matt.west.co.tt/music/fawm-2011/</link>
		<comments>http://matt.west.co.tt/music/fawm-2011/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 23:37:08 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[FAWM]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=225</guid>
		<description><![CDATA[February has been and gone, bringing with it my now customary jaunt into the world of February Album Writing Month. I fell some way short of the 14 song target this time, which I&#8217;ll blame on considerably increasing my production values this year, and not at all on being a lazy git. I&#8217;m holding back [...]]]></description>
			<content:encoded><![CDATA[<p>February has been and gone, bringing with it my now customary jaunt into the world of <a href="http://fawm.org/">February Album Writing Month</a>. I fell some way short of the 14 song target this time, which I&#8217;ll blame on considerably increasing my production values this year, and not at all on being a lazy git.</p>
<p>I&#8217;m holding back a few of the songs from general release, because they&#8217;ll be going towards <em>this</em> month&#8217;s exciting musical happening: <strong>the <a href="http://geekpop.podbean.com/">Geek Pop</a> virtual festival!</strong> Yes, all the greatest musical minds from the worlds of science and technology will be gathered in one place on the internet &#8211; and somehow I&#8217;ve ended up being one of them, performing on the Comical Flask stage alongside such luminaries as MJ &#8220;Hey Hey 16K&#8221; Hibbett. And because it&#8217;s a virtual festival, you don&#8217;t even need to drink beer out of a nasty plastic beaker or walk two miles to the nearest shower. Hurrah! Keep your browsers peeled (or something) at the Geek Pop website for the big unveiling on March 11th, or mosey on down to Wilton&#8217;s Music Hall, London on the 10th for the <a href="http://geekpop.podbean.com/2011/01/20/geek-pop-2011-launch-tickets-on-sale-now/">live launch gig</a>.</p>
<p>In the meantime, here&#8217;s some almost-as-good-or-equally-good-but-not-as-geeky music I also wrote last month&#8230;</p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370215&amp;show_comments=true&amp;auto_play=false&amp;color=ff7700"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370215&amp;show_comments=true&amp;auto_play=false&amp;color=ff7700" type="application/x-shockwave-flash" width="100%"></embed></object>   <span><a href="http://soundcloud.com/matt-westcott/avogadros-number">Avogadro&#8217;s Number</a> by <a href="http://soundcloud.com/matt-westcott">Matt Westcott</a></span></p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370442"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370442" type="application/x-shockwave-flash" width="100%"></embed></object>  <span><a href="http://soundcloud.com/matt-westcott/big-conversation">Big Conversation</a> by <a href="http://soundcloud.com/matt-westcott">Matt Westcott</a></span></p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370576"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F11370576" type="application/x-shockwave-flash" width="100%"></embed></object>  <span><a href="http://soundcloud.com/matt-westcott/in-the-future">In The Future</a> by <a href="http://soundcloud.com/matt-westcott">Matt Westcott</a></span></p>
<p>(Looking for the lyrics? Get them at <a href="http://fawm.org/fawmers/mattwestcott/">my FAWM profile page</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/fawm-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burton&#8217;s Wagon Wheels (Are Smaller Than They Used To Be)</title>
		<link>http://matt.west.co.tt/music/burtons-wagon-wheels-are-smaller-than-they-used-to-be/</link>
		<comments>http://matt.west.co.tt/music/burtons-wagon-wheels-are-smaller-than-they-used-to-be/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 19:55:53 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=200</guid>
		<description><![CDATA[In one of my rare non-FAWM outings, I&#8217;ve written a new song. A protest song. About biscuits. Burton&#8217;s Wagon Wheels (Are Smaller Than They Used To Be) by Matt Westcott Burtons Wagon Wheels are smaller than they used to be They&#8217;re taking us for suckers at the biscuit factory The PR guys deny it, but [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my rare non-<a href="http://fawm.org/">FAWM</a> outings, I&#8217;ve written a new song. A protest song. About biscuits.</p>
<p><object width="480" height="290"><param name="movie" value="http://www.youtube.com/v/xFRwEtBP0Gc?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xFRwEtBP0Gc?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="290"></embed></object></p>
<p><object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F8055111&#038;secret_url=false"></param><param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F8055111&#038;secret_url=false" type="application/x-shockwave-flash" width="100%"></embed></object>  <span><a href="http://soundcloud.com/matt-westcott/burtons-wagon-wheels">Burton&#8217;s Wagon Wheels (Are Smaller Than They Used To Be)</a> by <a href="http://soundcloud.com/matt-westcott">Matt Westcott</a></span> </p>
<p><span id="more-200"></span></p>
<p>Burtons Wagon Wheels are smaller than they used to be<br />
They&#8217;re taking us for suckers at the biscuit factory<br />
The PR guys deny it, but any fool can see<br />
That Burtons Wagon Wheels are smaller than they used to be</p>
<p>Now the marketers at Burtons would have us all believe<br />
That it&#8217;s an artefact of questionable childhood memories<br />
And that we have recollections of eating a confection<br />
Disproportionately larger than our hands</p>
<p>But a moment&#8217;s contemplation will expose that as a lie<br />
For if it were so, then clearly it would equally apply<br />
To Penguin biscuits, door handles and other random junk<br />
But you never hear anyone complaining that those things have shrunk</p>
<p>And that&#8217;s because<br />
Burtons Wagon Wheels are smaller than they used to be<br />
They&#8217;re taking us for suckers at the biscuit factory<br />
The PR guys deny it, but any fool can see<br />
That Burtons Wagon Wheels are smaller than they used to be</p>
<p>The Wagon Wheels you get today have a radius suggestive<br />
of the typical dimensions of a Hob-Nob or digestive<br />
It&#8217;s a universal standard, that our ancestors have handed<br />
Down through history across the Western world</p>
<p>But we all know that there was one exception to this scheme<br />
&#8216;Cause otherwise, it makes no sense for it ever to have been<br />
A defining characteristic of the Wagon Wheel at all<br />
On which to question our power of recall&#8230;</p>
<p>And was there not a line in Orwell&#8217;s Nineteen Eighty-Four<br />
About how chocolate rations are reduced from what they were before?<br />
Big Brother claims that they have risen, and by feat of hypnotism<br />
The population takes him at his word</p>
<p>So don&#8217;t let us be duped by this dystopian regime<br />
Rise up to fight against the evil biscuit tyranny<br />
And force them to admit the fact that any fool can see:<br />
That Burtons Wagon Wheels are smaller than they used to be</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/burtons-wagon-wheels-are-smaller-than-they-used-to-be/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jasmid &#8211; MIDI synthesis with Javascript and HTML5 audio</title>
		<link>http://matt.west.co.tt/music/jasmid-midi-synthesis-with-javascript-and-html5-audio/</link>
		<comments>http://matt.west.co.tt/music/jasmid-midi-synthesis-with-javascript-and-html5-audio/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 23:40:41 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Talks]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=190</guid>
		<description><![CDATA[The executive summary: At last weekend&#8217;s Barcamp London 8, I presented a talk entitled &#8220;Realtime audio generation for the web (because there&#8217;s not enough MIDI on webpages these days&#8221;. In it, I went over the current options for generating audio within the browser, and presented my latest hack in that direction, jasmid: a Javascript app [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The executive summary:</strong> At last weekend&#8217;s <a href="http://eight.barcamplondon.org/">Barcamp London 8</a>, I presented a talk entitled &#8220;Realtime audio generation for the web (because there&#8217;s not enough MIDI on webpages these days&#8221;. In it, I went over the current options for generating audio within the browser, and presented my latest hack in that direction, <strong>jasmid</strong>: a Javascript app that can read standard MIDI files, render them to wave audio (with, at present, some <em>very</em> simple waveforms) and play them directly from the browser, completely independently of your OS&#8217;s MIDI support.</p>
<ul>
<li><a href="https://github.com/gasman/jasmid">jasmid on Github</a></li>
<li><a href="http://jsspeccy.zxdemo.org/jasmid/">Online demo</a></li>
</ul>
<p>Read on for the complete notes/transcript of the talk (in hopefully more coherent form than the talk itself &#8211; next time I promise to spend less time on the flashy demo and more time figuring out exactly what I&#8217;m going to say&#8230;)<br />
<span id="more-190"></span></p>
<p>Right now everyone&#8217;s jolly excited about the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#audio">HTML5 audio element</a>. At last we have a standard-compliant way to drop audio clips into web pages that avoids all the gunk with external plugins and replaces it with a simple tag (well, once you&#8217;ve fought through the details of which browsers support MP3 versus Ogg anyway). It has a comprehensive API to handle all the details of buffering, programatically pausing, playing and skipping and so on &#8211; but one thing it stops short of is being able to generate the audio data on the fly, within the browser.</p>
<p>Why would you want that? Well, I can&#8217;t say why <em>you&#8217;d</em> want it, but I can tell you what I&#8217;m hoping to do with it: I&#8217;m involved in the <i>demo scene</i>, a community of programmers, artists and musicians who create digital art &#8211; something roughly like music videos, but with visuals generated in real time &#8211; and I&#8217;m working on <a href="http://demozoo.org/">a forthcoming website</a> that will showcase those productions. This community originates from the days of the Commodore 64, when people cracked games and added little intro animations to promote themselves, which became more and more elaborate as rival groups tried to outdo each other, until they evolved into full-scale artistic creations and the game cracking side of things took a back seat. And among the artefacts to come out of this community is a hell of a lot of music &#8211; we&#8217;re talking hundreds of thousands of tracks, all preserved in the native formats of the Commodore 64, and the Amiga, and all sorts of other things. And it would be quite neat to be able to play all of these from within my website.</p>
<p>I&#8217;m using this site as an excuse to play around with cool technologies, and at first I figured that this was an ideal job for <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> &#8211; set up a bunch of instances churning away in the background converting these files to MP3. However, when I started to learn about ways to generate audio in the browser, it made sense to take advantage of that and save myself a whole lot of up-front processing (not to mention bandwidth).</p>
<p>At the forefront of this new development is the <a href="https://wiki.mozilla.org/Audio_Data_API">Mozilla Audio Data API</a>, available in the latest nightly builds of Firefox. This extends the HTML5 audio API with a few new methods, the central ones being mozSetup &#8211; which allows you to initialise an empty audio stream with a specified sample rate and number of channels &#8211; and mozWriteAudio, which lets you pass in an array of floats representing some sample data to add to that stream. Like all good up-and-coming browser innovations, we can reasonably assume that once the Mozilla developers have got this API stable enough they&#8217;re going to submit it to WHATWG for inclusion in the HTML5 spec &#8211; but for the moment, it has somewhat limited adoption. There is a remedy for that though&#8230;</p>
<p>At my last Barcamp London, two years ago now, I gave the first public showing of <a href="http://jsspeccy.zxdemo.org">JSSpeccy</a>, my ZX Spectrum emulator written in Javascript, which has been something of a runaway internet hit &#8211; and I&#8217;ve been somewhat surprised by the number of people taking it <em>seriously</em>, rather than as the crazy pointless hack I built it as (not least, the guy who ripped it off and sold it on the App Store as the first ever iPhone Spectrum emulator, despite it running at about 30% speed *cough*). But one guy who&#8217;s picked up the concept of emulation in Javascript and taken it much further than I&#8217;d ever dreamed possible is <a href="http://benfirshman.com/">Ben Firshman</a>, who created <a href="http://benfirshman.com/projects/jsnes/">JSNES</a>, the Javascript <del datetime="2011-02-03T14:19:49+00:00">SNES</del> NES emulator, featuring a whole host of advanced optimisations and new features, including audio support.</p>
<p><img src="http://matt.west.co.tt/images/jsnes.jpg" alt="" /></p>
<p>To achieve this, he created the <a href="https://github.com/bfirsh/dynamicaudio.js">dynamicaudio.js</a> library, which sits on top of Mozilla&#8217;s Audio Data API, but also provides an invisible Flash widget for other browsers to fall back upon. Armed with this work, I was able to build the first step towards my goal: <a href="http://jsspeccy.zxdemo.org/jsmodplayer/">jsmodplayer</a>, a player for the MOD music format originally introduced on the Amiga. It&#8217;s a rather messy format to implement, with every man and his dog coming up with their own custom extensions to it in a very ad-hoc way, but at its heart it consists of a set of uncompressed wave samples (typically a second or two in length), and a script detailing when to trigger them and at what pitch. Put enough of those trigger events together, throw in some effects like volume control and pitch slide, and you have a song.</p>
<p>Now, as we all know from the Apple versus Adobe tiff, Flash is not exactly universal across the platforms we care about &#8211; so we haven&#8217;t covered all of our bases yet. However, for certain applications, there&#8217;s a possible third path (albeit one that I haven&#8217;t properly investigated yet), using another recent browser addition: <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">data: URIs</a>. Unlike typical URLs, which point to some external location that contains the data we want, a data: URI embeds that data directly, as a string of base64 or URL-encoded data. This means that we could generate a string containing a valid WAV file from Javascript (or indeed an MP3 or Ogg file, although generating those from Javascript is a little bit hardcore), and use that as the source of an &lt;audio&gt; element.</p>
<p>This does depend on us being able to generate the audio up-front before starting playback, so it&#8217;s arguably not truly &#8216;real time&#8217; &#8211; something like an emulator, which is generating audio in response to user interaction, couldn&#8217;t really do this. It&#8217;s good enough for our straightforward audio player, though.</p>
<p>For a while there was an unfortunate flaw in this plan: Chrome didn&#8217;t currently support WAV as an audio format. <a href="http://code.google.com/p/chromium/issues/detail?id=23916">The bug tracker ticket relating to this</a> featured some rather flimsy arguments defending this decision, such as &#8220;if we support WAV, people will start widely serving audio across the web as uncompressed WAV files&#8221; (um&#8230; just like everyone on the internet is using BMP files, which are supported by all major browsers, right?). Given the tendency of bug tickets to wander off onto unrelated subjects, it&#8217;s hard to tell what the eventual conclusion to this is &#8211; but if I&#8217;m reading it right, we can happily use WAVs as of Chrome 7.</p>
<p>(At this point, someone rightly mentioned that Internet Explorer imposes a 32K limit on URLs, so that won&#8217;t get you much of a wave file &#8211; especially with base64 or URL encoding to contend with. As such, all we can really do is hope that IE users will tend to have the Flash option available. Personally, I think it makes a refreshing change that we can even <em>consider</em> IE in our cutting-edge browser hacks once again&#8230;)</p>
<p>In fact, there&#8217;s another mechanism for feeding data into URLs dynamically, which I&#8217;d all but forgotten until I started preparing this talk: if you have a &#8216;javascript:&#8217; URL which returns a string when executed, that string will be used as the data. This trick was most prominently used in <a href="http://www.wolf5k.com/">Wolfenstein 5K</a> (long before the wider world caught on to the joys of Javascript size coding contests&#8230;), which constructed its display as an XBM image, an obscure text-based format. Before <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html">canvas</a> came along, I spent many happy hours trying to replicate that trick with GIF images, discovering along the way that Internet Explorer didn&#8217;t like strings containing zero bytes, which sent me down the garden path of constructing valid GIFs containing no zeros. Ah, happy days. In short, I don&#8217;t even know if this works at all with &lt;audio&gt;, and even if it does, it&#8217;s almost certainly as much of a dead end as it was back in 2004&#8230;</p>
<p><img src="http://matt.west.co.tt/images/fpc.png" alt="" /></p>
<p>One project of mine where I really <em>should</em> have seen the value of generating the audio up-front was <a href="http://matt.west.co.tt/demoscene/fake-plastic-cubes/">Fake Plastic Cubes</a>, a demo I wrote this summer to play around with the size reduction tricks I&#8217;d seen coming out of the <a href="http://10k.aneventapart.com/">10K Apart</a> and <a href="http://js1k.com/home">JS1k</a> contests, and to try and come up with something audiovisual in as small a size as possible. On the audio side, that meant ditching samples entirely, and doing the synthesis from first principles, building the sound up from plain sine waves &#8211; but in a classic case of project management fail, I spent a week building a really wonderful synthesiser framework and rushed everything else at the last minute, meaning that I had no chance to actually make something nice on top of it. As a result, it&#8217;s totally unpolished, and the animation keeps stuttering for a split second while it generates the next chunk of audio. It&#8217;s only a tiny fraction of the available processor time, but it&#8217;s enough to be very, very noticeable. I really should have just generated the entire audio track on startup and <em>then</em> kicked off the visuals &#8211; but there was no time for that, or to play around with <a href="http://www.whatwg.org/specs/web-workers/current-work/">web workers</a> which would seem to be another potential way to generate audio as a background process&#8230;</p>
<p>I also didn&#8217;t have time to compose a decent soundtrack, or experiment with the synth enough to come up with interesting sounds, or implement a vaguely sensible way to enter musical notes (as a dodgy workaround, I remapped the names of the notes in the scale to <a href="https://github.com/gasman/fakeplasticcubes/blob/master/src/synth.js">their positions on a QWERTY keyboard</a> and prodded out a melody from those</a>). Fortunately, I didn&#8217;t have to let a good routine go to waste: a week or so back, I encountered <a href="http://www.sergimansilla.com/blog/dinamically-generating-midi-in-javascript/">Sergi Mansilla&#8217;s jsmidi project</a>, which provides an easy way to create standard MIDI files from Javascript. However, it turns out that MIDI support in browsers has more or less stagnated &#8211; while wave audio goes from strength to strength, MIDI is still stuck in the world of OS-specific plugins &#8211; so there was a clear opportunity for some Javascript synthesiser love there. And so I&#8217;ve come up with <a href="https://github.com/gasman/jasmid">jasmid</a>, a JS library for reading MIDI files and playing them back through its own audio synthesis engine.</p>
<p>A MIDI file consists of a simple header, followed by a list of tracks &#8211; each of which is a list of timestamped events, which are usually note on/off events but could be a tempo change, change of instrument or various other things. The timestamps are actually a bit weird: you&#8217;d expect them to be given in something like microseconds, but they&#8217;re actually expressed as a number of &#8216;ticks&#8217;, where the MIDI file specifies a particular number of ticks per beat, and the tempo of the song is given in beats per second, which can change over time just to add further confusion. Ultimately it probably does make sense, because it means you can accurately use any rational number (within reason) as a tempo, and that&#8217;s handy for professional MIDI equipment that has to keep exact time for extended periods &#8211; it&#8217;s just an initial hurdle that you have to get over. Once you&#8217;ve got that in place, a MIDI synthesiser boils down to a set of generator functions that can emit audio waves for as long as you tell them to, and a main loop which picks events off the queue, running the generators until it&#8217;s time to process the next event.</p>
<p>For this first release, the generated sounds are not particularly interesting &#8211; just plain sine waves with a bit of attack/decay volume control applied &#8211; but now that we&#8217;ve got the initial framework in place it should be relatively straightforward to add more diverse sounds, and the synth engine should hopefully be flexible enough to support effects like harmonics and reverb.</p>
<p>Finally, as a glimpse of what&#8217;s in store for in-browser audio creation in the future, keep an eye on the <a href="http://mozillalabs.com/rainbow/">Mozilla Rainbow</a> project, which provides APIs for capturing audio and video from microphones / webcams. For the last few years I&#8217;ve been taking part in <a href="http://fawm.org/">February Album Writing Month</a>, a song writing community where collaborations over the internet play a major part &#8211; perhaps it won&#8217;t be too long until we&#8217;re doing that over a Google-Docs-style online equivalent of Audacity / GarageBand&#8230;?</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/jasmid-midi-synthesis-with-javascript-and-html5-audio/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Date Horse, 24th June</title>
		<link>http://matt.west.co.tt/music/date-horse-24th-june/</link>
		<comments>http://matt.west.co.tt/music/date-horse-24th-june/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 22:39:44 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=164</guid>
		<description><![CDATA[A quick heads-up that I&#8217;ll be playing my first ever proper not-just-an-open-mic gig this Thursday night as part of the Date Horse comedy and music night at the Vauxhall Griffin, London. Come along for some silly songs about Paris Hilton&#8217;s pet monkey and much more (and RSVP on the Facebook event)&#8230;]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.datehorse.com/"><img src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs344.snc4/41579_135573843122226_2947_n.jpg" alt="" style="float: right; margin-left: 16px;" /></a></p>
<p>A quick heads-up that I&#8217;ll be playing my first ever proper not-just-an-open-mic gig this Thursday night as part of the <a href="http://www.datehorse.com/">Date Horse</a> comedy and music night at the Vauxhall Griffin, London. Come along for some silly songs about Paris Hilton&#8217;s pet monkey and much more (and RSVP on <a href="http://www.facebook.com/event.php?eid=135573843122226">the Facebook event</a>)&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/date-horse-24th-june/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JSModPlayer &#8211; a Javascript .MOD player</title>
		<link>http://matt.west.co.tt/music/jsmodplayer/</link>
		<comments>http://matt.west.co.tt/music/jsmodplayer/#comments</comments>
		<pubDate>Sun, 23 May 2010 02:22:27 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=156</guid>
		<description><![CDATA[The epic Pacman 30th anniversary Google Doodle, along with Ben Firshman&#8217;s dynamicaudio.js library for dynamically generating audio, collectively persuaded me that I haven&#8217;t done any mad Javascript hacking for far too long. My response to this state of affairs is JSModPlayer, a player for .MOD music files (the mainstay of Amiga and PC sample-based music [...]]]></description>
			<content:encoded><![CDATA[<p>The epic Pacman 30th anniversary Google Doodle, along with Ben Firshman&#8217;s <a href="http://github.com/bfirsh/dynamicaudio.js">dynamicaudio.js</a> library for dynamically generating audio, collectively persuaded me that I haven&#8217;t done any mad Javascript hacking for far too long. My response to this state of affairs is <b><a href="http://jsspeccy.zxdemo.org/jsmodplayer/">JSModPlayer</a></b>, a player for .MOD music files (the mainstay of Amiga and PC sample-based music circa 1990).</p>
<p>So far it only implements a subset of the possible sample effects, and it demands a very fast Javascript engine &#8211; luckily all the new breed of browsers are pretty competitive at that now. Even so, unless your CPU is an absolute behemoth, it&#8217;ll probably struggle to keep up &#8211; the audio output is fixed at 44100Hz, and that&#8217;s rather a lot of numbers for Javascript to crunch, especially when the MOD file gets up to 16 or more channels. Which, amusingly enough, is exactly the situation we had back when we were using Gravis Ultrasounds on 386es. Hurrah for progress!</p>
<p><strong>Update 2010-06-08:</strong> Oops. In the process of testing how Safari 5 shapes up, I discovered a rather silly oversight: the audio buffering routine was set up to never use more than 10% of CPU. Now that I&#8217;ve fixed it, it turns out that Chrome and Safari (at least) have no trouble at all playing Jugi&#8217;s <em>Dope</em> theme in its 28-channel glory. (However, taking the brakes off the buffering does mean that we can&#8217;t reliably pause the audio any more. A small price to pay, I think you&#8217;ll agree.)</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/jsmodplayer/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Midibeep</title>
		<link>http://matt.west.co.tt/music/midibeep/</link>
		<comments>http://matt.west.co.tt/music/midibeep/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 00:11:52 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=130</guid>
		<description><![CDATA[Last week I posted possibly the most tedious Basic type-in listing ever to World Of Spectrum: (continues for approx 1500 more lines) Anyone typing it in in its entirety would be rewarded with this: Download midibeep_minute_waltz.mp3 Not bad for an evening&#8217;s work. Mind you, I did take an ever so teeny shortcut, by writing a [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I posted possibly <a href="http://www.worldofspectrum.org/forums/showthread.php?t=27028">the most tedious Basic type-in listing ever</a> to <a href="http://www.worldofspectrum.org/forums/">World Of Spectrum</a>:</p>
<p><img src="http://matt.west.co.tt/images/beep.png" width="320" height="240" alt="5 BEEP 0.212765, 20; 10 BEEP 0.106383,19..." /><br />
<em>(continues for approx 1500 more lines)</em></p>
<p>Anyone typing it in in its entirety would be rewarded with this:</p>
<p><a href="http://www.zxdemo.org/gasman/music/midibeep_minute_waltz.mp3">Download midibeep_minute_waltz.mp3</a></p>
<p>Not bad for an evening&#8217;s work. Mind you, I did take an ever so teeny shortcut, by writing a Ruby program to convert a MIDI file to BEEP format. (Any .mid file will do, although ones with a single instrument will survive the rather primitive selective-note-butchering process better. Oh, and anything much longer than this one will exceed the 48K Spectrum memory&#8230;) And now you can try it out too:</p>
<ul>
<li><a href="http://github.com/gasman/midibeep/">Midibeep source/downloads at Github</a></li>
<li><a href="http://www.zxdemo.org/extra/src/Mid2BEEP.zip">Midibeep Windows build</a> (thanks to Karl McNeil)</li>
<li><a href="http://www.zxdemo.org/gasman/music/chopin.tap">Minute Waltz (TAP, 38K)</a></li>
</ul>
<p><strong>Update 2010-05-26:</strong> Karl McNeil has adapted Midibeep into a variant called Mid2ASM, which outputs an assembler listing rather than Basic &#8211; this enables the data to be packed much more efficiently, paving the way for altogether longer pieces of music. <a href="http://www.zxdemo.org/extra/src/Mid2ASM.zip">Download Mid2ASM</a> (453K, Windows EXE included)</p>
<p><strong>Update 2010-06-02:</strong> Another update from Karl, featuring a Windows GUI, more space-saving tweaks, and embedding the output in a Basic REM statement. <a href="http://www.zxdemo.org/extra/src/Mid2ASM-2.zip">Download Mid2ASM v2</a> (3.4Mb)</p>
<p><strong>Update 2011-04-09:</strong> Karl McNeil has released the last version of Mid2ASM for a while, <a href="ftp://ftp.worldofspectrum.org/pub/sinclair/tools/pc/Mid2ASM.zip">version 3.2</a> &#8211; featuring primitive importing from .sid .psg and .wav, and the choice of Basic or assembly output. The <a href="ftp://ftp.worldofspectrum.org/pub/sinclair/tools/pc/Mid2ASM_SRC.zip">source archive</a> also contains the command-line version, midibeep2.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/midibeep/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
<enclosure url="http://www.zxdemo.org/gasman/music/midibeep_minute_waltz.mp3" length="1780424" type="audio/mpeg" />
		</item>
		<item>
		<title>Spectrumori-on</title>
		<link>http://matt.west.co.tt/music/spectrumori-on/</link>
		<comments>http://matt.west.co.tt/music/spectrumori-on/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 23:09:40 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=121</guid>
		<description><![CDATA[This 1K intro for the Spectrum (which received 3rd place in the oldskool demo competition at Sundown 2009) was inspired by Bill Bailey. No, really. His current live show features a spot on the Yamaha Tenori-on, which through the medium of &#8220;getting someone in the audience to splurge their hand on it&#8221;, he demonstrates that [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://matt.west.co.tt/images/spectrumorion_small.png" alt="" width="200" height="149" style="border: 5px solid #ccc; margin-left: 12px; float: right;" />This 1K intro for the Spectrum (which received 3rd place in the oldskool demo competition at <a href="http://www.sundowndemoparty.org/">Sundown 2009</a>) was inspired by Bill Bailey. No, really. His current live show features a spot on the Yamaha <a href="http://www.global.yamaha.com/design/tenori-on/">Tenori-on</a>, which through the medium of &#8220;getting someone in the audience to splurge their hand on it&#8221;, he demonstrates that it can&#8217;t fail to play something nice.</p>
<p>This makes it a good excuse for some experimentation with generative music. The secret is in the scale &#8211; it&#8217;s equivalent to playing only the black notes on a piano, and presumably has roots in oriental music (I previously rediscovered it while working on <a href="http://matt.west.co.tt/music/haiku/">Haiku</a>). To make it into something like a proper demo, rather than just a throwaway routine, I added a bit of subtle progression <a href="http://pouet.net/prod.php?which=11946">Cyberpunks Unity style</a>, so it drifts in and out of randomness as the graphical effects change. It even has a proper ending&#8230;</p>
<p>In recent months Yerzmyey has been pushing for the revival of the 16K Speccy as a platform, so I&#8217;m pleased to announce that this demo is &#8211; so we believe &#8211; the third ever demo to run on it.</p>
<ul>
<li><a href="http://www.zxdemo.org/f/200909/spectrumori-on_POSTPARTY.zip">Download Spectrumori-on</a> (TAP, 4Kb)</li>
<li><a href="http://pouet.net/prod.php?which=53831">Spectrumori-on on Pouet</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/spectrumori-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

