MIDI to Arduino Source Code Generator - Documentation
beep
A simple tone generator (see tone
), but works with the attiny84. The beep()
function isn't built into Arduino, so it will be appended to the generated sketch. You can optionally add a second pin number for a simple volume boost.
Notes | Notes will be recreated audibly. So if your MIDI file has a middle C, a square wave tone will be generated at 262hz. |
Duration | beep() is a blocking call! You cannot overlap events for the duration of a beep note in any track. |
Velocity | Velocities are pretty much ignored - if you create a note with any non-zero velocity, a tone will be generated. |
digital
Controls a pin's HIGH
/LOW
state using digitalWrite()
.
Notes | Different notes don't matter - any note on the track will control the pin state. Notes should not overlap. |
Duration | The pin will bet set HIGH for the duration of the note. At the end of the note, the pin will be set to LOW . |
Velocity | Any non-zero velocity will set the pin HIGH . |
servo
Connect a servo's control/data wire to this pin to control the angle of the servo's arm.
Notes | Different notes don't matter - any note on the track will control the servo rotation the same. Notes should not overlap. |
Duration | At the end of a note's duration, the servo will be reset to 90°. |
Velocity | Velocity is used to control the servo's rotation. MIDI velocities range from 0-127, while servo angles range from 0-180, so the values are mapped. If you turn a note's velocity all the way up (127), the servo will be rotated all the way up (180°); if the MIDI note only goes half-way (63), the servo will only be rotated half-way (90°); etc. |
tone
Plug one end of a speaker into this pin and the other end into GND to generate simple tones (see beep
for attiny84 support).
Notes | Notes will be recreated audibly. So if your MIDI file has a middle C, a square wave tone will be generated at hz. |
Duration | A delay() will be added for the duration of the note (or until the next event (whichever comes first)). At the end of the note's duration, a noTone() call is added to stop the tone, as well as an extra, short delay() to prevent consecutive notes from interfering with each other. |
Velocity | Velocities are pretty much ignored - if you create a note with any non-zero velocity, a tone will be generated. |
pwm
Generates PWM signals (analog-approximations)
Notes | Different notes don't matter - any note on the track will control the PWM state of the pin. Notes should not overlap. |
Duration | The pin's PWM value will be set for the duration of the note. At the end of the note, the pin will be set to zero. |
Velocity | Velocity is used to control the PWM state. MIDI velocities range from 0-127, while Arduino PWM values range from 0-255, so the values are mapped. If you turn a note's velocity all the way up (127), the servo will be rotated all the way up (255); if the MIDI note only goes half-way (63), the servo will only be rotated half-way (128); etc. |