the thief (pitch -> midi app)
one of my clients is a sax player who also plays synths for his band. he wanted me to find some way for him to control his synths (hardware or software) with his saxophone. we discussed the ewi controller, and decided that this was unsatisfactory as a solution, due to his use of falsetto and multiphonics. he also felt that the ewi controller wouldn’t be as comfortable as using his own familiar sax and reed. as a result, i wrote him a simple software solution that would read in pitch and amplitude values from the soundcard, and output midi values. the resulting software is super light-weight and ready to be deployed on a number of hardware configurations. it’s also completely modular and networkable. the working title for this guy is ‘the thief’.
currently, this software only runs in osx. >_< . i may eventually port it to linux, but if you’re running windoze, good luck to you. you will also need a soundcard (most computers these days have *some* kind of audio interface), and if you want to get fancy you should have a microphone.
this patch is not a single piece of compiled software that runs like a self-contained black box. rather, it is a system comprised of several programs networked together to provide a single service. so, in order to run this patch you will need the following (don’t worry, they’re all free):
occam, a lightweight midi client that speaks osc
supercollider, my development environment of choice for realtime audio
something to control with midi. this could be a hardware synth (if you have the appropriate cables), or ableton, logic, ardour, reason, whatever. choose your poison.
once you have these things installed and ready on your box, we can talk about the implementation. my source code is below. to run this code, paste it into a new window in supercollider, select the entire document, and press . note that is not . you should see the little server window on the bottom left boot up, some crap print to the post window, a hideous grey gui pop up, and occam open up. on the top part of my hideous grey gui there are two black buttons. one has a green [>], and one has a red . pressing the green [>] will turn it on, while pressing the red  will turn it off. hopefully that convention is obvious. there is also a single long slider with a number box next to it. you may type into the number box or you may move the slider with your mouse. this controls the rate at which new midi notes are sent to occam.
this patch simply analyzes audio for pitch and amplitude at a regular interval, and sends this data out as osc to occam, which converts it into midi. i chose this model instead of something more complex (that could, say, encode arbitrary audio into discreet midi notes) because i was hired to come up with a specific solution to my client’s problem, not a general solution to all midi-related problems. if you are so inclined, please take my code and do whatever you want with it, so that it will suit your needs. all that i ask is that you inform me and credit me.
and with that, here’s the code.
* * *
a few lessons stick out to me from this first development cycle.
1) i am reminded not to think like an engineer.
no offense to engineers– you guys are very important! i’m just not one of you. my methods are generally faster, more improvisational, and way less general. i spent considerable time banging my head against a wall trying to make my solution work in all cases. this was wrong.
2) working with clients can be rewarding in ways that doing your own work isn’t.
i now remember the midi spec.Â i never use midi and honestly it makes me seasick.Â as the result of this project, however, i’ve learned a lot about implementing solutions that use it. a major lesson regarding midi is that supercollider’s midi output implementation is a total joke. another one is that osculator, a fairly highly regarded osc-midi client, is also a total joke. occam is the lightest, fastest, simplest midi client i’ve found. another major lesson? i learned how to use the scary ‘environment’ window in logic. it totally looks like max! which makes me want to vomit. regardless, these lessons will definitely prove useful to my freelancing and for my own projects.
3) sometimes walking a noob through your algorithm is the best way to debug it.
one night, when i was particularly frustrated with trying to do the impossible with my app, i vented by trying to explain how horrible my life was to my roommate, who despite some familiarity with supercollider is definitely not a programmer. this turned out to be the most useful few hours i spent on the project, not because we happened upon a new algorithm, but because it gave me the confidence i needed to let go of the grand vision in favor of something more realistic. also debugging was thereafter a snap because i knew the algorithm like the back of my eyelids.
keep in mind this is the first iteration on this thing. i’ll be working on some other features, such as microtonal tracking, and the now-infamous “arrogance” knob. when i’ve brought this project up in conversation, there have been a few musician / producer types who really perked up. i want you cats to try this out, and complain to me about it! the more you complain, the more likely i will be to listen to you. also if you are a musician / producer / developer type, and you want to steal my code, please do that! but let me know so i can steal your code too. ^_^ happy tweaking!
ps – i made a short track with this patch, just for laughs. it doesn’t really demonstrate the patch very well at all. something more demonstrative will come after i have a meeting with my client and we record some user testing. it’s the track from this post, using a fender mexican strat through a homemade fuzz pedal.