Dave Smith Instruments – Pro 2 Mini-Review

December 21st, 2014 No comments

So, I bought a Dave Smith Instruments Pro 2 synthesizer.

Read more…

Categories: Opinions Tags:

Let’s have a national conversation about gun control.

December 16th, 2012 Comments off

Let’s have a national conversation about gun control.

But let’s have an informed, rational conversation. Let’s not let our justified horror over recent events overshadow our responsibility to consider facts when making national policy decisions; let’s make those decisions based on reality, rather than on our emotional reactions born of our natural grief.

I’d like to discuss a lot of common misconceptions I’ve been reading lately, to dispel some myth, and to attempt to discuss gun control on a more rational basis.

I’ve heard it said that “this is not the time” to talk about firearms facts. I disagree. I think that this is exactly the time, because this is exactly the time at which people will be using these misconceptions to potentially affect policies, and I’d like to see any policy changes we make be informed by actual facts, rather than misconceptions and emotion.

Misconceptions

I’ve seen a lot of people (Rupert Murdoch is the obvious high-profile example) talking about the need to ban “automatic weapons,” when, in fact, they’ve been banned since 1934, and in fact, no fully-automatic weapons have been used in mass shooting in the USA since then. (Not even the recent one that was committed at an Army base by an active-duty military officer.)

These people are almost certainly confusing “automatic weapons” (those which fire rapid bursts of rounds with a single continuous trigger pull) with “semi-automatic weapons” (those which use the action of one shot to re-cock the weapon and load the next round into the chamber).

The contrast to a semi-automatic handgun would be a revolver. (Revolvers come in two flavors: single-action and double-action. For purposes of this discussion, I’ll consider double-action revolvers only.) For a semi-automatic rifle, it would be a bolt-action or lever-action rifle (think old-west style here). (Or a muzzle-loader, I guess. For purposes of modern gun control discussion, I won’t even bother to mention muzzle-loaders again.) For a shotgun, it would be a pump-action shotgun.

There are two main differences between semi-automatic weapons and their non-semi-automatic counterparts: rate of fire and capacity.

As to rate of fire, from slowest to fastest, the various mechanisms would likely rank as follows: bolt-action, lever-action, revolver, pump-action, semi-automatic. (The ordering of the last two are arguable.)

As to capacity, the difference is not so much the action as it is the loading mechanism. The loading mechanism on nearly all semi-automatic weapons (except semi-automatic shotguns) is a magazine. These come in capacities from about 3 rounds on up. Magazines of more than 10 rounds were banned between 1994-2004. Magazines of more than 20 rounds, while no longer banned, are not readily available (to my knowledge) for most guns. Capacities of between 7 and 17 rounds are the most common. Most bolt-action rifles also use magazines, like their semi-automatic counterparts.

By contrast, revolvers tend to have capacities between 5 and 7 rounds, and these capacities are not readily expandable. Pump-action shotguns tend to use a tubular magazine under the barrel, with a capacity between 3 and about 10 shells (these also tend not to be readily expandable).

I’ve seen a lot of comments about “assault weapons”, without a lot of discussion about what those are. The Wikipedia article on the Federal Assault Weapons Ban discusses this at length. The long and short of it is that the definition hinges on cosmetic features and on magazine capacity. It is important to note that “assault weapons” are not fully-automatic weapons, which have been banned since 1934.

OK, but what should we do?

It seems that there are basically six questions we should answer before we decide what policies to change or enact.

1. Should we ban private gun ownership entirely?

Some people think we should. Personally, I’m undecided. Practically, we should admit to ourselves that at least in the USA, this will never actually fly. To do this, we’d need to repeal the 2nd Amendment, and frankly that just isn’t going to happen.

2. Should we ban based on capacity?

This seems to be a very popular idea. Personally, I’m not completely convinced. The thought process here seems to be that the shooter in a mass shooting wouldn’t be able to shoot as many victims if they can’t carry a high-capacity magazine.

But in many of these incidents, such as the 1991 Luby’s massacre in Killeen, TX, the shooter is said to have calmly reloaded their weapon; in most, the shooters used multiple weapons. My guess is that limiting magazine capacity will just motivate perpetrators to bring more magazines, or just bring more guns. However, It could also be argued that limiting magazine capacity, forcing shooters to reload or switch weapons, potentially gives other people at the scene an opportunity to intervene and overpower (or shoot back at) the shooter.

The shooter in the aforementioned Luby’s incident in Killeen paused to reload multiple times without being confronted; that would argue against the theory that reloading presents an opening. However, one person present at the scene, Suzanna Hupp, argued that the law requiring her to keep her own gun in her car (rather than on her person) was what prevented her from stopping the shooter, and that if she had had her gun, she could have stopped him (and she successfully campaigned for that law to be changed). Nick Meli, who was present at the recent shootings at Clackamas Mall in Oregon, believes that the fact that the shooter in the mall saw him pull out his own gun may have caused the shooter to give up sooner than he otherwise might have.

On balance, my guess is that limiting firearms capacity would have a net positive effect in reducing the victim count of mass shooting incidents. So I’d be in favor of such a move, reluctantly (because I am not 100% convinced).

What I am 100% convinced of is that we should have a discussion based on honest discussion of the issue, rather than emotional reactions.

3. Should we ban based on firing rate (or mechanism)?

Do we believe that it will make a difference? Most of these events take place over enough time that you would have a hard time convincing me that the firing rate of the weapon mechanism was itself the limiting factor in how rapidly the shooter fired shots.

Personally, my feeling is that this would make absolutely no difference at all, and I am therefore against it.

However, if a convincing, logical argument could be made that this would actually make a difference, I’d like to hear it, and might change my mind.

If we want to do this, let’s have that discussion and hear that argument. Let’s not just do it while weeping “think of the children!” We do not honor their memory by overreacting on their imagined behalf.

4. Should we ban based on cosmetic features?

It would seem that the obvious answer to this question is “no.”

I’m actually not so sure.

It’s clear that (almost by definition) the people who perpetrate these acts are mentally or emotionally unbalanced. I think it’s entirely possible that the cosmetic features of the weapons they use contributes to their state of mind in deciding to commit these heinous acts. The Fort Hood shooter reportedly asked for “the most technologically advanced weapon on the market”, and fitted it with not one, but two laser sights—which he then did not actually use in the shooting, except to threaten a potential victim by sweeping the dot over his face (and then didn’t fire).

So my personal feeling is that this might actually help. Opinions are widely divided on whether the Federal Assault Weapons Ban (which did basically ban weapons on cosmetic features in addition to magazine capacity limits) did or did not have a positive effect on gun violence.

Again, this is a discussion we should have— but again, we should have it openly, rationally and honestly.

5. Should we have stricter licensing of firearms?

Should we limit access to firearms by those who are mentally or emotionally unstable?

As we’ve said above, it’s clear that the perpetrators of mass shooting are mentally or emotionally unbalanced. I don’t know anybody who seriously argues that people who are known to be mentally or emotionally unbalanced should have easy access to firearms; even the die-hard NRA elite don’t have an issue with prohibiting convicted violent felons from owning guns.

But: should we do more extensive background checks for those purchasing firearms? Should we do not just background checks, but psychological examinations of firearms purchasers? Should we issue licenses that must be renewed periodically, with psychological testing for renewal (to catch those who develop issues after purchase)?

Personally, I don’t have a problem with background and psych testing for firearms purchases, or even renewable licenses with retesting. Naturally this would necessitate tracking purchases, so that we could require those who fail their tests to divest themselves of their guns.

This gets into a very sensitive area; people are naturally very suspicious of their government tracking gun ownership. The general sentiment goes that if the government tracks all guns, that just makes it easier to round ‘em all up when the other shoe drops. Personally I find that to be an overly paranoid point of view; I would like to think that the era of changing the political regime in the United States by force is over, and that our system of democratic elections and changing the government by peaceful political action could, after 200+ years, safely be considered “no longer an experiment.”

It also doesn’t solve the problem of unstable people taking guns from stable ones, by stealth, trickery or force. But clearly it would help quite a bit; as Mother Jones points out, more than three quarters of mass shooters over the last 30 years obtained their guns legally.

I would therefore vote for stricter gun licensing laws.

6. Should we improve access to mental health care?

Oh hell yes.

As I’ve said repeatedly, it is obvious that these shooters are mentally and/or emotionally impaired. Many of them were known to be unstable before they committed their crimes, but were largely untreated.

Because mental illness so often goes unreported/undiagnosed, it is hard to say what the real prevalence of it is. Because of the social stigma attached to mental illness (and treatment by psychologists/psychiatrists), many people who may benefit from such treatment refuse to seek it. In addition, the nature of many such illnesses is such that the illness itself causes the sufferer to believe that there is nothing wrong with them, or that treatment will be ineffective (depression is notorious for making sufferers believe that treatment would be futile).

But even depression is much more prevalent than people realize. It is estimated that one in six adults will experience major depressive disorder in their lifetime, with 6.7% of the adult population experiencing depression in a given 12-month period, with less than half of those receiving adequate treatment. This means that there are 6-7 million depressed adults in the US who are receiving inadequate treatment for depression alone.

We desperately need to remove the social stigma of diagnosis with mental and emotional disorders, and actively work to improve the treatment (and rate of treatment) of those suffering from them.

Summary

I’m generally in favor of stricter gun control; limits on magazine capacity, licensing, and even cosmetic features, but generally not firing rate/mechanism (except full-auto, of course, which is not at issue).

But I’d like to think that we can have a rational policy discussion, rather than rely on emotional reactions.

I’m also very much in favor of improved mental health access (and diagnosis), and I believe that that, possibly in combination with gun control, would do more to curb violent crime than gun control alone.

Categories: Opinions Tags:

Returning Retained Properties in Objective-C

July 24th, 2012 Comments off

In Objective-C, retained object properties are quite common:

@class MyOtherObject;

@interface MyObject : NSObject
{
    MyOtherObj* mOtherObj;
}

@property (nonatomic, retain) MyOtherObject* otherObj;

- (void) doSomeRandomThings;

@end

@implementation MyObject

@synthesize otherObj = mOtherObj;

// ...

@end

Well, that’s all well and good, but what does that @synthesize actually do?

You might think that it does something like this:

// The "getter"
- (MyOtherObject*) otherObj
{
    return mOtherObj;
}

// The "setter"
- (void) setOtherObj:(MyOtherObject*)otherObj
{
    [otherObj retain];
    [mOtherObj release];
    mOtherObj = otherObj;
}

And you’d be at least close. But that getter has a “gotcha” that might be obvious to some coders, and invisible to others.

The Bug

If we use this code as-is, we are subject to the following bug:

// Fetch myObj.otherObj:
MyOtherObj* otherObj = myObj.otherObj;
// Do some other things, including maybe:
[myObj doSomeRandomThings];
// Now use otherObj:
[otherObj doCoolStuff];

Looks fine, right?

Nope.

It crashes (sometimes?) on that last line, with something like EXC_BAD_ACCESS or an NSInvalidArgumentException where an unrecognized selector (guess which selector? right: it’s @selector(doCoolStuff)) was sent to some random object you’ve never heard of.

A zombie dereference.

How It Happens

But how is otherObj a zombie here?

Here’s how. Let’s take a look at -[MyObject doSomeRandomThings]:

- (void) doSomeRandomThings
{
    self.otherObj = [[[MyOtherObject alloc] init] autorelease];
}

Whoops. The old MyOtherObject that used to be referenced by otherObj has now been released, and the user has had it yanked out from under them.

How To Fix It

Let’s adjust the property getter:

- (MyOtherObject*) otherObj
{
    return [[mOtherObj retain] autorelease];
}

Problem solved.

Explanation

The return mOtherObj; idiom is very common, but it’s unsafe, for exactly the reason pointed out here. You’re returning the object you have now, and you know it’s valid now because you’re using it internally, but you really can’t make any guarantees about how long it will be valid, since something else might mutate your internal state.

The return [[mOtherObj retain] autorelease]; idiom is safer, because it adds a temporary extra reference on the object, in addition to the one you have internally, which is guaranteed to be valid at least until the current autorelease pool drains (which is certainly going to be at least until your caller returns, unless he is managing his own autorelease pools, in which case we hope he knows what he’s doing).

Pros and Cons

Some will argue that this idiom is wasteful, because it fills up the autorelease pools with objects that may live longer than they need to; that instead of making your getters do the [[mOtherObj retain] autorelease] dance, the callers should instead retain the objects they receive from getters and release them manually (or autorelease them themselves), since they know better what their needs are regarding the lifetime guarantees of objects they get. I disagree strongly, because I think that that is a brittle model. I think that the only time that this is likely to cause a real memory problem (a temporary increase in working set size) is when the caller is doing something in a loop for a potentially large number of iterations without returning to the main event loop, and if they’re doing that, they probably ought to be creating and draining their own autorelease pools for the loop anyway.

Categories: Tips Tags: ,

Usability in Hardware

November 9th, 2011 Comments off

I have a TC Electronic BMC-2 monitor controller, that I use and like, for controlling volume on nearfield monitors and headphones in my studio.

But it has a usability problem. We talk about usability in software all the time, but here’s an example of a hardware usability problem. Here’s the back panel:

BMC-2 Back Panel

Whose brilliant idea was it to put the headphone jack under the power jack? When I use it, I’m always in front of the unit, reaching over the top to control it. Which one of these jacks is likely to get plugged and unplugged more often?

Maybe the BMC-2mkII will reverse the positions of these. I doubt it will be a free downloadable update though.

Categories: Opinions Tags: ,

From the Audio Unit Programming Guide

November 4th, 2011 Comments off

Audio Plug-In manufacturers would do well to read and re-read this paragraph.

Adding Copy Protection

If you choose to add copy protection to your audio unit, it’s especially important to consider the audio unit’s opening sequence. The time for copy protection is during audio unit initialization—not instantiation. Therefore, you put copy protection code into an override of the Initialize method from the SDK’s AUBase superclass. You do not put copy protection code into an audio unit’s constructor.

Here is a scenario where this matters. Suppose a user doesn’t have the required hardware dongle for your (copy protected) audio unit. Perhaps he left it at home when he brought his laptop to a performance. If your audio unit invokes its copy protection on instantiation, this could prevent a host application from opening. If your audio unit invokes its copy protection on initialization, as recommended, the performer could at least use the host application.

Categories: Opinions Tags: , ,

Nerdy Mac Tip

September 19th, 2011 Comments off

Here’s a nerdy tip for Mac users. Open Automator, and create a new Service workflow. Set it to receive no input, then drag a “Run Shell Script” item into the workflow. Replace the default “cat” in the text area with this:

echo -n `uuidgen | tr A-Z a-z` | pbcopy

Save the service as “Copy New UUID to Pasteboard”. Now whenever you run the service, it generates a fresh UUID that is on your pasteboard, which you can then copy into whatever context you need it.

If you never need a UUID, then, umm, maybe just don’t worry about this tip.

Categories: Tips Tags:

What part of this is hard to understand?

September 12th, 2011 Comments off

Amendment 4.

The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 5.

No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.

Amendment 6.

In all criminal prosecutions, the accused shall enjoy the right to a speedy and public trial, by an impartial jury of the State and district wherein the crime shall have been committed, which district shall have been previously ascertained by law, and to be informed of the nature and cause of the accusation; to be confronted with the witnesses against him; to have compulsory process for obtaining witnesses in his favor, and to have the Assistance of Counsel for his defence.

I guess some people just don’t get it.

This is not the country in which I grew up and was taught that we were a free country, with principles, that stood for something.

Categories: Uncategorized Tags:

On the Timing of the Jobs Address

September 8th, 2011 Comments off

President Obama will address a Joint Session of Congress tonight (Thursday, Sept. 8th) regarding his job stimulus plan. He had originally requested to do so last night (Wednesday, Sept. 7th), but House Speaker John Boehner asked him to change the plan, and he agreed to it.

Mr. President: Please allow me to show you what the correct response should have been.

Read more…

Categories: Opinions Tags:

Those evil smartphones…

March 16th, 2011 Comments off

You can’t make this shit up: Richard Stallman thinks that smartphones are “Stalin’s Dream”. But:

“There’s a version of Android called Replicant that can run on the HTC Dream phone without proprietary software, except in the U.S. In the U.S., as of a few weeks ago there was still a problem in some dialing library, although it worked in Europe. By now, maybe it works. Maybe it doesn’t. I don’t know.”

And later:

Over the course of 38 minutes, our connection was lost five times, including just after Stallman’s comments about electronic eavesdropping and free software for phones. We tried to connect again several hours later but were unable to complete the interview via phone.

Note: I do not speak for my employer, who happens to make some pretty nice smartphones.

Categories: Uncategorized Tags:

Designated Initializers in Objective-C

September 21st, 2010 Comments off

So, if you are a Mac/Objective-C developer, you are probably familiar with the Designated Initializer. The Designated Initializer (“DI”) is, in an Objective-C class, the one initializer in a class that is supposed to do the heavy lifting in initializing an object for use. Other initializers of the class should generally invoke the DI.

Similarly, subclasses of a given class should, in their DI, invoke the superclass DI (and the other initializers of the subclass should invoke the subclass DI). This way, any way the object gets initialized, the DI of both the superclass and the subclass are sure to be invoked.

The documentation does a decent job of explaining this, but I think it’s easy to miss an important detail, and that is that in a subclass, you must take care not only to invoke the superclass’ DI, but you also have to override it. (If your DI is different from the superclass’ DI, this is not necessarily obvious.)

For example, take these two classes:

@interface DJMySuperclass : NSObject
{
    DJMyInfo* importantData_;
    BOOL someImportantSwitch_;
}

// The designated initializer for DJMySuperclass:
- (id) initWithImportantData:(DJMyInfo*)importantData;

@end

@interface DJMySubclass : DJMySuperclass
{
    DJMoreInfo* moreImportantData_;
}

// The designated initializer for DJMySubclass:
- (id) initWithImportantData:(DJMyInfo*)importantData
           moreImportantData:(DJMoreInfo*)moreImportantData;

@end

Fairly straightforward so far, right? Now, take this implementation:

@implementation DJMySuperclass

- (id) init
{
    return [self initWithImportantData:nil];
}

- (id) initWithImportantData:(DJMyInfo*)importantData
{
    if (self = [super init]) {
        if (importantData) {
            importantData_ = [importantData retain];
        } else {
            importantData_ = [[DJMyImportantData alloc] init];
        }
        someImportantSwitch_ = YES;
    }
    return self;
}

- (void) dealloc
{
    [importantData_ release];
    [super dealloc];
}

@end

So far so good; completely obvious. Now let’s take this subclass implementation:

@implementation DJMySubclass

- (id) init
{
    return [self initWithImportantData:nil moreImportantData:nil];
}

- (id) initWithImportantData:(DJMyInfo*)importantData
           moreImportantData:(DJMoreInfo*)moreImportantData
{
    if (self = [super initWithImportantData:importantData]) {
        someImportantSwitch_ = NO;
        if (moreImportantData) {
            moreImportantData_ = [moreImportantData retain];
        } else {
            moreImportantData_ = [[DJMoreInfo alloc] init];
        }
    }
    return self;
}

- (void) dealloc
{
    [moreImportantData_ release];
    [super dealloc];
}

@end

Again, totally straightforward, right? So where is the bug?

Imagine this extension (or, maybe instead of a category extension, imagine a similar future addition to the superclass and subclass, a year down the road and done by a different developer).

@interface DJMySuperclass(JBJoeBlowsAdditions)

- (id) JB_returnsACopy;

@end

@implementation DJMySuperclass(JBJoeBlowAdditions)

- (id) JB_returnsACopy
{
    return [[[[self class] alloc] initWithImportantData:importantData_] autorelease];
}

@end

@implementation DJMySubclass(JBJoeBlowAdditions)

- (id) JB_returnsACopy
{
    DJMySubclass* other = [super JB_returnsACopy];
    [other->moreImportantData_ release];
    other->moreImportantData_ = [moreImportantData_ retain];
    return other;
}

@end

Where’s the bug?

The bug is that if you have a DJMySubclass object called foo, and you call DJMySubclass* bar = [foo JB_returnsACopy];, you’ll discover that bar->someImportantSwitch_ contains YES, when you thought you had a class invariant for DJMySubclass where someImportantSwitch_ was always forced to NO.

Why?

Because JB_returnsACopy in the superclass uses the initWithImportantData: initializer, and you didn’t cover it in DJMySubclass, so your designated initializer in the subclass never got invoked.

The fix is simple: cover the superclass’ DI in your subclass, and invoke your DI.

@implementation DJMySubclass

- (id) initWithImportantData:(DJMyInfo*)importantData
{
    return [self initWithImportantData:importantData
                     moreImportantData:nil];
}

@end

The documentation for Designated Initializers says:

It’s important to know the designated initializer when defining a subclass. For example, suppose we define class C, a subclass of B, and implement an initWithName:fromFile: method. In addition to this method, we have to make sure that the inherited init and initWithName: methods also work for instances of C. This can be done just by covering B’s initWithName: with a version that invokes initWithName:fromFile:.

General Principle: The designated initializer in a class must, through a message to super, invoke the designated initializer in a superclass.

This general principle, while true, is not sufficient. You really need to make sure to cover the superclass’ DI in your subclass, as described in that first paragraph, and shown in the accompanying diagram 3-3.

Categories: Tips Tags: ,