Posted by: Cliff | December 17, 2009

y(n) = 0.5 x(n) + 0.5 x(n-1)

Hi, I’m Cliff. You’re here because you understand the formula above. I’m here because I wanna use the formula above against some of my favorite music tracks… while running on the iPhone. I’m NOT a mathematical guru. I work with some math gurus, who I respect deeply. I don’t pretend to have invented the above formula. I can barely pretend to understand it. But when you put it in practice, when playing something like Snoop Dog, well… you’ll just have to see for yourself.

Ok, enough teasing! What you are looking at is a simple low pass filter. It’s the thing that comes in your audio hardware, right under the bass dial. I’m feelin’ this because I love bass. I’m also feeling good because I think I just learned a couple of things about audio digital signal processing (DSP). What a great first lesson.

The actual formula for a low pass Infinite Impulse Response (IIR) filter would be:
y(n) = A x(n) + B y(n-1)

Why is that important? Well, when you get into audio programming you find that there are lots of things that you can do with sound. There are things that would have been exciting in the mid 80’s to late 90’s but are now typically found in some cheap $5 device at Walmart, such as applying the chipmunk effect to your voice, echoing effects, or something like the jet-pilot effect. These are some of the effects found in MaryTTS and typical things I used to find in, for eg., the Transformers headset that I got for Christmas that one year. I knew it cold be done. I’ve seen others do it. But up until now I never understood how it was done.

I mentioned a while back that I have a passion for audio and acoustics. That passion has resurfaced recently leading me into the study of audio encodings and such. I am such a novice here but I’ve managed to get my head around concepts such as Pulse Code Modulation and Pulse Position Modulation. I’m just scratching the surface. Eventually I’ll read up on compression and advanced DSP.

Posted by: Cliff | December 17, 2009

Dragon says, Bob bob bob…

What if you could touch a button on your phone, start speaking, and the phone could hear what you said and respond intelligently? What if you could type text messages with your voice, send emails and such? I know, there’s apps like VLingo and recently Nuance Dragon Dictation popped up in the AppStore.

So the other day I’m playing with Dragon Dictation, right? Oh yeah… Hi, I’m Cliff. You’re here because you wanna hear what Dragon said. Haha, funny funny, on with the story. So I’m playing with Dragon Dictation on the iPhone, right? And immediately this thing is nailing every word a stammer at it. (I sometimes stutter especially when I’m excited about something or get some new piece of tech in front of me.) I’m so impressed. I try it on my wife, without her knowing. I just wanted to see how powerful this thing truly is. So I set it to record while she goes on about her day. She catches on to what I’m doing and gets slightly annoyed. I then explain, “I’m just trying out this new voice stuff on the iPhone!” She grabs the phone from me and says, “I got something for your dumb phone!” (She is easily irritated when I play with toys in front of her.) While its on record she starts swearing into the thing. She was angry but in a playful way and so we both watched after I grabbed the phone back and clicked the stop button. “Dragon says Bob bob bob all about Bob!” read the display.

She tried a few more times with different inflections on the F-Bomb and each time it translated to “Bob”. At this point I go into one of my long winded explanations of how it uses a dictionary to translate audio into text at which point she becomes totally uninterested due to my overwhelming geekery. Its funny how audio translates into text. Its even more funny how funny this story would be if I actually told it to you out loud. Its more more funny how unfunny the story looks in text. Audio to text is funny! Too funny! If you want to laugh, try Dragon Dictation for free in the app store and tell it a really funny joke or story. Then paste the results below.

On a forum there was talk of:
Bold จอขาว แบบนี้ ทำไงดีครับ

And then someone said:
ส่งศูนย์เลยครับ

Which was later followed by:
เครื่องศูนย์แนะนำส่งศูนย์ครับ
แต่ถ้าเครื่องหิ้ว อาจต้อเปลี่ยนจอครับ
ผมเคยเป็นต้องเอาไปเปลี่ยนจอเลย

Eventually chanisar chimed in to mention:
วิีธีแก้ของเรา เราทำตามในเว็บนี้
http://codeforfun.wordpress.com/2008/04 … /#comments
หายเลย ใข้ได้ืัทันที

‘Atta boy Chanisar! You rule… I think.
(The above comments may have been taken completely out of context and all participants could just as well be cracking jokes about me. I’d never know. You gotta love the internet!)

Posted by: Cliff | December 15, 2009

Router upgrade confusion

I’d been thinking about upgrading my wifi router lately. I purchased it about 2-3 years ago, its a Netgear G and it does ok. My connection speed is acceptable though I notice I frequently get knocked off the net for no reason. I’m wondering about a new router because I now have a rather large network at home. With two phones sporting wifi 3-4 laptops, a printer, my old desktop its amazing how many things talk over our network. Here’s my dilemma. I have little knowledge of wifi other than knowing that my devices can open connections without being physically tied to other hardware. When I bought my Netgear device I asked the associate at Circuit City which to buy. I wasn’t certain whether or not my MacbookPro would benefit from the Super G+ on one rack or if I should splurge an extra $20-$30 for an “N”. I had all kinds of questions and he assured me that the enhanced G+ stuff did not follow spec and that I’d need specific hardware to benefit from it. He also told me that the my Mac might not get anything from the N router.

I’m still confused on how to check which versions of wifi are supported by which device. I see a few “N” routers priced around the $34 range then there are other more pricey models. I know the old saying, “you git what you pay for” but I’m still lost. How does one go about intelligently purchasing a router these days? Also, along the same lines, how do you spec modern processors? There has been such a shift in CPU technology, I miss the days when AMD was secretly on top when you could buy a more powerful CPU for a fraction of the price of the more popular CPU. The numbers seem to mean nothing and everything sports Core Duo so what gives? I’m slightly embarrassed to admit how stoopid I am with today’s tech but I’m willing to bet I’m not alone.

Posted by: Cliff | December 14, 2009

Lego Chessboxing

If this isn’t the craziest video on the net then your connection must be broken.

Posted by: Cliff | December 9, 2009

Version 11.2 of the same ol’ nonsense

AutoUpdate has discovered you are currently running Bonehead version 2.3 version of our product. Download our new enhanced X-Streamed version 11.2 of TextFileReaderNG Elite now with ASCII and Unicode support!

Does this sound like the bubble in the lower right hand corner of your windows install? Are you still running a dated version of notepad, calc, MSPaint, or some other commodity program? Do you often wonder what is so important that the product designer became arrogant enough to interrupt your work and nag you for the fifteenth time to upgrade? Have you been avoiding the upgrade process for several months now? Hi, I’m Cliff. You’re here because some computer person designed an upgrade bubble into the software you were just using. If you are anything like me (and you must or else why would you continue reading this page?), then you are constantly annoyed by the ever insisting upgrade bubbles that pop up on your screen from time to time. Why won’t they just leave me alone??

Today I gave in to Adobe, allowing them to interrupt my progress, rape my computer and my web browser for what feels like the eleventh time this year. All this for the sheer privelige of installing version 9.2 of their PDF reader. Maybe its because I work across several computers both physical and virtual. Maybe its because I so often ignore these upgrades. Whatever the case I can’t seem to escape the upgrade nags. If its not Adobe then its Microsoft with their “close all of your apps and reboot your entire computer/workflow now? Or in the next 3 minutes just before you hit compile when we decide to ask you again?” prompts. And once I finally get both Adobe and Microsoft products up to date here comes Firefox discovering a new version of some plugin that I depend on desperately. To be real, I can’t remember the last time I started Firefox without it upgrading itself, a plugin, or presenting me for no apparent reason with the “You are now upgraded to the latest Firefox” web page. I digress.

Back to Adobe. Let’s talk about their Reader upgrade experience. First of all, when was the last time you did something with a PDF reader aside from searching, zooming or paging through a document? I’m sure there are those of you that will be like, “I annotate my PDFs with little yellow 3M-like sticky notes for future reference all the time!” But, c’mon son! How often does an average user take advantage of what’s crammed into Acrobat? What in Paul’s Pet Shop is it that they are upgrading anyway? I’ve been a professional software programmer for exactly 11 years as of today (I just realized that today is my 11th anniversary of my 1st professional programming gig! Go me!) and I have yet to use let alone understand any of the features in Acrobat other than is text rendering feature. If I could get Notepad to open a PDF I might as well uninstall the whole thing entirely.

Maybe I’m being too harsh? Maybe I’m just so spoiled by Acrobat’s ability to transparently do its job that I take it for limestone? (Most people take things for granite, here at “can’t see nothing but the source code” we take things for completely alternate rock forms because granite is so… boring. However I do take my work address for granite and that’s a joke that is so lame that I had to include it. If you didn’t get it just nod your head and laugh and look it up later.) Yes, that’s it. I’m being too harsh. Tune in next episode when we take an in-depth look at the more elaborate features of Acrobat. I’m off topic once again.

Let’s really understand the upgrade experience offered by Adobe for the one product I came to know them by, Acrobat Reader. I get the upgrade prompt when I open a PDF. Here I have the option of ignoring the upgrade, so far so good, right? As discussed above one eventually tires of ignoring so lets consider what happens when one accepts. Some applications (most notably on the Mac) know how to allow you to continue working while they take care of themselves silently in the background. Acrobat spawns a new window in your web browser pointing to the new version. You must then take action to initiate the download. I’ve had this happen to me in the past where I won’t even notice the window and I continue my work only to be reminded at the end of the day when I close my browser that I never actually upgraded anything.

If its not enough to interrupt your work with an upgrade then require you to manually download the new package, Adobe goes a step further by tricking you into installing yet another piece of software along the way. My experience this morning found me visually scanning the new browser window for the upgrade button and mindlessly clicking on it. I was not interested in any of the other adornments on the page, I was only interested in finding that button that would finally make the upgrade nags go away. The button I found did NOT download the upgrade. It downloaded what Adobe refers to as their download manager! Now I’ve been interrupted, I’m forced to interact with a web browser window that I did not open (which I’m sure is a direct no-no in some user interface guidelines), and I’m downloading something that is not the “thing” that I’m supposed to be installing. As if I hadn’t wasted enough time I have to do a double take to realize the little blip that my browser puts at the top of the page warning me that the site is attempting to install something in my browser. In other words, the download manager is not a stand alone program, rather it’s a browser plugin which means that if I switch from, say Firefox to Chrome in the future then I’ll go through the entire dance on the next Adobe upgrade. Now I ask not only why I need a new version of Acrobat, but why do I need another download manager. I then ask how many different download managers do I have installed across all of my machines? Do these download managers need to be upgraded over time as well? Will I need to download a download manager manager? Every time I switch computers will I need to worry about this?

After installing the download manager I then need to restart Firefox, which of course will probably upgrade its own nonsense. I take the restart firefox option after installing the software I didn’t know I needed in one final attempt at upgrading the software I knew I didn’t need. I get one of those Mozilla crash reports. I now accidentally allow Firefox to send the report back to Mozilla in a quick attempt to dismiss the crash window which expenses more minutes out of my schedule. (Mozilla was kind enough to default the option to “yes please waste more time posting an HTTP request before killing this process”) On my restart I discover that I was using a test profile in Firefox. my default profile knows nothing about the download manager install that went bad. (Profiles are the thing that Firefox uses to separate users and browsing sessions from one another so using a different profile is the rough equivalent of using a completely different install of the web browser. Fortunately you won’t have this kind of situation unless you know enough about the internals of Firefox to find the secret spot where they are activated.) I then restart the entire upgrade process from the reader client because I’ve now invested too much time to call it a waste. After finally getting the manager installed it is wise enough to automatically initiate the upgrade that I originally came for. My upgrade completes and I have officially forgotten which document I was originally trying to read. I open Acrobat using the new icon added to my desktop clutter (nobody asked me if I wanted yet another desktop icon) to peruse its newer interface and explore exactly what I spent the last hour and a half fighting for. Adobe now assaults me with another prompt for the EULA. I guess they need to be sure I wont pursue legal retribution for the $25.32 in salary exhausted over the 2 hours I spent trying to use their product to read some text. My eyes quickly dance over the wall of text overlooking the hidden clause, “I promise not to ask Judge Judy to embarrass Adobe or any representatives from Adobe even as Adobe has thoroughly begged for the TV prime-time humiliation…” to find the “I ACCEPT” button.

Finally an empty Acrobat frame! I discover that ooh! We can now collaborate in Acrobat! Isn’t that what Netmeeting is for? No wait, WebEx and Cisco solved the collaboration thing years ago. And wasn’t collaboration in version 8 of Acrobat? There’s a digital editions option under the file menu as well. I thought PDFs were already digital? Can you digitize a PDF? What happens then? What to do with the millions of PDFs that aren’t digital? I click this option and guess what happens? It spwans a web browser window! Here I am gifted another wall of text explaining the “Digital Editions” experience complete with an Adobe Digital Editions Installer button. (This will probably spawn another window to install the Adobe Digital Editions Installer Manager.) I skim the text and learn that Digital Editions has something to do with eBooks. You mean after all these versions and upgrades Acrobat can’t open an eBook directly? Looking over the other features in the menus I note there is a Text To Speech engine that allows PDFs to be read out loud, there are some security options, and a weird Analysis menu. I also see an “About Adobe Plugins” option with no apparent way to add/remove/change the included plugins.

I think I’ve analyzed the Acrobat experience enough for now. None of what I mentioned above was funny nor was it an attempt to be funny or cruel. This is all reality as I seriously try to understand not only why my work needed to be interrupted but what it was interrupted for. Holler back if you’ve ever fought an upgrade process like Adobe’s and wondered why.

Posted by: Cliff | December 8, 2009

My Top 80’s Moments

I bring you tidings and cheer this year. All the way from Stonegate Drive where I spent many an hour in front of the T.V. I list my top five 80’s moments.

Transformers The Movie (One shall stand, one shall fall)

The Last Dragon (Busta Rhymes and Marlon Wayans need to do a remake!)

Bruce Lee Nunchucks (Nuff said)

Bruce Lee and Kareem (Now why would they use the Asian lengthening effect for a clip with Kareem?)

Breaking Electric Boogaloo (Sweeping the living room hadn’t been the same since!)

And number six (I can’t leave it out) Storm Shadow vs. Snake Eyes

Honestly I’m not sure if it was more cool to have the glow or the touch but either way I found myself in front of the mirror practicing mentally induced spontaneous combustion. (Don’t act like it was just me! A whole lot of you thought you could light up an empty dark room but instead found a way to accidentally crap your pants when showing your homies.)

Posted by: Cliff | December 1, 2009

You must fail before you can succeed!

If you try to fail and you succeed, which have you actually done? Are you a success? Or a failure? Is it good to be a failure? Is it better to be successful at failure? Let’s add detail to the question. By the way, I’m Cliff. You’re here because you tried to fail and you succeeded. Today’s topic is something I’ve visited before. It’s a new thing I’m trying with unit tests. Actually it’s an old thing to many but I’m trying it for the first time in both C++ and ObjC so it feels sorta new-ish.

How do you unit test?
Let’s start with how you unit test. What are your steps? What are the recommended steps? In order to be successful at TDD you must appreciate the entirety of the practice. It goes, “Red, Green, Refactor”. Red comes before Green, just like with traffic lights. What I’m saying is that you have to begin with a failing test. The first test is important. The first failure should describe what work you have to do. In my case, I’m swimming in un-ventured waters (C++/ObjC++ testing) so there’s some learning that needs to be re-enforced. Here’s how I’ve been starting my tests recently:

//
//  MyCoolNewObjectTest.m
//  Created by cliftoncraig07 on 12/1/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#include "MyCoolNewObject.h"

@interface MyCoolNewObjectTest : SenTestCase
{
  MyCoolNewObject *coolObject;
}
@end

@implementation MyCoolNewObjectTest

-(void) setUp
{}

@end

The test shell is completely empty except for references to the “thing” I’m about to create. I get my first failure which is a compile error stating that this thing does not exist. “No such file error…” around the include. Here I have an opportunity to review my design as minimalist as it is. I ask, “Does the error make sense? Is it expected? Do I like the name of this cool new thing I’m creating? Is it specific to the task I’m assigned to?” Always review each error with these question. After creating the files for the new “thing” I then follow up with:

//
//  MyCoolNewObjectTest.m
//  Created by cliftoncraig07 on 12/1/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#include "MyCoolNewObject.h"

@interface MyCoolNewObjectTest : SenTestCase
{
  MyCoolNewObject *coolObject;
}
@end

@implementation MyCoolNewObjectTest

-(void) setUp
{ STFail(@"You must fail before you can succeed!"); }

@end

Also important, while I train myself on the new testing framework, because I need to catch myself misnaming the “setup” method which should have a capital “U”. It also lets me know that my test is actually running as part of the suite. Far too often, in Xcode, I’ll have the wrong target active and begin writing the wrong code because I was getting false positives from tests that were never run. Here’s where it gets interesting. The STFail in the above example does not fail! Now we face our original question, if you try to fail, as we have above, and you succeed like our test suite will do here, which have you actually done? The first time I hit the unexpected success I got nervous and read all around the SenTesting framework and OCUnit. Eventually I settled on the conclusion that because there were no tests to run the setUp was being optimized away as unnecessary. What the above example is pointing out is that such a test case can never fail since there are no tests. That leads us to our final step…

//
//  MyCoolNewObjectTest.m
//  Created by cliftoncraig07 on 12/1/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#include "MyCoolNewObject.h"

@interface MyCoolNewObjectTest : SenTestCase
{
  MyCoolNewObject *coolObject;
}
@end

@implementation MyCoolNewObjectTest

-(void) setUp
{ STFail(@"You must fail before you can succeed!"); }

-(void) testSomething
{}

@end

…and here we get our familiar red bar! Our test case is complete and we now understand a little more about OCUnit. That’s it for today. Go on. Nothing else to see here. I know what you’re thinking. “We haven’t written or learned anything new!” Sure we have! We’ve written and validated our first test case in ObjC++. (I’m using OCUnit w/ C++ extensions to exercise or test drive C++ code.) The little amount we went over here is persistent through all the testing you will do from then on. It starts from the basic mechanics. Make sure every line of code is proceeded by some test (or compiler) failure. If you’ve done more than 2-3 things and haven’t run a build to generate a failure then you’re completely off track.

Posted by: Cliff | November 30, 2009

Too many social networks

I rode the Wave then Twitter sucked me in! I don’t do Facebook anymore because too many people would know too much of my dirty laundry. (Not that I have anything to hide I’m just careful on what I share with whom.) It started over a year ago when those Facebook apps got to be fun. Before I knew it I was answering “would you rather…” questions and rating friends in a way that could be taken out of context. Nobody would believe that I was “just trying out this little app” if they were to come across some of the stoopidity I was putting in the checkboxes. Its dangerous. Not only do these social network apps link people in ways never thought of before, they have a way of weening information out of you that you wouldn’t typically share in a regular situation.

I’m a mostly open guy but I have a certain edge to my personality that, when not kept under control, can lead to random outbursts in awkward situations. Because 90% of my connections were work related and because Facebook has no qualms with broadcasting every minute move you make to your entire Friend list by default I found it’d be easier if I just left it alone, lest somebody thought I was experiencing a breakdown of some sort. I’m putting this out there as a warning to some of you who may be on Facebook and not realizing that the stuff you do there IS broadcasted and permanent. You won’t realize until someone in your office taps you and asks about your “wall” or inquires why you were up at 12am updating the movie preferences with Steel Magnolia topping your list.

More important is the distraction these things impose on your normal activity. Something as personal as spending the holiday with your family can now be interrupted by a series of dumb tweets on a nonsense topic. I don’t usually reveal too much of my personal life here because it’s supposed to be all about the sourcecode but that last statement is too true and speaks to my level of discipline. While I don’t believe I did anything too damaging with Twitter (following the Wayans Bros. trends) this weekend I do understand the potential for chaos.

Google Wave is another big nothing. On its own, its an IM/Email/Live-Twitter-Board that doesn’t give you anything you don’t already have. It just aggregates existing tools in an interesting new way and because it wears a “Google” badge you’ll use it regardless of its current usability issues. I burned an entire day trying to work around usability flaws my and lack of Wave connections and find some practical advantage of the new platform. I feel it does have potential and there is something big that could happen over the next few months but it is just taking too much of my time to follow along with everything else.

I always used to wonder about people who would pay for Cable, Pay-Per-View, NetFlix, Blockbuster, cell service, a land line, Satellite radio, and multiple-magazine subscriptions. Now I fear I’m becoming one if I don’t tone things down.

Posted by: Cliff | November 30, 2009

Objective-C Gotchas

You’re working in Objective-C land trying to get a product out the door and into the Apple iTunes Store, right? (Don’t argue with me I’m just setting the stage.) You’re feeling the second cup of coffee seep into your bloodstream which creates a certain euphoric sensation as the last 3 times you mashed Cmd+B turned up no errors. Yes, that’s what’s happening in your copy of XCode right now. You then Cmd+Tilde to toggle the other XCode window active (Cmd+Tilde is a nifty Apple shortcut for switching active windows in the current app) and Cmd+B once again when a red flag on the play pops up in some code that had been just fine moments ago? What happened? Hi, I’m Cliff. You’re here because XCode got’cha and you’re not quite sure how/why/where. I’m here because I wanna list as many of these got’chas before I forget them.

Property accessor notation in Earlier SDKs
Here’s one weird gotcha that I just hit again for the first time. If you have a variable typed as a protocol and that protocol has a setter, which takes another protocol type defined then you may get an error when using dot notation in SDKs earlier than 3.0. That is a definition like this:

@protocol MyCoolAbstractType <NSObject>
-(void) setNetworkDataProvider:(id<MyNetworkDataProvider>)aNetworkDataProvider;
@end

…should be coded like this:

@protocol MyCoolAbstractType <NSObject>
@property (nonatomic, retain) id<MyNetworkDataProvider> networkDataProvider;
@end

…before you can do this:

id<MyCoolAbstractType> myObj = //create object from factory
myObj.networkDataProvider = [[MyConcreteNetworkDataProvider alloc] init];

Evidently the “Discover setter is a property” feature is something new Santa delivered with 3.0 and never told me about. Here I thought I had that toy from 2 years ago!

Unit Tests Can’t Be Signed
I added a unit test dependency to my “Application” target the other week in order to streamline my dev cycles. The idea was to ensure any changes I made to satisfy the integrated application bundle did not impact behaviors outlined in my test cases. (I use mini applications to perform my integration testing.) The problem here is that, even though this works well for simulator builds, an on-device build will fail as XCode attempts to sign your unit test target output. I haven’t discovered a work-around for this one yet so I’m gonna just punt and remove the test dependency from any targets meant to run on device.

I’ll trow up more as I find them…

Older Posts »

Categories