We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries, there is a full getting started guide here.

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. You can learn about Mu and its installation in this tutorial.

There's a guide to get you up and running with CircuitPython specifically for the NeoTrellis M4. You should read it before starting to get the most recent CircuitPython build for the NeoTrellisM4 installed and running along with the required libraries.

Full code with links to github is on the Downloads page.

Navigating the NeoTrellis

To get your NeoTrellis M4 set up to run this project's code, first follow these steps:

1) Update the bootloader for NeoTrellis from the NeoTrellis M4 guide

2) Install the latest CircuitPython for NeoTrellis from the NeoTrellis M4 guide

3) Get the latest CircuitPython library pack, the version number of which should match your version of CircuitPython (4.x or greater), unzip it, and drag the libraries you need over into the /lib folder on CIRCUITPY. The latest library package includes support for NeoTrellis.

For this project you will need the following libraries:

  • adafruit_trellism4.mpy
  • neopixel.mpy
  • adafruit_matrixkeypad.mpy

Overall Structure

The codebase is broken into several classes/files:

  • main.py sets everything up and contains the main loop the checks for input from the user and acts accordingly
  • parser.py contains the MIDI file parser
  • header.py contains a class implementing the MIDI file header structure
  • events.py contains several classes representing the various events that can be present in the MIDI files
  • sequencer.py contains the sequencer which takes a MIDI track (a temporally ordered list of events) and executes them
  • synth.py contains the Synthesizer class that plays samples as required
Click Download Project Zip below to get the full project with all the files

Below is a snapshot of what CIRCUITPY should look like.

Temporarily unable to load content:

This guide was first published on Dec 12, 2018. It was last updated on Jul 18, 2024.

This page (Code) was last updated on Jul 18, 2024.

Text editor powered by tinymce.