MIDI to trigger DIY eurorack module

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: luketeaford, Joe., lisa, Kent

Post Reply
User avatar
Picard
Common Wiggler
Posts: 52
Joined: Wed Jun 01, 2016 4:31 pm
Location: Europe

MIDI to trigger DIY eurorack module

Post by Picard » Thu Sep 12, 2019 9:56 am

For live performance I need to sync the eurorack to a master MIDI clock. To make trigger pulses available for 16th, 8th, 4th, half, and full notes I built a small straight forward module based on a Atmega328. It is just listening to the MIDI clock messages (0xF8) and counting 16th notes internally.

It was important to also evaluate the MIDI START message (0xFA) to reset the internal 16th counter to sync all triggers to the start of a bar.

Look at this:
Image

Image

User avatar
Picard
Common Wiggler
Posts: 52
Joined: Wed Jun 01, 2016 4:31 pm
Location: Europe

Post by Picard » Thu Sep 12, 2019 1:30 pm

The firmware is Arduino-based and uses event handlers for the clock messages.
micros() is used to get trigger puls widths of 10 ms.

Code: Select all

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE&#40;&#41;;

static const unsigned b&#91;&#93; = &#123;PD3, PD2, PD4, PD5, PD6&#125;;
static const byte m&#91;&#93; = &#123;96, 48, 24, 12, 6&#125;;
byte a&#91;&#93; = &#123;0, 0, 0, 0, 0&#125;;
unsigned long t&#91;&#93; = &#123;0, 0, 0, 0, 0&#125;;
byte c = 96;
byte i;

void handleClock&#40;void&#41;
&#123;
  for &#40;i = 0; i <= 4; i++&#41;
    if &#40;&#40;c % m&#91;i&#93;&#41; == 0&#41; &#123;
      digitalWrite&#40;b&#91;i&#93;, HIGH&#41;;
      a&#91;i&#93; = 1;
      t&#91;i&#93; = micros&#40;&#41;;
    &#125;
  c--;
  if &#40;c == 0&#41; c = 96;
&#125;
void handleStart&#40;void&#41;
&#123;
  c = 96;
&#125;
void handleContinue&#40;void&#41;
&#123;
  
&#125;
void handleStop&#40;void&#41;
&#123;

&#125;

void setup&#40;&#41;
&#123;
  for &#40;i = 0; i <= 4; i++&#41; pinMode&#40;b&#91;i&#93;, OUTPUT&#41;;

  MIDI.setHandleClock&#40;handleClock&#41;;
  MIDI.setHandleStart&#40;handleStart&#41;;
  MIDI.setHandleContinue&#40;handleContinue&#41;;
  MIDI.setHandleStop&#40;handleStop&#41;;
  MIDI.begin&#40;MIDI_CHANNEL_OMNI&#41;;
  MIDI.turnThruOff&#40;&#41;;
&#125;

void loop&#40;&#41;
&#123;
  MIDI.read&#40;&#41;;
  for &#40;i = 0; i <= 4; i++&#41;
    if &#40;a&#91;i&#93; == 1&#41;
      if &#40;&#40;micros&#40;&#41; - t&#91;i&#93;&#41; > 10000&#41; &#123;
        digitalWrite&#40;b&#91;i&#93;, LOW&#41;;
        a&#91;i&#93; = 0;
      &#125;
&#125;

User avatar
Bjarne
Common Wiggler
Posts: 101
Joined: Sat Jul 20, 2013 10:31 am
Location: Stockholm

Post by Bjarne » Thu Sep 12, 2019 1:51 pm

Thanks for sharing! This looks like a nice schematic for breadboarding a minimalistic midi to drum trigger gadget as well.
Cheers

aabbcc
Wiggling with Experience
Posts: 312
Joined: Fri Feb 02, 2018 10:47 am
Location: Sweden

Post by aabbcc » Fri Sep 13, 2019 4:05 pm

Looks awesome! Any chance the code code be modified to support accent/velocity changes over midi?

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1496
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Post by devinw1 » Fri Sep 13, 2019 9:30 pm

Nice! Simple but effective! :tu:

User avatar
cackland
Super Deluxe Wiggler
Posts: 2161
Joined: Thu Dec 28, 2017 5:42 pm
Location: Los Angeles, California

Post by cackland » Fri Sep 13, 2019 11:13 pm

aabbcc wrote:Looks awesome! Any chance the code code be modified to support accent/velocity changes over midi?
Yes, this is easily done.

Post Reply

Return to “Music Tech DIY”