Documentos de Académico
Documentos de Profesional
Documentos de Cultura
01 HIDUINO Traducido
01 HIDUINO Traducido
El proyecto HIDUINO proporciona firmwares, documentación y código de ejemplo para la construcción 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 través 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 más antiguas que usen un chip FTDI como
controlador USB (por ejemplo Duemilanove). Muchos baratos Arduino knockoffs que pretenden ser un Uno o Mega
también podría no funcionar, ya que tienden a utilizar los chips (más ligero) más barato FTDI.
HIDUINO se basa en el marco LUFA por Dean Camera. HIDUINO fue desarrollado previamente para instrumentos
robóticos 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 contenía muchos tipos de dispositivos
USB-HID (joystick, ratón, teclado, etc.). El nombre "mididuino" está en uso por un proyecto existente, aunque sería un
título más apropiado para este proyecto.
Algunos buenos ejemplos de HIDUINO en acción:
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 código 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 estándar de Arduino no se ha actualizado para usar el formato de archivo de
"propiedades" más reciente, pero se pueden encontrar detalles en el wiki.
Inicio rápido
El wiki de Github contiene una gran cantidad de información sobre cómo 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 través del cargador de arranque DFU.
Si utiliza el método ISP, una forma más fácil de desarrollo es destellar el controlador de controlador USB con HIDUINO
sólo 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
interacción de línea de comandos a través de un ISP o DFU. Mientras HIDUINO se carga en el controlador USB, no
intente la comunicación serie a través 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
.avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:arduino_midi.hex \
-U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
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 más abajo. En las revisiones más antiguas, se utiliza el chip 8u2. Los
firmwares 8u2 también 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 genérico 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 compilación del firmware desde cero le permite cambiar el nombre del dispositivo USB (HIDUINO por defecto).
Proyectos similares
• HID - Aplicación 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
cláusula de atribución 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 también debería funcionar, pero no probado.
3. Especificaciones
(1) USB bidireccional-MIDI a puente Serial-MIDI.
(2) velocidad de baudios para MIDI serie es 312500Hz (estándar)
4. Aplicaciones
Yo uso PSG Shield diseñado por Genie-san y HKHacks-san.
http://shield.io/psg
Nota: Necesitas USB-HUB autónomo con iPad, ya que LUFA informa de 500mA para su consumo de
energía.
5.Licencia
Creative Commons 2.5 Share / alike
6. 6. Descargar
1. Para Arduino UNO
MocoLUFA-110123.tgz
#include <MIDI.h>
~MIDI_Class ()
Default destructor for MIDI_Class.
Send a Note Off message (a real Note Off, not a Note On with null velocity)
void sendSysEx (int length, const byte *const array, bool ArrayContainsBoundaries=false)
void sendTuneRequest ()
Send a Tune Request message.
void send (kMIDIType type, byte param1, byte param2, byte channel)
bool read ()
Read a MIDI message from the serial port using the main input channel
(see setInputChannel() for reference).
Reading/thru-ing method, the same as read() with a given input channel to read on.
void turnThruOff ()
Detailed Description
#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:
return mMessage.sysex_array;
Returns:
{ return mThruActivated; }
See also:
kMIDIType
return mMessage.type;
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
}
void MIDI_Class::sendAfterTouch ( byte Pressure,
byte Channel
Parameters:
send(AfterTouchChannel,Pressure,0,Channel);
byte ControlValue,
byte Channel
Parameters:
send(ControlChange,ControlNumber,ControlValue,Channel);
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);
}
void MIDI_Class::sendPitchBend ( double PitchValue,
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.
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
{
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 {
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)
Definition at line 357 of file MIDI.cpp.
sendRealTime(TuneRequest);
{ mActiveSensingCallback = fptr; }
{ mAfterTouchChannelCallback = fptr; }
{ mAfterTouchPolyCallback = fptr; }
{ mClockCallback = fptr; }
{ mContinueCallback = fptr; }
{ mControlChangeCallback = fptr; }
{ mNoteOffCallback = fptr; }
void MIDI_Class::setHandleNoteOn ( void(*)(byte channel, byte note, byte velocity) fptr )
{ mNoteOnCallback = fptr; }
{ mPitchBendCallback = fptr; }
{ mProgramChangeCallback = fptr; }
{ mSongPositionCallback = fptr; }
{ mSongSelectCallback = fptr; }
{ mStartCallback = fptr; }
{ mStopCallback = fptr; }
{ mSystemExclusiveCallback = fptr; }
void MIDI_Class::setHandleSystemReset ( void(*)(void) 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;
Parameters:
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