BeepSex: TranceVibrator Patch for Max/MSP

Thanks to Ganucheau for poking me into playing with this in the first place.

Update 2013-05-25: Most of the code listed in this article now lives on my github, http://github.com/qdot/np_trancevibe. For drivers, use libtrancevibe: http://github.com/qdot/libtrancevibe. Links to old code are left intact in article but will most likely not work.

Beepy Shit

Mmmmm lordy, do I love the beepy shit. Most of the music I listen to these days can be defined as such. I've moved beyond instruments, beyond vocals, to the point where I can be completely happy listening to something that most people would mistake for a broken CD player being fisted by angry robots. It's with that interest in mind that I'm starting up the BeepSex portion of Slashdong.

Now, I'm assuming many of the readers of this page are familiar with techno, electronica, glitch, IDM, or whatever the hell else you want to call it. If not, welcome to the world of good music, you fucking luddite. Put that neandrathal acoustic guitar away and pick up a sequencer, 'cause you're on the bullet train to modern elitest, obscure, inaccessible music!

Seriously, if you aren't familiar with types of electronic music and actually care to read up, the best place to go is Ishkur's Guide to Electronic Music. It's a nice overview of all of the hojillion genres available in electronic music today. Most of the sarcastic comments in these entries will refer to the Glitch and IDM genres, as that's what I know more than you about.

Autechre button-pushing performing.

So, why have a section of a sex tech website dedicated to audio software interfacing? Simple. Ever been to an IDM show? Boring as shit, ain't it? One, maybe two guys, a ton of laptops and racks, and zero performance value. Everyone nods asynchronously to what THEY believe is the proper time signature (music quality is judged by the number of head-nodding patterns observed in the audience, more is better, as it shows that there are multiple interpretations of the white noise music happening), possibly some side to side movement of the performers. Add a turntable and DJ to the mix, and it's fucking christmas for those of us brave enough to leave our bedrooms and mailing list arguments long enough to go to a tiny, tiny, tiny room to see the show.

In other words, the majority of electronic shows blow. Bigtime.

BeepSex is an attempt to add a little bit of physical feedback to the music. During the original SeXBox articles period, we got quite a few emails from couples saying they enjoyed spending time together playing video games after building the SeXBox. Now, those significant others unfortunate enough to love someone who sits in front of a computer monitor for hours at a time fucking with waveforms when they could just as easily open their computer and kick it repeatedly while in close vicinity of a tape recorder can now be physically part of the grueling composition process.

Max/What?

I usually answer the question "What is Max/MSP, anyways?" with the answer "The shit. Totally."

Most people don't seem to like this answer very much.

Max/MSP is actually two things, so let's break it up.

Max is a visual programming language, created in 1986 as an environment for producing interactive music environments. In 1991, it was picked up by Opcode, and in 2000 changed hands to Cycling '74, who still owns it today.

The basic of Max are very, very simple. You have objects, and patch cables. Put the objects together, put patch cables in between them, and suddenly they can communicate to each other.

For example, the picture above is a very, very simple Max patch. The top object is a button. Whenever that button is pressed, it sends a "Bang" message across the patch cable to the Random object. When the Random object receives a Bang message, it generates a number between 0 and the argument given to it, in this case, 100. It then sends that number over the line to the Print object. The Print object prints the input received on the line to the Max Print Window. Eureka, we have a working Max Patch!

As you can see, programming in Max is very intuitive. No crazy syntax to remember (though value spread orders can get crazy, as they are dependant on the location of the object in the patch workspace), pictures you can drag instead of big boring text windows. Of course, what we just showed is rather simple. Actually, stupidly simple.

Real Max patches tend to look more like this (click the picture to see the fullsize version). That hurts my head.

So what does this have to do with music? That's where the MSP part comes in. MSP is a set of patches for audio construction and performance. Combined with the integrated MIDI functionality of Max, users can create mixers, software synths, and many other horribly complex things that boring violin players like me don't grok. There's also a patch set called Jitter that provides video manipulation patches. All of these patches can be used together to create complex audio/visual performance environments.

One of the great things about Max is the fact that you can load in External Objects. Using a freely available C SDK, you can write your own objects to insert directly into the Max workspace, meaning the development environment is almost infinitely extensible. And extend it we will!

Anyways, we'll let the artists make the pinko commie shit, we're here to engineer. Let's get to work.

Porting the TranceVibe to C

Our goal is to get a Windows Max object that will control a Rez TranceVibrator (Sorry Mac users, I swear I'll create a Mac version of the patch the second I get time to develop C TranceVibe code for the Mac). In a later article, we'll have it control a SexBox, but since there's a higher chance of people that playing with Max/MSP owning a Rez TranceVibrator, we're concentrating on that for the moment.

From the information in the earlier Rez TranceVibrator article here on Slashdong, we have C# source code and a driver DLL available. Since the DLL is in C, that means that C# is using basically the same calls a C program would to get to the juicy parts of the DLL. Yay for cross-language reusability!

You can skip this paragraph if you've already got your TranceVibrator working on your machine. Pick up the Trance Sharp Alpha utility. This has the INF and DLL file you'll need to use to install your TranceVibrator. Next, follow the instructions here on how to install the drivers for your TranceVibrator. Finally, assuming you've got the .Net Framework installed, run the TranceSharp program and make sure things vibrate.

Porting this to C is pretty simple. In fact, I'll just go ahead and list the source code here.

To compile the program, you'll need to link it with the uusbd.lib library in order to have the USB communications functions available. You can pick up the uusbd SDK by clicking here. To run the program, you'll need to have the uusbd DLL in either the same directory as the executable or in one of the designated DLL library paths.

TranceVibeC Source Code

The TranceVibrator wants a number between 0 and 255 to set the motor power with. So, for those of you that don't read C, this program takes a number from the command line, and feeds it to the TranceVibrator. If no number is passed, it just turns the TranceVibrator off. Please note that there's a ton of interesting and fun ways to crash the program, so don't go expecting to use it for everything, it's just a quick example to get this working in C.

Writing the Max/MSP Patch

Now that we have this working as a simple C program, we can start porting to the Max patch format. To do this, I gutted the plussz demo project that came with the Max/MSP SDK, divided up the code that we used in the prior program to get the TranceVibrator running, and pasted it to the proper functions in the patch code.

MaxTrance Patch Source Code

MaxTrance Patch Binaries

So, there's the code. Instead of taking our value from the command line input, we now take it from the bang event sent from whatever object is connected to the input of the MaxTrance event. Lots more work than just getting it from the command line, but it'll also be a lot cooler in the end, too. :)

Connecting it All Together

Ok, now that we have the patch together, we need to add it to Max and set up a control environment. We put the .mxe file into the patches directory of the Max/MSP install, and then select "Install" from the File menu. Select the new patch in the install file dialog, and you're ready to go!

Here's a picture of the demo patch we used.

This is just a slider bar with the output connected to a print statement and the MaxTrance object. Every time the bar is changed, it sends a Bang event over the output, which prints the value of the slider bar, and sets the motor speed of the TranceVibrator.

That's it! Max/MSP is now a sex toy controller.

Towards More Entertaining Beepy Shit Shows

There is now no excuse for there to be boring musical performances. You can hook sex toys up to this shit, for christ sake, so just hire some porn model to get on stage and offset your geeky, knob twiddling ass with some hawt sex0rz. It doesn't matter if you play the shittiest speedcore ever heard by man, I can guarentee people will show up, they just may not remember the performance for the 1000bpm earfuck you think is music.

Oh yeah, and if someone could tell me where to pick up the "l33t ae trickz" patch, that'd be awesome.