Is there a way to trigger a kick drum sound by connecting a pedal on the input? (Dwarf)

I didn’t know those are that cheap - always used an arduino pro micro (clone) for the midi usb stuff.
But great and simple - do you mind posting code for the expression input part? Then I might build a box just for fun.

see above - if someone ist interested let me know. I build one for myself and while I’m at it throw together a few more.

5 Likes

Sure! Here it is, I have kept the code for the footswitch and added an expression input:

import adafruit_midi
import board
import digitalio
import simpleio
import usb_midi

from adafruit_debouncer import Debouncer

from adafruit_midi.note_on          import NoteOn
from adafruit_midi.note_off         import NoteOff
from adafruit_midi.control_change   import ControlChange

from analogio import AnalogIn

#  MIDI setup as MIDI out device
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0)

switchPin = digitalio.DigitalInOut(board.GP2)
switchPin.direction = digitalio.Direction.INPUT
switchPin.pull = digitalio.Pull.UP
switch = Debouncer(switchPin)

analogIn = AnalogIn(board.A2)

#Set these according to your expression pedal. 
# you might need to increase the min and decrease the max 
# until you get the full 0-127 range in the CC
min = 0
max = 32768

#Keep the previous readings in a list to use for smoothing out noise
previousReadings = []

#keep the last smoothed reading so that we can only send a new CC if it changes
previousSmoothedReading = 0

# A simple moving average filter
def sma(reading):
    previousReadings.append(reading)
    if (len(previousReadings) > 30):
        previousReadings.pop(0)
    return sum(previousReadings) / len(previousReadings)

while True:
    #  Read the analog input
    rawReading = analogIn.value
    # Smooth out the analog input reading using a SMA filter
    smoothedReading = sma(rawReading)
    mappedReading = int(simpleio.map_range(smoothedReading,min,max,0,127))

    #Only send MIDI data if the reading has changed
    if (mappedReading != previousSmoothedReading):
        print(mappedReading);
        midi.send(ControlChange(0, mappedReading))
        previousSmoothedReading = mappedReading

    #Check if the footswitch has changed state
    switch.update()
    if switch.rose:
        print('Pressed')
        midi.send(NoteOn(60))
    if switch.fell:
        print('Released')
        midi.send(NoteOff(60))


Regarding the hardware, things are a bit trickier than the last time:

Red is 3.3V, Black is Ground & Yellow is the analog A2 pin. They go to a female stereo jack socket:

  • Black (Ground) goes to the sleeve
  • Red (3.3V) goes to the ring, through a 10K resistor
  • Yellow (Analog In) goes to the tip

The 10K resistor is there so that if the 3.3V and Ground are short circuited the current will be kept low and the Pico won’t fry up.

The following two components are not strictly needed but they help:

  • I have added a pulldown resistor between Ground and Analog in, otherwise the analog in pin is left floating and the signal is pure noise when you don’t have an expression pedal connected.
    I used a 10K resistor but I would suggest using a much bigger one (100K) because it forms a voltage divider with the 10K resistor on 3.3V and you end up being able to only read half the possible range.

  • I also added an 100nF ceramic capacitor between Ground and Analog in to filter out some noise

Last but not least, the way the connections were done was based on the expression pedal I have, a cheapo Nektar NX-P that has the signal on its tip.

10 Likes

Ah, that does not sound overly good. Thanks for looking that up!

1 Like

To come back to the original request, it should actually be possible to connect a TS footswitch to the Dwarf and use some CV trickery to get it running. Not the best UX, but possible nonetheless.

When connecting a TS footswitch, there is basically an antenna effect over the cable, which gets shorted to ground when pressed. We can use this to detect no noise VS noise and use that to trigger samples.

I did a little example pedalboard of this here:

First the audio is gained up a LOT, translated to CV and made unipolar. Then it goes to a slew rate limiter, to prevent some accidental triggers. that signal goes to a range divider which outputs a signal when the CV value is between 0V and 1V (no noise). That goes to a CV gate where it triggers a clean 10V which is used to trigger the MINDI to play a note

not the prettiest, but works :slight_smile:
Hope this is useful to someone!

13 Likes

This is excellent! Is it safe for the hardware though?

3 Likes

sure! Electrically the same is happening as re-plugging a jack all the time, because the Dwarf inputs are grounded internally when nothing is connected :slight_smile:

3 Likes

Yes for a few times, but would it be safe to do it continuously for 6 hours straight? Does it cause any kind of wear?

3 Likes

no not at all. grounding an input does not cause any harm :slight_smile:

4 Likes

An update for anyone interested:
The solution provided by @christosku (with the Raspberry pie) worked perfectly, thank you so much! No latency or issues whatsoever. Its even working with the “exampler” pedal (Exampler - MOD Devices) to trigger a nice kick drum sample instead of the basic ones from the device. This is the one I have been using if anyone wants it ALEFADNS.wav - Google Drive

Unfortunately the solution by @Jan was not reliable. Even the slightest noise in the signal can trigger a false positive, so its pretty much random. I tried tuning the sensitivity with the gain knobs, but no luck. It will either be random, or not work at all. Its a very good proof of concept tho, maybe with a reliable source of audio (like one of those piezo kick drum stomp boxes) you can use it to trigger an actual good sample of a kick drum (or whatever your heart desires)

6 Likes