In this example the converter is set-up and running, with the summary of chosen ports displayed. Demo sketch to play notes from middle C in the 4th octave up to B in the 5th octave and then back down. The objective of this project is to allow everyone that has a micro-controller of some kind be it an Arduino, PIC, Basic Stamp etc It is intended to be used with simple projects for fun and is not a full substitute for a hardware solution.
Screen shot from oscilloscope, showing delay from sending serial MIDI formated message to start of audio playing. It is actually two 5ms pulses close together, one right before the message was sent and another as soon as it was sent. It uses two key libraries to do what it does, the Processing Serial Library from the processing web site and themidibus by Severin Smith.
Learn :. Projects :. Serial - MIDI converter. What it does. Intro to MIDI. Set-up Mac. Set-up Windows. How to use. How it was made. Build a drum machine 2. Build a keyboard 3. Build a completely new type of musical instrument 4. Make a score that controls bells and tapping solenoids 5.
Make a score that flashes lights and triggers special effects 6. Send data from your existing MIDI controller out to a serial device 7. Illustration of how the data flows to and from the serial ports and MIDI. Important update for Mac OS X:. To set it up you will need two other pieces of software. Launch the SM and follow along with these steps.
Version: v2D Improvements: 1. Updated compatibility with newer version of Java. Version: v2C Improvements: 1. Selectable serial baud rate 2. Longer list for the serial and MIDI ports. Demo Arduino Sketch: Demo sketch to play notes from middle C in the 4th octave up to B in the 5th octave and then back down. In conclusion, MIDI is a general purpose communication standard that focuses on music applications.
Adding this controller to a MIDI network allows you to synchronize special audio effects to other events in the music performance. In an alternative set-up, the H monitors all kinds of other sensors that can be attached to it and sends MIDI packets to notify the entire MIDI network of these events. The protocol is not unlike a typical RS protocol: one start bit must be 0 , eight data bits, one stop bit must be 1 , no parity and no hardware handshaking.
In order to get a fair level of immunity against electrical interference irradiation , MIDI uses a current loop signal line 5mA, usually at approximately 5V , rather than the standard voltage level signals. A logic 0 is defined as current flowing, and a logic 1 as no current.
This counter-intuitive definition was chosen so that an unconnected input wire does not "see" a series of start bits —a start bit is logic 0.
Pins 4 and 5 carry the signal, with pin 4 being the positive voltage; pin 2 is connected to the shielding of the cable on the output connector, but it is left unconnected on the input connector; pins 1 and 3 are not used.
To avoid ground loops, there is an opto-isolator at the input connector. The resistors in the signal lines R1 and R2 are ohm, together with the voltage drop of the opto-coupler 6N , these regulate the current at approximately 5 mA. The value of R3 is not critical; 1k is fine. The circuit assumes that it will be connected to a "DCE" device. When you wish to connect it to a "DTE" device, such as a PC, you should replace the male DB9 connector K1 by a female one and swap the pins 2 and 3 on that connector.
The circuit requires an external power source. I chose an explicit 5V connector because the H MP3 player provides a 5V power source and because I feel that using signal lines as a power source is more like a hack than a design. Therefore PCs will typically need either a special RS card or an interface with a memory buffer and a Baud rate converter typically based in a micro-controller.
MIDI commands have a variable size with a fixed structure. Every byte carries 7 bits of information. The highest bit of a byte is set for the first byte in a command and clear for any follower bytes. The start of a command can therefore be detected easily.
The end of a command is not marked in a specific manner; to determine weather a you have received the last byte in a stream, you can use a set of heuristics:. The last two heuristics are easy to implement on the H programmable MP3 player , because the function packetfilter allows you to specify the format of an acceptable packet and a time-out for waiting for more follower bytes.
The packet specification is in a string notation that looks like a regular expression. Since MIDI defines a leader byte as one with the highest bit set, the byte value for a leader byte will be in the range Follower bytes are, hence, in the range A specification for the packet format is then: a byte in the range followed by zero or more bytes in the range Sets or ranges in square brackets match a single byte; sets or ranges in braces curly brackets match zero or more bytes.
However, the pawn syntaxes do not let you insert a zero byte in a string. The back-quote notation is therefore preferred. MIDI works with channels, and a device often monitors only a single channel plus a handful of commands that apply to all channels. A second parameter in the packetfilter function allows you to specify a filter to let only those commands through that pass the filter.
0コメント