Show Posts
Pages: [1]
1  Using Arduino / Audio / Re: Piezo MIDI Drums on: April 24, 2013, 10:14:14 am
by delay I mean time between hitting the drum pad and sound from PC.
yep, I tryed serial monitor and problem seems to be in MIDI chain in PC
and it cannot be fixed easy i think smiley-grin I tryed combinaton of more SW but nothig worked :/

thanks anyway smiley

and one more problem, why it doesnt work with two midi msg at the same time? when i hit 2 pads simultaneously, plays only one or none.
2  Using Arduino / Audio / Piezo MIDI Drums on: April 23, 2013, 10:46:46 am
Hi I could use some help.
I have simple MIDI drums based on piezo sensors. I use this code:

int piezo1 = A0;
int piezo2 = A2;
int piezo3 = A4;
int piezo4 = A6;
int piezo5 = A8;
int threshold = 500; 
int sensorReading = 0;
int val,oldcas;

void setup() {

 
  pinMode(piezo1, INPUT);
  pinMode(piezo2, INPUT);
  pinMode(piezo3, INPUT);
  pinMode(piezo4, INPUT);
  pinMode(piezo5, INPUT);
  Serial.begin(57600);     

}

void loop() {

  //////////////////CRASH////////////////

  sensorReading = analogRead(piezo5);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo5) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo5) / 8;
      }
    }
   
    MidiTX(144, 1, val);
    MidiTX(128, 1, val);
  }
 
  //////////R-TOM////////////////////
 
    sensorReading = analogRead(piezo4);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo4) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo4) / 8;
      }
    }
   
    MidiTX(144, 2, val);
    MidiTX(128, 2, val);
  }
 
  ///////////////SNARE////////////////
 
    sensorReading = analogRead(piezo3);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo3) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo3) / 8;
      }
    }
   
    MidiTX(144, 3, val);
    MidiTX(128, 3, val);
  }
 
  ///////////////L-TOM/////////////
 
    sensorReading = analogRead(piezo2);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo2) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo2) / 8;
      }
    }
   
    MidiTX(144, 4, val);
    MidiTX(128, 4, val);
  }
 
  //////////////HI-HIT/////////////////
 
 
    sensorReading = analogRead(piezo1);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo1) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo1) / 8;
      }
    }
   
    MidiTX(144, 5, val);
    MidiTX(128, 5, val);
  }
}

void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)
{
  Serial.write(StatusByte);
  Serial.write(Note);
  Serial.write(Val);
}

with virtual MIDI port loopbe1 , Serial - MIDI converter V2D (by Mark Demers - Spikenzielab.com) and Battery 3 as sample player. but audio from battery is delayed. I tryed another SW with Battery 3 ( Maple Virtual Midi Cable as virtual midi port and Hairless MIDI<->Serial Bridge as converter ) but ther is still delay.

where is problem??
3  Using Arduino / Sensors / Re: Piezo MIDI Drums on: January 19, 2013, 02:03:12 pm
now it works almost fine. there is one problem with latency. I hit the piezo, but sound is delayed by  500 milliseconds approx. do you think that problem is with converter or virtual midi interface or software that plays samples?

code:

int ledPin = 12;
int piezo = A0;
int threshold = 200; 
int sensorReading = 0;
int val,oldcas,cas;

void setup() {

  pinMode(ledPin, OUTPUT);
  pinMode(piezo, INPUT);
  Serial.begin(57600);     

}

void loop() {

  //    SNARE

  sensorReading = analogRead(piezo);

  if( sensorReading > threshold ) {
    oldcas = millis()+5;
    while(analogRead(piezo) > threshold)
    {
      if(millis()==oldcas)
      {
        val = analogRead(piezo) / 8;
      }
    }
    /*Serial.println(val);*/
    MidiTX(144, 0, val);
    MidiTX(128, 0, val);
  }
}

void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)
{
  Serial.write(StatusByte);
  Serial.write(Note);
  Serial.write(Val);
}

4  Using Arduino / Sensors / Re: Piezo MIDI Drums on: January 09, 2013, 05:24:54 pm
thanks Krodal, I tried that timing, and it seems to work.

int ledPin = 12;
int piezo = A0;
int threshold = 200; 
int sensorReading = 0;
int val,oldtime,time;

void setup() {

  pinMode(ledPin, OUTPUT);
  pinMode(piezo, INPUT);
  Serial.begin(57600);     

}

void loop() {

////////////////////SNARE/////////////////////////////////////////////
  oldcas = millis()+10;
 
   sensorReading = analogRead(piezo);
  if( sensorReading > threshold ) {
   
   
    while(analogRead(piezo) > threshold) {
    time = millis();
      if(time==oldtime) val = map(analogRead(piezo), 0,1023, 0, 127);
       
    }
 
    MidiTX(144, 0, val);
    MidiTX(128, 0, val);
  }
      }
   

void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)
{
  Serial.write(StatusByte);
  Serial.write(Note);
  Serial.write(Val);
}
5  Using Arduino / Sensors / Re: Piezo MIDI Drums on: January 08, 2013, 03:29:12 pm
nop. only multimeter
6  Using Arduino / Sensors / Re: Piezo MIDI Drums on: January 07, 2013, 10:27:46 am
I measured it and max was something about 3.3V
7  Using Arduino / Sensors / Re: Piezo MIDI Drums on: January 07, 2013, 10:22:20 am
yop, I have parallel 1MOhm and serial diode to evade negative pulses
8  Using Arduino / Sensors / Piezo MIDI Drums on: January 07, 2013, 09:20:09 am
Hi everybody,

This piezo midi drums are my school project. For now I have just one "drum". My Arduino sends a signal to Serial to MIDI Coverter then via LoopBe1 to Native Instruments:Traktor.
I have one serious problem. When I hit the piezo I get multiply values, sometimes it's even 20 values smiley-eek . Program should search for maximum value
I hope you can help me.
here is my code:

int ledPin = 12;
int piezo = A0;
int threshold = 100; 
int sensorReading = 0;
int i=0,MAX=0;

void setup() {

  pinMode(ledPin, OUTPUT);
  pinMode(piezo, INPUT);
  Serial.begin(57600);     

}

void loop() {

 sensorReading = analogRead(piezo);   


  if (sensorReading > threshold) {

    while(sensorReading > threshold){

      if(sensorReading > MAX)

        MAX=sensorReading;
      else {   
        i++;

        /*analogWrite(ledPin,MAX);
        MidiTX(176, 0, 127);*/

        Serial.println(MAX);
        Serial.println(i);
        Serial.println("\t");
        Serial.println("TUC");
        break;
      }
    }

  }

  MAX = 0;
  digitalWrite(ledPin, LOW);
  delay(20);
 
/*void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)
{
  Serial.write(StatusByte);
  Serial.write(Note);
  Serial.write(Val);
}
*/
Pages: [1]