New Program available – MIDI Sequencer

I’ve uploaded a new program to the repository, a MIDI Sequencer that allows you to use miniMO as a pattern sequencer with any MIDI device.

Software-wise, the sequencer uses a modified version of the SoftwareSerial library, which lets me set any pins I want for MIDI In and Out; this feature is critical, as I’m bound by the original hardware design. I had to modify the library because by default it takes over an interrupt which the program needs to detect button presses; after my changes, the library won’t control the interrupt unless I request for it (never, in this program). With that issue sorted out, configuring SoftwareSerial couldn’t be simpler:

SoftwareSerial midiSerial(-1, 4); // digital pins for soft serial RX & TX. (-1 = OFF)

… and, in setup(),

midiSerial.begin(31250);

later in the program, sending MIDI messages is as easy as using the write method, as for instance:

midiSerial.write(note);   //note is the MIDI note number

 

Hardware-wise things were a bit harder, as I had to build a MIDI cable and figure out what pin to use for output:

  • The MIDI cable needs to derive a power line from the device, in addition to the data line. Fortunately, I had a custom-made three-pin jumper which I already used in the Display module, precisely for that purpose

    When you use this jumper, Vcc in becomes Vcc out 🙂

  • As for the output, MIDI was originally designed for 5 Volts, but the specs were revised in 2014 to account for new devices running at 3.3 Volts; in the end, it’s a matter of having the right resistors in the power and data lines:

    Bottom to top: data- 10Ω; ground; power – 33Ω

  • There is one last piece to this puzzle -miniMO’s inputs/outputs already have resistors in the circuit, and their values are too high for 3V MIDI out. Initially I thought it would not be possible to run the sequencer from the internal battery, so I built an adapter that allowed me to both power the miniMO and the MIDI cable from a 9V battery,

    The regulator is an S7V7F5 from Pololu

    but later on I realized that the ATtiny’s output pin (pin 4) is located so close to the output 2’s positive pin that I could bridge them, thus bypassing the resistor:

    With this bridge, the sequencer runs on battery

The finished cable is reliable and trouble-free, which is quite surprising as it is actually two hacks in one! :D. It stays in place just fine, and I’ve got more than 12 hours of continuous use of the sequencer on a single battery (and counting -I haven’t replaced it yet). The only drawback I’ve found is that I cannot fit a top cover because of the bridge, so I might modify the cover’s design to accommodate for it.

midiMO Sequencer 😀

UPDATE – I ended up revising the top cover; the new design has a cutout for the bridge, and a laminated faceplate with text and markings. I’ve also improved on the MIDI cable, which is now easier to build and has a better finish.

The finished model

Feature-wise I’ve packed as much functionality as possible, considering the limitations of the interface. Before uploading the program, there is a “user-friendly” section of the code with a number of relevant parameters to decide on, most important being the list of notes to use in the sequences:

targetNotes[targetNotesArrayLength] = {52,55,59,60,64,67,71,72,76,};

I could use all the notes in the chromatic range, but I think it is more practical to think on what kind of patterns I want to generate, then select the notes accordingly: it makes live-editing easier, and since the module generates a random pattern every time it is turned ON, limiting the notes allows for interesting patterns from the get go -I usually turn the unit ON and OFF a few times until I get a pattern I like, then work from there.

Other relevant parameters in code are the MIDI Channel, the default note velocity, the pattern length, the maximum number of octaves for octave spread and the intervals for pattern transposing, which I have set to two octaves, and Tangerine/Zimmerian intervals, respectively.

Once the program is loaded and running, it plays a random sequence, which you can edit and manipulate in various ways:

  • Sequence editing: you can change the notes and their lengths. The steps’ length is constant, but you can make a note last for the whole duration of the step, half the step, or leave the step silent
  • Sequence direction change: you can make the sequence play forward or backward. Originally I also had a random option, but I found it confusing in practice
  • Octave Spread: repeats the sequence over several octaves (two by default), in addition to the original
  • Sequence transposing: you can transpose the whole sequence up or down on several fixed intervals using the knob. In the setup I made it so that the original pattern corresponds to the knob’s center position
  • Tempo Change

When the unit starts playing, the knob controls the tempo; you can access all other features via button presses. Editing requires that you remember to press the button once to enter or exit the mode, and press twice to change the note length while editing, but that’s about as hard as it gets. Also, you can edit the sequence at any time: if you’re transposing, the available notes also get transposed accordingly.

That’s about it at the moment, but there’s room for maybe two extra features in the future: external sync (the module already sends trigger signals via I/O 4, so I would have to figure out how to make it a “slave” on startup, then disable tempo control and make it follow triggers received on that same port), and transposing from a MIDI keyboard (for which I’d need simultaneous MIDI in).

In all, I’m really happy with this little sequencer. It’s a ton of fun to play around with, and it expands miniMO’s uses to about every keyboard and module ever released!

Posted in Blog, Programs and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.