<?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>Last Ray of Hope</title>
	<atom:link href="http://www.lastrayofhope.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lastrayofhope.com</link>
	<description>Home of Kaluriel Hargrove</description>
	<lastBuildDate>Wed, 27 Jan 2010 21:56:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Re: Site Theme Update</title>
		<link>http://www.lastrayofhope.com/2010/01/27/re-site-theme-update/</link>
		<comments>http://www.lastrayofhope.com/2010/01/27/re-site-theme-update/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:56:37 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Aeros]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=3061</guid>
		<description><![CDATA[My browser at work seemed to keep the background image, so for now I&#8217;ve removed the image from the website so it won&#8217;t be able to find it.
At the weekend I&#8217;ll see if I can find out whats causing it to appear.
Also at the moment I&#8217;m working on trying out some types of pagination for [...]]]></description>
			<content:encoded><![CDATA[<p>My browser at work seemed to keep the background image, so for now I&#8217;ve removed the image from the website so it won&#8217;t be able to find it.</p>
<p>At the weekend I&#8217;ll see if I can find out whats causing it to appear.</p>
<p>Also at the moment I&#8217;m working on trying out some types of pagination for multi-page posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/27/re-site-theme-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Theme Update</title>
		<link>http://www.lastrayofhope.com/2010/01/26/site-theme-update/</link>
		<comments>http://www.lastrayofhope.com/2010/01/26/site-theme-update/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 22:42:00 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Aeros]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=3049</guid>
		<description><![CDATA[Just updated the site theme to v3.0.0, seems Wordpress doesn&#8217;t notify me when it goes out of date since I was using v1.0.8.
Text seems a lot more crisp in this one.
]]></description>
			<content:encoded><![CDATA[<p>Just updated the site theme to v3.0.0, seems Wordpress doesn&#8217;t notify me when it goes out of date since I was using v1.0.8.</p>
<p>Text seems a lot more crisp in this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/26/site-theme-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dejaBoards</title>
		<link>http://www.lastrayofhope.com/2010/01/24/dejaboards/</link>
		<comments>http://www.lastrayofhope.com/2010/01/24/dejaboards/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 02:41:46 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[dejaBoards]]></category>
		<category><![CDATA[forums]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=3040</guid>
		<description><![CDATA[Today while browsing around the interwebs, I came by an archive of my old website, which was originally a Final Fantasy website.
But in my news posts from around that time, I was talking about a newer version of the battle system I had built into the custom made forums I had created since I couldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/1190379400winrar3ye5ye3-1.jpg"><img class="alignleft size-medium wp-image-3041" title="WinRAR" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/1190379400winrar3ye5ye3-1-288x300.jpg" alt="" width="173" height="180" /></a>Today while browsing around the interwebs, I came by an archive of my old website, which was originally a Final Fantasy website.</p>
<p>But in my news posts from around that time, I was talking about a newer version of the battle system I had built into the custom made forums I had created since I couldn&#8217;t afford vBulletin. I named them dejaBoards, after a friend who had the alias Dejaina Rhea.</p>
<p>I had completely forgot I had wrote them, and the fact they made a lot of other forums hate LastRay since also being Final Fantasy forums, they couldn&#8217;t do it.</p>
<p>Though funny story about that, Final Fantasy Republic actually purchased the ability to look at the sourcecode for them back in the day they were making theirs. I think they also stole the idea of shops from me.</p>
<p>Hopefully at some point get around to re-uploading them to this site and reverse engineer the database I had setup for them. Then maybe even update them use java to get a better graphical version. They certainly need their queries cleaned up though.</p>
<p>Updated my Wordpress blog with the old entries from the archive.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/24/dejaboards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overloaded Virtual Methods</title>
		<link>http://www.lastrayofhope.com/2010/01/09/overloaded-pure-virtual-methods/</link>
		<comments>http://www.lastrayofhope.com/2010/01/09/overloaded-pure-virtual-methods/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 17:51:47 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2912</guid>
		<description><![CDATA[This week I came by a new kind of bug that I&#8217;ve never had before, and is up the top of bugs I&#8217;ve came by when using CodeWarrior, the top still being invisible syntax.
Though I don&#8217;t think anything can top that, it can be hell if you have garbage at the end of a line, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/1222283336417.jpg"><img class="alignleft size-medium wp-image-3036" title="Clever Girl" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/1222283336417-129x300.jpg" alt="" width="129" height="300" /></a>This week I came by a new kind of bug that I&#8217;ve never had before, and is up the top of bugs I&#8217;ve came by when using CodeWarrior, the top still being invisible syntax.</p>
<p>Though I don&#8217;t think anything can top that, it can be hell if you have garbage at the end of a line, and you can&#8217;t see it when even though the compiler tells you something is wrong, luckily to solve that one, you just press a key or change someone on the same line and it makes it visible.</p>
<p>Anyways, this bug is caused by having overloaded pure virtual or virtual methods in a base class, but only implementing some of the them in the derived class.</p>
<p>It causes the compiler to not acknowledge any of the other overloaded functions, which you can end up spending a lot of time trying to solve if you&#8217;re not familiar with it.</p>
<p>The below code shows an example base class for causing this error.</p>
<pre class="brush: cpp;">
class BaseClass
{
    //
    // Functions
    public:
        //
        //
        BaseClass()
        {
        }

        //
        //
        virtual ~BaseClass()
        {
        }

        //
        //
        virtual int Multiply( const int inValue1 )
        {
            return 2 * inValue;
        }

        //
        //
        virtual int Multiply( const int inValue1, const int inValue2 )
        {
            return 2 * inValue1 * inValue2;
        }
};
</pre>
<p>If in the derived class you implement one of these, as shown below, and then try to access one of the other overloaded that are only implemented in the base, the error will happen, telling you something like there are no overloaded versions of that function that take that parameters you are giving.</p>
<pre class="brush: cpp;">
class DerivedClass : public BaseClass
{
    //
    // Functions
    public:
        DerivedClass()
            :
            BaseClass()
        {
        }

        //
        //
        int Multiply( const int inValue1 )
        {
            return 3 * inValue1;
        }
};

//
//
int Main()
{
    DerivedClass testClass;
    return testClass.Multiply( 2, 3 );
}
</pre>
<p>Now I&#8217;m sure I had use overloaded virtual functions before, so why was this happening now. So after a bit of searching I found out that only some compilers have support for this.</p>
<p>The reason the error occurs, is because the compiler generates a list of virtual function names to link to in the class. However, if it fails to find a function matching the name of what is being called, it will check the base.</p>
<p>Because we had overloaded only one of overloaded virtual functions, it ended its search in the derived class. And when it tries to associate the correct function call with the correct function, it notices that the function has a different number of parameters to that which is recorded in the list, and causes an error.</p>
<p>Now there is a way around it, you explicitly tell the compiler to use the functions listed in the base by use of the &#8220;<strong>using</strong>&#8221; keyword.</p>
<pre class="brush: cpp;">
class DerivedClass : public BaseClass
{
    //
    // Functions
    public:
        //
        //
        DerivedClass()
            :
            BaseClass()
        {
        }

        //
        //
        using BaseClass::Multiply;

        //
        //
        int Multiply( const int inValue1 )
        {
            return 3 * inValue1;
        }
};

//
//
int Main()
{
    DerivedClass testClass;
    return testClass.Multiply( 2, 3 );
}
</pre>
<p>This will not error, since when the compiler is generating a list of functions, it will also include the Multiply functions in the base. The using keyword also has scope, so putting it in public will make the functions accessible outside the class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/09/overloaded-pure-virtual-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even More Snow</title>
		<link>http://www.lastrayofhope.com/2010/01/06/even-more-snow/</link>
		<comments>http://www.lastrayofhope.com/2010/01/06/even-more-snow/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 19:00:49 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[snow]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2941</guid>
		<description><![CDATA[A great end to 2009 and start to 2010, SNOW!
To think a short time ago, having a white Christmas was extremely unlikely, nowadays it seems to be every year. Thanks Global Warming :).
It started on the same night as the office Christmas party, and on my way home I literally got covered in snow to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_0063.jpg"><img class="alignleft size-medium wp-image-2944" title="The Blizzard Begins..." src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_0063-225x300.jpg" alt="" width="135" height="180" /></a>A great end to 2009 and start to 2010, SNOW!</p>
<p>To think a short time ago, having a white Christmas was extremely unlikely, nowadays it seems to be every year. Thanks Global Warming :).</p>
<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_00711.jpg"><img class="size-medium wp-image-2946 alignright" title="Snowman" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_00711-225x300.jpg" alt="" width="135" height="180" /></a>It started on the same night as the office Christmas party, and on my way home I literally got covered in snow to the point of becoming a walking snowman.</p>
<p>In January it snowed some more, creating a layer of ice which turned everywhere into what looked like a glacier. Apparently, they run out of grit too, which was unfortunate, because when they finally got some more to put down, it began to snow again.</p>
<p>Lots of great snowmen this year :).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/06/even-more-snow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# &#8211; Endian Swap</title>
		<link>http://www.lastrayofhope.com/2010/01/03/csharp-endian-swap/</link>
		<comments>http://www.lastrayofhope.com/2010/01/03/csharp-endian-swap/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:37:16 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Csharp]]></category>
		<category><![CDATA[Midi]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2883</guid>
		<description><![CDATA[In 1726, there were tensions between Lilliput and Blefuscu, the problem being soft-boiled eggs. The inhabitants of Lilliput crack open their eggs at the small end, while the inhabitants of Blefuscu crack open theirs at the big end.
In 2010, while writing a Midi file parser in C#, I needed the ability to swap the endian [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/gullivers_travels.jpg"><img class="alignleft size-medium wp-image-2894" title="Gulliver's Travels" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/gullivers_travels-184x300.jpg" alt="" width="110" height="180" /></a>In 1726, there were tensions between Lilliput and Blefuscu, the problem being soft-boiled eggs. The inhabitants of Lilliput crack open their eggs at the small end, while the inhabitants of Blefuscu crack open theirs at the big end.</p>
<p>In 2010, while writing a Midi file parser in C#, I needed the ability to swap the endian of the data, since Midi files are stored as Big Endian, converting them into Little Endian.</p>
<p>I would have thought there would be some function within the BitConverter class to be able to swap, but there didn&#8217;t appear to be, so I wrote my own.</p>
<p>Since swapping endian is just reversing the byte order, the simplest method would be to get the bytes of a number, and reverse the array, then reconstruct the number using the reversed bytes.</p>
<pre class="brush: csharp;">
//
//
using System;

//
//
namespace Midi
{
    class Endian
    {
        //
        //
        public static UInt16 SwapUInt16( UInt16 inValue )
        {
            byte[] byteArray = BitConverter.GetBytes(inValue);
            Array.Reverse(byteArray);
            return BitConverter.ToUInt16(byteArray,0);
        }

        //
        //
        public static UInt32 SwapUInt32( UInt32 inValue )
        {
            byte[] byteArray = BitConverter.GetBytes(inValue);
            Array.Reverse(byteArray);
            return BitConverter.ToUInt32(byteArray,0);
        }
    }
}
</pre>
<p>But this method is slower than just using a bitshift.</p>
<pre class="brush: csharp;">
//
//
using System;

//
//
namespace Midi
{
    class Endian
    {
        //
        //
        public static UInt16 SwapUInt16( UInt16 inValue )
        {
            return (UInt16)( ((inValue &amp; 0xff00) &gt;&gt; 8) |
                             ((inValue &amp; 0x00ff) &lt;&lt; 8) );
        }

        //
        //
        public static UInt32 SwapUInt32( UInt32 inValue )
        {
            return (UInt32)( ((inValue &amp; 0xff000000) &gt;&gt; 24) |
                             ((inValue &amp; 0x00ff0000) &gt;&gt; 8) |
                             ((inValue &amp; 0x0000ff00) &lt;&lt; 8) |
                             ((inValue &amp; 0x000000ff) &lt;&lt; 24) );
        }
    }
}
</pre>
<p>Since any the there are only 16 bit and 32 bit numbers in the Midi file format, and anything larger is of Variable Length Quantity, these are the only two required.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2010/01/03/csharp-endian-swap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LEGO</title>
		<link>http://www.lastrayofhope.com/2009/12/27/lego/</link>
		<comments>http://www.lastrayofhope.com/2009/12/27/lego/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 18:45:42 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[LEGO]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2926</guid>
		<description><![CDATA[Whilst home for Christmas, I found my LEGO model that I made years ago, though it was in a broken.
Strangely enough despite being years since I last worked on it, I was able to fix most of it.
Unfortunately, there wasn&#8217;t enough room in my bag to bring it back home with me, but hopefully I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_0069.jpg"><img class="alignleft size-medium wp-image-2929" title="LEGO Ship 3" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_0069-225x300.jpg" alt="" width="135" height="180" /></a>Whilst home for Christmas, I found my LEGO model that I made years ago, though it was in a broken.</p>
<p>Strangely enough despite being years since I last worked on it, I was able to fix most of it.</p>
<p>Unfortunately, there wasn&#8217;t enough room in my bag to bring it back home with me, but hopefully I&#8217;ll be able to bring it back up in a few month.</p>
<p><img class="alignright size-medium wp-image-2930" title="LEGO Ship 4" src="http://www.lastrayofhope.com/wp-content/uploads/2010/01/IMG_0070-300x225.jpg" alt="" width="180" height="135" /></p>
<p>Then I can take it apart and come up with instructions to make it, and maybe buy some new LEGO bricks to replace some of the flats I combined to make a brick when I ran out of pieces.</p>
<p>And the ultimate goal, is to maybe even build it in the LEGO MMO.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2009/12/27/lego/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Midi Delta Time Ticks to Seconds</title>
		<link>http://www.lastrayofhope.com/2009/12/23/midi-delta-time-ticks-to-seconds/</link>
		<comments>http://www.lastrayofhope.com/2009/12/23/midi-delta-time-ticks-to-seconds/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 17:56:12 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Csharp]]></category>
		<category><![CDATA[Midi]]></category>
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2915</guid>
		<description><![CDATA[One of the main problems with parsing midi files, is the amount of bad documentation people has put on their websites for converting delta time ticks into seconds or milliseconds.
Eventually I got ahold of the Midi Standard 1.0 which helped me solve this riddle for when calculating it myself, and will hopefully help others who [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2009/12/3_quarter_time.gif"><img class="alignleft size-full wp-image-2921" title="3 Quarter Time" src="http://www.lastrayofhope.com/wp-content/uploads/2009/12/3_quarter_time.gif" alt="" width="193" height="80" /></a>One of the main problems with parsing midi files, is the amount of bad documentation people has put on their websites for converting delta time ticks into seconds or milliseconds.</p>
<p>Eventually I got ahold of the Midi Standard 1.0 which helped me solve this riddle for when calculating it myself, and will hopefully help others who have this problem.</p>
<p>When calculating delta time, &#8220;Set Tempo&#8221; and &#8220;Time Signature&#8221; meta events need to be handled. Also remember that the raw denominator for &#8220;Time Signature&#8221; meta events needs to be used as the exponent for raising two to a power:</p>
<pre class="brush: cpp;">
const float kTimeSignatureDenominator = powf( 2, rawTimeSignatureDenominator );
</pre>
<p>This first page will cover correctly calculating &#8220;Beats Per Minute&#8221; (BPM) correctly. And although a lot of examples seem to think you require this to convert delta time ticks to seconds or milliseconds, you don&#8217;t.</p>
<h1>What is a Beat?</h1>
<p>In music, there is something called a <strong>Bar</strong>, which is a segment of time defined by a given number of beats of a given duration. The values which define a <strong>Bar</strong>, are called the <strong>Time Signature</strong>.</p>
<p>A <strong>Time Signature</strong>, is two numbers, one on top of the other. The numerator describes the number of <strong>Beats</strong> in a <strong>Bar</strong>, while the denominator describes of what note value a <strong>Beat</strong> is.</p>
<p>So 4/4 would be four <strong>quarter-notes</strong> per <strong>Bar</strong>, while 4/2 would be four <strong>half-notes</strong> per <strong>Bar</strong>, 4/8 would be four <strong>eighth-notes</strong> per <strong>Bar</strong>, and 2/4 would be two <strong>quarter-notes</strong> per <strong>Bar</strong>.</p>
<h1>Calculating BPM</h1>
<p>Now a lot of examples say to default the tempo to 120 BPM, and the time signature to 4/4, which is correct. But when handling the &#8220;Set Tempo&#8221; meta event, the same examples just use the value straight out to calculate the BPM, which is incorrect if the time signature has changed.</p>
<p>The &#8220;Set Tempo&#8221; meta event in midi only deals in quarter notes, so if the time signature is 4/8, a quarter-note is not a Beat since its described as an eighth-note, so using it to calculate BPM  on its own is incorrect.</p>
<pre class="brush: cpp;">
const float kOneMinuteInMicroseconds = 60000000;

// This is wrong if the time signature is not 4/4
float BPM = kOneMinuteInMicroseconds / newMicrosecondsPerQuarterNote;
</pre>
<p>So how do we solve this? We use the new time signature to scale our BPM to the correct value.</p>
<pre class="brush: cpp;">
const float kOneMinuteInMicroseconds = 60000000;
const float kTimeSignatureNumerator = 4.0f; // For show only, use the actual time signature numerator
const float kTimeSignatureDenominator = 4.0f; // For show only, use the actual time signature denominator
// This is correct
float BPM = ( kOneMinuteInMicroseconds / newMicrosecondsPerQuarterNote ) * ( kTimeSignatureDenominator / 4.0f );
</pre>
<p>In the code above, we divide the time signature denominator by four (The number four is the denominator value for quarter note), this gives us the number of notes per quarter note. Four divided by four is one, so the BPM remains the same.</p>
<p>If the value of kTimeSignatureDenominator was &#8220;8.0f&#8221;, then eight divided by four is two (there are two eighth-notes in a quarter note).</p>
<p>The next page will cover the actual conversion of delta time ticks to seconds (or milliseconds).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2009/12/23/midi-delta-time-ticks-to-seconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# &#8211; Midi Variable Length Quantity</title>
		<link>http://www.lastrayofhope.com/2009/12/22/c-midi-variable-length-quantity/</link>
		<comments>http://www.lastrayofhope.com/2009/12/22/c-midi-variable-length-quantity/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 17:31:22 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Csharp]]></category>
		<category><![CDATA[Midi]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2900</guid>
		<description><![CDATA[On the way home on the train for Christmas, I began porting my Midi parsing class over to C#.
The snippet below shows how to read to read a Variable Length Quantity (sometimes known as a Variable Length Value).
The way it works is very simple, it checks the first byte to see if the MSB is [...]]]></description>
			<content:encoded><![CDATA[<p>On the way home on the train for Christmas, I began porting my Midi parsing class over to C#.</p>
<p>The snippet below shows how to read to read a Variable Length Quantity (sometimes known as a Variable Length Value).</p>
<p>The way it works is very simple, it checks the first byte to see if the MSB is set, if it set it will keep iterating, moving along one byte and doing the same, shifting the previous value across 7 bits until the MSB isn&#8217;t set.</p>
<p>If it isn&#8217;t set on the initial test, the value from that byte will be used for the value of the VLQ.</p>
<pre class="brush: csharp;">
//
//
using System;

//
//
namespace Midi
{
    class VariableLengthQuantity
    {
        //
        // Functions
        public VariableLengthQuantity( byte[] inVariableData, int inOffset )
        {
            int offset = inOffset;

            // At least one byte is always used
            m_value = inVariableData[offset];
            m_numBytes = 1;
            ++offset;

            //
            if( ((m_value &amp; 0x80) != 0) )
            {
                UInt32 c;

                //
                m_value &amp;= 0x7F;

                //
                do
                {
                    //
                    c = inVariableData[offset];

                    //
                    m_value = (m_value &lt;&lt; 7) + (c &amp; 0x7F);

                    //
                    ++m_numBytes;
                    ++offset;
                } while( (c &amp; 0x80) != 0 );
            }
        }

        //
        //
        public UInt32 Value
        {
            get
            {
                return m_value;
            }
        }

        //
        //
        public UInt32 NumBytes
        {
            get
            {
                return m_numBytes;
            }
        }

        //
        // Attributes
        UInt32 m_value;
        UInt32 m_numBytes;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2009/12/22/c-midi-variable-length-quantity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New 5.1 Surround Sound</title>
		<link>http://www.lastrayofhope.com/2009/11/27/new-5-1-surround-sound/</link>
		<comments>http://www.lastrayofhope.com/2009/11/27/new-5-1-surround-sound/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 17:47:09 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[logitech]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=2906</guid>
		<description><![CDATA[Having just upgraded my XBox 360 monitor to HD, I was now lacking a descent sound system to back it up with.
When watching films at a friends house, we have 5.1 surround sound, and I&#8217;m often noticing the sounds coming from different directions, which is something I&#8217;m not use to with only having 2.1.
So my [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2009/11/Logitech-z5500.jpg"><img class="alignleft size-medium wp-image-2938" title="Logitech z5500" src="http://www.lastrayofhope.com/wp-content/uploads/2009/11/Logitech-z5500-300x210.jpg" alt="" width="180" height="126" /></a>Having just upgraded my XBox 360 monitor to HD, I was now lacking a descent sound system to back it up with.</p>
<p>When watching films at a friends house, we have 5.1 surround sound, and I&#8217;m often noticing the sounds coming from different directions, which is something I&#8217;m not use to with only having 2.1.</p>
<p>So my requirements for speakers would be first to be 5.1, have a remote control for turning down at night, and to support optical for the better sound quality.</p>
<p>After a bit of searching, and dismissing a lot of speakers that come with DVD players, I came by the Logitech Z-5500 5.1 THX 500W Speakers.</p>
<p>And with luck, they were also available on <a href="http://www.misco.co.uk" target="_blank">Misco</a>, which was surprising since I couldn&#8217;t find a speaker section on the website. Ordering them for Saturday delivery, they didn&#8217;t arrive, so on Monday I was going to book some holiday for Tuesday and Wednesday mornings, but they early and my neighbour signed them for me.</p>
<p>Opening the huge box, I found where most of my money went, the subwoofer. It has a hilarious notice with it, telling me to keep it two feet away from any other electronics, which after rearranging my room I was able to achieve.</p>
<p>The only downside was that I couldn&#8217;t use them til Tuesday, since despite paying £230, they didn&#8217;t give me an optical cable with it. Speaking of which, <a href="http://www.maplin.co.uk" target="_blank">Maplin</a> sells a gold plated optical cable&#8230; how does that even make sense?</p>
<p>Playing Borderlands later that night was a lot easier to know where enemies were shooting me from.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2009/11/27/new-5-1-surround-sound/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
