# Keyboard Gremlins

I had a great time playing [Amherst](http://amherstcontra.org/Amherst_Contradance/Home.html) last night [with](https://www.kingfisherband.com/) [Cecilia](https://www.ceciliavacanti.com/), except for the keyboard gremlins. I just got a new keyboard (more on that later!) and it worked great when I tried it at home. At the dance, however, there were strange crackles. Even weirder, when I played the highest notes on the piano, I got a very small amount of phantom bass, maybe four octaves down. It got louder and quieter, as I turned the keyboard up and down or played at different volumes, and if I turned down the volume on the keyboard it went away. MIDI output, which is a key part of my [rhythm stage setup](https://www.jefftk.com/news/jammer), was totally clean.

I was really very confused. I thought maybe this keyboard didn't have good enough electrical shielding, and having my little stage computer velcroed to the keyboard might be causing it? In support of this theory, turning off the little computer did fix it. But moving the little computer to the floor, where it should not have been able to generate meaningful interference, did not. After trying a lot of things, I eventually realized that disconnecting the MIDI cable was enough to fix it.

This is one of the main differences between this keyboard and my previous one: it's USB MIDI instead of 5-pin MIDI. But I had used my system with USB MIDI before, with no issues. It was really frustrating, and I was baffled. I took a video:

This evening, I tried to reproduce it. The same setup as I had on stage did trigger the issue. Connecting it to my laptop, however, did not trigger the issue. So probably not a keyboard problem, and instead some thing my little stage computer is doing.

I thought maybe I was sending MIDI back out, which should never have previously mattered because I never used to connect the MIDI cable in the other direction. I started installing `tshark` to debug, when I realized the problem:

My little box is set up to do two things:

*   If it detects it is being used as a [MIDI router](https://github.com/jeffkaufman/jammer), it routes MIDI and synthesizes audio. This is triggered by noticing that MIDI devices are connected.
    
*   If it detects, it is being used as a [bass whistle](https://github.com/jeffkaufman/whistle-synth), it interprets audio and generates bass. This is triggered by noticing certain soundcards being connected, ignoring both the built-in one and the one I use in MIDI routing mode.
    

In this case both of these conditions were met. I was using it as a MIDI router, but also the new keyboard presents itself to the computer, among other things, as a USB audio device suitable for bass whistling. When I played high notes on the keyboard they were being sent out as MIDI, but they were also being sent out as USB audio, which was going into my bass whistle logic. If the note was in the same range as my whistling, it would dutifully transpose it down four octaves and send it back out via the same device, the keyboard, and from there to the hall sound system on the keyboard channel. The crackles are something the whistle sometimes does when it is sufficiently confused about its input.

What makes this especially unfortunate is that I have completely moved on from ever using my little box for bass whistle. Instead, I have an [arduino-based system](https://www.jefftk.com/p/embedded-whistle-synth), which I like a lot. The fix turned out to be just disabling the bass whistle code I should have removed a while ago. No more gremlins!

*Comment via: [facebook](https://www.facebook.com/jefftk/posts/pfbid02nwHGJXQettsapHyFXj6ESGwPBxZA156YAk2B2KSZ92Ww1hLJ8ybrVGj1LzR8cJ1Hl), [mastodon](https://mastodon.mit.edu/@jefftk/113167497961302696)*