AUTO-TUNER
An STM32-Based Automatic Guitar Tuner
The Auto-Tuner (AT) is a handheld device designed to automatically tune guitar strings one at a time. It operates by placing the tuning motor fork over one of the guitar’s tuning pegs and then plucking the corresponding string. The AT detects the string’s pitch through vibration sensing and adjusts the tuning peg until the string reaches the correct pitch. Once the string is in tune, the device alerts the user by emitting two short vibration pulses. Click the thumbnail below to see it in action!
Since building the original Auto-Tuner, I’ve learned a lot and decided to rebuild this repository from the ground up with several key improvements. Version 1 remains available in the legacy branch.
Completed:
- Full separation of application and driver logic — simpler to port to different MCUs using provided API templates
- CMake-based build system
- Optimised implementation of the McLeod Pitch Method (reduced from
$84$ ms to$1.7$ ms) - Introduction of an adaptive noise gate
- Expanded documentation explaining algorithm design decisions
Todo:
- Improved pitch tracking with median and Kalman filtering (in progress)
- Motor PID controller
- Display integration
Future Improvements:
- GUI system to allow custom string tunings
- Replace analog pre-amplifier with charge amplifier (better suited for piezo inputs)
- Integrated all analog circuitry on PCB to reduce size
- 3D-printed enclosure
- Rechargeable LiPo power supply
Prerequisites:
- ARM GCC toolchain (
arm-none-eabi-gcc) - CMake ≥ 3.15
- OpenOCD (required for
make flash)
- Using My Setup
-
Order the RaptorXL4 breakout board (KiCad design files available in that repo)
-
Connect a Piezo sensor to the ADC through a pre-amplifier that adds a DC bias of
$3.3/2 ,\text{V}$ . -
Connect a PWM-driven motor using either an H-bridge or a continuous rotation servo
(the demo video uses a DF15RSMG 360° motor) to pin PA11. -
Provide both a 3.3 V and a 5–6 V power source
(in the demo video: two AA batteries in series with an LDO regulator → 3.3 V). -
Clone the repository
git clone https://github.com/b-ashford/Auto-Tuner.git
cd Auto-Tuner- Configure with CMake and flash with OpenOCD via ST-Link
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/arm-none-eabi-toolchain.cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
make flash- Using a Custom Board
To use a different board, create a new directory inhw/boards/following the naming convention shown below.
Inside that directory, implement all the APIs defined inboard_api.h.
hw/
├── boards/
│ ├── <my_board>/
│ │ ├── linker/
│ │ │ └── <my_board>_FLASH.ld # Linker script
│ │ ├── <my_board>.cfg # OpenOCD configuration
│ │ ├── <my_board>.cmake # CMake toolchain file
│ │ ├── board_api.c # Implementation of board APIs
│ │ └── board_api.h # API definitions (template provided)- Implementation Details
- Reference Paper
- McLeod’s original paper, transcribed to Markdown:
A Smarter Way to Find Pitch
- McLeod’s original paper, transcribed to Markdown: