<?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"
	>

<channel>
	<title>benbritten.com</title>
	<atom:link href="http://benbritten.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://benbritten.com/blog</link>
	<description>Blog</description>
	<pubDate>Thu, 06 Nov 2008 02:25:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>openAL sound on the iPhone</title>
		<link>http://benbritten.com/blog/2008/11/06/openal-sound-on-the-iphone/</link>
		<comments>http://benbritten.com/blog/2008/11/06/openal-sound-on-the-iphone/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 02:25:05 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=216</guid>
		<description><![CDATA[Hey all,
Now that the NDA is lifted, and we can start talking about the iPhone code out in the open, i thought it might be nice to talk about some of the problems I have encountered in my forays into the iPhone world and how I went about fixing them.
Currently I am working on an [...]]]></description>
			<content:encoded><![CDATA[<p>Hey all,</p>
<p>Now that the NDA is lifted, and we can start talking about the iPhone code out in the open, i thought it might be nice to talk about some of the problems I have encountered in my forays into the iPhone world and how I went about fixing them.</p>
<p>Currently I am working on an iPhone game.  It is all openGLES based and uses openAL for sound. I think I am gonna talk about openAL today.</p>
<p>For now I am only going to be talking about sounds that are less than 30 seconds, so sound effects and short loops. Before you can think about playing sounds on the iPhone they need to be in the right format (or they should be in the right format, many of the audio toolbox methods will handle multiple formats, but if you put the sound in the right format to start, then the iPhone wont have to do it at play time). </p>
<p>So, pop open terminal and type this:</p>
<pre lang="bash">
/usr/bin/afconvert -f caff -d LEI16@44100 inputSoundFile.aiff outputSoundFile.caf
</pre>
<p>what the hell does that do? you ask.  it puts the file into a nice Little-Endian 16-bit 44,100 sample rate format.  (generally saved with a .caf extension)</p>
<p>OK! now we have a nice .caf file in the proper format, we are ready to do something.</p>
<p>There are lots of ways to play sound on the iPhone, there is the &#8216;easy&#8217; way, and then there are a few &#8216;hard ways&#8217;.. I am gonna touch on the easy way quickly and then move onto the openAL &#8216;hard way&#8217;.</p>
<p>the quickest (and easiest) way to make the iPhone spit out some sound is to use the audio system services:</p>
<pre lang="objc">
NSString* path = [[NSBundle mainBundle] pathForResource:@&#8221;soundEffect1&#8243; ofType:@&#8221;caf&#8221;];
NSURL * afUrl = [NSURL fileURLWithPath:path];
UInt32 soundID;
AudioServicesCreateSystemSoundID((CFURLRef)afUrl,&#038;soundID);
AudioServicesPlaySystemSound (soundID);
</pre>
<p>this works well for making your interface buttons click and simple UI interaction stuff. However, it is absolutely shite for anything more complicated than that (think: a game).  It doest always play right away, and if you are trying to match up specific frame of your game with specific sound effects, then this method is basically useless.  (I actually implemented my whole sound engine using the above style of code, then i got onto the phone and every time a sound played, it was either late by many frames or the whole thing would pause and wait for the audio toolbox to load the sound into the buffer, it sucked. </p>
<p>For better control of the sound, you will require either openAL or audioUnits or the audioQueue.</p>
<p>I decided to go with openAL so that my sound code could be kinda sorta portable, and by learning how to use openAL I would be able to use those skills on some other platform besides the iPhone.  (and since I am a code-mercenary, i figured that having openAL experience was more marketable than audioQueue experience) (that and I already have familiarity with openGL, and openAL is very similar, and the audio units and audio queue code is kinda ugly)</p>
<p>So, this will be a super quick tutorial on openAL and the absolute bare minimum you need to do to accomplish static sound generated from openAL.</p>
<p>OpenAL is really quite straight forward. there are 3 main entities: the Listener, the Source, and the Buffer.</p>
<p>The Listener is you. Any sound the listener can &#8216;hear&#8217; comes out the speakers. openAL allows you to specify where the listener is in relation to the sources, but for this example we dont care, we are going to bare minimum static sound, so just keep in mind that there is a concept of &#8216;listener&#8217; and that you could move this object around if you wanted to do more complicated stuff, but I wont go into it in this post.</p>
<p>The Source: basically this is analogous to a speaker.  it generates sound which the listener can &#8216;hear&#8217;.  like the listener, you can move the sources around and get groovy positional effects.  However, for this example we wont be doing that.</p>
<p>The buffer: basically this is the sound that will be played.  the buffer holds the raw audio data.  </p>
<p>there are two other very important objects: the device and the context.<br />
the device is the actual bit of hardware that will be playing the sound, and the context is the current &#8217;session&#8217; that all these sounds are going to be played in (you can think of it as the room that all the sources and the listener is in. Or it is the air that the sound is played through, or whatever.. it is the context.)</p>
<p>How does this all work: (this is the bare minimum)</p>
<p>1) get the device<br />
2) make a context with the device<br />
3) put some data into a buffer<br />
4) attach the buffer to a source<br />
5) play the source</p>
<p>that is it!  The above presumes that your implementation of openAL has decent defaults for the listener and if you dont specify any listener or source positions then this will all work dandy. (it works just dandy on the iPhone in any case)</p>
<p>so, lets look at some code:</p>
<pre lang="objc">
// define these somewhere, like in your .h file
ALCcontext* mContext;
ALCdevice* mDevice;

// start up openAL
-(void)initOpenAL
{
	// Initialization
	mDevice = alcOpenDevice(NULL); // select the "preferred device"
	if (mDevice) {
		// use the device to make a context
		mContext=alcCreateContext(mDevice,NULL);
		// set my context to the currently active one
		alcMakeContextCurrent(mContext);
	}
}
</pre>
<p>Pretty straight forward really.  get the &#8216;default&#8217; device. then use it to build a context! done.</p>
<p>Next: put data into a buffer, this is a bit more complicated:</p>
<p>First: you need to open the file in a nice audio-friendly way</p>
<pre lang="objc">
// get the full path of the file
NSString* fileName = [[NSBundle mainBundle] pathForResource:@&#8221;neatoEffect&#8221; ofType:@&#8221;caf&#8221;];
// first, open the file
AudioFileID fileID = [self openAudioFile:fileName];
</pre>
<p>wait! what is that: openAudioFile: method?<br />
here it is:</p>
<pre lang="objc">
// open the audio file
// returns a big audio ID struct
-(AudioFileID)openAudioFile:(NSString*)filePath
{
	AudioFileID outAFID;
	// use the NSURl instead of a cfurlref cuz it is easier
	NSURL * afUrl = [NSURL fileURLWithPath:filePath];

	// do some platform specific stuff..
#if TARGET_OS_IPHONE
	OSStatus result = AudioFileOpenURL((CFURLRef)afUrl, kAudioFileReadPermission, 0, &#038;outAFID);
#else
	OSStatus result = AudioFileOpenURL((CFURLRef)afUrl, fsRdPerm, 0, &#038;outAFID);
#endif
	if (result != 0) NSLog(@&#8221;cannot openf file: %@&#8221;,filePath);
	return outAFID;
}
</pre>
<p>this is pretty simple: we get the file path from the main bundle, then send it off to this handy method which checks the platform and uses the audio toolkit method: AudioFileOpenURL() to generate an AudioFileID.</p>
<p>What&#8217;s next? Oh yes: get the actual audio data out of the file. To do this we need to figure out how much data is in the file:</p>
<pre lang="objc">
// find out how big the actual audio data is
UInt32 fileSize = [self audioFileSize:fileID];
</pre>
<p>another handy method is needed:</p>
<pre lang="objc">
// find the audio portion of the file
// return the size in bytes
-(UInt32)audioFileSize:(AudioFileID)fileDescriptor
{
	UInt64 outDataSize = 0;
	UInt32 thePropSize = sizeof(UInt64);
	OSStatus result = AudioFileGetProperty(fileDescriptor, kAudioFilePropertyAudioDataByteCount, &#038;thePropSize, &#038;outDataSize);
	if(result != 0) NSLog(@"cannot find file size");
	return (UInt32)outDataSize;
}
</pre>
<p>This uses the esoteric method: AudioFileGetProperty() to figure out how much sound data there is in the file and jams it into the outDataSize variable.  groovy, next!</p>
<p>Now we are ready to copy the data from the file into an openAL buffer:</p>
<pre lang="objc">

// this is where the audio data will live for the moment
unsigned char * outData = malloc(fileSize);

// this where we actually get the bytes from the file and put them
// into the data buffer
OSStatus result = noErr;
result = AudioFileReadBytes(fileID, false, 0, &#038;fileSize, outData);

if (result != 0) NSLog(@"cannot load effect: %@",fileName);

NSUInteger bufferID;
// grab a buffer ID from openAL
alGenBuffers(1, &#038;bufferID);

// jam the audio data into the new buffer
alBufferData(bufferID,AL_FORMAT_STEREO16,outData,fileSize,44100); 

// save the buffer so I can release it later
[bufferStorageArray addObject:[NSNumber numberWithUnsignedInteger:bufferID]];
</pre>
<p>OK, lots went on here (well, not really).  made some room for the data, used the AudioFileReadBytes() function from the audio toolkit to read the bytes from the file into the awaiting block of memory.  The next bit is slightly more interesting.  We call alGenBuffers() to make us a valid bufferID, then we call alBufferData() to load the awaiting data blob into the openAL buffer.</p>
<p>Here I have just hardcoded the format and the frequency.  If you use the afconvert command at the top of the post to generate your audio files, then you will know what their format and sample rate are.  However, if you want to be able to do any kind of audio format or frequency, then you will need to build some methods similar to audioFileSize: but using kAudioFilePropertyDataFormat to get the format, then convert it to the proper AL_FORMAT, and something even more byzantine to figure out the frequency.  I am lazy so i just make sure my files are formatted properly.</p>
<p>Next I put the number into a nice NSArray for later reference.  you can do with that ID whatever you want.</p>
<p>OK, now we have a buffer! neato. Time to hook it to the source.</p>
<pre lang="objc">
NSUInteger sourceID;

// grab a source ID from openAL
alGenSources(1, &#038;sourceID); 

// attach the buffer to the source
alSourcei(sourceID, AL_BUFFER, bufferID);
// set some basic source prefs
alSourcef(sourceID, AL_PITCH, 1.0f);
alSourcef(sourceID, AL_GAIN, 1.0f);
if (loops) alSourcei(sourceID, AL_LOOPING, AL_TRUE);

// store this for future use
[soundDictionary setObject:[NSNumber numberWithUnsignedInt:sourceID] forKey:@&#8221;neatoSound&#8221;];	

// clean up the buffer
if (outData)
{
	free(outData);
	outData = NULL;
}
</pre>
<p>Much like the buffer, we need to get a valid sourceID from openAL.  Once we have that we can connect the source and the buffer.  finally we will throw in a few basic buffer settings just to make sure it is all set up right.  If we want it to loop, then we need to set the AL_LOOPING to true, if not, the default is not to loop, so ignore it.  Then I store the ID into a nice dictionary do I can call it out by name.</p>
<p>lastly, clean up our temporary memory.</p>
<p>So close now! everything is all ready to go, now we just need to play the damn thing:</p>
<pre lang="objc">
// the main method: grab the sound ID from the library
// and start the source playing
- (void)playSound:(NSString*)soundKey
{
	NSNumber * numVal = [soundDictionary objectForKey:soundKey];
	if (numVal == nil) return;
	NSUInteger sourceID = [numVal unsignedIntValue];
	alSourcePlay(sourceID);
}
</pre>
<p>that&#8217;s it.  alSourcePlay().. easy.  If the sound doesnt loop, it will stop of it&#8217;s own accord when it is all done.  If it is looping, or you want to stop it early:</p>
<pre lang="objc">
- (void)stopSound:(NSString*)soundKey
{
	NSNumber * numVal = [soundDictionary objectForKey:soundKey];
	if (numVal == nil) return;
	NSUInteger sourceID = [numVal unsignedIntValue];
	alSourceStop(sourceID);
}
</pre>
<p>That is basically the quickest and simplest way to get sound out of the iPhone using openAL.  (that I can figure out anyway). </p>
<p>Lastly, when you are done with everything, be nice and clean up:</p>
<pre lang="objc">
-(void)cleanUpOpenAL:(id)sender
{
	// delete the sources
	for (NSNumber * sourceNumber in [soundDictionary allValues]) {
		NSUInteger sourceID = [sourceNumber unsignedIntegerValue];
		alDeleteSources(1, &#038;sourceID);
	}
	[soundDictionary removeAllObjects];

	// delete the buffers
	for (NSNumber * bufferNumber in bufferStorageArray) {
		NSUInteger bufferID = [bufferNumber unsignedIntegerValue];
		alDeleteBuffers(1, &#038;bufferID);
	}
	[bufferStorageArray removeAllObjects];

	// destroy the context
	alcDestroyContext(mContext);
	// close the device
	alcCloseDevice(mDevice);
}
</pre>
<p>One note: in a real implementation you will probably have more than one source (I have a source for each buffer, but I only have about 8 sounds, so this is not a problem). There is an upper limit on the number of sources you can have.  I dont know the actual number on the iphone, but it is probably something like 16 or 32.  The way to deal with this is to load all your buffers, then dynamically assign those buffers the the next available source that isnt already playing something else. </p>
<p>Groovy, hopefully this will be helpful to someone.  I had a bit of a hard time finding a good basic sample to get myself started so I made this one by going through the <a href="http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf">openAL programmers guide</a> and just doing the very minimum.  </p>
<p>Cheers!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/11/06/openal-sound-on-the-iphone/feed/</wfw:commentRss>
		</item>
		<item>
		<title>bugs bugs bugs</title>
		<link>http://benbritten.com/blog/2008/10/09/bugs-bugs-bugs/</link>
		<comments>http://benbritten.com/blog/2008/10/09/bugs-bugs-bugs/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 07:36:52 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=215</guid>
		<description><![CDATA[many thanks to ScreamingDrills for finding a nasty little bug:  Turns out when you are in the filter config window, you used to be able to put in all sorts of numbers that would break things.  I added some nice constraints, but did a poor job of it :-)  as of r157 [...]]]></description>
			<content:encoded><![CDATA[<p>many thanks to ScreamingDrills for finding a nasty little bug:  Turns out when you are in the filter config window, you used to be able to put in all sorts of numbers that would break things.  I added some nice constraints, but did a poor job of it :-)  as of r157 you could still squeeze in a few bad numbers (ie 1 for any of the kernel sizes) so I went and fixed all that up.  SO!</p>
<p>update your stuff to r158. (there is a new binary on the opentouch code site)</p>
<p>NOTE: Don&#8217;t forget that BBTouch requires openCV.framework now. so be sure to grab that as well and stick it into your ~/Library/Frameworks folder.  (you may have to make this folder)..  It is actually a private framework, and I have been playing around with trying to get it to be part of the BBTouch codebase, but googlecode is not playing nice with it (it claims to be locked, which is possible since I got it from someone else who had compiled it.  So anyway, i haven&#8217;t had the time to go in and see why SVN thinks it is locked and so it is still not technically part of BBTouch, so you have to install it manually, my apologies)</p>
<p>But! if you do not install it, then BBTouch will brash on load.  so if you re having crash on load issues, start with openCV.  (BTW I uploaded the version that I am testing against to the opentouch downloads page, so you can get it there. (the link to the right that says &#8220;Fairly recent binaries&#8221;).</p>
<p>Anyhow, I am in the process of trying to find the time to get around to thinking about updating the documentation to include the above warning about openCV as well as all the new filtery stuff. But I havent had the chance, so tell your friends. </p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/09/bugs-bugs-bugs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More videos of BBTouch and xPrexxo</title>
		<link>http://benbritten.com/blog/2008/10/09/more-videos-of-bbtouch-and-xprexxo/</link>
		<comments>http://benbritten.com/blog/2008/10/09/more-videos-of-bbtouch-and-xprexxo/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 05:08:32 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=214</guid>
		<description><![CDATA[This is a quick video (slightly better quality than the last one, altho i do manage to get in the way of the camera a few times :-) of one of the apps that i wrote for Sandor at Corporate Design Cologne.  It is a combination of multi-touch coverflow (sometimes with actual covers :-) [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick video (slightly better quality than the last one, altho i do manage to get in the way of the camera a few times :-) of one of the apps that i wrote for Sandor at <a href="http://www.cd-cologne.de">Corporate Design Cologne</a>.  It is a combination of multi-touch coverflow (sometimes with actual covers :-)  and the light box app (which I have decided is basically like the hello-world of multi-touch apps, everyone needs to write one at least once :-)</p>
<p>Anyhow this is all running on my prototype table which is a diffused illumination setup, the tracker is BBTouch and it is all using TUIO to communicate.  The tech is all core animation using CALayers.  there is lots of mipmapping going on to keep the performance up even when there are tons of images, and it works quite nicely even on my macbook pro.  BBtouch never tops 50% processor and xPrexxo is similar.  </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/PSgZeBjk2ho&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/PSgZeBjk2ho&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/09/more-videos-of-bbtouch-and-xprexxo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BBOSC in the wild</title>
		<link>http://benbritten.com/blog/2008/10/09/bbosc-in-the-wild/</link>
		<comments>http://benbritten.com/blog/2008/10/09/bbosc-in-the-wild/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 00:54:33 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=213</guid>
		<description><![CDATA[I just wanted to take a minute to pimp a cool project that I just found out about:
Some of you may be aware of the monome project: http://monome.org/ I think these guys have a great deal in common with the Multi-touch community :-) 
Anyhow, there is a cool iphone port of the monome stuff called [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to take a minute to pimp a cool project that I just found out about:</p>
<p>Some of you may be aware of the monome project: <a href="http://monome.org/">http://monome.org/</a> I think these guys have a great deal in common with the Multi-touch community :-) </p>
<p>Anyhow, there is a cool iphone port of the monome stuff called Haplome: <a href="http://toddtreece.com/haplome/">http://toddtreece.com/haplome/</a> it allows you to pretend you have a monome button array on your iPhone.  fun stuff.</p>
<p>Anyhow, the reason this is topical to my lame site is that he is using BBOSC to help talk to the other OSC apps thet can play nice with the monome stuff.  So there you go!</p>
<p>Thanks Todd for a cool project!</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/09/bbosc-in-the-wild/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BBTUIOTest is now part of a google code repo</title>
		<link>http://benbritten.com/blog/2008/10/07/bbtuiotest-is-now-part-of-a-google-code-repo/</link>
		<comments>http://benbritten.com/blog/2008/10/07/bbtuiotest-is-now-part-of-a-google-code-repo/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 07:12:13 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=212</guid>
		<description><![CDATA[I just re-assembled BBTUIOTest app (the latest and greatest, now referred to as rev 2).  I just created a google code repo for the various TUIO based cocoa apps that I am planning on generating in the days to come.
Here it is:
http://code.google.com/p/bbtuio/
the most recent BBTUIOTest is there as I mentioned, and a binary of [...]]]></description>
			<content:encoded><![CDATA[<p>I just re-assembled BBTUIOTest app (the latest and greatest, now referred to as rev 2).  I just created a google code repo for the various TUIO based cocoa apps that I am planning on generating in the days to come.</p>
<p>Here it is:<br />
<a href="http://code.google.com/p/bbtuio/">http://code.google.com/p/bbtuio/</a></p>
<p>the most recent BBTUIOTest is there as I mentioned, and a binary of the same is also on the downloads page.</p>
<p><a href='http://benbritten.com/blog/wp-content/uploads/2008/10/picture-1.png'><img src="http://benbritten.com/blog/wp-content/uploads/2008/10/picture-1-281x300.png" alt="" title="picture-1" width="281" height="300" class="alignnone size-medium wp-image-211" /></a></p>
<p>It is pretty straightforward to use, just load it up, set the port and hit &#8217;start listening&#8217;.  If you want to run it full screen, then just pick a screen and hit &#8216;go fullscreen&#8217;. to get out of fullscreen either hit &#8217;stop fullscreen&#8217; (if you can see the original window) or make sure the fullscreen window is in front ( by clicking it with the mouse ) and hit &#8216;ESC&#8217;.  Quitting the app will also get you out of fullscreen.  </p>
<p>the &#8216;fake mouse events&#8217; tries to use the first recognized TUIO cursor as a mouse.  If it &#8216;locks up&#8217; while faking mouse events then it probably fakes a mouse down and then never faked a mouse-up.  if you simply wait long enough this should resolve itself, but if you are in a hurry; command - option -esc will open the force-quit dialog.  The act of opening this dialog will break you out of any mouse events that the TUIOTest got you into. (you dont actually need to force-quit anything)</p>
<p>Groovy!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/07/bbtuiotest-is-now-part-of-a-google-code-repo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BBTouch r157 now with a bit less suck</title>
		<link>http://benbritten.com/blog/2008/10/07/bbtouch-r157-now-with-a-bit-less-suck/</link>
		<comments>http://benbritten.com/blog/2008/10/07/bbtouch-r157-now-with-a-bit-less-suck/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 07:02:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=209</guid>
		<description><![CDATA[Hey All,
I just commited a few more files, bringing BBTouch up to r157.  I had been running 152 all week with no trouble, but Sandor managed to find a handful of bugs (of course, right when he is trying to use it at a show :-) so I made some changes and hopefully it [...]]]></description>
			<content:encoded><![CDATA[<p>Hey All,</p>
<p>I just commited a few more files, bringing BBTouch up to r157.  I had been running 152 all week with no trouble, but Sandor managed to find a handful of bugs (of course, right when he is trying to use it at a show :-) so I made some changes and hopefully it is a bit better.</p>
<p>The biggest changes between 152 and 157 are that I fixed some very minor UI issues where the TUIO settings fields were not being properly disabled so you could change them out from under the OSC objects (causing some odd behavior). But the big one was that in some circumstances BBTouch would boot up and the filter settings (and the dark blobs pref) would be basically disconnected from the detector objects.  no matter how much you changed them they didnt really affect anything.  In any case, with 157 that is all fixed. </p>
<p>That is all for now :-)</p>
<p>I should be posting the newest BBTUIOTest.app soon, once I get it all back together.</p>
<p>cheers!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/07/bbtouch-r157-now-with-a-bit-less-suck/feed/</wfw:commentRss>
		</item>
		<item>
		<title>i am teh coding Newbz0rz!</title>
		<link>http://benbritten.com/blog/2008/10/01/i-am-teh-coding-newbz0rz/</link>
		<comments>http://benbritten.com/blog/2008/10/01/i-am-teh-coding-newbz0rz/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 23:37:33 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=207</guid>
		<description><![CDATA[OK, so i am dumb. changed all the cool config stuff and broke the TUIO on/off button (rendering it useless). I tested everything else last night but that d’oh!
Anyhow, r152 is up now with working TUIO again. (like, 3 lines had to change, i suck!)
here is the new binary:
bbtouchr152app
]]></description>
			<content:encoded><![CDATA[<p>OK, so i am dumb. changed all the cool config stuff and broke the TUIO on/off button (rendering it useless). I tested everything else last night but that d’oh!</p>
<p>Anyhow, r152 is up now with working TUIO again. (like, 3 lines had to change, i suck!)</p>
<p>here is the new binary:<br />
<a href='http://benbritten.com/blog/wp-content/uploads/2008/10/bbtouchr152app.zip'>bbtouchr152app</a></p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/10/01/i-am-teh-coding-newbz0rz/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BBTouch Code Updated to r151</title>
		<link>http://benbritten.com/blog/2008/09/30/bbtouch-code-updated-to-r151/</link>
		<comments>http://benbritten.com/blog/2008/09/30/bbtouch-code-updated-to-r151/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 08:54:59 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=196</guid>
		<description><![CDATA[Hey all!
I just checked in a big chunk of new code and a new interface for BBTouch.  (now up to r151)
I moved some of the interface stuff around, I put the TUIO stuff and the Screen Selector into sheets to unclutter the main interface a bit.  I also added a button to open [...]]]></description>
			<content:encoded><![CDATA[<p>Hey all!</p>
<p>I just checked in a big chunk of new code and a new interface for BBTouch.  (now up to r151)</p>
<p>I moved some of the interface stuff around, I put the TUIO stuff and the Screen Selector into sheets to unclutter the main interface a bit.  I also added a button to open the filter config window. as well as the new config library :-) more on that in a sec.  </p>
<p><a href='http://benbritten.com/blog/wp-content/uploads/2008/09/picture-42.png'><img src="http://benbritten.com/blog/wp-content/uploads/2008/09/picture-42.png" alt="" title="picture-42" width="166" height="193" class="alignnone size-full wp-image-198" /></a></p>
<p>I added a whole new configuration control system.  Now you can save and load configurations on the fly very easily through the config library.</p>
<p><a href='http://benbritten.com/blog/wp-content/uploads/2008/09/picture-43.png'><img src="http://benbritten.com/blog/wp-content/uploads/2008/09/picture-43-300x183.png" alt="" title="picture-43" width="300" height="183" class="alignnone size-medium wp-image-197" /></a></p>
<p>It is pretty straight forward: just get all the settings to where you like them, then open the library, hit &#8220;+&#8221; and it will add a new configuration (double click to edit the name).  each configuration holds every value on the interface as well as both the camera mesh and the projection mesh.  So now you can configure all the various surfaces/situations you might need and just switch them easily on the fly.  </p>
<p>Thanks again to Sandor for funding all these new changes (as well as the other code that I am working on that will be posted next week; a few demo apps like a cocoa based lightbox (all TUIO of course, so you can use it even if you dont want to use BBTouch).  Also, Sandor and I are rushing to get these apps working by Monday, so if you want to help out, load up bbtouch and break the hell out of it and let me know what bugs you find.  </p>
<p>Here is a binary of r151:<br />
<del datetime="2008-09-30T23:37:44+00:00">bbtouchr151app</del> (check more recent posts for newer binaries)</p>
<p>also the code is up on the repo, link in the sidebar to the right.</p>
<p>I will probably be changing the BBTouch code a few times this week, so check back for the most recent stuff. (i will always commit the code to the google repo too, so that will always be updated)</p>
<p>Cheers!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/09/30/bbtouch-code-updated-to-r151/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quick Code Update for BBTouch</title>
		<link>http://benbritten.com/blog/2008/09/29/quick-code-update-for-bbtouch/</link>
		<comments>http://benbritten.com/blog/2008/09/29/quick-code-update-for-bbtouch/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 23:18:20 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=195</guid>
		<description><![CDATA[Hey All,
I just finished committing the last of the new filter code to the repository. (r150)  No binary yet (I am at a conference, waiting for the keynote to start, so no time now :-)  so you will have to compile your own. You will also need the openCV.framework
(found here: http://www.ubaa.net/shared/processing/opencv/)
(I plan to [...]]]></description>
			<content:encoded><![CDATA[<p>Hey All,</p>
<p>I just finished committing the last of the new filter code to the repository. (r150)  No binary yet (I am at a conference, waiting for the keynote to start, so no time now :-)  so you will have to compile your own. You will also need the openCV.framework<br />
(found here: <a href="http://www.ubaa.net/shared/processing/opencv/">http://www.ubaa.net/shared/processing/opencv/</a>)</p>
<p>(I plan to add it properly to the project as a private framework, but didnt do it when i added it first for some reason, and now I keep forgetting)</p>
<p>anyhow, the only thing to know really is that in the View Menu, there is a new option : Filter Config&#8230; This will allow you to adjust the filter parameters for your setup.  It is kinda optimized for DI stuff right now (because that is what I have) but I will add more FTIR friendly filters later (if someone tells me what they need)  Oh, and dont put even numbers (or zero) in for the kernel values, or it will crash. I need to put a constraint on that, but haven&#8217;t got to it. You can put any number in for the Threshold Mean Offset tho. (negative numbers usually work best)</p>
<p>Let me know any bugs you find!</p>
<p>CHeers!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/09/29/quick-code-update-for-bbtouch/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quick BBTouch Update</title>
		<link>http://benbritten.com/blog/2008/09/28/quick-bbtouch-update/</link>
		<comments>http://benbritten.com/blog/2008/09/28/quick-bbtouch-update/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 01:22:36 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[code]]></category>

		<category><![CDATA[multitouch]]></category>

		<guid isPermaLink="false">http://benbritten.com/blog/?p=193</guid>
		<description><![CDATA[ 
Here is a youtube video (my first :-) of the initial testing of the newer/better/more filtery-er BBTouch along with the BBTUIOTest app (now with more lightboxyness).
Apologies for the supreme craptacularness of the video quality.  I don&#8217;t have a camcorder, so I just pointed my laptop&#8217;s built-in iSight at the table and used iMovie [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/aDaonzrOAMo"></param> <embed src="http://www.youtube.com/v/aDaonzrOAMo" type="application/x-shockwave-flash" width="425" height="350"></embed></object></p>
<p>Here is a youtube video (my first :-) of the initial testing of the newer/better/more filtery-er BBTouch along with the BBTUIOTest app (now with more lightboxyness).</p>
<p>Apologies for the supreme craptacularness of the video quality.  I don&#8217;t have a camcorder, so I just pointed my laptop&#8217;s built-in iSight at the table and used iMovie to capture. (while also running BBTouch in the background)</p>
<p>Anyhow, the BBTouch setup was like so:</p>
<p>BBTouch tracking, generating TUIO events, sending them via wifi to yet another machine running BBTUIOTest which is running the projector, and is running the lightbox code.</p>
<p>I know what you are all thinking: since when does BBTUIOTest have a lightbox feature??  and the answer to that would be since a few days ago when I added it.  (no code up yet, it is still pretty raw)</p>
<p>I think it is also important to note that all this development comes with much thanks from Sandor&#8217;s development budget.  I have been working with him on an MT app that he designed (more on that later :-) and now we are moving to the next step and getting BBTouch and some nice (yet to be made :-) cocoa/core image demo apps up to snuff so that he can use them for his own nefarious purposes :-)  So!  Everyone needs to buy Sandor a beer and thank him for his generous funding of BBTouch and Multitouch code development, and fastracking BBTouch improvements that I may never have gotten to otherwise! (thus saving me at least temporarily from some other, far less interesting jobs :-)</p>
<p>SO! BBTouch, now with more filters: It is still in a very raw state, and the code wont be stable for a few more days at the very least, but here is a sneak peek:</p>
<p><a href='http://benbritten.com/blog/wp-content/uploads/2008/09/picture-33.png'><img src="http://benbritten.com/blog/wp-content/uploads/2008/09/picture-33-300x202.png" alt="" title="picture-33" width="300" height="202" class="alignnone size-medium wp-image-194" /></a></p>
<p>I know, everyone is wondering why I didnt add filtering sooner.  Well, it is like this: I like to keep things as simple and minimal as possible (especially things that are generally very complex, like MT stuff). And before, when BBTouch was merely a pet project and I could optimize the blob detection algorithm to my heart&#8217;s content, that is what i did.  I think it paid off in the end, because i think that just the blob detector pre new filtery goodness was about 85% there.  All it was doing was a background subtraction and a simple threshold, and I got really good coverage across about 85% of my surface.  However, I was getting the bane of all DI surfaces: false hits from you palm or curled fingers on the light areas and no hits for any blobs in the dark areas. These filters help with that immensely.</p>
<p>Now I have added basically two more filters: a High Pass and an Adaptive Threshold.  (and a noise reducer for the highpass, so I guess technically 3 filters.) (all using the openCV image filters. more on that later too)</p>
<p>The High pass filter made all the difference.   For anyone doing DI type setups, make sure that you are using a higpass, it will make your life so much easier.  </p>
<p>Anyhow, enough for now, back to work for me!</p>
<p>Cheers!<br />
-b</p>
]]></content:encoded>
			<wfw:commentRss>http://benbritten.com/blog/2008/09/28/quick-bbtouch-update/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
