├── samples ├── clap.wav ├── kick.wav ├── open.wav ├── closed.wav ├── cymbal.wav └── snare.wav ├── schematic ├── beetbox.fzz └── beetbox.jpg ├── beetbox.py ├── ReadMe.md └── mpr121.py /samples/clap.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/clap.wav -------------------------------------------------------------------------------- /samples/kick.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/kick.wav -------------------------------------------------------------------------------- /samples/open.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/open.wav -------------------------------------------------------------------------------- /samples/closed.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/closed.wav -------------------------------------------------------------------------------- /samples/cymbal.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/cymbal.wav -------------------------------------------------------------------------------- /samples/snare.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/samples/snare.wav -------------------------------------------------------------------------------- /schematic/beetbox.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/schematic/beetbox.fzz -------------------------------------------------------------------------------- /schematic/beetbox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottgarner/BeetBox/HEAD/schematic/beetbox.jpg -------------------------------------------------------------------------------- /beetbox.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """beetbox.py: Trigger script for the BeetBox.""" 4 | 5 | __author__ = "Scott Garner" 6 | __email__ = "scott@j38.net" 7 | 8 | import pygame 9 | 10 | import RPi.GPIO as GPIO 11 | import mpr121 12 | 13 | # Use GPIO Interrupt Pin 14 | 15 | GPIO.setmode(GPIO.BOARD) 16 | GPIO.setup(7, GPIO.IN) 17 | 18 | # Use mpr121 class for everything else 19 | 20 | mpr121.TOU_THRESH = 0x30 21 | mpr121.REL_THRESH = 0x33 22 | mpr121.setup(0x5a) 23 | 24 | # User pygame for sounds 25 | 26 | pygame.mixer.pre_init(44100, -16, 12, 512) 27 | pygame.init() 28 | 29 | kick = pygame.mixer.Sound('samples/kick.wav') 30 | kick.set_volume(.65); 31 | snare = pygame.mixer.Sound('samples/snare.wav') 32 | snare.set_volume(.65); 33 | openhh = pygame.mixer.Sound('samples/open.wav') 34 | openhh.set_volume(.65); 35 | closedhh = pygame.mixer.Sound('samples/closed.wav') 36 | closedhh.set_volume(.65); 37 | clap = pygame.mixer.Sound('samples/clap.wav') 38 | clap.set_volume(.65); 39 | cymbal = pygame.mixer.Sound('samples/cymbal.wav') 40 | cymbal.set_volume(.65); 41 | 42 | # Track touches 43 | 44 | touches = [0,0,0,0,0,0]; 45 | 46 | while True: 47 | 48 | if (GPIO.input(7)): # Interupt pin is high 49 | pass 50 | else: # Interupt pin is low 51 | 52 | touchData = mpr121.readData(0x5a) 53 | 54 | for i in range(6): 55 | if (touchData & (1< baseline. 77 | 78 | bus.write_byte_data(address, MHD_R, 0x01) 79 | bus.write_byte_data(address, NHD_R, 0x01) 80 | bus.write_byte_data(address, NCL_R, 0x00) 81 | bus.write_byte_data(address, FDL_R, 0x00) 82 | 83 | # Section B - Controls filtering when data is < baseline. 84 | 85 | bus.write_byte_data(address, MHD_F, 0x01) 86 | bus.write_byte_data(address, NHD_F, 0x01) 87 | bus.write_byte_data(address, NCL_F, 0xFF) 88 | bus.write_byte_data(address, FDL_F, 0x02) 89 | 90 | #Section C - Sets touch and release thresholds for each electrode 91 | 92 | bus.write_byte_data(address, ELE0_T, TOU_THRESH) 93 | bus.write_byte_data(address, ELE0_R, REL_THRESH) 94 | 95 | bus.write_byte_data(address, ELE1_T, TOU_THRESH) 96 | bus.write_byte_data(address, ELE1_R, REL_THRESH) 97 | 98 | bus.write_byte_data(address, ELE2_T, TOU_THRESH) 99 | bus.write_byte_data(address, ELE2_R, REL_THRESH) 100 | 101 | bus.write_byte_data(address, ELE3_T, TOU_THRESH) 102 | bus.write_byte_data(address, ELE3_R, REL_THRESH) 103 | 104 | bus.write_byte_data(address, ELE4_T, TOU_THRESH) 105 | bus.write_byte_data(address, ELE4_R, REL_THRESH) 106 | 107 | bus.write_byte_data(address, ELE5_T, TOU_THRESH) 108 | bus.write_byte_data(address, ELE5_R, REL_THRESH) 109 | 110 | bus.write_byte_data(address, ELE6_T, TOU_THRESH) 111 | bus.write_byte_data(address, ELE6_R, REL_THRESH) 112 | 113 | bus.write_byte_data(address, ELE7_T, TOU_THRESH) 114 | bus.write_byte_data(address, ELE7_R, REL_THRESH) 115 | 116 | bus.write_byte_data(address, ELE8_T, TOU_THRESH) 117 | bus.write_byte_data(address, ELE8_R, REL_THRESH) 118 | 119 | bus.write_byte_data(address, ELE9_T, TOU_THRESH) 120 | bus.write_byte_data(address, ELE9_R, REL_THRESH) 121 | 122 | bus.write_byte_data(address, ELE10_T, TOU_THRESH) 123 | bus.write_byte_data(address, ELE10_R, REL_THRESH) 124 | 125 | bus.write_byte_data(address, ELE11_T, TOU_THRESH) 126 | bus.write_byte_data(address, ELE11_R, REL_THRESH) 127 | 128 | # Section D 129 | # Set the Filter Configuration 130 | # Set ESI2 131 | 132 | bus.write_byte_data(address, FIL_CFG, 0x04) 133 | 134 | # Section E 135 | # Electrode Configuration 136 | # Set ELE_CFG to 0x00 to return to standby mode 137 | 138 | bus.write_byte_data(address, ELE_CFG, 0x0C) # Enables all 12 Electrodes 139 | --------------------------------------------------------------------------------