Guitar Tuning By Ear

(This is edited from an answer I posted to KeyMinor, a music Q&A site. They need more users!)

A lot of recordings end up slightly higher/lower than standardized pitch (I always called this “in the cracks” but don’t google it!), and this is the quickest way I’ve found to tune a guitar to them.  This method seems simplistic but has several advantages going for it:

  • All strings are tuned to the same reference pitch, so there’s no accumulation of error as you move from string to string (and you can tune any of the top 5 in any order).
  • The higher the frequency, the easier it is to notice the beat when two identical notes differ slightly in pitch. Matching high pitches yields lower error.
  • All pitch matching is done with notes in the same octave; this also helps you notice the beat

Here it is. Continue reading  

SQL Server Mgmt Studio Can’t Export CSV

I’m trying to export large (e.g. 16M rows) SQL Server 2008 views for eventual import into MySQL. The underlying setup for these views is bizarre: A SELECT for a single row can take over two minutes, a SELECT * FROM view with no WHERE clause is much faster, but still too slow to finish an export in any client we’ve connected with. The only reasonable solution I’ve found is to use SQL Server Management Studio, right-click the DB > Tasks > Export Data… and target a flat file. This seriously seems about 100x as fast as a direct query in SSMS and 200x as fast as an ODBC connection.

There’s only one (major) gotcha: The flat file writer in SQL Server Management Studio (ver 10.0.2531.0) is broken for CSV output. There’s no configuration I can find that will correctly escape characters that need to be. By default it doesn’t enclose any values in quotes, but even if you specify the double quote as “Text Qualifier” (yay for obscure proprietary descriptions), double quotes within values won’t be escaped in any way. Not with \" nor "" (the CSV standard). This means you can either export fixed-width columns, or try to find chars that never exist in your data to use as field/line delimiters. The escape char \ is also not escaped, so you could end up with a line feed character in your import when the original data was literally “foo\road”. Stupid.

Again, I can’t just select all rows in the tool and then save the resulting recordset as CSV (which isn’t broken) because the views are so big that the queries time out (the resultsets would probably crash the tool anyway) and because there’s no way to partition the query that doesn’t destroy performance. I’m going to have to create a local SQL Server DB and do a DB to DB transfer, then use a client connection to export.

Update: You can at least use obscure Unicode chars as delimiters, though it outputs invalid UTF-8 chars after the first row. You have to export as “Unicode” (UTF-16 little-endian. 2-byte chars with a leading \xFF\xFE BOM). If you pick delimiters like ʖ and ʁ and go this path, you won’t be able to use traditional line-by-line file reading functions. You’ll have to stream a fixed number of bytes at a time, building up columns (and validating that the number of columns/row stays constant) and converting to rational CSV that can be handled by MySQL. Another vote for setting up a local SQL Server instance.

Bash: unbom (to remove UTF-8 BOMs)

Tests for and removes UTF8 BOMs.

for F in $1
  if [[ -f $F && `head -c 3 $F` == $'\xef\xbb\xbf' ]]; then
      # file exists and has UTF-8 BOM
      mv $F $F.bak
      tail -c +4 $F.bak > $F
      echo "removed BOM from $F"

USAGE: ./unbom *.txt

The magic is tail -c +4 which strips the first 3 bytes.

Could this be an OpenSSH bug?

Last week I tried to SSH into my webhost account (on Site5) from work and—forgetting my password—it locked me out after several failed attempts. SSHd would just close the connection without asking my password.

work:~$ ssh
Connection closed by xx.xx.xx.xx

I could log in from any other location, so I figured it was an IP ban and after a few days and a support ticket, I’d be in, but things got strange.

  1. The Site5 techs could not find any evidence of a block on my account. They were pretty responsive.
  2. It couldn’t be an IP block because I could log in from a virtual machine which used my workstation IP as gateway.
  3. When connected to VPN (different public IP) it still refused me.
  4. It couldn’t be a port 22 block because I could attempt a login to a different account on the same host and it would give me a password prompt.
  5. Could it be Snow Leopard? I could log in from another workstation running it.
  6. My machine? I could log in to several other hosts, including another account on a different Site5 host.

On the server I had an ~/.ssh/authorized_keys file with an old public key—the file hadn’t been touched for 2 years. I deleted it and—voila—SSHd would again ask for my password and log me in fine.

Why would the presence of authorized_keys cause SSHd to refuse to give a password prompt to one particular client’s connection to one particular account? OSX did give me a default RSA keypair, but even if the public key had been forwarded, SSHd should revert to password auth if it doesn’t find it in authorized_keys.

Chord Theory: 13 is probably 7(13)

A 7th add 13 chord is often voiced r-5-7-3-13, sometimes leaving out the fifth. To pin this to a key, a G7(13)—G⁷⁽¹³⁾ if your chart can handle Unicode—is usually voiced G-D-F-B-E and is a common (in jazz and standards anyway) way to make the resolution from G7 to C more subtle and harmonically interesting. In G7 – C, the F resolving to E is hard to ignore, but in G7(13) – C, the E is already present, making the removal of the F more subtle. The dissonance between F and E (a major seventh interval) gives the G7(13) a richer sound.

The consensus on the web seems to be that this is actually a 13th chord, even though there’s no 9th or 11th present:

“In modern pop/jazz harmony … a thirteenth chord does not imply the quality of the ninth or eleventh scale degrees.” [Thirteenth on Wikipedia]

I disagree. Since the true 13th chord is an extension of the 11th chord, it should sound more like an 11th than a 7th. Elevenths almost always imply a suspended, missing, or nearly inaudible 3rd, but the 3rd in 7(13) is usually very prominent. If you really think G13 and G7(13) are the same chord, play these two voicings one after one another on guitar:

  • G13 3-x-3-2-1-0 →  G7(13) 3-x-3-0-0-0

Clearly there is movement; they are different chords. If you see a 13th chord in a pop music chart, know that it is really a 7(13).

Some easy V7(13) to I resolutions on guitar (with the 3rd kept on top)

  • A7(13) x-0-5-6-7-xD x-x-0-2-3-2
  • G7(13) 3-x-3-0-0-0C x-3-2-0-1-0
  • D7(13) x-5-4-5-0-xG 3-2-0-0-0-x
  • E7(13) 0-5-6-6-x-xA x-0-2-2-2-x

About the Eleventh (and its third)

As I mentioned, 11th chords almost never have the 3rd present*. You will almost never hear a B in a G11 chord. Some people write these as F/G, and, for voicing purposes this OK, but I dislike the notion that G11 should be thought of as an F chord. 1) it has a D in it. We could write it as F6/G or Dm7/G, but that’s taking us down the wrong path. 2) “G11” gives the reader a better impression that the chord will resolve to (and that our key is) major C.

*So it might really be a 9sus4, but writing it is as 11 seems a less egregious error than writing 7(13) as 13.

AFA Leader Would Like to Fix Gays by Force of Law

I support the American Family Association’s right to pay for the Tebow ad—Americans have no right to not see promotions of ideas they might disagree with—but the AFA’s new leader, Rev. Bryan Fischer, should be watched. He has an interesting idea to fix a country that’s so broken that gays can…continue to exist: Fischer suggests we legally force all “active homosexuals” through an “effective reparative therapy program”.

Did your stomach just turn a little? Classically Liberal gives this the skewering it deserves, pointing out the necessary costs to taxpayers, to civil liberties, and the innocents caught up in the eventual SWAT raids. Don’t think for a moment there wouldn’t be raids. The war on drugs has gradually eroded away quite a bit of the privacies and 4th Amendment protections that could be expected in the earlier days of the war on gays. If you gotta catch ’em in the act, no knock warrants would be the norm. Oh, but what a new industry we could build on fixing gays—there’s a lot of em and more every year!

I eagerly await to read Fischer’s proposed law. Who would set the standards for these programs? What would suffice as proof of efficacy? Would the desire for non-traditional sex with the opposite sex be considered satisfactory or still in need of repair? What would be the penalty of “failing to stop acting gay”? Indefinite therapy? Body chemistry experimentation? Jail time? If a gay is homosexually assaulted in jail, would that get him/her more therapy, more jail-time, or both? Would we re-open the previous research done on gays in asylums and institutions? If gay sex is an offense, would we not need to label them all “sex offenders”?

The whole notion is thoroughly disgusting. Classically Liberal points out—if we’re to make our laws truly consistent with the guiding passages—surely there will be goodies for straight people, too.

The alleged Pauline verse also says that this applies to “whatever else is contrary to sound doctrine.” I suppose we will need courts to determine “sound doctrine” from unsound doctrine. And, I know people like you well, I grew up with you guys and went to your schools. So I know that by unsound doctrine you mean, and this is only a partial list: Mormons, Catholics, Jehovah’s Witnesses, Christian Scientists, Spiritualists, Scientologists, Quakers, Shakers, Unitarians, Muslims, humanists, Hindus, Buddhists, Sikhs, Taoists, Christadelphians, and hundreds of other sects, cults and churches. Even the mainstream Protestants aren’t of “sound doctrine” in the eye of fundamentalists. Once “sound doctrine” is put under federal law there is no limit to who can be incarcerated in your moral America.

And in case he missed anyone: anyone having had engaged in premarital/extramarital/oral/anal sex, of course. If we’re truly going to protect the American Family, we’re going to need to break down a lot more doors.