<?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>Wouter Hisschemöller &#187; admin</title>
	<atom:link href="http://www.hisschemoller.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hisschemoller.com</link>
	<description>Flash actionscript and audio programming</description>
	<lastBuildDate>Fri, 09 Apr 2010 20:32:43 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sine synthesizer with PureMVC</title>
		<link>http://www.hisschemoller.com/2009/sine-synthesizer-in-puremvc/</link>
		<comments>http://www.hisschemoller.com/2009/sine-synthesizer-in-puremvc/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 21:04:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=136</guid>
		<description><![CDATA[The past weeks I&#8217;ve been learning PureMVC. It had been on my mind for some time, and now that a project (a pianoroll type MIDI editor) became too complicated and the lack of structure took the fun out of programming I figured it was time for a nice new clean framework.

I read the &#8216;Framework Overview [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 260px"><img class=" " title="Part of the sequencer" src="http://www.hisschemoller.com/wp-content/uploads/2009/07/sinesynth_screenshot.gif" alt="Screenshot" width="250" height="200" /><p class="wp-caption-text">Screenshot</p></div>
<p>The past weeks I&#8217;ve been learning <a href="http://www.puremvc.org">PureMVC</a>. It had been on my mind for some time, and now that a project (a pianoroll type MIDI editor) became too complicated and the lack of structure took the fun out of programming I figured it was time for a nice new clean framework.</p>
<p><span id="more-136"></span><br />
I read the <a href="http://puremvc.org/component/option,com_wrapper/Itemid,35/http://puremvc.org/component/option,com_wrapper/Itemid,35/">&#8216;Framework Overview with UML&#8217;</a>, the <a href="http://puremvc.org/component/option,com_wrapper/Itemid,174/">&#8216;Implementation Idioms and Best Practices&#8217;</a> and memorized the famous <a href="http://puremvc.org/component/option,com_wrapper/Itemid,34/">conceptual diagram</a> with it&#8217;s interconnected cloud of meaningfull data blobs (see picture). I looked up some basic tutorials, <a href="http://www.as3dp.com/2007/12/27/minimalist-mvc-example-using-the-puremvc-framework/">&#8216;Minimalist MVC example using the PureMVC Framework&#8217;</a>, <a href="http://hubflanger.com/building-a-flash-site-using-puremvc/">&#8216;Building a Flash site using PureMVC&#8217;</a> and found this useful page: <a href="http://mariusht.com/blog/2009/05/21/puremvc-in-a-week/">&#8216;PureMVC in a week&#8217;</a>. And then felt ready for some PureMVC action of my own.</p>
<div class="wp-caption aligncenter" style="width: 440px"><a href="http://www.puremvc.org"><img title="The PureMVC conceptual diagram" src="http://www.hisschemoller.com/images/puremvc_diagram.jpg" alt="The PureMVC conceptual diagram" width="430" height="294" /></a><p class="wp-caption-text">The PureMVC conceptual diagram</p></div>
<p>And I must say: It&#8217;s not as complicated as I feared it would be. The first hurdle is a bit high with a lot of concepts and rules to remember, but then it quickly becomes clearer what part of the code goes where. My previous framework experience was with Cairngorm which is MVC based as well, so that definitely helped me to get my head round PureMVC.</p>
<p>Here is my first PureMVC test project, done to check how the audio programming stuff would integrate with the framework: It&#8217;s a small synthesizer that plays sine waves. Only sine waves. You can use keys on the computer keyboard to play the synth as a piano keyboard (see picture for the keys) and use Z and X to switch octaves and C and V to change the volume. This keyboard layout was taken from Ableton Live. I like the way it works there. So thank you <a href="http://www.ableton.com">Ableton</a>.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="puremvc"
			class="flashmovie"
			width="450"
			height="450">
	<param name="movie" value="http://www.hisschemoller.com/flash/v009_sine_puremvc/static/swf/puremvc.swf" />
	<param name="menu" value="false" />
	<param name="quality" value="best" />
	<param name="base" value="http://www.hisschemoller.com/flash/v009_sine_puremvc/static/swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.hisschemoller.com/flash/v009_sine_puremvc/static/swf/puremvc.swf"
			name="puremvc"
			width="450"
			height="450">
		<param name="menu" value="false" />
		<param name="quality" value="best" />
		<param name="base" value="http://www.hisschemoller.com/flash/v009_sine_puremvc/static/swf" />
	<!--<![endif]-->
		<br />
<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The source files are available again : <a href="http://hisschemoller.com/flash/v009_sine_puremvc/sine_puremvc.zip">Download the source files here.</a></p>
<p>Take note however that there is no FLA file. This is an ActionScript only project made in FDT. But if you want to compile it in Flash, it will probably work if you set App.as as the document root.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img title="Use the computer keyboard to play" src="http://www.hisschemoller.com/images/keyboard_midi.jpg" alt="Use the computer keyboard to play" width="450" height="155" /><p class="wp-caption-text">Use the computer keyboard to play</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/sine-synthesizer-in-puremvc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Step sequencer / drum machine</title>
		<link>http://www.hisschemoller.com/2009/step-sequencer-drum-machine/</link>
		<comments>http://www.hisschemoller.com/2009/step-sequencer-drum-machine/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 19:16:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=112</guid>
		<description><![CDATA[Here is a basic step sequencer for creating rhythms. The sounds it plays are small MP3 files. Short sound clips of drum noises, blips and plings. So it&#8217;s more a sample player than a drum synth. But the main thing is that it loads and plays rhythm patterns and that the patterns can easily be [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 278px"><img title="Part of the sequencer" src="http://www.hisschemoller.com/images/stepseq_v008.gif" alt="Part of the sequencer" width="268" height="231" /><p class="wp-caption-text">Part of the sequencer</p></div>
<p>Here is a basic step sequencer for creating rhythms. The sounds it plays are small MP3 files. Short sound clips of drum noises, blips and plings. So it&#8217;s more a sample player than a drum synth. But the main thing is that it loads and plays rhythm patterns and that the patterns can easily be edited. That&#8217;s what I wanted to do here. </p>
<p>It plays patterns in the same way <a href="http://flstudio.image-line.com">FL Studio (FruityLoops)</a> does. There&#8217;s twelve tracks that each play their own sound and each track has sixteen steps that can be switched on or off by clicking the step buttons.</p>
<p>Besides that the volume of each step can be changed by holding the &#8220;1&#8243; (one) key on the computer keyboard while dragging the mouse up or down on the step button. The blue rectangle on the step will change in height to indicate the volume level.</p>
<p>The image of the waveform on the left of each track can be clicked to play the sound. And there are four patterns. Switch between them with the &#8216;1&#8242; to &#8216;4&#8242; buttons at the bottom.</p>
<p><span id="more-112"></span></p>
<p>Try it out below. This time I added play and stop buttons because in the previous two players I didn&#8217;t and that started to annoy me. Things on web pages should only make noise when they&#8217;re specifically told so.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="stepseq"
			class="flashmovie"
			width="500"
			height="500">
	<param name="movie" value="http://www.hisschemoller.com/flash/v008_stepseq/static/swf/midiXml.swf" />
	<param name="menu" value="false" />
	<param name="quality" value="best" />
	<param name="scale" value="noscale" />
	<param name="salign" value="tl" />
	<param name="base" value="http://www.hisschemoller.com/flash/v008_stepseq/static/swf/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.hisschemoller.com/flash/v008_stepseq/static/swf/midiXml.swf"
			name="stepseq"
			width="500"
			height="500">
		<param name="menu" value="false" />
		<param name="quality" value="best" />
		<param name="scale" value="noscale" />
		<param name="salign" value="tl" />
		<param name="base" value="http://www.hisschemoller.com/flash/v008_stepseq/static/swf/" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><br >If you&#8217;re interested in any of the ActionScript code then download the full source of this project <a href="http://hisschemoller.com/flash/v008_stepseq/stepseq_v008.zip">here</a>. The ZIP includes all ActionScript classes, the samples and everything needed to compile and run the project.</p>
<p>A few notes on the source:</p>
<p>The project was made in FDT 3. There is no FLA file as a base to compile the SWF from. Instead you&#8217;ll need to set the class AppController (flash/classes/com/hisschemoller/AppController.as) as the main class in the project&#8217;s Run/Debug settings.</p>
<p>All visual elements of the projects were made in the Flash file flash/assets/assets.fla. That&#8217;s where all the button graphics are. This file is compiled to the SWC file assets.swc and that must be added to the class path in FDT. (Right click on the SWC file in FDT&#8217;s Flash explorer and choose &#8216;Add to Classpath&#8217;.) Then the scripts in FDT can find the MovieClips in the Flash library that were given a class name.</p>
<p>There might be all kinds of weird hidden Mac files in the ZIP. As well as the FDT launch and project setting files. I&#8217;m quite new to working on a Mac and I&#8217;m not shure what it adds that I don&#8217;t see. Sorry for that. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/step-sequencer-drum-machine/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MIDI and XML for a drum machine</title>
		<link>http://www.hisschemoller.com/2009/midi-and-xml/</link>
		<comments>http://www.hisschemoller.com/2009/midi-and-xml/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 12:50:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MIDI]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=78</guid>
		<description><![CDATA[As a next project I want to make a simple drum machine. Several tracks that each play a different drum sample and each track has sixteen steps. Just like a Roland 808 or the main step sequencer in FruityLoops. It&#8217;s nothing complicated but it made me think about how to store the patterns the drum [...]]]></description>
			<content:encoded><![CDATA[<p>As a next project I want to make a simple drum machine. Several tracks that each play a different drum sample and each track has sixteen steps. Just like a Roland 808 or the main step sequencer in FruityLoops. It&#8217;s nothing complicated but it made me think about how to store the patterns the drum machine plays.</p>
<div class="wp-caption alignright" style="width: 310px"><img title="MIDI" src="http://www.hisschemoller.com/images/midi_setup2.gif" alt="MIDI" width="300" height="128" /><p class="wp-caption-text">MIDI</p></div>
<p>I&#8217;d like to put in an XML file all the information about how many patterns there are, how many tracks, which sound plays when and so on. But I want to keep the file as flexible as possible. It must be easy to later change the length of a pattern to 32 tracks, to add melodic patterns, notes of different length, filter settings&#8230; Whatever I need I want to be able to include in the file.</p>
<p>Then it occurred to me that such a file already exist: MIDI!</p>
<p>MIDI has been around since 1982, and today still is one of the main formats for music. Besides channels, notes and timing it can hold all kinds of extra settings as &#8220;Control Change&#8221; values or &#8220;System Exclusive&#8221; messages. Very general and flexible and just what I need. Only, MIDI is no XML. And Flash can&#8217;t read MIDI files. So I googled MIDI and XML and found I&#8217;m not the first to need MIDI in an XML form.</p>
<p>As far as I&#8217;ve been able to find two standards exist to format MIDI as XML:</p>
<p><span id="more-78"></span></p>
<p><strong>MIDI XML</strong></p>
<p>The first one is MIDI XML. The good thing is that it&#8217;s been developed by the <a href="http://www.midi.org">MIDI Manufacturers Organization</a> which is the organization that made the original MIDI specification. But the bad thing is that it seems to be incomplete and their only <a href="http://www.midi.org/dtds/midi_xml.php">page about MIDI XML</a> was last updated in July 2003.</p>
<p>A few <a href="http://www.midi.org/dtds/">DTD pages</a> exist to show how the XML should be formatted, but that&#8217;s about it. Not a lot of information. The most interesting DTD file is <a href="http://www.midi.org/dtds/MIDIEvents10.dtd">MIDIEvents10.dtd</a>, which shows how to represent MIDI events. This is what the XML should look like according to the file:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p78code4'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p784"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p78code4"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NoteOn</span> <span style="color: #000066;">Channel</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Note</span>=<span style="color: #ff0000;">&quot;60&quot;</span> <span style="color: #000066;">Velocity</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NoteOn</span> <span style="color: #000066;">Channel</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Note</span>=<span style="color: #ff0000;">&quot;62&quot;</span> <span style="color: #000066;">Velocity</span>=<span style="color: #ff0000;">&quot;127&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ControlChange</span> <span style="color: #000066;">Channel</span>=<span style="color: #ff0000;">&quot;16&quot;</span> <span style="color: #000066;">Control</span>=<span style="color: #ff0000;">&quot;7&quot;</span> <span style="color: #000066;">Value</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ProgramChange</span> <span style="color: #000066;">Channel</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Number</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Clear enough, but this is only useful for a direct stream of MIDI events. Not to represent a MIDI file with a complete song. If only because there is no time information. You&#8217;d never know how much time it takes from one note to the next.</p>
<p><strong>MusicXML</strong></p>
<p>The second one is <a href="http://www.recordare.com/xml.html">MusicXML</a>. A much more complete standard made by <a href="http://www.recordare.com">Recordare</a>, a music and software company I had never heard of before. It seems to build on the MIDI XML standard, but goes much further. This is how an event would be represented in MusicXML:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p78code5'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p785"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p78code5"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Delta<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Delta<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NoteOn</span> <span style="color: #000066;">Channel</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Note</span>=<span style="color: #ff0000;">&quot;60&quot;</span> <span style="color: #000066;">Velocity</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The main new thing is the <b>&lt;Delta&gt;</b> tag. It&#8217;s value is the time it takes from this event to the next, measured in &#8220;Ticks Per Beat&#8221;. How many ticks per beat there are can be found in the first section of the XML file. This is from the XML file I use for my drum machine:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p78code6'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p786"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p78code6"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE MIDIFile PUBLIC</span>
<span style="color: #00bbdd;">  &quot;-//Recordare//DTD MusicXML 0.9 MIDI//EN&quot;</span>
<span style="color: #00bbdd;">  &quot;http://www.musicxml.org/dtds/midixml.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MIDIFile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Format<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Format<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TrackCount<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TrackCount<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TicksPerBeat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TicksPerBeat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TimestampType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Delta<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TimestampType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This means:</p>
<ul>
<li>&lt;Format&gt; holds the MIDI file type (0 or 1. 2 is not supported by MusicXML)</li>
<li>&lt;TrackCount&gt; the number of tracks (which is one because a type zero MIDI file can only have one track)</li>
<li>&lt;TicksPerBeat&gt; is the finest timing precision of the file. I used four because my drum machine has sixteen steps for a pattern of one bar, which is four steps for one beat. I don&#8217;t need more precision here.</li>
<li>&lt;TimeStampType&gt; is the way time is notated. It can be <em>Delta</em> or <em>Absolute</em>. <em>Delta</em> means  time is the amount of time between the current event and the next event, <em>Absolute</em> means the total time between the start of the song and the current event. I used <em>Delta</em> because real Standard MIDI files (.MID) only use Delta time.</li>
</ul>
<p>Much more information is available at the Recordare <a href="http://www.recordare.com/xml.html">MusicXML pages</a>, including DTD and XSD files, FAQ, tutorials and alphabetical index.</p>
<p>Another very helpful page is <a href="http://staff.dasdeck.de/valentin/midi">http://staff.dasdeck.de/valentin/midi</a>. It&#8217;s a collection of PHP scripts to work with MIDI. Especially useful is <a href="http://staff.dasdeck.de/valentin/midi/mid2xml.php">Midi2Xml</a> where you can upload a standard MIDI file which it translates into MusicXML format. It helped me a lot to discover how MusicXML works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/midi-and-xml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slicer with waveform display</title>
		<link>http://www.hisschemoller.com/2009/slicer-with-waveform-display/</link>
		<comments>http://www.hisschemoller.com/2009/slicer-with-waveform-display/#comments</comments>
		<pubDate>Sun, 10 May 2009 15:55:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=69</guid>
		<description><![CDATA[This slicer works the same as the previous one. Only difference is that is uses eight slices instead of sixteen.
The new stuff is in the interface: Waveforms to see what&#8217;s playing. And nicer to look at as well.
To use this app you can click the buttons as before to select a slice to play, and [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 285px"><img title="Slicer with waveform display" src="http://www.hisschemoller.com/images/waveformslicer.gif" alt="slicer with waveform display" width="275" height="198" /><p class="wp-caption-text">Slicer with waveform display</p></div>
<p>This slicer works the same as the previous one. Only difference is that is uses eight slices instead of sixteen.</p>
<p>The new stuff is in the interface: Waveforms to see what&#8217;s playing. And nicer to look at as well.</p>
<p>To use this app you can click the buttons as before to select a slice to play, and now you will see the waveform change to represent the slice.</p>
<p>The second way to change the slices is to click and drag on the waveforms itself. Drag up for later slices and down for earlier ones. Drag all the way down for an empty slice and silence.<span id="more-69"></span></p>
<p>Here it is! The music is from a track by <a href="http://www.flying-lotus.com">Flying Lotus</a>. I don&#8217;t know which one exactly: It&#8217;s track nr. 23 from a collection called &#8220;38 Cartoons&#8221;, but I couldn&#8217;t find any information about it online.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_waveformslicer_1800001341"
			class="flashmovie"
			width="590"
			height="240">
	<param name="movie" value="http://www.hisschemoller.com/flash/v007_waveformslicer/static/swf/waveformslicer.swf" />
	<param name="menu" value="false" />
	<param name="quality" value="best" />
	<param name="scale" value="noscale" />
	<param name="base" value="http://www.hisschemoller.com/flash/v007_waveformslicer/static/swf/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.hisschemoller.com/flash/v007_waveformslicer/static/swf/waveformslicer.swf"
			name="fm_waveformslicer_1800001341"
			width="590"
			height="240">
		<param name="menu" value="false" />
		<param name="quality" value="best" />
		<param name="scale" value="noscale" />
		<param name="base" value="http://www.hisschemoller.com/flash/v007_waveformslicer/static/swf/" />
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><strong>How to get an image from MP3 sound data</strong></p>
<p>The way I did it is first to calculate how many samples of a slice represent one pixel of the image, then get the biggest amplitude of those samples. That will be a number between 0 and 1. Then multiply it by half of the images height to get the size of the line to draw. And finally draw the line to a BitMapData object.</p>
<p>It generates a simplified waveform: The positive and negative amplitudes are the same and it&#8217;s only the left channel. But it&#8217;s good enough for this purpose. It&#8217;s a good impression of the waveform.</p>
<p>Here is the main part of the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p69code8'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p698"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code" id="p69code8"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mp3NumSamples : <span style="color: #0066CC;">Number</span> = mMp3Loop.<span style="color: #006600;">extract</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">41000</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> - mMp3StartOffset;
mMp3NumSamplesPerSlice = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span>mp3NumSamples <span style="color: #66cc66;">/</span> Model.<span style="color: #006600;">NUM_SLICES</span><span style="color: #66cc66;">&#41;</span>;
mBPM = TimeConversion.<span style="color: #006600;">numSamplesToBPM</span><span style="color: #66cc66;">&#40;</span>mp3NumSamples, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> sampleIndex : <span style="color: #0066CC;">int</span> = mMp3StartOffset;
<span style="color: #000000; font-weight: bold;">var</span> imageWidth : <span style="color: #0066CC;">int</span> = Model.<span style="color: #006600;">BUTTON_WIDTH</span>;
<span style="color: #000000; font-weight: bold;">var</span> samplesPerPixel : <span style="color: #0066CC;">int</span> = mMp3NumSamplesPerSlice <span style="color: #66cc66;">/</span> imageWidth;
&nbsp;
<span style="color: #808080; font-style: italic;">// loop through the slices</span>
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;i <span style="color: #66cc66;">&lt;</span> Model.<span style="color: #006600;">NUM_SLICES</span>; ++i<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> byteArray : ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> numSamples : <span style="color: #0066CC;">int</span> = mMp3Loop.<span style="color: #006600;">extract</span><span style="color: #66cc66;">&#40;</span>byteArray, mMp3NumSamplesPerSlice, sampleIndex<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">position</span> : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> lineMiddle : <span style="color: #0066CC;">int</span> = <span style="color: #66cc66;">&#40;</span>Model.<span style="color: #006600;">DISPLAY_HEIGHT</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	byteArray.<span style="color: #0066CC;">position</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
	mMp3WaveformData<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>Model.<span style="color: #006600;">BUTTON_WIDTH</span>, Model.<span style="color: #006600;">DISPLAY_HEIGHT</span>, <span style="color: #000000; font-weight: bold;">true</span>, 0xFF0000<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> bitmapData : BitmapData = mMp3WaveformData<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// loop through the pixels of a waveform image's width</span>
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;j <span style="color: #66cc66;">&lt;</span> imageWidth; ++j<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> waveHeight : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0.0</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// get maximum of all samples within pixel</span>
		<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> k : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; k <span style="color: #66cc66;">&lt;</span> samplesPerPixel ; ++k<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">position</span> <span style="color: #66cc66;">&lt;</span> numSamples<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> l : <span style="color: #0066CC;">Number</span> = byteArray.<span style="color: #006600;">readFloat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				byteArray.<span style="color: #006600;">readFloat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				l = <span style="color: #cc66cc;">0</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			waveHeight = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">max</span><span style="color: #66cc66;">&#40;</span>waveHeight, <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>l<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">position</span> ++;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		waveHeight <span style="color: #66cc66;">*</span>= lineMiddle;
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">start</span> : <span style="color: #0066CC;">int</span> = lineMiddle - waveHeight;
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">end</span> : <span style="color: #0066CC;">int</span> = lineMiddle + waveHeight;
&nbsp;
		<span style="color: #808080; font-style: italic;">// draw to bitmapdata</span>
		<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>k = <span style="color: #0066CC;">start</span>; k <span style="color: #66cc66;">&lt;</span> <span style="color: #0066CC;">end</span> ; ++k<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			bitmapData.<span style="color: #006600;">setPixel32</span><span style="color: #66cc66;">&#40;</span>j, k, 0xFFFFFFCC<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	sampleIndex += mMp3NumSamplesPerSlice;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/slicer-with-waveform-display/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A basic slicer</title>
		<link>http://www.hisschemoller.com/2009/a-basic-slicer/</link>
		<comments>http://www.hisschemoller.com/2009/a-basic-slicer/#comments</comments>
		<pubDate>Fri, 08 May 2009 14:51:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=27</guid>
		<description><![CDATA[This is it! The first one: A slicer.
It loads and plays an MP3 file. But not only that. It divides the file in sixteen equal parts and you can change the order in which the parts are played.
When it&#8217;s loaded the slicer plays all the parts in the right order. Part 1, 2, 3 and [...]]]></description>
			<content:encoded><![CDATA[<div id="v006_slicer_img" class="wp-caption alignright" style="width: 290px"><img title="Slicer" src="http://www.hisschemoller.com/flash/v006_slicer/static/images/v006_slicer.gif" alt="Part of the slicer" width="280" height="210" /><p class="wp-caption-text">Part of the slicer</p></div>
<p><strong>This is it! The first one: A slicer.</strong></p>
<p>It loads and plays an MP3 file. But not only that. It divides the file in sixteen equal parts and you can change the order in which the parts are played.</p>
<p>When it&#8217;s loaded the slicer plays all the parts in the right order. Part 1, 2, 3 and up until part 16. With the buttons you can change the order and for example play part 4, then 3, 11, 8 and so on. With the right MP3 loop this will create all kinds of interesting rhythmic variations.</p>
<p>It works best if the MP3 file is a short  piece of music with a steady rhythm that loops seamlessly (so the start and end of the sound fit together exactly). Then every slice has a little bit of rhythm in it. Just one or two sounds like a kick or snare drum.</p>
<p>Best to check it out for yourself. I will put the actual SWF files on the &#8216;Read more&#8217; pages of the posts, so they won&#8217;t all be playing at the same time and use up each other&#8217;s CPU cycles. <span id="more-27"></span></p>
<p><strong>The interface</strong></p>
<p>It&#8217;s a matrix! Sixteen buttons wide for the time slots, sixteen high for the slices. So the bottom left button selects slice one to be played first, the top left button plays slice sixteen at position one. Just click around and you&#8217;ll get it.</p>
<p><strong>The code</strong></p>
<p>The main thing in this application is the Sound.extract() method. Once the MP3 is loaded the total amount of samples in the file is divided by sixteen. Then it can store the duration in samples of a slice and at which sample exactly each slice starts. So the file isn&#8217;t actually split into sixteen parts. It only stores the starting point of each slice within the loop.</p>
<p>One thing I didn&#8217;t know but found out trying is how to get the total amount of samples in an MP3 file: Use extract() and request a length longer than you know the MP3 file is. For example one hour. Then extract() will get as many samples as it can. Which are all the samples in the file, and it returns that number:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code10'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2710"><td class="code" id="p27code10"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> oneHour : uint = <span style="color: #cc66cc;">44100</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span>;
<span style="color: #000000; font-weight: bold;">var</span> numSamples : uint = mp3File.<span style="color: #006600;">extract</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, oneHour<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_slicer_149506678"
			class="flashmovie"
			width="600"
			height="600">
	<param name="movie" value="http://www.hisschemoller.com/flash/v006_slicer/static/swf/slicer.swf" />
	<param name="menu" value="false" />
	<param name="quality" value="best" />
	<param name="scale" value="noscale" />
	<param name="base" value="http://www.hisschemoller.com/flash/v006_slicer/static/swf/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.hisschemoller.com/flash/v006_slicer/static/swf/slicer.swf"
			name="fm_slicer_149506678"
			width="600"
			height="600">
		<param name="menu" value="false" />
		<param name="quality" value="best" />
		<param name="scale" value="noscale" />
		<param name="base" value="http://www.hisschemoller.com/flash/v006_slicer/static/swf/" />
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>If you recognized the loop but thought it was somehow different: You&#8217;re right! It&#8217;s Mr Oizo&#8217;s &#8220;Bobby Can&#8217;t Dance&#8221; from his album &#8220;Analog Worms Attack&#8221; (1999). But speeded up to 120 BPM. I liked it a bit faster. (The speeding up wasn&#8217;t done with this slicer by the way. No advanced ActionScript 3.0 timestretching algorithm yet I&#8217;m afraid.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/a-basic-slicer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A blog on Flash and audio</title>
		<link>http://www.hisschemoller.com/2009/hello-world/</link>
		<comments>http://www.hisschemoller.com/2009/hello-world/#comments</comments>
		<pubDate>Thu, 07 May 2009 12:23:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.hisschemoller.com/?p=1</guid>
		<description><![CDATA[Oh yes! Finally I have my own blog.
I&#8217;ve had this www.hisschemoller.com domain for years, but didn&#8217;t really have any use for it. I just got it because it was there &#8211; my own name as a dot com. Better get it before someone else does. Especially before one of those companies get it that buy [...]]]></description>
			<content:encoded><![CDATA[<p>Oh yes! Finally I have my own blog.</p>
<p>I&#8217;ve had this www.hisschemoller.com domain for years, but didn&#8217;t really have any use for it. I just got it because it was there &#8211; my own name as a dot com. Better get it before someone else does. Especially before one of those companies get it that buy domain names just to sell them for a profit. &#8220;Get some money out of those Hisschemöllers&#8221; they might think. That&#8217;s not how the internet should work.</p>
<p>Now I have a use: The past months I&#8217;ve been getting more and more into programming audio stuff with Flash. Small experiments with sound, music, samples etcetera. I&#8217;ll post those Flash files here. And the sources as well if I come up with anything good. I learned a lot from other blogs, so now I can do something in return.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hisschemoller.com/2009/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
