Nel maggio 2015 ho partecipato MIDI Hack
Se leggete un precedente mio articolo , si sa che io consiglio vivamente la piattaforma Arduino per fare controller MIDI fai da te. Ho scelto Arduino per questo progetto su altre piattaforme suggeriti in quanto fornisce con un sacco di controllo su ciò che si fa con i dati di ingresso / uscita, tuttavia è ancora estremamente principiante amichevole con un sacco di sostegno e guida ufficiale. Questa guida si rivolge a persone che sono principianti in elettronica, lo sviluppo del software, e Arduino.
Ecco una lista delle cose che hai bisogno per questo progetto. Tutti i componenti elettronici qui menzionati possono essere acquistati presso qualsiasi buon fai da te / hobbisti negozio di elettronica, come ad esempio SparkFun.
Prima di poter iniziare a inserire l'elettronica nel vostro piano, è necessario rimuovere le aste di suono, o modificarle in modo da poter montare le piezo a loro. L'insieme di barre in mio pianoforte stati avvitato alla parte inferiore della parte superiore, così ho semplicemente svitato per eliminarli e quindi avvitato in un blocco di legno che ho potuto fissare i sensori piezoelettrici a. Una soluzione alternativa potrebbe essere quella di fissare un pezzo piatto e sottile di materiale (ad esempio, cartone, legno) alla parte inferiore delle aste che i piezo può essere stabilito a, ma si possono trovare più difficile da attaccare qualcosa alle aste, più si possono anche trovare le aste avranno nel modo quando si tenta di inserire l'elettronica.
Da in alto a sinistra in senso orario
Un'altra modifica potrebbe essere necessario fare per il vostro pianoforte è l'aggiunta di un picco / punto sulla superficie del martello che colpirà i piezo. Se le testine martelli sono più larghe rispetto alla ristretta cerchia dei piezo non possono innescare i sensori correttamente, in modo di superare questo problema con il mio pianoforte ho registrato piccole sfere di saldatura sui martelli per creare un punto sollevato.
Noi ora posizionare i sensori piezoelettrici al lato inferiore della parte superiore del piano in cui i meccanismi martello sarebbero generalmente colpire le aste sonori quando vengono premuti i tasti. Se il piano è fatto a mano come la mia, probabilmente troverete che i martelli aren
Una volta che si
Per completare il circuito è necessario prima di collegare la basetta / s e Arduino all'interno del pianoforte. Se il piano si apre dal fondo come la mia ha fatto si avrà probabilmente bisogno di attaccare le tavole per la parte inferiore della parte superiore, se il piano si apre dall'alto probabilmente si potrebbe completare il progetto, semplicemente mettendo le tavole a fondo senza bisogno di attaccare giù. Posizionare la basetta / s più vicino ai piezo, con l'Arduino sull'altro lato.
Dopodiché è necessario per collegare i componenti alla basetta / s. Ci sono due sezioni principali per la maggior parte delle basette (come mostrato nella figura seguente)
Come mostrato nel diagramma precedente, per ogni tasto / piezo, il nero (massa) dal piezo deve essere collegato ad una delle strisce di bus a terra, mentre il filo rosso (segnale) deve essere collegato a uno dei terminali strisce. È quindi necessario collegare una resistenza (in qualsiasi orientamento) dalla morsettiera per la striscia di terra; un filo dalla morsettiera ad uno dei pin di ingresso analogici Arduino, e un altro filo dalla striscia terra ad uno dei pin di terra. È quindi necessario ripetere questo circuito per ogni piezo, utilizzando una morsettiera diversa e Arduino pin di ingresso analogico ogni volta, come mostrato nel seguente diagramma.
Mi consiglia di utilizzare diversi fili di colore per ogni connessione di ingresso analogico, in quanto ciò rende più facile vedere cosa
Dopo l'hardware e l'elettronica è completa, è quindi necessario caricare alcuni software per la scheda Arduino che trasformerà letture dei piezo in note MIDI. Una volta scaricato e installato sia il software di Arduino e il MIDI Biblioteca Arduino, aprire l'applicazione Arduino e copiare il codice qui sotto nell'editor di testo Arduino:
/* MIDI Toy Piano Hack Code */ #include MIDI_CREATE_DEFAULT_INSTANCE(); //======================================================================================== //Values you may need to change //Set this value to the number of keys/piezos you are using const int NUM_OF_KEYS = 16; //Adjust this value to change the sensitivity of the piezos const int THRESHOLD = 5; //Set this value to the number of microseconds you want each MIDI note to last for const int NOTE_LENGTH = 50; //Adjust this value to set the range of MIDI note velocity values const int VEL_SENSE_VAL = 2; //Change this number to set what MIDI channel the MIDI notes are set to const int midiChan = 1; //Change these numbers to set what MIDI note number each key/piezo will send. //Also make sure that the total number of numbers here matches the value of NUM_OF_KEYS const int midiNote[NUM_OF_KEYS] = {86, 84, 83, 81, 79, 77, 76, 74, 72, 71, 69, 67, 65, 64, 62, 60}; //Change these values to set which analog input pins you are using //Also make sure that the total number of values here matches the value of NUM_OF_KEYS const int triggerSensor[NUM_OF_KEYS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15}; //======================================================================================= //Variables for storing certain values int triggerVal[NUM_OF_KEYS] = {0}; bool noteIsOn[NUM_OF_KEYS] = {false}; int midiNoteTime[NUM_OF_KEYS] = {0}; int midiVelocityVal[NUM_OF_KEYS] = {0}; void setup() { MIDI.begin(MIDI_CHANNEL_OMNI); } void loop() { //repeat the below code for each anaolog input/piezo sensor for (int count; count < NUM_OF_KEYS; count++) { //read the piezo value triggerVal[count] = analogRead(triggerSensor[count]); //if the value is over the threshold and there isn't currently a note on for this piezo if (triggerVal[count] > THRESHOLD && noteIsOn[count] == false) { //get a velocity value based on the value midiVelocityVal[count] = triggerVal[count] * (127.0/1023.0); //increase sensitivity midiVelocityVal[count] *= VEL_SENSE_VAL; //make sure we don't go out of range if (midiVelocityVal[count] > 127) midiVelocityVal[count] = 127; //send a MIDI note-on message MIDI.sendNoteOn (midiNote[count], midiVelocityVal[count], midiChan); //flag that the note is on noteIsOn[count] = true; //start a timer for the note to be on for midiNoteTime[count] = NOTE_LENGTH; } //if the note is currently on if (noteIsOn[count] == true) { //reduce the time value by 1 midiNoteTime[count]--; //if time value equals 0 if (midiNoteTime[count] == 0) { //turn off the note MIDI.sendNoteOff (midiNote[count], 0, midiChan); noteIsOn[count] = false; } } } //pause the loop delay(1); }
Vi insegna come utilizzare il software di Arduino e come codificare è un po 'oltre la portata di questo articolo, in modo da
Una volta che si
Notare che
Infine, è necessario avviare e collegare tutto il software necessario sul computer:
Impostare una porta MIDI virtuale:
Se siete su Windows:
Se siete su OS X:
Collega Hairless MIDI-to-Serial Bridge per Arduino e la porta MIDI virtuale:
Si Collegare software dello strumento DAW / MIDI alla porta virtuale:
Si prega di notare - se il vostro Arduino è violato con HIDUINO, punti 1 e 2 don
Una volta che questo è stato completato si dovrebbe ora essere in grado di attivare le note dai vostri strumenti MIDI con il pianoforte giocattolo.
Guarda un breve video demo del pianoforte giocattolo controller MIDI acustico in azione:
Affinché
Inoltre, se siete interessanti a partecipare al prossimo evento MIDI Hack, tenere d'occhio il sito MIDI Hack per gli annunci. Ci sono anche un paio di simili hackathons Musica Tecnologia che si svolgono ogni anno in tutto il mondo, come Musica HackDay e Musica Tecnologia Fest, così come i vari one-off e gli eventi locali.
Per saperne di più su MIDI qui.
Discussion
You could connect a different type of sensor or electronic source and get results without changing the code, however it will only create a note based on the first reading it gets over the threshold (due to the logic implemented for turning piezo inputs into MIDI notes). Using just electrical current to trigger a reading would be very similar to using a simple push button (where pressing the button completes the circuit and creates a reading), so I'd recommend looking at Arduino button tutorials for that.
It sounds like your piezo sensors are not properly connected to the Arduino. Check that they are connected to the correct pins. You may also need to correct the value of NUM_OF_KEYS in the code if you are using less than 16 sensors/keys. You may also need to up the value of THRESHOLD in the code if your piezos are particularly sensitive.
thanks for answering me so fast , I'll check that the wires are connected correctly, I have another doubt about the code it in the end you said : "repeat the below code for each anaolog input/piezo sensor", and I 'm trying to do with a arduino uno with only 3 pins I changed all that you said , but the end I do not know where to get the code to be copied to each piezo I have and also do not know where it ends.
look I change this:
NUM_OF_KEYS = 3;
midiNote[NUM_OF_KEYS] = {86, 84, 83}
triggerSensor[NUM_OF_KEYS] = {A0, A1, A2}
IN THIS PART I WILL NEED TO PUT SOME NUMBER? -> (int count; count < NUM_OF_KEYS; count++)
Im sorry for all this question but im very lost with this and thank you so much for your help and sorry for my english.
Im from Brasil.
NUM_OF_KEYS, midiNote, and triggerSensor are the only values you need to change, which you have correctly done. The "repeat the below code for each anaolog input/piezo sensor" comment is actually a description of what the below 'for' loop does, rather than being an instruction. You shouldn't have to change any code in that section for it to work.
Thank you so much, this time again made ​​the piezos cables and worked, thanks for your help I buy one arduino mega
and when it comes I gonna do with the 16 piezos.
please let me ask you one more question?! can I put on this project potentiometers or one pitch bend?
Glad you got it working.
If you want to attach something like a potentiometer you'll need to change the code for reading from that particular analogue input. However the code needed here is a lot simpler - see https://www.arduino.cc/en/Tutorial/AnalogReadSerial to lean how to do this.
_____
#include
____
He's answering me this
#include
^
exit status 1
#include expects "FILENAME" or
Do you have an idea?
Thanks,
Florent
Thanks for the kind words and for spotting this mistake.
The code above has now been updated to the correct version.
Thanks,
Liam.
Project = allow young people to explore (play) the out-of-reach pipe organ from a wireless-midi capable keyboard.
So far... I have an arduino, a wireless midi transmitter/receiver (Medeli WIMIDI - tested and quite surprised by performance), a breadboard (cables, female midi socket etc).
I want to connect the wireless midi transmitter to the out socket of the remote keyboard and the wireless midi receiver to the arduino (I need to solder connect to arduino via breadboard). With the arduino midi library I presume I will then be able to receive the incoming midi signal ? This is where it becomes tricky for me to ascertain next steps!... I then want to translate the midi in to individual note signals (much like what you have done in this article). Is this possible?
If this is doable, my last sticking point is how to get the individual note signals 'transferred' to the organ console. I have seen an article where someone attaches a solenoid for each note to a wooden board and then rests the board over the top of the organ keyboard. However, the organ we are planning to work on already has access to the rear of the keyboard and each note has a visible switch (2 cables to each note) on a low voltage (12v) system. Is it possible to intercept each of these switches with the arduino outputs for each note? My apologies if this is a stupid question!?
This is an awesome tutorial. It'll help me a lot with what I want to do cause the setting is similar but usage is completely different.
I wonder if the amount of the contact mics can be different? Is there any maximum we can connect?
Also, is it possible to use condenser mics instead of piezos, possibly with a little trick?? Otherwise do you have any suggestions of how I can do it?
Thanks a lot!
The number of piezo sensors you can connect depends on the number of analog inputs that your microcontroller has e.g. on an Arduino Mega you have 16 analog inputs. However it is possible to expand this number using multiplexer components - see https://playground.arduino.cc/Learning/4051. There are also Arduino IO expander shields that can do this for you.
Regarding using consider mics instead, the extra complexity depends on whether you are just trying to detect a sound level, or trying to capture actual sound data. For just detecting sound levels see http://www.learningaboutelectronics.com/Articles/Arduino-microphone-circuit.php as an example, however recording actual audio is more complex (e.g. see http://www.instructables.com/id/Arduino-Audio-Input/).
Thanks a lot for your answer.
I have an Ard.Mega and I indeed only need to use them to retrieve vibration data - not sound.
Do you think I can use your setup the same, but differ the code to make it receive only vibration level - say from 0 to 100? In that case, would you mind sharing how the code shall be?
Many thanks.
I had a question. You used 18 piezo. But the Arduino mega allows only 16 input. What ambi missing?
""""const int THRESHOLD = {5,6,8,4,2,5,7,8,5,6};""""
What is the highest treshold value ?
Can you please tell me how i can separately change treshold, and limit the maximum & minumum velocity of each individual piezo?
If possible, write me another command line where i can adust the time amount for the gap between two stroke to avoid double triggering problem.
Thank you.
The highest value a piezo sensor can send using an Arduino is 1023, so threshold values could be anything up to this.
If you just want to 'clip' limit the velocity value, you could change the values on lines 'if (midiVelocityVal[count] > 127) midiVelocityVal[count] = 127;' to set a lower max value, and you could do the same kind of thing for the minimum limit e.g. 'if (midiVelocityVal[count] < 10) midiVelocityVal[count] = 10;'.
To limit how often a stoke can happen you could use the Arduino Millis Library (https://www.arduino.cc/en/Reference/Millis) to store a time for every stoke and then only process a new stroke if it's time is greater than the last time by a certain amount.
I saw padcycles in some sketch. I think it's about avoiding double triggering. I am not sure though. I tried Google. Didn't get enough learning about that term.
I have been playing my DIY arduino midi drum for a year.
your code works flawlessly. Recently i have decided to use a foot switch instead of using 2 separate pads for closed & open hat.
I use Arduino meda...Can you please guide me how the momentary switch should be wired to my arduino ?
And what modification i have to make into my current code for activating the switch functionality ?
My current Code is given below...
/*
Midi drum ..with 10 piezo.. no pedal(2 separate pad with 2 separate piezo for closed hat and open hat), Kick,snare, open hat, closed hat, tom1, tom2, tom3, crash1, crash2, ride
*/
#include
MIDI_CREATE_DEFAULT_INSTANCE();
//========================================================================================
//Set this value to the number of keys/piezos you are using
const int NUM_OF_KEYS = 10;
//Adjust this value to change the sensitivity of the piezos
const int THRESHOLD = 10;
//Set this value to the number of microseconds you want each MIDI note to last for
const int NOTE_LENGTH = 50;
//Adjust this value to set the range of MIDI note velocity values
const int VEL_SENSE_VAL = 10;
//Change this number to set what MIDI channel the MIDI notes are set to
const int midiChan = 1;
//Change these numbers to set what MIDI note number each key/piezo will send.
//Also make sure that the total number of numbers here matches the value of NUM_OF_KEYS
const int midiNote[NUM_OF_KEYS] = {36, 38, 60, 61, 49, 52, 48, 47, 43, 84};
//Change these values to set which analog input pins you are using
//Also make sure that the total number of values here matches the value of NUM_OF_KEYS
const int triggerSensor[NUM_OF_KEYS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,};
//=======================================================================================
//Variables for storing certain values
int triggerVal[NUM_OF_KEYS] = {0};
bool noteIsOn[NUM_OF_KEYS] = {false};
int midiNoteTime[NUM_OF_KEYS] = {0};
int midiVelocityVal[NUM_OF_KEYS] = {0};
void setup()
{
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(115200); //REMOVE THIS LINE IF USING HIDUINO INSTEAD OF HAIRLESS
}
void loop()
{
//repeat the below code for each anaolog input/piezo sensor
for (int count; count < NUM_OF_KEYS; count++)
{
//read the piezo value
triggerVal[count] = analogRead(triggerSensor[count]);
//if the value is over the threshold and there isn't currently a note on for this piezo
if (triggerVal[count] > THRESHOLD && noteIsOn[count] == false)
{
//get a velocity value based on the value
midiVelocityVal[count] = triggerVal[count] * (127.0 / 1523.0);
//increase sensitivity
midiVelocityVal[count] *= VEL_SENSE_VAL;
//make sure we don't go out of range
if (midiVelocityVal[count] > 127)
midiVelocityVal[count] = 80;
//send a MIDI note-on message
MIDI.sendNoteOn (midiNote[count], midiVelocityVal[count], midiChan);
//flag that the note is on
noteIsOn[count] = true;
//start a timer for the note to be on for
midiNoteTime[count] = NOTE_LENGTH;
}
//if the note is currently on
if (noteIsOn[count] == true)
{
//reduce the time value by 1
midiNoteTime[count]--;
//if time value equals 0
if (midiNoteTime[count] == 0)
{
//turn off the note
MIDI.sendNoteOff (midiNote[count], 0, midiChan);
noteIsOn[count] = false;
}
}
}
//pause the loop
delay(1);
}
I want to add a momentary switch as a foot pedal which will triggers note between 61 & 60 ( Closed & open HiHat). Thank You
Want to join the discussion?
Create an account or login to get started!