This action might not be possible to undo. Are you sure you want to continue?
FACULTY OF ENGINEERING
Arduino MIDI Synthesizer
BSc – Music, Multimedia and Electronics ELEC2645 Embedded Systems Project
Session Student ID
2010 / 2011 200481604
Abstract 2.Contents 1. Software Overview 4. Introduction 3. Testing 6. Conclusion 7. Hardware Overview 5. References 2 2 2 4 5 6 7 1 .
Introduc1on The Arduino is a popular device for prototyping projects that integrate hardware and soKware by programming a microcontroller. The sound output is then either sent through an in-‐built speaker or sent to a 3. The program then analyses the ﬁrst byte (MIDI. the user can change the frequency and length values of a note at a par5cular output pin. 2. The output can be selected by the user by a toggle switch.M. the “sound()” func5on is called. The fact that I am enrolled as an M. Firstly. This method of designing embedded systems can bring together many diﬀerent areas of electronics without having to create new interfaces between them. This report outlines the diﬀerent stages involved in the comple5on of this project. interpret and generate MIDI serial data. The only MIDI data I am concerned with in my project is note data. The user can further manipulate the sound by deﬁning a note length using the knob on the top of the enclosure. I don’t use the data from the second byte. So4ware Overview The most basic form of musicality is available in the form of the tone() func5on. and a large selec5on of these are musically related.getData2 -‐ this contains the velocity and dura5on informa5on) is not greater than 0. this is a modiﬁed version of wiring’s pulse-‐width modula5on library. I thought it would be interes5ng to research diﬀerent musical opportuni5es available using the Arduino.1. 3.getData1) to get the pitch of the note (between 0-‐127). This frequency. The Arduino microcontrollers can operate a variety of components from servos to LCD displays -‐ most commonly using logic func5ons in and out of the microcontroller pins or a stream of serial data from a single pin. where instead of being able to adjust the duty cycle. the func5on will end. my program analyses all incoming MIDI messages and ﬁlters out “NoteOn’ messages. This is a complete self-‐contained product that can interpret an incoming MIDI signal from a 5-‐pin DIN connec5on and translate it into a pitched square-‐oscillator. If the second byte (MIDI. headphones). This is the main func5on that my project u5lises. The corresponding frequency is then determined from my array declared at the start of the code (int MIDI). Since the tone() output only has one velocity. Instead I have a poten5ometer to adjust the dura5on of the notes. The device is accompanied by a piece of simple desktop soKware that allows the user to create programs for the microcontroller in an easy program language called “Wiring”.E student was major factor in the process of deciding what my project was going to be. The soKware sec5on of the code relies on a small sec5on of the Arduino MIDI library. This comes as two bytes in the serial. Abstract The basis of this module was the design and crea5on of a microcontroller-‐based embedded system -‐ in my case a MIDI-‐controlled synthesiser. This library makes it easy to set the baud rate to 31250 (MIDI-‐compliant). In the wiring library for the Arduino. There are many websites where people share and discuss ideas rela5ng to Arduino projects. combined with the current mapped value of the poten5ometer is applied to a tone() func5on with two variables and the note indicator LED is ac5vated. a modiﬁed version of C/C++ that makes designing input/output applica5ons much easier. When a “NoteOn” message is received. Here is an overview of the program: 2 .5mm audio outlet that can be plugged into many devices (mixer.
30.getType If type = NoteOn Checks to see if there is incoming note data YES (Convert M IDI number to frequency) int pitch = midi[n] NO Digital Pin 2 = LOW (Note L ED) sound() Func?on (Poten?ometer input) analogRead Pin 0 = sustain (Suitable Values for delay) sustain = map(sustain.Start/Stop sound() Func?on Declare Global Variables (int M IDI.1000) loop() Func?on (Main sound output) tone pin 8 frequency = pitch delay = sustain Stop 3 .getData2 > 0 Set Outputs. 0.1023.) Start Declare Local Variables setup() Func?on If M IDI. Inputs YES Digital Pin 2 = HIGH (Note L ED) loop() Func?on NO (Speaker Pin) Digital Pin 8 = noTone MIDI.read int n = MIDI.getData1 MIDI.
that it can’t calculate indices of that scale on the ﬂy. I believe that it is because of physical limita5ons in the microcontroller. frequency = 440 * 2^((n-‐69)/12) 4.Before deciding on using an array to store the frequency values. away from the board. I experimented with an algorithm that converted the MIDI number into the actual frequency: (Where “n” is the MIDI number) This gave a frequency accurate to as many decimal places as you need but I ran into errors when tes5ng it out on the hardware. Hardware Overview Most of the components in my project are housed in the enclosure. OUTSOURCED COMPONENTS -On switch -Output toggle -MIDI connector -Audio jack -Speaker -Potentiometer -Red LED -Blue LED -Battery Clip / 9V Battery CIRCUIT BOARD COMPONENTS -Voltage regulator (9V -> 5V) -16MHz crystal oscillator -ATMega328P chip -Op amp -Resistors / Capacitors 19 connections This sec5on of the schema5c outlines the power regula5on in the circuit. The IC in the centre converts a 9V bafery’s voltage to 5V -‐ a safe opera5ng level for the ATMega328. 4 .
I tested the circuit with basic programs to switch on LEDs or make a noise through the speaker. largely due to the fact I mis-‐labelled signal paths.5mm jack has a 220Ω resistor in series to reduce the volume at the output. the components that appear to be afached to the main IC are just through-‐holes for external components. I corrected my PCB design for this report: 5 . Except for the op amp. you can see the rest of my circuit. so I translated the design into veroboard that worked as planned. I discovered there were errors with the PCB. and this was a reasonable volume for the built -‐in speaker. When I discovered the circuit was not playing any of the test programs. I knew there was something wrong with the PCB.Here. Tes1ng When assembling the project. 5. oscillator and a few resistors. The Op amp circuit required no feedback or bias resistors as it na5vely gave a gain of 20. it is processed by the 10 bit analog to digital converter on-‐board the ATMega328 and mapped to desired values in the programming code. The poten5ometer is connected between ground and +5V so the user can deﬁne a voltage between the two points. The serial input from the MIDI socket is allocated the the “Rx” pin on the ATMega328. The alterna5ve output at the 3. it creates a comfortable volume for headphones and a decent line volume also. The power and note indicator LEDs have 220Ω current-‐reducing resistors in series to supply them with the appropriate current level. this is the only pin that can read incoming serial data there is also a “Tx” pin that is reserved for transmiing serial data. The Reset switch works as a pull-‐up resistor when the switch is pressed.
6 . so that s5ll works as it should. I quite like the idea of a project-‐in-‐progress to be on veroboard. This new regulator provided less current than the original and wasn’t quite enough to fuel the amp without turning the whole synth oﬀ. The output signal could also be modiﬁed to be at a more suitable level for digital audio by using a biased op amp to limit the output dB. as this is much easier to expand on and create new sec5ons -‐ unless the project uses surface mount components or it requires a high component density. I connected up a MIDI cable from my laptop and had a complete range of notes playing at various speeds. To test the actual func5onality of the synthesiser. this worked just as well. I could create modular eﬀects that the user could deﬁne. I also tested a direct MIDI connec5on from my keyboard to the synth. This would probably require other ICs to process the pulse wave. The connec5on in the jack was a lifle loose. subtrac5ve synthesis would be a viable op5on. A PCB would be preferable once it is complete because it can be replicated with the soKware design and they are usually of a higher build quality to veroboard. The speaker s5ll gives a reasonable volume and the 3. veroboard is a good way to design.5mm socket didn’t use the op amp. One diﬀerence between the two circuits is the absence of the op amp in the veroboard design. Conclusion If I were to con5nue on this project and improve it somehow. 6. I tested both the speaker output and the 3. so you have to play around with the cable to get sound through both channels. I would try to incorporate some further signal processing to create 5mbres other than a square wave. I used a diﬀerent voltage regulator to the one used on the PCB.5mm jack output. such as an LFO or envelope. meaning they will last longer.
<h/p://sourceforge. 17 May 2011. 17 May 2011.  "Arduino MIDI Library". < h/p://wiring.References  "Wiring Language (API)".org.co/reference/ >. 7 .net/projects/arduinomidilib/ >.
This action might not be possible to undo. Are you sure you want to continue?