Tutorial.Midi History

Hide minor edits - Show changes to markup

June 01, 2010, at 11:50 AM by Equipo Traduccion -
Added lines 40-41:

Este código muestra cómo enviar notas con el protocolo MIDI a través del pin 1 (TX) de la Arduino. Si se conecta a un sintetizador MIDI, tocará las notas F#-0 (0x1E) a F#-5 (0x5A).

June 01, 2010, at 11:47 AM by Equipo Traduccion -
Changed lines 3-29 from:

MIDI Note Player

This tutorial shows how to play MIDI notes from an Arduino.

MIDI, the Musical Instrument Digital Interface, is a useful protocol for controlling synthesizers, sequencers, and other musical devices. MIDI devices are generally grouped in to two broad classes: controllers (i.e. devices that generate MIDI signals based on human actions) and synthesizers (including samplers, sequencers, and so forth). The latter take MIDI data in and make sound, light, or some other effect.

MIDI is a serial protocol that operates at 31,250 bits per second. The Arduino's built-in serial port (all of them on the Mega as well) can send data at that rate.

MIDI bytes are divided into two types: command bytes and data bytes. Command bytes are always 128 or greater, or 0x80 to 0xFF in hexadecimal. Data bytes are always less than 127, or 0x00 to 0x7F in hex. Commands include things such as note on, note off, pitch bend, and so forth. Data bytes include things like the pitch of the note to play, the velocity, or loudness of the note, and amount of pitch bend, and so forth. For more details, see the MIDI specification, or one of the many MIDI Protocol Guides on the Web.

MIDI data is usually notated in hexadecimal because MIDI banks and instruments are grouped in groups of 16.

For more see this introduction to MIDI or this example.

Circuit

All MIDI connectors are female, by definition of the MIDI spec. Here's how to wire the connector to the Arduino:

  • digital in 1 connected to MIDI jack pin 5
  • MIDI jack pin 2 connected to ground
  • MIDI jack pin 4 connected to +5V through 220-ohm resistor

click the image to enlarge

to:

Generador de notas MIDI

Este tutorial explica cómo generar notas MIDI desde una Arduino.

MIDI es el interfaz digital de instrumento musical (Musical Instrument Digital Interface) es un protocolo útil para controlar sintetizadores, secuenciadores y otros aparatos musicales. Hay dos tipos de máquinas MIDI: controladores (por ejemplo aparatos que generan señales MIDI a partir de acciones humanas) y sintetizadores (que incluye samplers, secuenciadores, etc.). Los últimos reaccionan a los datos MIDI generando sonido, luz o efectos.

MIDI es un protocolo serie que opera a 31250 bits por segundo. El puerto serie interno de Arduino (y todos los puertos de la Mega) son capaces de enviar datos a esta velocidad.

Los bytes MIDI se dividen en dos tipos: bytes de comando y bytes de datos. Los de comando son mayores o iguales a 128 (de 0x80 a 0xFF en hexadecimal). Los de datos son menores o iguales a 127 (de 0x00 a 0x7F en hexadecimal). Los comandos incluyen inicio de nota, fin de nota, picth bend (portamento), etc. Los datos incluyen cosas como el tono de la nota a tocar, la fuerza (también llamada velocidad, se refiere al volumen normalmente), etc. Para más detalles, ver la especificación MIDI o alguna de las muchas Guías del protocolo MIDI en la Web.

Los datos MIDI normalmente se escriben en hexadecimal porque los bancos MIDI y los instrumentos están dispuestos en grupos de 16.

Para más información, consultar introduction to MIDI (inglés) o este ejemplo (inglés).

Circuito

Todas las conexiones MIDI son hembra por definición de la especificación MIDI. Se conectan a la Arduino de la siguiente manera:

  • pin digital 1 conectado al conector MIDI en el pin 5
  • pin 2 del conector MIDI conectado a tierra
  • pin 4 del conector MIDI conectado a 5V mediante una resistencia de 220 ohmios

Para ver la imagen en su tamaño original, hacer click en la imagen.

Changed lines 29-35 from:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic

click the image to enlarge

to:

imagen generada con fritzing Fritzing. Para más información visitar la página del proyecto Fritzing

Esquema

Para ver la imagen en su tamaño original, hacer click en la imagen.

Changed line 39 from:

Code

to:

Código

February 23, 2010, at 08:14 PM by Tom Igoe -
Changed line 45 from:
to:
February 23, 2010, at 08:13 PM by Tom Igoe -
February 23, 2010, at 08:13 PM by Tom Igoe -
Changed line 45 from:
to:
February 23, 2010, at 08:12 PM by Tom Igoe -
Changed lines 45-50 from:
 /*
  MIDI note player
  
  This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
  If this circuit is connected to a MIDI synth, it will play 
  the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.
to:
Deleted lines 46-85:
  
  The circuit:
  * digital in 1 connected to MIDI jack pin 5
  * MIDI jack pin 2 connected to ground
  * MIDI jack pin 4 connected to +5V through 220-ohm resistor
  Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

  created 13 Jun 2006
  modified 2 Jul 2009
  by Tom Igoe 
  
  http://www.arduino.cc/en/Tutorial/MIDI
  
  */

 void setup() {
   //  Set MIDI baud rate:
   Serial.begin(31250);
 }

 void loop() {
   // play notes from F#-0 (0x1E) to F#-5 (0x5A):
   for (intnote = 0x1E; note < 0x5A; note ++) {
     //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
     noteOn(0x90, note, 0x45);
     delay(100);
     //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
     noteOn(0x90, note, 0x00);   
     delay(100);
   }
 }

 //  plays a MIDI note.  Doesn't check to see that
 //  cmd is greater than 127, or that data values are  less than 127:
 void noteOn(int cmd, int pitch, int velocity) {
   Serial.print(cmd, BYTE);
   Serial.print(pitch, BYTE);
   Serial.print(velocity, BYTE);
 }
August 27, 2009, at 08:57 PM by Tom Igoe -
Changed lines 32-34 from:
to:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

July 05, 2009, at 07:44 PM by Tom Igoe -
Changed lines 41-44 from:

[@ /*

 MIDI note player
to:
Changed lines 50-53 from:
 This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
 If this circuit is connected to a MIDI synth, it will play 
 the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.
to:
  
  The circuit:
  * digital in 1 connected to MIDI jack pin 5
  * MIDI jack pin 2 connected to ground
  * MIDI jack pin 4 connected to +5V through 220-ohm resistor
  Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
Changed lines 57-65 from:
 The circuit:
 * digital in 1 connected to MIDI jack pin 5
 * MIDI jack pin 2 connected to ground
 * MIDI jack pin 4 connected to +5V through 220-ohm resistor
 Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

 created 13 Jun 2006
 modified 2 Jul 2009
 by Tom Igoe 
to:
  created 13 Jun 2006
  modified 2 Jul 2009
  by Tom Igoe 
  
  http://www.arduino.cc/en/Tutorial/MIDI
  
  */
Changed lines 65-68 from:
 http://www.arduino.cc/en/Tutorial/MIDI
to:
 void setup() {
   //  Set MIDI baud rate:
   Serial.begin(31250);
 }
Changed lines 70-98 from:
 */

void setup() {

  //  Set MIDI baud rate:
  Serial.begin(31250);

}

void loop() {

  // play notes from F#-0 (0x1E) to F#-5 (0x5A):
  for (intnote = 0x1E; note < 0x5A; note ++) {
    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0x45);
    delay(100);
    //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);   
    delay(100);
  }

}

// plays a MIDI note. Doesn't check to see that // cmd is greater than 127, or that data values are less than 127: void noteOn(int cmd, int pitch, int velocity) {

  Serial.print(cmd, BYTE);
  Serial.print(pitch, BYTE);
  Serial.print(velocity, BYTE);

}

@]

to:
July 03, 2009, at 12:51 AM by Tom Igoe -
Added lines 5-6:

This tutorial shows how to play MIDI notes from an Arduino.

Changed lines 17-18 from:

For more see this introduction to MIDI or this example

to:

For more see this introduction to MIDI or this example.

Changed lines 27-29 from:

Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

to:
July 03, 2009, at 12:50 AM by Tom Igoe -
Changed lines 5-16 from:

This tutorial on MIDI is still in progress. For more see http://itp.nyu.edu/physcomp/Labs/MIDIOutput

to:

MIDI, the Musical Instrument Digital Interface, is a useful protocol for controlling synthesizers, sequencers, and other musical devices. MIDI devices are generally grouped in to two broad classes: controllers (i.e. devices that generate MIDI signals based on human actions) and synthesizers (including samplers, sequencers, and so forth). The latter take MIDI data in and make sound, light, or some other effect.

MIDI is a serial protocol that operates at 31,250 bits per second. The Arduino's built-in serial port (all of them on the Mega as well) can send data at that rate.

MIDI bytes are divided into two types: command bytes and data bytes. Command bytes are always 128 or greater, or 0x80 to 0xFF in hexadecimal. Data bytes are always less than 127, or 0x00 to 0x7F in hex. Commands include things such as note on, note off, pitch bend, and so forth. Data bytes include things like the pitch of the note to play, the velocity, or loudness of the note, and amount of pitch bend, and so forth. For more details, see the MIDI specification, or one of the many MIDI Protocol Guides on the Web.

MIDI data is usually notated in hexadecimal because MIDI banks and instruments are grouped in groups of 16.

For more see this introduction to MIDI or this example

Changed lines 18-19 from:

An LED connected to pin 9. use appropriate resistor as needed. For most common LEDs, you can usually do without the resistor, as the current output of the digital I/O pins is limited.

to:

All MIDI connectors are female, by definition of the MIDI spec. Here's how to wire the connector to the Arduino:

  • digital in 1 connected to MIDI jack pin 5
  • MIDI jack pin 2 connected to ground
  • MIDI jack pin 4 connected to +5V through 220-ohm resistor

Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

July 03, 2009, at 12:30 AM by Tom Igoe -
Changed lines 5-6 from:

MIDI

to:

This tutorial on MIDI is still in progress. For more see http://itp.nyu.edu/physcomp/Labs/MIDIOutput

Changed line 42 from:
 http://www.arduino.cc/en/Tutorial/PIRSensor
to:
 http://www.arduino.cc/en/Tutorial/MIDI
July 03, 2009, at 12:29 AM by Tom Igoe -
Changed lines 25-26 from:
to:

/*

 MIDI note player

 This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
 If this circuit is connected to a MIDI synth, it will play 
 the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.

 The circuit:
 * digital in 1 connected to MIDI jack pin 5
 * MIDI jack pin 2 connected to ground
 * MIDI jack pin 4 connected to +5V through 220-ohm resistor
 Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

 created 13 Jun 2006
 modified 2 Jul 2009
 by Tom Igoe 

 http://www.arduino.cc/en/Tutorial/PIRSensor

 */

void setup() {

  //  Set MIDI baud rate:
  Serial.begin(31250);

}

void loop() {

  // play notes from F#-0 (0x1E) to F#-5 (0x5A):
  for (intnote = 0x1E; note < 0x5A; note ++) {
    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0x45);
    delay(100);
    //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);   
    delay(100);
  }

}

// plays a MIDI note. Doesn't check to see that // cmd is greater than 127, or that data values are less than 127: void noteOn(int cmd, int pitch, int velocity) {

  Serial.print(cmd, BYTE);
  Serial.print(pitch, BYTE);
  Serial.print(velocity, BYTE);

}

Deleted lines 73-74:

Max code

July 03, 2009, at 12:15 AM by Tom Igoe -
Added lines 1-29:

Examples > Communication

MIDI Note Player

MIDI

Circuit

An LED connected to pin 9. use appropriate resistor as needed. For most common LEDs, you can usually do without the resistor, as the current output of the digital I/O pins is limited.

click the image to enlarge

Schematic

click the image to enlarge

Code




Max code

Share