Documente Academic
Documente Profesional
Documente Cultură
El proyecto HIDUINO proporciona firmwares, documentacin y cdigo de ejemplo para la construccin de un dispositivo
USB-MIDI compatible con la clase de un Arduino UNO o Mega 2560. HIDUINO no utiliza software de middleware para
convertir mensajes en serie a travs de un puerto de loopback MIDI (como LoopBe1 en Windows o IAC en OSX). En su
lugar, HIDUINO proporciona un verdadero dispositivo USB-MIDI para la compatibilidad plug-and-play en Windows, OSX y
Linux, al igual que un controlador comercial MIDI.
HIDUINO se aprovecha de las placas Arduino donde se utiliza un segundo chip AVR como controlador USB, por lo que no
funcionar con variantes de un solo chip (por ejemplo, Leonardo), ni tablas ms antiguas que usen un chip FTDI como
controlador USB (por ejemplo Duemilanove). Muchos baratos Arduino knockoffs que pretenden ser un Uno o Mega
tambin podra no funcionar, ya que tienden a utilizar los chips (ms ligero) ms barato FTDI.
HIDUINO se basa en el marco LUFA por Dean Camera. HIDUINO fue desarrollado previamente para instrumentos
robticos y nuevas interfaces musicales en el Instituto de las Artes de California.
.
El nombre del proyecto hace referencia a un momento en el que se pensaba que contena muchos tipos de dispositivos
USB-HID (joystick, ratn, teclado, etc.). El nombre "mididuino" est en uso por un proyecto existente, aunque sera un
ttulo ms apropiado para este proyecto.
Algunos buenos ejemplos de HIDUINO en accin:
MHzKontrol NotomotoN Diaktoros
.
Requisitos
La lista completa de requisitos se enumera en el wiki. Por lo menos, necesitar:
Crosspack en OSX / o / WinAVR en Windows
Arduino IDE 1.6.7 y la ltima biblioteca MIDI de Arduino
(Recomendado) AVRISPMKII
Biblioteca MIDI
Dado que HIDUINO no viene con cdigo para consumir o producir datos MIDI en los bocetos en s, una biblioteca
independiente de Arduino debe usarse para codificar / decodificar el formato MIDI entre el firmware de HIDUINO y el
boceto. Notablemente, la biblioteca midi estndar de Arduino no se ha actualizado para usar el formato de archivo de
"propiedades" ms reciente, pero se pueden encontrar detalles en el wiki.
Inicio rpido
El wiki de Github contiene una gran cantidad de informacin sobre cmo trabajar con HIDUINO. HIDUINO puede ser
lanzado sobre el ATmega (8u2 / 16u2) chip en la UNO y Mega2560. Los bocetos no se pueden cargar en un Arduino
mientras se carga un firmware HIDUINO en el 8u2, por lo que los usuarios pueden esperar cambiar entre los firmwares
por defecto usbserial y HIDUINO regularmente durante el desarrollo. El proceso intermitente se puede llevar a cabo
utilizando un ISP (recomendado) oa travs del cargador de arranque DFU.
Si utiliza el mtodo ISP, una forma ms fcil de desarrollo es destellar el controlador de controlador USB con HIDUINO
slo una vez. Luego, en el IDE de Arduino, seleccione "Cargar usando el programador" y conecte el ISP al bloque de
encabezado cerca del chip principal. Esto significa que el boceto de Arduino puede ser transmitido desde el IDE sin
interaccin de lnea de comandos a travs de un ISP o DFU. Mientras HIDUINO se carga en el controlador USB, no intente
la comunicacin serie a travs de Serial.print () / println (): esto interrumpir la secuencia serial MIDI en el controlador
USB.
Flasheando el firmware arduino_midi ubicado en el directorio compiled_firmwares: Nota: Quite las barras en
un programa como el Bloc de notas si est en Windows
Las ltimas revisiones (3+) del Mega y UNO (y Due) utilizan el chip Atmega 16u2, as que tenga en cuenta los cambios de
nombre del firmware usbserial por defecto ms abajo. En las revisiones ms antiguas, se utiliza el chip 8u2. Los
firmwares 8u2 tambin se incluyen en el directorio Firmware compilado. La nica diferencia importante entre ellos es la
cadena de producto que aparece cuando un Arduino se conecta a una computadora. Avrdude dar un error genrico si
intenta destello un chip 8u2 con un firmware 16u2 y viceversa. El perfil de chip at90usb82 se utiliza para los siguientes
comandos, ya que se asemeja a 16u2 y 8u2 - una cosa menos que recordar cambiar.
La compilacin del firmware desde cero le permite cambiar el nombre del dispositivo USB (HIDUINO por
defecto).
Proyectos similares
HID - Aplicacin HID habilitada para MIDI para placas Arduino basadas en 32u4 (Leonardo) o Uno / Mega
con cargador de arranque personalizado
Licencia
HIDUINO es liberado bajo la licencia del MIT. HIDUINO hereda de la licencia MIT establecida por LUFA. Una
licencia comercial de LUFA est disponible para productos de origen cercano que no desean mantener la
clusula de atribucin del MIT.
NOTA: El original Mico / Moco es un software para puente USB-MIDI con V-USB.
http://web.mac.com/kuwatay/morecat_lab./MOCO-e.html
2. Requisitos
(1) gcc 4.X para compilar
Utilizo CrossPack en OSX.
(2) LUFA101122 para compilar y enlazar
(3) Arduino UNO
Recomiendo agregar el conector ICSP para atmega 8u2
(4) programador AVR como USBtinyISP
DFU Programmer tambin debera funcionar, pero no probado.
3. Especificaciones
(1) USB bidireccional-MIDI a puente Serial-MIDI.
(2) velocidad de baudios para MIDI serie es 312500Hz (estndar)
4. Aplicaciones
Yo uso PSG Shield diseado por Genie-san y HKHacks-san.
http://shield.io/psg
Nota: Necesitas USB-HUB autnomo con iPad, ya que LUFA informa de 500mA para su
consumo de energa.
5.Licencia
Creative Commons 2.5 Share / alike
6. 6. Descargar
MIDI_Class ()
Default constructor for MIDI_Class.
~MIDI_Class ()
Default destructor for MIDI_Class.
void sendSysEx (int length, const byte *const array, bool ArrayContainsBoundaries=false)
Generate and send a System Exclusive frame.
void sendTuneRequest ()
Send a Tune Request message.
void send (kMIDIType type, byte param1, byte param2, byte channel)
Generate and send a MIDI message from the values given.
bool read ()
Read a MIDI message from the serial port using the main input channel
(see setInputChannel() for reference).
void turnThruOff ()
Setter method: turn message mirroring off.
Detailed Description
MIDI_Class::MIDI_Class ( )
#if USE_CALLBACKS
#endif
MIDI_Class::~MIDI_Class ( )
#if COMPILE_MIDI_OUT
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif // USE_RUNNING_STATUS
#endif // COMPILE_MIDI_OUT
#if COMPILE_MIDI_IN
mInputChannel = inChannel;
mRunningStatus_RX = InvalidType;
mPendingMessageIndex = 0;
mPendingMessageExpectedLenght = 0;
mMessage.valid = false;
mMessage.type = InvalidType;
mMessage.channel = 0;
mMessage.data1 = 0;
mMessage.data2 = 0;
#endif // COMPILE_MIDI_IN
mThruFilterMode = Full;
mThruActivated = true;
#endif // Thru
return mMessage.valid;
Parameters:
Type The type of message to unbind. When a message of this type is received, no function will be called.
switch (Type) {
case NoteOff: mNoteOffCallback = NULL; break;
case NoteOn: mNoteOnCallback = NULL; break;
case AfterTouchPoly: mAfterTouchPolyCallback = NULL; break;
case ControlChange: mControlChangeCallback = NULL; break;
case ProgramChange: mProgramChangeCallback = NULL; break;
case AfterTouchChannel: mAfterTouchChannelCallback = NULL; break;
case PitchBend: mPitchBendCallback = NULL; break;
case SystemExclusive: mSystemExclusiveCallback = NULL; break;
case TimeCodeQuarterFrame: mTimeCodeQuarterFrameCallback = NULL; break;
case SongPosition: mSongPositionCallback = NULL; break;
case SongSelect: mSongSelectCallback = NULL; break;
case TuneRequest: mTuneRequestCallback = NULL; break;
case Clock: mClockCallback = NULL; break;
case Start: mStartCallback = NULL; break;
case Continue: mContinueCallback = NULL; break;
case Stop: mStopCallback = NULL; break;
case ActiveSensing: mActiveSensingCallback = NULL; break;
case SystemReset: mSystemResetCallback = NULL; break;
default:
break;
}
return mMessage.channel;
return mMessage.data1;
return mMessage.data2;
{ return mThruFilterMode; }
{
return mInputChannel;
}
See also:
getSysExArrayLength to get the array's length in bytes.
return mMessage.sysex_array;
Returns:
{ return mThruActivated; }
See also:
kMIDIType
return mMessage.type;
}
static const kMIDIType MIDI_Class::getTypeFromStatusByte ( const byte inStatus ) [inline, static]
This is a utility static method, used internally, made public so you can handle kMIDITypes more easily.
{
if ((inStatus < 0x80)
|| (inStatus == 0xF4)
|| (inStatus == 0xF5)
|| (inStatus == 0xF9)
|| (inStatus == 0xFD)) return InvalidType; // data bytes and undefined.
if (inStatus < 0xF0) return (kMIDIType)(inStatus & 0xF0); // Channel message, remove
channel nibble.
else return (kMIDIType)inStatus;
}
Reading/thru-ing method, the same as read() with a given input channel to read on.
if (parse(inChannel)) {
if (input_filter(inChannel)) {
#if USE_CALLBACKS
launchCallback();
#endif
return true;
}
return false;
bool MIDI_Class::read ( )
Read a MIDI message from the serial port using the main input channel (see setInputChannel() for reference).
Returned value: true if any valid message has been stored in the structure, false if not. A valid message is a message
that matches the input channel.
If the Thru is enabled and the messages matches the filter, it is sent back on the MIDI output.
return read(mInputChannel);
byte data1,
byte data2,
byte channel
Parameters:
data2 The second data byte (if the message contains only 1 data byte, set this one to 0).
channel The output channel on which the message will be sent (values from 1 to 16). Note: you cannot send
to OMNI.
This is an internal method, use it only if you need to send raw data from your code, at your own risks.
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif
#if USE_RUNNING_STATUS
// Check Running Status
if (mRunningStatus_TX != statusbyte) {
// New message, memorise and send header
mRunningStatus_TX = statusbyte;
USE_SERIAL_PORT.write(mRunningStatus_TX);
}
#else
// Don't care about running status, send the Control byte.
USE_SERIAL_PORT.write(statusbyte);
#endif
byte Channel
Parameters:
{
send(AfterTouchChannel,Pressure,0,Channel);
byte ControlValue,
byte Channel
Parameters:
send(ControlChange,ControlNumber,ControlValue,Channel);
byte Velocity,
byte Channel
Send a Note Off message (a real Note Off, not a Note On with null velocity)
Parameters:
NoteNumber Pitch value in the MIDI format (0 to 127). Take a look at the values, names and frequencies of
notes here: http://www.phys.unsw.edu.au/jw/notes.html
{
send(NoteOff,NoteNumber,Velocity,Channel);
byte Velocity,
byte Channel
Parameters:
NoteNumber Pitch value in the MIDI format (0 to 127). Take a look at the values, names and frequencies of
notes here: http://www.phys.unsw.edu.au/jw/notes.html
Velocity Note attack velocity (0 to 127). A NoteOn with 0 velocity is considered as a NoteOff.
send(NoteOn,NoteNumber,Velocity,Channel);
byte Channel
Parameters:
PitchValue The amount of bend to send (in a floating point format), between -1.0f (maximum downwards
bend) and +1.0f (max upwards bend), center value is 0.0f.
byte Channel
Parameters:
PitchValue The amount of bend to send (in a signed integer format), between -8192 (maximum downwards
bend) and 8191 (max upwards bend), center value is 0.
byte Channel
Parameters:
PitchValue The amount of bend to send (in a signed integer format), between 0 (maximum downwards bend)
and 16383 (max upwards bend), center value is 8192.
byte Pressure,
byte Channel
)
Parameters:
send(AfterTouchPoly,NoteNumber,Pressure,Channel);
byte Channel
Parameters:
send(ProgramChange,ProgramNumber,0,Channel);
Parameters:
Type The available Real Time types are: Start, Stop, Continue, Clock, ActiveSensing and SystemReset. You
can also send a Tune Request with this method.
See also:
kMIDIType
Definition at line 435 of file MIDI.cpp.
{
switch (Type) {
case TuneRequest: // Not really real-time, but one byte anyway.
case Clock:
case Start:
case Stop:
case Continue:
case ActiveSensing:
case SystemReset:
USE_SERIAL_PORT.write((byte)Type);
break;
default:
// Invalid Real Time marker
break;
}
// Do not cancel Running Status for real-time messages as they can be interleaved within any
message.
// Though, TuneRequest can be sent here, and as it is a System Common message, it must reset
Running Status.
#if USE_RUNNING_STATUS
if (Type == TuneRequest) mRunningStatus_TX = InvalidType;
#endif
Parameters:
USE_SERIAL_PORT.write((byte)SongPosition);
USE_SERIAL_PORT.write(Beats & 0x7F);
USE_SERIAL_PORT.write((Beats >> 7) & 0x7F);
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif
USE_SERIAL_PORT.write((byte)SongSelect);
USE_SERIAL_PORT.write(SongNumber & 0x7F);
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif
Parameters:
ArrayContainsBoundaries When set to 'true', 0xF0 & 0xF7 bytes (start & stop SysEx) will NOT be sent (and
therefore must be included in the array). default value is set to 'false' for
compatibility with previous versions of the library.
if (ArrayContainsBoundaries == false) {
USE_SERIAL_PORT.write(0xF0);
USE_SERIAL_PORT.write(array[i]);
USE_SERIAL_PORT.write(0xF7);
}
else {
for (int i=0;i<length;++i) {
USE_SERIAL_PORT.write(array[i]);
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif
Parameters:
data if you want to encode directly the nibbles in your program, you can send the byte here.
USE_SERIAL_PORT.write((byte)TimeCodeQuarterFrame);
USE_SERIAL_PORT.write(data);
#if USE_RUNNING_STATUS
mRunningStatus_TX = InvalidType;
#endif
byte ValuesNibble
Parameters:
void MIDI_Class::sendTuneRequest ( )
When a MIDI unit receives this message, it should tune its oscillators (if equipped with any)
sendRealTime(TuneRequest);
{ mActiveSensingCallback = fptr; }
{ mAfterTouchChannelCallback = fptr; }
{ mAfterTouchPolyCallback = fptr; }
{ mClockCallback = fptr; }
{ mContinueCallback = fptr; }
{ mControlChangeCallback = fptr; }
{ mNoteOffCallback = fptr; }
{ mNoteOnCallback = fptr; }
{ mPitchBendCallback = fptr; }
{ mProgramChangeCallback = fptr; }
{ mSongPositionCallback = fptr; }
{ mSongSelectCallback = fptr; }
{ mStartCallback = fptr; }
void MIDI_Class::setHandleStop ( void(*)(void) fptr )
{ mStopCallback = fptr; }
{ mSystemExclusiveCallback = fptr; }
{ mSystemResetCallback = fptr; }
{ mTimeCodeQuarterFrameCallback = fptr; }
{ mTuneRequestCallback = fptr; }
Parameters:
Channel the channel value. Valid values are 1 to 16, MIDI_CHANNEL_OMNI if you want to listen to all
channels, and MIDI_CHANNEL_OFF to disable MIDI input.
mInputChannel = Channel;
See also:
kThruFilterMode
mThruFilterMode = inThruFilterMode;
if (mThruFilterMode != Off) mThruActivated = true;
else mThruActivated = false;
void MIDI_Class::turnThruOff ( )
mThruActivated = false;
mThruFilterMode = Off;
mThruActivated = true;
mThruFilterMode = inThruFilterMode;
The documentation for this class was generated from the following files:
/Users/franky/Documents/Dropbox/SVN/embedded/toolbox/libraries/MIDILib/trunk/Arduino/MIDI/MIDI.h
/Users/franky/Documents/Dropbox/SVN/embedded/toolbox/libraries/MIDILib/trunk/Arduino/MIDI/MIDI.cpp