MPFII: a Touch-Sensitive Synthesizer

Introduction
Welcome to this complete tutorial for building the MPFII (Micro Polyphonic Flexible Instrument II), a modern homage to Taiwanese Apple II clones. This touch-sensitive synthesizer combines the power of the ESP32 with an intuitive interface based on a resistive wire to create a unique and expressive musical instrument.
The MPFII allows you to play notes by simply moving your finger along a resistive wire, while offering advanced features like multiple waveforms, delay effects, arpeggios, and different musical scales.
Required Materials
Main Components
- ESP32-WROVER (with built-in DAC) - ~$10
- 128x64 OLED Display (I2C, SSD1306) - ~$5
- Nichrome Resistive Wire (100Ω, 1m) - ~$3
- LM386 Audio Amplifier - ~$2
- 8Ω 0.5W Speaker - ~$3
- 4 Push Buttons - ~$2
- Resistors: 10kΩ (x4), 1kΩ (x1) - ~$1
- Breadboard or custom PCB - ~$5
- Enclosure (3D printed or existing box) - ~$10
Estimated total cost: ~$40
Tools
- Soldering iron
- Wiring wire
- Multimeter
- Computer with Arduino IDE
Wiring Diagram
Circuit Overview
1 | ESP32 Components |
LM386 Amplifier Detailed Wiring
1 | LM386: |
Physical Assembly
Step 1: Preparing the Resistive Wire
The resistive wire is the central element of our touch interface. For optimal response:
- Cut 30cm of 100Ω nichrome wire
- Stretch it slightly to make it perfectly straight
- Solder the ends to terminal blocks or directly to the board
- Calibrate the voltage: one end to 3.3V, the other to GND
Pro tip: For better durability, you can wrap the resistive wire with enameled copper wire at the solder points.
Step 2: Button Mounting
The 4 push buttons control different functions:
- Waveform (GPIO13): Cycle through 5 waveforms
- Delay (GPIO12): Enable/disable delay with 5 different times
- Arpeggio (GPIO14): Enable/disable arpeggio mode
- Scale (GPIO27): Change the musical scale
Each button should be wired with a 10kΩ pull-down resistor.
Step 3: OLED Display Installation
The OLED display shows all parameters in real-time:
- Connect SDA to GPIO21
- Connect SCL to GPIO22
- Power with 3.3V and GND
- Mount it in a visible location on your enclosure
Step 4: Audio Wiring
The audio chain is crucial for sound quality:
- GPIO25 (DAC1) → 1kΩ Resistor → LM386 Input
- LM386 Output → 220µF Capacitor → Speaker
- Add a 10kΩ potentiometer at input for volume control (optional)
ESP32 Programming
Arduino IDE Configuration
Install ESP32 support:
- File > Preferences
- Additional Boards Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Tools > Board Manager > Search for “ESP32” and install
Install required libraries:
Adafruit GFX Library
Adafruit SSD1306
The Complete Code
1 |
|
Detailed Features
1. Touch Interface
The heart of the MPFII is its touch interface based on a resistive wire:
- Principle: The resistive wire acts as a linear potentiometer
- Reading: The ESP32 measures voltage via its ADC (GPIO34)
- Mapping: The 0-4095 value is mapped to notes of the selected scale
- Precision: 8 notes per scale, evenly distributed along the wire length
2. Waveforms
The MPFII offers 5 distinct waveforms:
- Sine: Pure, soft wave, ideal for pads
- Square: Typical 8-bit sound, rich in harmonics
- Saw: Bright sound, perfect for leads
- Triangle: Soft, synthetic sound, between sine and square
- Noise: White noise, useful for percussion and effects
3. Musical Scales
Four scales are available to explore different musical styles:
- Major: Standard Western scale, happy
- Minor: Melancholic, dramatic scale
- Oriental: Characteristic Middle Eastern intervals
- Chinese: Pentatonic, traditional Asian sound
4. Delay Effect
The delay adds depth to the sound:
- 5 different times: 100ms, 200ms, 300ms, 500ms, 800ms
- Circular buffer: 44100 samples (1 second at 44.1kHz)
- Wet/dry mix: 50% original signal, 50% delayed signal
5. Arpeggiator
The arpeggiator automates note playing:
- 5 speeds: From fast to ultra slow
- Automatic cycling: Plays through all scale notes
- Timing: Based on millis() for temporal accuracy
Calibration and Settings
Resistive Wire Calibration
For optimal response, calibrate your wire:
- Open the serial monitor (115200 baud)
- Touch the wire ends and note the min/max values
- Adjust the mapping in the code if necessary:
1
int newNote = map(touchValue, minVal, maxVal, 0, scaleSizes[currentScale]-1);
Volume Control
To add volume control:
- Add a 10kΩ potentiometer on GPIO35
- Modify the code:
1
2
3
4
5
int volume = analogRead(VOLUME_PIN) / 16; // 0-255
// In generateAudio():
audioValue = (audioValue * volume) / 255;
Latency Optimization
For faster response:
- Reduce SAMPLE_RATE to 22050 for less latency
- Optimize delayMicroseconds() according to your setup
- Disable Serial.begin() after debugging
Enclosure and Design
Option 1: 3D Printed Enclosure
Create a custom enclosure with these dimensions:
- External dimensions: 200mm x 100mm x 50mm
- Display location: 128x64mm with 2mm margin
- Button locations: 4 holes of 12mm diameter
- Touch wire area: 250mm x 20mm
Option 2: Reuse
Transform an old keyboard or existing box:
- Vintage keyboard: Remove keys, keep the case
- Cigar box: Perfect for a retro look
- Effect pedal case: Sturdy and professional
Troubleshooting
Common Issues
No sound:
- Check amplifier wiring
- Test speaker with a battery
- Verify DAC is properly initialized
Noise in sound:
- Add decoupling capacitors (100nF) on power supply
- Keep audio wires away from power wires
- Use short, twisted wiring
Display not showing:
- Check I2C address (usually 0x3C)
- Test with I2C scanner
- Check SDA/SCL connections
Inaccurate touch response:
- Calibrate resistive wire
- Check pull-up/pull-down resistors
- Clean the resistive wire
Possible Improvements
Add an LFO:
1
2
3
4float lfoPhase = 0.0;
float lfoFrequency = 5.0; // 5Hz
float lfoValue = sin(lfoPhase);
frequency = baseFrequency * (1.0 + 0.1 * lfoValue); // VibratoLow-pass filter:
1
float filteredValue = 0.9 * filteredValue + 0.1 * audioValue;
Preset saving:
Use EEPROM to save settingsMIDI Bluetooth:
Add Bluetooth module to control external synthesizers
Conclusion

The MPFII is much more than a simple electronics project: it’s a truly innovative musical interface that combines the simplicity of a traditional instrument with the power of digital synthesis. With its modest cost and rich features, it represents an excellent introduction to both electronics and sound synthesis.
I hope I’ve provided you with all the necessary steps to build your own MPFII. Feel free to experiment, modify the code, and customize the design to create an instrument that reflects your personality.
Happy musical creations with your MPFII!