|
1 | | -# Digital Kalimba for Daisy Seed |
| 1 | +# KarplusStrongMachine – Digital Kalimba on Daisy Seed |
2 | 2 |
|
3 | | -A 7-button polyphonic synthesizer using Karplus-Strong physical modeling synthesis with 5 selectable musical scales. |
| 3 | +A playable **Karplus–Strong “digital Kalimba”** built on the Daisy Seed platform. |
| 4 | +Designed as both an **instrument** and a **teaching tool** for exploring physical modelling, microcontrollers, and sound design. |
4 | 5 |
|
5 | | -## Features |
6 | | - |
7 | | -- **Full Polyphony:** All 7 notes can play simultaneously |
8 | | -- **5 Musical Scales:** Pentatonic Major, Dorian, Chromatic, Kalimba, Just Intonation |
9 | | -- **Octave Shift:** -2 to +2 octaves (5 octave range) |
10 | | -- **Frequency-Dependent Decay:** Low notes sustain longer, high notes decay faster |
11 | | -- **Stereo Reverb:** High-quality ReverbSc for spatial depth |
12 | | -- **Real-Time Control:** Brightness, Decay, Scale Select, Reverb Mix/Time |
13 | | -- **OLED Display:** Shows current scale, octave, and active notes |
14 | | -- **Low Latency:** ~0.08ms |
15 | | - |
16 | | -## Quick Start (Easiest Way) |
17 | | - |
18 | | -**Flash directly from your browser! No software installation required.** |
19 | | - |
20 | | -1. **Connect** your Daisy Seed to your computer via USB. |
21 | | -2. **Visit the Web Flasher:** |
22 | | - 👉 **[https://willbearfruits.github.io/KarplusStrongMachine/web-flasher/](https://willbearfruits.github.io/KarplusStrongMachine/web-flasher/)** |
23 | | -3. **Put Daisy in Bootloader Mode:** |
24 | | - * Hold **BOOT** button. |
25 | | - * Press **RESET** button. |
26 | | - * Release **BOOT** button. |
27 | | -4. Click **"Connect to Daisy Seed"** and select your device. |
28 | | -5. Click **"Flash Firmware"**. |
29 | | -6. Press **RESET** to play! |
| 6 | +**Status:** Workshop-ready; evolving with student feedback. |
30 | 7 |
|
31 | 8 | --- |
32 | 9 |
|
33 | | -## Alternative: Build from Source (CLI) |
| 10 | +## 🎯 What this project is |
34 | 11 |
|
35 | | -### 1. Build and Upload |
36 | | - |
37 | | -```bash |
38 | | -cd ~/Documents/KarplusStrongMachine |
39 | | -make program-dfu |
40 | | -``` |
| 12 | +- A complete **hardware + firmware** project: |
| 13 | + - Daisy Seed-based audio core |
| 14 | + - Simple controls for tuning, decay, damping, etc. |
| 15 | + - Audio out designed for pedal/synth workflows |
| 16 | +- A **workshop-ready** instrument: |
| 17 | + - **[Web Flasher](https://willbearfruits.github.io/KarplusStrongMachine/web-flasher/)** so students can program it from a browser (no toolchain needed!) |
| 18 | + - Clear wiring diagrams and parts list |
| 19 | + - Documentation written for people who like to experiment and break things |
41 | 20 |
|
42 | | -## Hardware Setup |
43 | | - |
44 | | -### Minimum Required Wiring |
45 | | - |
46 | | -**7 Buttons (to GND):** |
47 | | -- D1 (Pin 2) - G4 (Center note) |
48 | | -- D2 (Pin 3) - A3 |
49 | | -- D3 (Pin 4) - B4 |
50 | | -- D4 (Pin 5) - D4 |
51 | | -- D5 (Pin 6) - E4 |
52 | | -- D6 (Pin 7) - G3 (Lowest note) |
53 | | -- D7 (Pin 8) - A4 |
| 21 | +--- |
54 | 22 |
|
55 | | -Each button connects GPIO pin to GND (momentary push buttons, normally open). |
| 23 | +## 🧱 Features |
56 | 24 |
|
57 | | -**Audio Output:** |
58 | | -- Pin 19 (Left) → Amplifier/Headphones |
59 | | -- Pin 20 (Right) → Amplifier/Headphones |
60 | | -- Pin 40 (GND) → Common ground |
| 25 | +- **Karplus–Strong synthesis** (plucked string / Kalimba vibe) with 7-voice polyphony |
| 26 | +- **5 Selectable Scales** (Pentatonic, Dorian, Chromatic, Kalimba, Just Intonation) |
| 27 | +- **Stereo Reverb** (ReverbSc) for spatial depth |
| 28 | +- **Octave Shift** (-2 to +2 range) |
| 29 | +- **Low Latency** (~0.08ms) for responsive playability |
| 30 | +- **Parameters exposed** as simple potentiometers, making it easy to teach DSP concepts like "damping" and "feedback" physically. |
61 | 31 |
|
62 | | -### Optional Controls |
| 32 | +--- |
63 | 33 |
|
64 | | -**6 Potentiometers (10kΩ, wiper to ADC pin):** |
65 | | -- A0 (Pin 15) - Global Brightness |
66 | | -- A1 (Pin 16) - Global Decay/Sustain |
67 | | -- A2 (Pin 17) - Octave Shift |
68 | | -- A3 (Pin 18) - Scale Select |
69 | | -- A4 (Pin 19) - Reverb Mix |
70 | | -- A5 (Pin 20) - Reverb Time |
| 34 | +## 🔌 Hardware Overview |
71 | 35 |
|
72 | | -**OLED Display (I2C, 0.96" SSD1306):** |
73 | | -- D11 (Pin 12) - SCL |
74 | | -- D12 (Pin 13) - SDA |
75 | | -- 3.3V - VCC |
76 | | -- GND - GND |
| 36 | +- **Core:** Electrosmith Daisy Seed (STM32H750) |
| 37 | +- **Controls:** |
| 38 | + - 7 Push Buttons (Notes D1-D7) |
| 39 | + - 6 Potentiometers (Tone, Decay, Octave, Scale, Reverb Mix, Reverb Time) |
| 40 | + - 1 OLED Display (Optional, I2C) |
| 41 | +- **I/O:** |
| 42 | + - Stereo Audio Out (Pins 19/20) |
| 43 | + - USB for flashing |
77 | 44 |
|
78 | | -For complete wiring instructions, see **KALIMBA_WIRING.md** |
| 45 | +See **[KALIMBA_WIRING.md](KALIMBA_WIRING.md)** for complete wiring details and pinouts. |
79 | 46 |
|
80 | | -## Button Layout |
| 47 | +--- |
81 | 48 |
|
82 | | -Traditional kalimba center-out alternating pattern: |
| 49 | +## 🚀 Quickstart |
83 | 50 |
|
84 | | -``` |
85 | | - Left Side Center Right Side |
| 51 | +### 1. The Easy Way (WebUSB) |
| 52 | +No coding required. Perfect for workshops. |
| 53 | +1. Connect Daisy Seed via USB. |
| 54 | +2. Put in bootloader mode (Hold BOOT, press RESET). |
| 55 | +3. Go to the **[Web Flasher](https://willbearfruits.github.io/KarplusStrongMachine/web-flasher/)**. |
| 56 | +4. Click "Connect" -> "Flash". |
86 | 57 |
|
87 | | - [6] G3 |
88 | | - [4] D4 |
89 | | - [2] A3 [1] G4 |
90 | | - [3] B4 |
91 | | - [5] E4 |
92 | | - [7] A4 |
| 58 | +### 2. The Developer Way (CLI) |
| 59 | +For modifying the code and DSP. |
93 | 60 |
|
94 | | - Playing order (low to high): |
95 | | - 6 (G3) → 2 (A3) → 4 (D4) → 5 (E4) → 1 (G4) → 7 (A4) → 3 (B4) |
96 | | -``` |
| 61 | +```bash |
| 62 | +git clone https://github.com/willbearfruits/KarplusStrongMachine.git |
| 63 | +cd KarplusStrongMachine |
97 | 64 |
|
98 | | -**Tuning:** G Major Pentatonic |
99 | | -**Scale degrees:** G A B D E G A |
100 | | -**Range:** G3 (196 Hz) to B4 (493.88 Hz) |
101 | | - |
102 | | -## Note Characteristics |
103 | | - |
104 | | -| Button | Note | Frequency | Sustain | Character | |
105 | | -|--------|------|-----------|---------|-----------| |
106 | | -| 1 | G4 | 392 Hz | Medium-Long | Balanced | |
107 | | -| 2 | A3 | 220 Hz | Very Long | Warm, deep | |
108 | | -| 3 | B4 | 494 Hz | Short | Bright, clear | |
109 | | -| 4 | D4 | 294 Hz | Long | Rich, full | |
110 | | -| 5 | E4 | 330 Hz | Medium | Sweet | |
111 | | -| 6 | G3 | 196 Hz | Longest | Deep, resonant | |
112 | | -| 7 | A4 | 440 Hz | Medium | Bright | |
113 | | - |
114 | | -## Controls (Potentiometers) |
115 | | - |
116 | | -| Control | Function | Effect | |
117 | | -|---------|----------|--------| |
118 | | -| **A0 - Brightness** | Tone color | CCW: Warmer, darker / CW: Brighter, metallic | |
119 | | -| **A1 - Decay** | Sustain time | CCW: Short plucks / CW: Long sustain | |
120 | | -| **A2 - Octave Shift** | Pitch range | Center: Normal. Left: -1/-2 oct. Right: +1/+2 oct | |
121 | | -| **A3 - Scale Select** | Musical Scale | 5 regions: Pentatonic -> Dorian -> Chromatic -> Kalimba -> Just Intonation | |
122 | | -| **A4 - Reverb Mix** | Dry/wet mix | CCW: Dry / CW: Full reverb | |
123 | | -| **A5 - Reverb Time** | Room size | CCW: Small room / CW: Large hall | |
124 | | - |
125 | | -## Tips for Playing |
126 | | - |
127 | | -### Basic Technique |
128 | | -- Press buttons firmly for clean attack |
129 | | -- Multiple buttons can be pressed simultaneously for chords |
130 | | -- Experiment with rhythmic patterns |
131 | | - |
132 | | -### Musical Ideas |
133 | | -- **Arpeggio:** Play 6-2-4-5-1-7-3 slowly for ascending melody |
134 | | -- **Chord:** Press 6+4+1 together for G major triad |
135 | | -- **Drone:** Hold button 6 (G3) while playing melody on other buttons |
136 | | -- **Rhythm:** Use buttons 1 and 3 alternating for simple rhythm |
137 | | - |
138 | | -### Sound Shaping |
139 | | -- **Plucked sound:** Brightness high (A0 CW), Decay medium (A1 center) |
140 | | -- **Bell-like:** Brightness very high (A0 full CW), Reverb high (A4/A5 CW) |
141 | | -- **Warm pad:** Brightness low (A0 CCW), Decay high (A1 CW), Reverb high (A4 CW) |
142 | | -- **Octave Jump:** Turn A2 left/right to shift range down/up |
143 | | -- **Scale Change:** Turn A3 to explore different moods (Dorian, Chromatic, etc.) |
144 | | - |
145 | | -## Technical Specifications |
146 | | - |
147 | | -**Platform:** Electrosmith Daisy Seed (STM32H750, ARM Cortex-M7 @ 480MHz) |
148 | | -**DSP Algorithm:** Karplus-Strong string synthesis with DC blocking |
149 | | -**Audio Quality:** 48kHz sample rate, floating-point processing |
150 | | -**Polyphony:** 7 voices (fully independent strings) |
151 | | -**Effects:** ReverbSc, optional LFO modulation (vibrato/tremolo) |
152 | | -**Latency:** ~0.08ms (4-sample buffer) |
153 | | -**CPU Usage:** 12-15% |
154 | | -**Memory:** ~95KB Flash, ~30KB RAM |
155 | | - |
156 | | -## Customization |
157 | | - |
158 | | -The tuning and parameters can be easily modified in `DigitalKalimba.cpp`: |
159 | | - |
160 | | -### Change Tuning |
161 | | -Edit the `base_frequencies[]` array: |
162 | | -```cpp |
163 | | -// Example: C Major Pentatonic |
164 | | -const float base_frequencies[NUM_STRINGS] = { |
165 | | - 261.63f, // C4 |
166 | | - 146.83f, // D3 |
167 | | - 329.63f, // E4 |
168 | | - 196.00f, // G3 |
169 | | - 440.00f, // A4 |
170 | | - 130.81f, // C3 |
171 | | - 293.66f // D4 |
172 | | -}; |
173 | | -``` |
| 65 | +# Build |
| 66 | +make -j4 |
174 | 67 |
|
175 | | -### Adjust Sustain Times |
176 | | -Edit the `base_damping[]` array (0.5 = short, 0.99 = very long): |
177 | | -```cpp |
178 | | -const float base_damping[NUM_STRINGS] = { |
179 | | - 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f |
180 | | -}; |
| 68 | +# Flash |
| 69 | +make program-dfu |
181 | 70 | ``` |
182 | 71 |
|
183 | | -### Change Button Pins |
184 | | -Edit the `button_pins[]` array to use different GPIO pins. |
185 | | - |
186 | | -## Troubleshooting |
187 | | - |
188 | | -**No sound:** |
189 | | -- Check audio cable connections |
190 | | -- Verify buttons are wired correctly (GPIO to GND) |
191 | | -- Ensure Daisy is powered and reset after upload |
192 | | - |
193 | | -**Wrong notes:** |
194 | | -- Verify button connections match pin assignments |
195 | | -- Check for swapped wires |
196 | | -- Re-upload firmware |
197 | | - |
198 | | -**Buttons not responding:** |
199 | | -- Test button continuity with multimeter |
200 | | -- Check for cold solder joints |
201 | | -- Verify GND connection |
202 | | - |
203 | | -**Display not working:** |
204 | | -- Non-critical - kalimba works without display |
205 | | -- Check I2C wiring (SCL/SDA not swapped) |
206 | | -- Verify 3.3V power to display |
207 | | - |
208 | | -**Pots not responding:** |
209 | | -- Optional feature - kalimba works without pots |
210 | | -- Check 3.3V and GND connections |
211 | | -- Verify wiper connection to ADC pin |
| 72 | +--- |
212 | 73 |
|
213 | | -## Future Enhancements |
| 74 | +## 🎓 Teaching & Workshop Use |
214 | 75 |
|
215 | | -With 85% CPU remaining, you can add: |
216 | | -- **Delay effect** for rhythmic echoes |
217 | | -- **Chorus** for lush, shimmering texture |
218 | | -- **Multiple tuning presets** (button combo to switch) |
219 | | -- **Recording/looping** |
220 | | -- **Velocity sensitivity** (FSR sensors) |
221 | | -- **MIDI output** to control other synths |
222 | | -- **Sympathetic resonance** (notes trigger related harmonics) |
223 | | -- **Expand to 8-12 notes** |
| 76 | +I use this project in workshops on: |
| 77 | +- **Synths and Microcontrollers** |
| 78 | +- **Physical Modelling Synthesis** |
| 79 | +- **Building Complete Instruments** (DSP + Hardware + Enclosure) |
224 | 80 |
|
225 | | -## Files |
| 81 | +It is intentionally: |
| 82 | +- **Minimal enough** for beginners to follow the signal path. |
| 83 | +- **Open enough** for advanced students to fork (e.g., "change the scale," "add a delay effect," "make it a drone machine"). |
226 | 84 |
|
227 | | -- **DigitalKalimba.cpp** - Main source code |
228 | | -- **Makefile** - Build configuration |
229 | | -- **web-flasher/** - WebUSB firmware uploader |
230 | | -- **KALIMBA_WIRING.md** - Complete wiring guide |
231 | | -- **build.sh / upload.sh** - Convenience scripts |
| 85 | +If you use it in a class, feel free to open an issue or PR with notes! |
232 | 86 |
|
| 87 | +--- |
233 | 88 |
|
234 | | -## Credits |
| 89 | +## 🧪 Technical Details |
235 | 90 |
|
236 | | -Based on the KarplusStrongMachine project by glitches. |
237 | | -Uses libDaisy and DaisySP libraries by Electrosmith. |
238 | | -Karplus-Strong algorithm ported from Mutable Instruments Rings. |
| 91 | +- **Platform:** Daisy Seed (ARM Cortex-M7 @ 480MHz) |
| 92 | +- **Audio:** 48kHz, 24-bit, 4-sample block size |
| 93 | +- **DSP:** Custom `String` class (ported from Mutable Instruments Rings) |
| 94 | +- **CPU Usage:** ~15% (plenty of room for more effects) |
239 | 95 |
|
240 | 96 | ## License |
241 | 97 |
|
242 | | -MIT License (same as libDaisy/DaisySP) |
243 | | - |
244 | | ---- |
245 | | - |
246 | | -**Enjoy your Digital Kalimba!** 🎵 |
247 | | - |
248 | | -For questions or issues, check KALIMBA_WIRING.md or CLAUDE.md for detailed documentation. |
| 98 | +MIT. Break it, bend it, rebuild it. |
0 commit comments