Ok. I am still waiting for the stuff to arrive. Meanwhile i have been looking at the arduino code SpikenzieLabs provide with this kit, and modified it in such a way that it to the best of my understanding now should send a signal via ttymidi each time a piezo is being struck above its sensitivity threshold and the note is not already playing.
Sensitivity adjustments and playtime limit must be figured out after assembly.
Also it would be interesting to have the note value output of one of the instruments change as a response to a digital button input so that it would be possible to have both open and closed hi-hat on the same drum, controlled with a pedal, like real drums work. This should be a piece of cake.
The code after first glance and slight modifications:
#include <ardumidi.h> //Midi library from ttymidi
//*******************************************************************************************************************
// User settable variables
//*******************************************************************************************************************
unsigned char PadNote[6] = {36,37,38,39,40,41}; // MIDI notes from 36 to 41 (the six first drums of Hydrogen)
int PadCutOff[6] = {600,600,600,600,600,600}; // Minimum Analog value to cause a drum hit
int MaxPlayTime[6] = {90,90,90,90,90,90}; // Cycles before a 2nd hit is allowed
#define midichannel 0; // MIDI channel from 0 to 15 (+1 in "real world")
//*******************************************************************************************************************
// Internal Use Variables
//*******************************************************************************************************************
boolean activePad[6] = {0,0,0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[6] = {0,0,0,0,0,0}; // Counter since pad started to play
unsigned char status;
int pin = 0;
int hitavg = 0;
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
Serial.begin(115200); // connect to the serial port 115200
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop()
{
for(int pin=0; pin < 6; pin++)
{
hitavg = analogRead(pin); // read the input pin
if((hitavg > PadCutOff[pin]))
{
if((activePad[pin] == false))
{
// hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)
hitavg = (hitavg / 8) -1 ; // Upper range
midi_note_on(0,PadNote[pin],hitavg);
PinPlayTime[pin] = 0;
activePad[pin] = true;
}
else
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
}
}
else if((activePad[pin] == true))
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
if(PinPlayTime[pin] > MaxPlayTime[pin])
{
activePad[pin] = false;
midi_note_off(0,PadNote[pin],127);
}
}
}
}
I was utterly pleased after noticing how easy it was to get the button to control Hydrogen output yesterday. Huge thanks are due to the publisher of ttymidi!
If this works well, I would also be intrigued about adding more drums to the equation, but i would require more analog input pins. Is there a way to expand the Duemilanove, or will i have to buy a Mega?