pifantastic
09-09-2008, 12:09 AM
So I was bored the other day and decided it would be cool if I could control my 32 channel Olsen 595 with my MIDI keyboard.
I've gotten pretty far, in fact, I have the lights lighting up when I hit keys, but I'm getting really weird behavior. I was hoping that someone out there with some C# knowledge could help me debug this piece of code.
This function should take an integer array and output it to the parallel port. Each slot in the keys array represents a channel on the board, and the value represents the velocity of the key.
int clockhi = 1; // bin 00000001
int clocklo = 3; // bin 00000011
int latchhi = 2; // bin 00000010
int latchlo = 3; // bin 00000011
try
{
for (int x = 0; x < 32; x++)
{
Output(888, (keys[x] > 0) ? 1 : 0);
Output(890, clockhi);
Output(890, clocklo);
}
Output(890, latchhi);
Output(890, latchlo);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
Whenever I tickle the ivories, I get random keys lighting up and eventually no channels will work. Any ideas?
Let me know if I need to give more information.
I've gotten pretty far, in fact, I have the lights lighting up when I hit keys, but I'm getting really weird behavior. I was hoping that someone out there with some C# knowledge could help me debug this piece of code.
This function should take an integer array and output it to the parallel port. Each slot in the keys array represents a channel on the board, and the value represents the velocity of the key.
int clockhi = 1; // bin 00000001
int clocklo = 3; // bin 00000011
int latchhi = 2; // bin 00000010
int latchlo = 3; // bin 00000011
try
{
for (int x = 0; x < 32; x++)
{
Output(888, (keys[x] > 0) ? 1 : 0);
Output(890, clockhi);
Output(890, clocklo);
}
Output(890, latchhi);
Output(890, latchlo);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
Whenever I tickle the ivories, I get random keys lighting up and eventually no channels will work. Any ideas?
Let me know if I need to give more information.