<?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>Baron Knoxburry &#187; tutorial</title>
	<atom:link href="http://b-knox.com/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://b-knox.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 03 May 2012 04:41:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>April Fools&#8217; Pranks with Javascript and jQuery</title>
		<link>http://b-knox.com/127/april-fools-pranks-with-javascript-and-jquery/</link>
		<comments>http://b-knox.com/127/april-fools-pranks-with-javascript-and-jquery/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 20:06:13 +0000</pubDate>
		<dc:creator>b-knox</dc:creator>
				<category><![CDATA[Web Tutorial]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prank]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://b-knox.com/?p=127</guid>
		<description><![CDATA[Tomorrow is April Fools&#8217; Day and I thought, &#8220;This year, Imma gonna do-a sumptin!&#8221;  Who am I going to prank?  Battle of the Bits of course!  I don&#8217;t think those noobs even know I have this blog.  :/ So&#8230; to get started&#8230;  we need to detect that it is indeed April 1st, the day of [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow is April Fools&#8217; Day and I thought, &#8220;This year, Imma gonna do-a sumptin!&#8221;  Who am I going to prank? <a href="http://battleofthebits.org"> Battle of the Bits</a> of course!  I don&#8217;t think those noobs even know I have this blog.  :/</p>
<p>So&#8230; to get started&#8230;  we need to detect that it is indeed April 1st, the day of April Fools&#8217;.  This can be done with some simple javascript —</p>
<p><code>var today = new Date();<br />
if (today.getMonth()+'.'+today.getDate()=='3.1')  {<br />
/*  put your pranks in HERE!!  :D  */<br />
}<br />
</code></p>
<p>At first glance this looks screwy.  We create a Date() object and get today&#8217;s month and day.  But April 1st != 3.1 &#8211; it should equal 4.1 right?  Silly javascript!  Month values are stored [0..11] instead of one through twelve.  I thought maybe the day would be messed up too as it is stored [0..31] but it works correctly.  I tested this code by setting my operating systems clock ahead to 4/1.  The neat thing about using javascript for the date check is that it uses the visitors&#8217; system clock rather than the servers.</p>
<h3>Let&#8217;s add a prank : Sound</h3>
<p>And for my first prank I will add a sound to every link click.  This sound happens to be my own voice exclaiming *KLINK*.  Here I add some jQuery, using the .live() method on all anchor tags.</p>
<p><code>$(document).ready(function(){<br />
  $('a').live('click',<br />
    function(event) {<br />
      event.preventDefault();<br />
      $('#footer').before('<embed src="/klink.wav" hidden="true" autostart="true"/>');<br />
      if (!$(this).hasClass('updateAjaxContent')&amp;&amp;!$(this).hasClass('speakerPopout'))<br />
      window.setTimeout('window.location="'+$(this).attr('href')+'"',500);<br />
    }<br />
  );<br />
});</code></p>
<p>This code is placed inside the date check so it will only run on April Foools&#8217; Day.  First, we prevent the default event from the click.  Then we insert a hidden &lt;embed&gt; tag that autoplays our sound.  The visitor&#8217;s browser should know what to do, automajikally throwing a Windows Media or Quicktime player into the page depending on browser settings.  If you don&#8217;t have a #footer, make sure to change that to a place that exists on your page.  Finally, I run a check on the link&#8217;s classes to make sure they don&#8217;t already have javascript functionality.  If they do, the sound just plays.  If they don&#8217;t, we give the browser a half second to play the sound and then move on to the next page.</p>
<h3>Another prank : Color</h3>
<p>Want to really confuse your visitors?  Let&#8217;s shift the colors of your layout randomly!  Once again I use some jQuery, embed the following code inside the $(document).ready() which is inside the date check.</p>
<p><code>function dec2hex(a) {<br />
      a = parseInt(a).toString(16);<br />
      return a.length&lt;2?"0"+a:a;<br />
    }<br />
<br />
    var swatch, r, g, b, color;<br />
<br />
    randomColor();<br />
<br />
    function randomColor()  {<br />
      swatch = Math.floor(Math.random()*5);<br />
      r = dec2hex(Math.floor(Math.random()*256));<br />
      g = dec2hex(Math.floor(Math.random()*256));<br />
      b = dec2hex(Math.floor(Math.random()*256));<br />
      color = '#'+r+g+b;<br />
      switch (swatch) {<br />
        case 0:<br />
          $('boxLink:hover').css('background-color',color);<br />
          $('body').animate({color:color},2500,function(){randomColor()});<br />
          break;<br />
        case 1:<br />
          $('.boxLink').css('color',color);<br />
          $('a').animate({color:color},12500,function(){randomColor()});<br />
          break;<br />
        case 2:<br />
          $('.logo1').animate({color:color},3500,function(){randomColor()});<br />
          break;<br />
        case 3:<br />
          $('.logo0').animate({color:color},1500,function(){randomColor()});<br />
          break;<br />
        case 4:<br />
          $('html').css('background-color',color);<br />
          $('body').css('background-color',color);<br />
          $('boxLink:hover').animate({color:color},4500,function(){randomColor()});<br />
          break;<br />
      }<br />
    }</code></p>
<p>I removed over half of the elements I am affecting with the randomly generated colors to make this easier to understand.  The variable &#8216;swatch&#8217; is used to identify which color is being affected in the layout.  dec2hex() helps convert the random values to a hex color value.  I&#8217;m using the callback feature of the .animate() function to keep the colors fluxing (though I don&#8217;t see any color fading to another color {a bug?!?!}).  If you call randomColor() directly from inside itself the browser will hang or you&#8217;ll get a recursive script error.</p>
<h3><a href="http://b-knox.com/tut_demos/BotB_AprilFools/Battle%20of%20the%20Bits.htm">View Demo Here</a></h3>
<h3><a href="http://b-knox.com/tut_demos/BotB_AprilFools/BotB_AprilFools.zip">Get Source Here</a></h3>
<p>Tested in Firefox and Chrome.  I saved a BotB render page to share the effects.  I only replaced the links in the main menu and disabled the April Fools check in jqueryAprilFools.js so you can see the prank in actions always!</p>
<p>I hope somebody learns something.  :D</p>
]]></content:encoded>
			<wfw:commentRss>http://b-knox.com/127/april-fools-pranks-with-javascript-and-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LSDJ Kick Drum on Pulse, Wave and/or Noise Channels</title>
		<link>http://b-knox.com/43/lsdj-kick-drum-on-pulse-wave-andor-noise-channels/</link>
		<comments>http://b-knox.com/43/lsdj-kick-drum-on-pulse-wave-andor-noise-channels/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 01:34:03 +0000</pubDate>
		<dc:creator>b-knox</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[gameboy]]></category>
		<category><![CDATA[kick drum]]></category>
		<category><![CDATA[lsdj]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://b-knox.com/?p=43</guid>
		<description><![CDATA[The LSDJ manual comes with an example for the pulse wave kick drum. My variation is on the right. I often use F1 on the volume envelope for a quick kick but if I want a long boom I use F3 to F6.  I keep the sweep envelope the same (and remember this sweep effect [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-pulse-kick1.png"><img class="alignright size-full wp-image-62" title="lsdj-pulse-kick" src="http://b-knox.com/wp-content/uploads/2010/03/lsdj-pulse-kick1.png" alt="" width="170" height="213" /></a>The LSDJ manual comes with an example for the pulse wave kick drum. My variation is on the right. I often use F1 on the volume envelope for a quick kick but if I want a long boom I use F3 to F6.  I keep the sweep envelope the same (and remember this sweep effect only works on the PU1 channel).  C-5 seems to be a happy trigger for the kick&#8217;s sweep.</p>
<p>But reserving a pulse channel for the kick can be restrictive to your harmonies.  Sure, you can fit notes between the kicks but sometimes that just won&#8217;t do. Let&#8217;s explore some more!</p>
<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-wave-synth-kick-groove.png"><img class="alignright size-full wp-image-59" title="lsdj-wave-synth-kick-groove" src="http://b-knox.com/wp-content/uploads/2010/03/lsdj-wave-synth-kick-groove.png" alt="" width="170" height="220" /></a>The wave channel features built-in sample banks known as &#8216;kits&#8217;.  You can use two kits simultaneously and they come out software mixed. For the most part, the samples have shite quality and I prefer to use this channel for a growly synth bass. For kicks, try doubling the 808 kick and the 909 or Linndrum kicks. Having the bass line play in between the kicks can make for funky syncopations!</p>
<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kit-n-synth-groove.mp3">Download audio file (lsdj-kit-n-synth-groove.mp3)</a><br /><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kit-n-synth-groove.mp3">lsdj kit n synth groove.mp3</a></p>
<p>Googling the net, I stumbled upon an <a href="http://8bitcollective.com/forums/viewtopic.php?id=177">old 8bc thread</a> where <a href="http://battleofthebits.org/barracks/Profile/Ikuma/">Ikuma</a> explained his method for synthesizing a kick drum (pictured below). Personally, I had a hard time getting it loud enough and keeping it bassy. If you want to use this method you should compensate the volume in the rest of your instruments.  I tried triggering this with all the octaves and C-8 seemed to have the most punch.</p>
<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-wave-kick.png"><img class="alignnone size-full wp-image-44" title="lsdj-wave-kick" src="http://b-knox.com/wp-content/uploads/2010/03/lsdj-wave-kick.png" alt="" width="600" height="200" /></a></p>
<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-noise-kick.png"><img class="alignright size-full wp-image-55" title="lsdj-noise-kick" src="http://b-knox.com/wp-content/uploads/2010/03/lsdj-noise-kick.png" alt="" width="170" height="376" /></a>Last, but not least, the noise channel.  I played around a lot with this but I&#8217;m thinking there might be a better way (either that or the NES&#8217;s 2A03 is superior in my ears).  C-3 seems to be the best pitch but, again, the kick sounds rather flat, kind of quiet and lacking punch.  If you try out C-5 with this same instrument LSDJ plays back a textured snare-like sound which, incidentally, is a bit louder.  So I tried layering the noise and wave kicks and it seemed to work for volume compensation. With this particular &#8216;combination method&#8217; we have freed up our two pulse channels but used up the two remaining.</p>
<p><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kick-samples.mp3">Download audio file (lsdj-kick-samples.mp3)</a><br /><a href="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kick-samples.mp3">lsdj kick samples.mp3</a></p>
<p>Pulse bent bass drum kick wins out in my book but that won&#8217;t keep me from trying new things!</p>
]]></content:encoded>
			<wfw:commentRss>http://b-knox.com/43/lsdj-kick-drum-on-pulse-wave-andor-noise-channels/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kit-n-synth-groove.mp3" length="335512" type="audio/mpeg" />
<enclosure url="http://b-knox.com/wp-content/uploads/2010/03/lsdj-kick-samples.mp3" length="608392" type="audio/mpeg" />
		</item>
	</channel>
</rss>

