[Arduino Series 12] Arduino USB Midi box making secrets revealed
Jan 19, 2021 11:00 · 1785 words · 9 minute read
Many people know that Carlos likes to combine STEM and music to make instruments I often teach my students to make acoustic instruments Such as Kalimba, Recorder, Ukulele, etc.
00:28 - The invention and production of musical instruments last for a long time in human history New musical instruments keep emerging Computers will play a very important role in music in the future Today Carlos will use the Arduino you are most familiar with Start with a DIY Midi box Reveal the veil of computer music Let’s get started Just a reminder, if you like the channel of Organist Carlos Please click subscribe in the lower right corner If you want to be notified of new videos as soon as possible Please click the bell You are also welcome to add likes and comments In fact, many new instruments are just array of buttons Like the launchpad in my hand Is an 8X8 button array With the program Ableton Live Specially let DJ improvise live music Just take a moment to put different music and sound effects files Into these 64 buttons I can transform into DJ Carlos 8X8 64 buttons, each button represents a midi message Every time I talk to friends major in science and engineering about music They all think I’ve got my head in the clouds Gradually I learned to use a scientific method Talking to them about music makes it easier for them to understand I now open a music sequencer Launchpad is selected as the input device Actually, a sequencer is used to output data Following the sequence Now I press every button on the input device to make a sound It’s the same as when I press keys on a computer keyboard to output letters I now start the step record function It can record my keystrokes I keep pressing all 64 keys You will see some notes appear on the staff If you can’t read the staff I turn to piano roll view so that you can understand Just like looking at a chart, the X axis is time and the Y axis is pitch What we call midi messages Simply put every note into a number For example, the so-called middle C in music is represented by 60 Since midi is just numbers Then we can use our handy Arduino to connect buttons Let it output midi numbers to a computer or other musical instruments Then we can DIY electronic musical instruments Carlos was exposed to midi format more than 30 years ago And wrote a book And about ten years ago, I even combine the knowledge of midi with hardware and programming to make my own musical instruments At that time only this small Arduino could be bought I use the traditional midi to connect computer After many years, I switched to the commonly used UNO I also follow the trend to change the computer connection to usb midi But to program the arduino into a usb midi instrument You must select the arduino with ICSP2 connection in the upper left corner Many people don’t know the existence of this socket The original arduino has two In-Circuit Serial Programming plug To make it simple, each arduino has two Atmel chips We usually use one of them in programming The other one stores the bootloader It is the firmware of arduino Only with bootloader can programming via usb But if you want to turn the arduino into a midi instrument Bootloader is useless Instead, another firmware needs to be written in So that it can input and output midi messages The actual method will be detailed later Since we plan to make a midi input device with reference to launchpad At least a box must be printed The box must be able to install an arduino I prepared the box and arduino Due to the need to connect many buttons I prepared a self-made shield These pins are used to solder on the shield as leads Then put the arduino into the box Try to insert the shield to check its position Then I think about how to program UNO has only 13 digital inputs Even if the 6 analog inputs are converted to digital, there are only 19 If you make an electronic musical instrument with only 19 notes, definitely not enough! Here you can refer to the circuit designed by Carlos I used a set of 8 pins and a set of 9 pins To form a keyboard matrix circuit Allow 8X9 72 keys to be input at the same time You may not understand the circuit, or you may not understand what a matrix is But you know how to multiply, right? Eight times nine equals 72 So you can see on the circuit When the 17-pin is pulled out, and 72 buttons can be connected All keyboards designed by Carlos are made in this way Of course, 17 pins need to be scanned quickly in programming Determine which pair of pins are conducting To discuss eight times nine may be too complicated We use two times two to explain There are four buttons on this circuit They are A, B, C, D C1 and C2 take turns to output HIGH R1 R2 are responsible for detecting which key is pressed When C1 turns on, and the A key is pressed R1 will receive message As long as C1 and C2 swapping quickly R1 will continuously receive the message that the A button is pressed Suppose I am playing harmony What happens if I press A and D continuously When C1 turns on, R1 detects that A key is pressed When C2 starts, R2 detects that D key is pressed Only need to match the state of C1 and C2 in programming You will know that A and D are pressed at the same time I did not invent this circuit It is very common Generally, instruments with many keys Such as computer keyboards, remote controls, etc.
07:55 - All use this circuit to save digital input I uploaded the program I wrote for the eight times nine keyboard The program has been placed in the info bar, you can download it at will After uploading, remember that we said to modify the bootloader To make it a midi instrument We are going to prepare an ISP programmer The one I’m using is called AVRISP mk II The six-pin plug of the programmer is plugged into the ICSP2 of the arduino Also connect a usb cable to the computer for the programmer There are two USB cables connected to the computer at the same time Then search for Atmel studio to download This software is specifically used to program Atmel chips Follow my procedure after downloading the software Put the Carlos_Stop.
hex file in the info bar to arduino to replace bootloader It is worth mentioning that If you want to modify the program in the future, you must restore the bootloader first I also put the bootloader in the info bar The file name is usbseiral_uno_16u2. hex All connections must be unplugged after completing all operations Then reconnect to start the midi box If you want to know if it works You can observe the device manager’s Audio, video and game controllers When inserted in the midi box, you will clearly see the new Carlos_Stop device That is, this arduino has been transformed into Carlos_Stop Open a music program such as Ableton live Look at midi input setting You will find that launchpad mini is not installed now Instead, Carlos_Stop is installed Basically the midi box has been completed But we haven’t connected the buttons yet, how do we play? For a simple demonstration, today we only connect four buttons I now design a small box for four buttons and print Wiring after installing four buttons Almost forgot one thing! For matrix keyboard If you plan to press many keys at the same time Ghosting may occur For example, if you press A, B, D When C1 turns on Obviously I didn’t press the C key But because of B and D’s feedback The C key seems to be pressed! This phenomenon is called Ghosting The solution is to put a diode next to each button to limit the direction of current In my circuit diagram, I have also considered this aspect The diodes used in circuit is generally IN4148 There are many ways to connect the four buttons Four wires are needed to use two by two It takes five wires to use one by four One by four connection is relatively simple So I use one by four to demonstrate The blue wire is the common line Each of the four color wires is responsible for one key Connect the blue wire of arduino to A3 Connect the four-color wires to D2 D3 D4 D5 Now you can use usb to connect to the midi box for testing Carlos_Stop has been detected by Ableton live already There is no big difference between the operation of launchpad But you only have four buttons We put four drum waves into four buttons respectively Start playing Although my small self-made launchpad has only four buttons But it’s small in size and can be used as a joystick in your hand.
12:31 - Although Carlos likes DIY I never said that homemade devices are the best To compare with launchpad mini Its buttons are very mute And these four buttons I bought are too noisy In addition, it has 64 buttons, which have more functions Also, it can not only input but it can also receive output and turn on LED Of course you can also have a lot of keys and input and output in your design But the design is much more complicated You have to consider whether you have the perseverance All in all, DIY or Buy is up to you If you DIY you can enjoy the fun of making After experiencing research and creation You will have a deeper understanding of the principle of the product After today’s midi box production I believe you have a deeper understanding of midi digital music Understand that programming to control computer music is not difficult But the use of midi is more than that In addition to the production of midi input In the future, Carlos can teach you how to make midi output To control a variety of new electronic musical instruments After knowing the concept, you can use these midi input and output boxes to invent your own new musical instrument If you are intereted, don’t miss any of my electronic music videos Please remember to subscribe, like and share.