The StompByte uses an ATMega328p produce drum sounds/patterns using PCM when a button is pressed/released. Holding the button for two seconds changes the sound/pattern. The StompByte is a creation of Geek Funk Labs, where you can find a complete bill of materials, links to obtain kits/builds, etc.
There are 10 samples and 3 patterns:
- muted kick
- rock kick
- tr808 kick
- woodblock
- cross stick
- tambourine
- handclap
- mario bump
- mario fireball
- mario jump
- pattern: rock kick – woodblock – tambourine – woodblock
- pattern: tr808 kick – tambourine – handclap – tambourine
- pattern: mario bump – mario fireball – mario jump – mario fireball
The code is written for the Arduino IDE. The code can be most easily compiled and flashed to the ATMega328P by swapping it with the ATMega in an Arduino UNO and uploading the code, then swapping the ATMega back into the StompByte. You can also use your own programmer, in which case you should use the Boards Manager in the IDE to install the DIY AVR boards definitions, then select the ATMega328P as your board and select 16MHz crystal/resonator as your processor speed. To compile a .hex file for flashing directly using your own programmer, choose "Export compiled Binary" in the IDE.
To program your ATMega328P using a Raspberry Pi, make the following connections from the GPIO header:
RPi Physical Pin | ATMega328P |
---|---|
23 (SCLK) | 19 (SCK) |
21 (MISO) | 18 (MISO) |
19 (MOSI) | 17 (MOSI) |
22 (GPIO25) | 1 (RESET) |
2 (5V) | 7 (VCC) |
6 (GND) | 8 (GND) |
You must also connect a 16MHz clock source (quartz oscillator) to pins 9&10 (XTAL1&2) on the ATMega, and ground each pin through a 22pF capacitor. Enter the following commands to flash the compiled .hex file and properly set the fuses (E:FF, H:DF, L:EF) on the ATMega328p using the SPI interface on a Raspberry PI:
sudo apt install avrdude
sudo avrdude -c linuxspi -P /dev/spidev0.0 -p m328p -U flash:w:stompbyte.ino.arduino_standard.hex:i
sudo avrdude -c linuxspi -P /dev/spidev0.0 -p m328p -U lfuse:w:0xef:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
You can change the sounds in the StompByte by modifying the code and re-flashing the ATMega328P as described above. You must save your audio samples as 8-bit, 8kHz .wav files - the ATMega328P can store roughly ~4 seconds total of audio this way. Convert your samples to an array of integers and replace the contents of the variables at the top of stompbyte.ino - you may want to rename some of the variables. Consult the comments in PCM.h for help converting your samples to integers.