Thursday, 14 September 2006

A little step behind

For anyone interested into Powerglove hacking, here follow the hardware modifications required.

The idea is to modify the 7-poles connector of the glove to became a standard parallel interface.
You can achieve this by soldering the wires as described in the scheme on the right. As you can see, the glove's circuitry requires an external +5V alimentation that is NOT provided by the parallel port.

You can obtain it from the PS2 keyboard connector, or from the floppy drive power chord. The glove I bought on eBay was previously modified for PC use, so I restored the connections. The original owner did the soldering directly on the board of the glove itself, using the parallel port cables to bring the +5V directly on the circuit. Check out the picture!

On the other side, I soldered the three wires at the port as described, and the fourth to the +5V power supply.

That's it! Ready to rumble!!

Tuesday, 12 September 2006

Multithreading in C++

The Powerglove periodically squeezes out its datas. One way to keep the informations up-to-date is to delegate the readings of its status to a separate thread, which stores data in a circular buffer. This can be achieved with the multithreading tecnique: one process but more than one separate, and virtually parallel, thread of execution. It's gonna be my "producer".

The "consumer" will be the main procedure, which will obtain the deglitched coordinates with specifically concurrent methods. I'm wondering if a separate thread for the MIDI could be useful.

Btw, for anyone who'd like to write multithreaded classes, here's my snippet:


void threadFunc() {
  // actual thread routines
}

void launcher()
{
  // you can pass useful parameters to the thread using this variable
  long * param;

  // the "threadID" variable will contain the reference of the created thread
  DWORD threadID;

  // the NULL and the zeros are additional features of the syscall
  // check out references for further info
  // they're not needed for a simple thread creation
  HANDLE ret = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) threadFunc, param, 0, &threadID);
}

Saturday, 9 September 2006

Powerglove as MIDI device


A second attempt. This time I gave more throttle via scheduler: the latency is really better now!

Priorities in Win32

I found that increasing process priority is a nice (asd) way to improve performances of my Powerglove, expecially on less powerful machines.

The glove itself produces trains of data at ~500hz: casts ten bytes and then waits 2ms. Too bad, I couldn't leave the scheduler the privilege to subtract more time.

What follows is a short C function to change priority of the running process:


void prioritizza(DWORD value) {
// PID of this process
int processID = GetCurrentProcessId();

// handler of this process
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, processID);

// actually sets priority
SetPriorityClass(hProcess, value);
};


Remember to include "windows.h" , for many structures and constants are defined there.

In the end, as values, I used the constant HIGH_PRIORITY_CLASS. Here follow the constants you could use in your own programs:
  • IDLE_PRIORITY_CLASS
  • BELOW_NORMAL_PRIORITY_CLASS
  • NORMAL_PRIORITY_CLASS
  • ABOVE_NORMAL_PRIORITY_CLASS
  • HIGH_PRIORITY_CLASS
  • REALTIME_PRIORITY_CLASS
As you could imagine, they are ordered by increasing performance.

Tuesday, 5 September 2006

Using Powerglove as MIDI controller?

I modified a Powerglove to use it on PC via parallel port; using C++ I programmed it for translating the detected spatial coordinates into MIDI messages. Now I'm gonna optimize the software in order to play synth with my band Simmetry.

As you can see from the footages, my software suffers latency. Maybe it's due to the low-level MIDI programming, instead using DirectX, and the error correction routines which waste several milliseconds.