미디 컨트롤러 사용 아두 이노에 빈티지 장난감 피아노를 켜기

Could you turn a wooden toy piano into a MIDI controller? Could you do it in 24 hours? Liam Lacey did it at MIDI Hack 2015 in Berlin and won a prize too. Now you can make your own as Liam shares all.

2015년 5월에서 나는 참석 미디 해킹

MIDI Hack 2015. Photos by Sebastian Höglund.

당신이 읽는다면 내 이전 기사를 , 당신은 내가 매우 DIY 미디 컨트롤러를 만들기위한 아두 이노 플랫폼을 추천 것을 알게 될 것입니다. 그러나 나는 아직도 공식적인 지원과 가이드의 많은 매우 초보자 친절, 당신이 입력 / 출력 데이터로 무엇을 제어 많은 당신을 제공하기 때문에 다른 제안 된 플랫폼을 통해이 프로젝트를 위해 아두 이노를 선택했다. 이 가이드는 완전한 전자에서 초보자, 소프트웨어 개발, 아두 이노있는 개인을 목표로한다.

다음은이 프로젝트에 필요한 것들의 목록입니다. 여기에 언급 된 모든 전자 부품은 스파크 펀으로, 좋은 DIY / 취미 전자 제품 가게에서 구입하실 수 있습니다.

What You Will Need for this Project

  • 음향 나무 장난감 피아노. 나는 그러나 당신은 또한 때때로 자선 상점과 벼룩 시장에서 찾을 수 있습니다, 보통 몇 사용할 수가있는 경우, 약 $ 15 이베이 떨어져 내 장난감 피아노를 구입했다. 이 프로젝트는 키를 망치는 공진​​ 객체의 일종을 공격하게된다 메커니즘과 피아노를 기반으로한다; 장난감 전자 키보드를 사용하여 여기에 작동하지 않습니다.
  • 아두 이노 보드. 이 될 마이크로 컨트롤러
  • 압전 요소. 피에조 소자 센서는 진동과 노킹 검출에 사용하고, 인기 성분 DIY 및 상업용 드럼 트리거 제품에 특히 사용되어있다. 우리는 키에서 프레스를 감지하는 이들를 사용하고, 각 키에 대한 이들 중 하나가 필요합니다. 넌 피아노 내의 해머 헤드의 크기에 따라 필요한 피에조의 크기를 고려할 필요가있을 것이다
  • 1M 옴 저항. 저항기는 전기 회로의 가장 기본적인 구성 요소와 공통이며, 전기의 흐름에 저항하기 위해 사용된다. 각 키 / 압전에 대한 이들 중 하나가 필요합니다.
  • 전선. 아두 이노 또한 남성 - 투 - 남성 점퍼 선으로 알려져 브레드 보드 친화적 인 전선, 사용하기 쉬운 것입니다, 우리는 아두 이노에 모든 구성 요소를 연결하는이를 사용합니다. 당신은 여분의 각 키 / 압전뿐만 아니라 소수의 2가 필요합니다.
  • 솔더없는 밀가루 반죽. 솔더없는 밀가루 반죽은 당신이 모든 것을 함께 납땜 할 필요없이 전자 회로를 만들 수 있습니다. 당신은 당신의 장난감 피아노가 얼마나 많은 키에 따라 다음의 몇 가지를해야 할 수도 있습니다.
  • USB 케이블
  • 양면 접착 테이프
  • 아두 이노 소프트웨어. 아두 이노 소프트웨어는 우리가하고 싶은 일을 아두 이노 보드를 프로그래밍하는 데 사용됩니다. 이에 자유롭게 사용할 아두 이노 소프트웨어 페이지 및 OS X, 윈도우, 리눅스에서 실행할 수 있습니다. 또한 아두 이노 미디 라이브러리를 다운로드해야합니다.
  • -MIDI 직렬 및 가상 MIDI 포트 소프트웨어. 당신은 MIDI 메시지로 아두 이노에서 나오는 메시지를 변환하는 일부 직렬 - 미디 소프트웨어가 필요합니다. 그러나 나는 가능한 다른 사람의 숫자가, 직렬 Bridge 응용 프로그램에 무료 사나이 미디를 추천합니다. 당신은 또한 당신의 DAW 또는 MIDI 악기의 입력에 사나이의 출력을 연결하는 가상 MIDI 포트를 사용해야합니다. 이를 위해 나는 윈도우에 loopMIDI 추천, 또는 OS X의 당신은 내장 된 IAC 드라이버를 사용할 수 있습니다. 대안 적으로는 가능하다
  • 미디 소프트웨어. 당신

Step 1—Prepare your Piano

당신이 당신의 피아노에 전자 장치를 삽입 시작하기 전에 당신이 그들에 피에조를 탑재 할 수 있도록, 당신은 소리 봉을 제거하거나 수정해야합니다. 내 피아노에 봉 세트는 상단의 밑면에 나사했다, 그래서 나는 단순히 그들을 제거를 풀고, 다음 내가 피에조 센서를 고정 할 수 나무 블록에 나사. 또 다른 옵션은 그러나 당신이 더 어려워로드에 뭔가를 연결하는 찾을 수 있습니다, 피에조가 고정 될 수있다 막대의 아래쪽에 재료의 얇은 평면 조각 (예를 들어, 판지, 나무)을 해결하기 위해 수, 플러스 것 또한 전자를 삽입 할 때로드 길을 드릴 것입니다 찾을 수 있습니다.

왼쪽 위 시계 방향에서

당신이 당신의 피아노에 수행해야 할 수있는 또 다른 수정은 피에조을 칠 것이다 망치의 표면에 스파이크 / 지점을 추가하고있다. 해머 헤드가 제대로 센서를 트리거하지 않을 수 있습니다 피에조의 내부 원보다 넓은 경우, 그래서 제기 포인트를 작성 망치에 솔더의 작은 공을 녹화 나의 피아노와 함께이 문제를 극복하기 위해.

Step 2—Attach the Piezos

이제 키를 누를 때 해머 메커니즘은 일반적으로 사운드로드를 찍는 것 피아노의 상부의 밑면에 압전 센서를 배치한다. 피아노 내 같은 핸드 메이드 인 경우, 당신은 아마 망치는 때로 믿을 것을 발견 할 것이다

당신이 한 번

부착 된 압전 센서

Step 3—Complete the Circuitry

회로를 완료하려면 먼저 피아노의 내부에 브레드 보드 / s와 아두 이노 보드를 연결해야합니다. 피아노가 바닥에서 열립니다 광산처럼 당신은 아마 피아노 상단에서 열 경우 그러나 당신은 아마 고수 할 필요없이 바닥에서 보드를 배치하여 프로젝트를 완료 할 수, 상단의 밑면에 보드를 부착해야합니다 그 아래로. 다른 측면에서 아두 이노와 함께, 브레드 보드 / s의 가장 가까운 피에조에 놓습니다.

다음으로 브레드 보드 / s의 구성 요소를 연결해야합니다. 대부분의 밀가루 반죽에 두 가지 섹션 (다음 그림에서와 같이)가 있습니다

아두 이노 보드에 하나의 압전 센서를 연결하는 방법

이전 도면에 표시된 것과 같이 적색 (신호) 와이어 단자 중 하나에 접속 될 필요가있는 반면, 각각의 압전 / 키, 피에조로부터 블랙 (접지) 와이어는 접지 버스 스트립 중 하나에 접속 될 필요 스트립. 그런 다음 접지 스트립 터미널 스트립에서 (어떤 방향으로) 저항을 연결해야합니다; 아두 이노의 아날로그 입력 단자들 중 하나에 단자로부터 와이어 스트립 및 접지 핀 중 하나와 접지 스트립에서 다른 와이어. 다음 그림에서 설명 된대로 다음, 다른 터미널 스트립과 아두 이노 아날로그 입력 핀 각각의 시간을 사용하여, 각각의 압전이 회로를 반복해야합니다.

어떻게 아두 이노 보드에 여러 개의 피에조 센서를 연결하는

이 무엇을보고 쉽게 만들면서 나는, 각 아날로그 입력 연결을 위해 다른 색 와이어를 사용하는 것이 좋습니다

상단

Step 4—Edit and Upload the Code

하드웨어와 전자가 완료 후에는 MIDI 노트로 피에조에서 측정 값을 설정합니다 아두 이노 보드에 일부 소프트웨어를 업로드해야합니다. 당신이 다운로드 아두 이노 소프트웨어와 아두 이노 미디 라이브러리를 모두 설치 한 후, 아두 이노 응용 프로그램을 열고 아두 이노 텍스트 편집기에 아래 코드를 복사 :

/*
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);
}
        

방법 아두 이노 소프트웨어를 사용하는 방법을 교육하는 방법과 코드를하는 것은이 글의 범위를 넘어 비트, 그래서

  • NUM_OF_KEYS
  • 한계
  • NOTE_LENGTH
  • VEL_SENSE_VAL
  • midiChan
  • midiNote
  • triggerSensor

아두 이노 소프트웨어

당신이 한 번

  • 가다
  • USB를 통해 컴퓨터에 아두 이노 보드를 연결합니다.
  • 가다
  • 가다
  • 가다

주의 사항

Spotlight Courses

More courses released every few days.

Step 5—Connect the Software

왼쪽 : 직렬 브리지로 구성 사나이 MIDI : OS X의 우측 상단에 가상 MIDI 포트를 설정. 우측 하단 :을 Ableton 라이브의 가상 MIDI 포트에 연결합니다.

마지막으로 실행하고 사용자의 컴퓨터에 필요한 모든 소프트웨어를 연결해야합니다 :

가상 MIDI 포트를 설정합니다 :

당신은 Windows의 경우 :

  • loopMIDI을 엽니 다
  • 를 클릭
  • 응용 프로그램을 실행 남겨주세요

당신은 OS X의에있는 경우 :

  • 시작
  • 가다
  • 두 번 클릭
  • 있는지 확인
  • 응용 프로그램을 닫습니다

연결 사나이 미디 직렬 아두 이노와 가상 미디 포트 브릿지 :

  • 사나이 시작
  • 왼손 측 집합
  • 오른쪽 측면에서 설정
  • 확인
  • 응용 프로그램을 실행 남겨주세요

가상 포트에 당신에게 DAW / MIDI 악기 소프트웨어를 연결합니다

  • 당신의 DAW 또는 MIDI 악기를 시작합니다
  • 그 아래

당신의 아두 이노가 HIDUINO으로 해킹하는 경우, 1, 2 돈 단계 - 유의하시기 바랍니다

이 완료되면 당신은 지금 장난감 피아노와 미디 악기에서 노트를 트리거 할 수 있어야한다.

액션 음향 장난감 피아노 MIDI 컨트롤러의 짧은 비디오 데모보기 :

Conclusion

너무

당신이 다음 미디 해킹 이벤트에 참여에 흥미있는 경우 또한,에 눈을 유지 미디 해킹 웹 사이트에 공지합니다. 같은 음악 Hackday과 음악 테크 페스트로 전 세계 매년 개최되는 유사한 음악 기술 hackathons,뿐만 아니라 다양한 일회성 및 지역 행사의 몇 가지가있다.

여기 미디에 대해 자세히 알아보십시오.

Synthesis 101
The Filter
by Bob Moog Foundation

"Liam is the Head Of Development specialising in software development at Modal Electronics, the company behind the 002, 008, CRAFT and SKULPT synthesisers, and was previously the lead software developer at nu desine, the developers of the AlphaSphere MIDI controllers. He was also an Associate Lecturer at UWE, Bristol, UK where he gradua..." Read More

Discussion

Joe
How would the code change if I wanted to use something besides a piezo. What if I just wanted to turn the Arduino into a Makey Makey and connect electrical currents from the GND to A0.
Liam Lacey
Hey Joe,
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.
Michel Mariano
when I put the code in my arduino notes repeatedly play without stopping and I do not touch any key how do I resolve this error I think it's the end I am not able to understand. please help me.
Liam Lacey
Hey Michel,
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.
Michel Mariano
Hey Liam,

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.
Liam Lacey
Hey Michel,

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.
Michel Mariano
Hey Liam,

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?
Liam Lacey
Hey Michel,

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.
Florent
Hi ! Thanks for the amazing tutorial. This code line doesn't work on my Arduino when I try to install it.

_____

#include

____

He's answering me this

#include
^
exit status 1
#include expects "FILENAME" or

Do you have an idea?

Thanks,
Florent
Liam Lacey
Hey Florent,

Thanks for the kind words and for spotting this mistake.
The code above has now been updated to the correct version.

Thanks,
Liam.
Florent
Thanks! So I need this Midi.h file? Best, Florent
Liam Lacey
Yes, you need to download and install the Arduino MIDI library from http://playground.arduino.cc/Main/MIDILibrary. Best, Liam.
Florent
It's perfectly working now ! Thank you so much !
Organist
Great article thanks @Liam. I am embarking on a charity project as part of a education outreach project for our local 'large' parish church and wonder whether you would be able to give me some help with some sticking points (understand if not)...

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!?
Emin
Hej Liam!

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!
Liam Lacey
Hey Emin,

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/).
Emin
Hey Liam!

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.
manirbangladesh
It's very specific tutorial. Great. Anyone can learn from this tutorial. I will use this guide for a midi drum. 9 piezos will be used.
I had a question. You used 18 piezo. But the Arduino mega allows only 16 input. What ambi missing?
Liam Lacey
Hey manirbangladesh. Contrary to the photos of the piano, I only actually used 16 piezos due to the 16 input limit on the Arduino Mega (originally I was going to use a multiplexer to allow for 18 piezos, however I later decided to abandon this idea for simplicity sake, but then forgot to remove the extra 2 piezos).
manirbangladesh
I used your code for my 10 piezo drum. All worked well. I will be very happy to know if i can change the treshold of each individual piezo by following line ?
""""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.

Liam Lacey
To create individual threshold values for each sensor you could create an array of const int values, e.g. const int THRESHOLD[NUM_OF_KEYS] = {5,6,8,4,2,5,7,8,5,6}; .

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.
manirbangladesh
Thank you... i have learned a lot from you. Thank you again
manirbangladesh
Millis library is not a safe thing to try i think. Anything else?
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.
manirbangladesh
Hello Again...
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);
}

manirbangladesh
can you help...?
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!