Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: [queued] TeensyMIDIPolySynth

Threaded View

  1. #1
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    102

    [queued] TeensyMIDIPolySynth

    OK, so here's yet another Teensy4-based MIDI-capable 16-note polyphonic 2-voice synthesizer . . . that's a real mouthful.

    PERSONAL BACKGROUND: I am a software engineer by day, so I write software (almost) all day long. My wife thinks I'm absolutely crazy for many reasons, but mostly because I also like to write software when I get home & want to relax !! However, truth be known, my hobby software is very often quite sloppy & unprofessional, so if you happen to take a look at my sketch, make sure to set your expectations appropriately low.

    PROJECT OBJECTIVE/BACKGROUND: I've always been interested in synthesizers from the time that I started developing my taste in late '70s / early '80s music (think Styx, Kansas, ELO, etc.). I've longed to understand both how synths worked & the deep meaning of all of the terminology (e.g. VFO, LFO, CV, envelope, attack, decay, filtering, etc.). In the process of ordering a PC board from OshPark (in addition to software, I dabble in hardware/PCBs as well), the checkout process asked if i would like to add a Teensy 4.0 to my order. I thought to myself "I don't have any idea what a Teensy is, but for the price. . . sure !!" Upon receipt of that order, I did some quick research on "Teensy projects" & the first thing I found was, with the addition of an inexpensive "Teensy Audio Board", I could produce a very functional synthesizer. BONUS !! So, off I went . . .

    CAPABILITIES (the initial idea for the capabilities that I would target was based upon a friend's Behringer Neutron - a *real* synthesizer, albeit monophonic & only *slightly* more expensive):
    - implemented using the Teensy 4.0 + Teensy 4.0 Audio Board, plus Sparkfun 16-channel analog MUXs to manage the 48-pots, the 42 pushbuttons, and the 42 LEDs (the LEDs will need to be converted over to being driven using 74HC595 8-output shift register boards instead - the analog MUXs are managing so many inputs/outputs that the duty cycle on driving the LEDs is very low, so they are way too dim !!)
    - 16-note polyphony, 2-voice (2 VFOs) per note
    - LFO #1 serves as an input into the two VFO waveform generators for FM modulation
    - modulation LFO can mix any combination of sine, square, pulse (with adjustable duty cycle), triangle, sawtooth, & sample/hold (each with amplitude control, both positive & negative, as well as waveform on/off pushbutton control)
    - the modulation LFO can also operate in "single waveform" mode (to allow quick changes among the selectable waveforms)
    - each of the two VFOs has an independent octave control (+/- 3 octave range)
    - each of the two VFOs can mix any combination of sine, square, triangle, sawtooth, string, white noise, pink noise (each with individual amplitude control, both positive & negative, as well as individual waveform on/off pushbutton control), & tonesweep (with sweep rate control, either rising or falling frequency, & on/off pushbutton control)
    - each of the two VFOs can also operate in "single waveform" mode (to allow quick changes among the selectable waveforms)
    - the output from each of the two VFOs feed into an envelope generator, with attack, hold, decay, sustain, & release controls
    - LFO #2 serves as an input into the filter for FM modulation of the corner frequency
    - filter LFO can mix any combination of sine, square, pulse (with adjustable duty cycle), triangle, sawtooth, & sample/hold (each with amplitude control, both positive & negative, as well as individual waveform on/off pushbutton control)
    - the filter LFO can also operate in "single waveform" mode (to allow quick changes among the selectable waveforms)
    - the output from the envelope generator feeds into a filter, with selections for NONE (no filtering), lowpass, bandpass, & highpass, (with any mix of the last three) as well as control of the corner frequency & resonance
    - control of master volume, AB balance (balance between the two VFOs), VFO tuning (to allow the output from this synth to be tuned to a physical instrument, like a piano), & AB detuning (add a small beat difference between the two VFOs)
    - MIDI channel can be set to "All" (respond to all notes on all channels), or any individual channel from 1-16
    - includes a "MIDI panic" button (stop all notes immediately without a power-cycle)
    - has MIDI-in & MIDI-thru jacks
    - has 1/8" audio out jack
    - LIPO battery powered (12-20 hours of operation on a single charge), w/ Adafruit PowerBoost 1000 for battery management, as well as USB-powered
    - appears as a USB MIDI device (named "Teensy16PolySynth")
    - fully supports use of PitchBend wheel, Modulation wheel, & sustain pedal

    LESSONS LEARNED:
    1) this is definitely a one-off project . . . if I were to consider building another one, I'd definitely put the effort into designing a PC board for it - I would not survive trying to wire a 2nd copy
    1) this is *NOT* a project that you take on to build something for less money than if you went out & bought the same capabilities !!
    2) the wiring was very, very, very, very tedious & almost prevented me from completing the project
    3) writing the software was the easy part for me (& I don't think it will ever be "finally & fully done") - again, it is very sloppy, but fully functional !!
    4) I now completely understand synth terminology (at least the terms that I needed for this) & can at least appreciate the functionality (if not the actual operation under the covers) of the components (VFO, LFO, envelope, filter, mixer, etc.) of a real synth
    5) the Teensy audio library is absolutely amazing in how easy it is to use & all of the capabilities that it provides !!

    IF I WERE TO DO THIS AGAIN, CHANGES TO BE CONSIDERED:
    - much of the layout was driven by the "plastic storage box" chosen for the build - get a bigger box (so more controls can be accomodated) !!
    - add a separate envelope generator for each VFO
    - add a separate envelope generator for the modulation LFO
    - add a separate envelope generator for the filter LFO
    - need to figure out how to add portamento/glide

    FINAL COMMENTS:
    The source is available for perusal on my Google Drive at the following link: https://drive.google.com/open?id=1UL...bfLNNLCdPRF13J

    Example video of circus music played (via MIDI file) on a TeensyMIDIPolySynth configuration which emulates my idea of a calliope: https://youtu.be/5jyEEnRqu9s

    Example video of carousel music played (via MIDI file) on a TeensyMIDIPolySynth configuration which emulates my idea of a calliope: https://youtu.be/adJfd6ney_g

    The two MIDI files used for the YouTube videos can be found in the "MIDI" sub-folder via the Google Drive link given above. Looking at the content of these two example MIDI files can give a feel for the complexity of the polyphonic content that the TeensyMIDIPolySynth is capable of playing !!

    I don't have any "in-progress" pictures (I don't want to be reminded of the pain), but a few pictures of the finished product can be found in the "pictures" sub-folder via the Google Drive link given above. That same pictures sub-folder also contains several snapshots from the Teensy Audio Layout GUI for reference.

    The front-panel labeling started out as just a "drill template" & I had tentatively planned to add tape labels to the controls. I definitely did not look forward to how I was going to keep the haphazard alignment of the labels from making the finished product look very unprofessional. After laying out the drill template in the 2D/3D CAD program that I use, I realized that the drill template could easily transform into a full front panel overlay, with the labels included in the print. However, if you look closely (ignoring the hand-labeled areas), you can see where I changed my mind on some of the controls, so there are still a few label tape overlays.

    Mark J Culross
    KD5RXT

    P.S. If you would like to try out the "calliope" for yourself, you don't need to build a full TeensyMIDIPolySynth of your own (even if you thought you might want to endure the pain !!). You can simply connect a Teensy4.0 + Teensy 4.0 Audio Board together & you have all the hardware that's needed !! Appropriate initial values are already incorporated into the setup() function. Simply change the "#define" lines near the top of the source file as follows, compile, download, & you're all set to use it as a USB MIDI device emulating my idea of a calliope:

    //#define CHECK_CYCLE_TIME
    //#define DEBUG_NOTE_MSGS
    //#define DEBUG_CC_MSGS
    //#define DEBUG_POTS
    //#define DEBUG_PBUTTONS
    //#define DISABLE_POT_MUX_SETTLING_TIME
    //#define DISABLE_PB_MUX_SETTLING_TIME
    //#define ENABLE_LED_MUX_SETTLING_TIME
    //#define DISABLE_STATUS
    #define DISABLE_POT_READ
    #define DISABLE_PB_READ
    #define DISABLE_EEPROM_READ
    #define DISABLE_EEPROM_WRITE
    //#define DEBUG_EEPROM_WRITE
    //#define DEBUG_EEPROM_READ
    //#define DEBUG_MAKE_NOTE_AVAILABLE
    #define SKIP_LED_TEST

    Have fun !! MJC
    Last edited by kd5rxt-mark; 04-30-2020 at 04:25 AM. Reason: forgot the "CHANGES" section & corrected a few typos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •