Skip to content

Repository files navigation

Impedance Synthesis STM32H7

Programmable synthetic impedance for hybrid analog-digital audio effects.

This repository contains the STM32 firmware for a synthetic impedance hybrid analog-digital audio-effects prototype: a digitally controlled two-terminal circuit element that can be inserted into an analog circuit and made to behave like a diode pair, or other voltage-current relationship.

The project is demonstrated by replacing the antiparallel diode pair in the clipping stage of a Boss DS-1 distortion pedal with a software-defined synthetic diode pair. Instead of modelling the whole pedal digitally, this approach keeps the analog circuit intact and replaces only one coupled circuit element with real-time DSP.

Instead of routing audio through a conventional ADC → DSP → DAC signal chain, this project lets a microcontroller participate in the circuit as a programmable impedance. The prototype is demonstrated by replacing the diode clipping pair in a Boss DS-1 distortion pedal with a software-defined synthetic diode pair.

The result is a hybrid analog–digital effect: the surrounding pedal circuit stays analog and physically coupled, while the replaced component becomes programmable in firmware.

What is synthetic impedance?

Most audio DSP is unidirectional: signal in, processing, signal out. Real analog circuits are not like that. Components interact through voltage, current, impedance, loading, feedback, and nonlinear coupling.

A synthetic impedance element digitally defines the relationship between terminal voltage and terminal current. With the right analog front end, the firmware can make a circuit node behave like a resistor, capacitor, inductor, diode, or a custom nonlinear element.

In this project, the STM32 reads a circuit voltage, computes the desired current, and drives a voltage-controlled current source through the DAC.

For the Boss DS-1 demonstration, the firmware implements an anti-parallel silicon diode model based on the Shockley diode equation:

I = Is * (exp(Vd / (n * Vt)) - 1) - Is * (exp(-Vd / (n * Vt)) - 1)

Why this is useful

This approach makes it possible to:

  • replace selected analog components without modelling an entire circuit,
  • keep the character of the surrounding analog hardware,
  • explore circuit-bending-style modifications in software,
  • switch between diode clipping behaviours without rewiring,
  • create hybrid effects where analog and digital domains remain bidirectionally coupled,
  • prototype impractical or exotic impedance relationships inside real circuits.

Case study: Boss DS-1 synthetic diode clipping

The main case study replaces the Boss DS-1 clipping diode pair, D4/D5, with a synthetic impedance element.

The standard Boss DS-1 clipping stage uses anti-parallel silicon diodes. This firmware models that diode pair digitally, then drives the analog synthetic-impedance circuit so the pedal sees a similar voltage-current relationship at the clipping node.

The companion DAFx25 paper and dataset compare:

  • real 1N4148 diode clipping,
  • synthetic 1F1R diode clipping,
  • synthetic asymmetric diode variants such as 2F1R and 4F1R,
  • out-of-circuit measurements,
  • in-circuit measurements inside the DS-1 pedal,
  • time-domain waveforms,
  • spectra, THD, SNR, and harmonic levels.

Repository status

This repository is currently a research prototype. It contains STM32CubeIDE firmware for the synthetic diode / impedance experiment. It is not yet packaged as a reusable embedded audio library.

Use it as a starting point for:

  • reproducing the DS-1 synthetic clipping experiment,
  • experimenting with programmable diode models,
  • developing other synthetic impedance components,
  • extending the code into a more general hybrid analog–digital audio platform.

Hardware target

The project is configured for an STM32H750-based target.

Known configuration from the firmware and STM32Cube project:

  • MCU family: STM32H7
  • MCU target: STM32H750XBHx / STM32H750XBH6
  • ADC: ADC1, channel 3
  • DAC: DAC1, channel 1
  • Timer: TIM8
  • Debug/test GPIO: test_output
  • Toolchain: STM32CubeIDE

The external analog circuit is a voltage-controlled current source with level shifting between the STM32 ADC/DAC range and the audio circuit voltage range.

Firmware overview

The real-time loop is conceptually:

  1. Read the circuit terminal voltage with the ADC.
  2. Convert the ADC value to a bipolar voltage representation.
  3. Apply stability / conditioning filters.
  4. Compute the desired synthetic component current.
  5. Convert current into the DAC voltage needed by the current-source circuit.
  6. Write the DAC output.

The core relationship used by the current-source front end is:

Iin = (Vin - Vout) / Rout

The firmware computes the required output voltage as:

Vdac = Vadc - Rout * I

where I is the current predicted by the selected impedance model.

Repository structure

.
├── Core/
│   ├── Inc/
│   │   ├── DiodeClipper.h
│   │   ├── LPFilter_1stOrder.h
│   │   ├── RCFilter.h
│   │   ├── main.h
│   │   └── ...
│   ├── Src/
│   │   ├── main.c
│   │   ├── DiodeClipper.c
│   │   ├── LPFilter_1stOrder.c
│   │   ├── RCFilter.c
│   │   └── ...
│   └── Startup/
├── DAC-ADC.ioc
├── DAC-ADC Debug.launch
├── STM32H750XBHX_FLASH.ld
├── STM32H750XBHX_RAM.ld
└── README.md

Important source files

Core/Src/main.c

Initialises the STM32 peripherals, filters, diode model, ADC, DAC, and timer. The main loop performs the ADC → model → DAC update.

Important parameters include:

double fs = 70300.0f;      // approximate sample rate
double fc = 7000.0f;       // low-pass filter cutoff
double hpf_fc = 5.0f;      // high-pass / DC-blocking cutoff
const double Rl = 99.2;    // measured current-setting resistance

Core/Src/DiodeClipper.c

Implements the diode current model.

Default model:

  • 1F1R: one forward diode and one reverse diode, matching the standard DS-1 anti-parallel clipping pair.

Commented variants include:

  • 2F1R: two diodes in series in one direction,
  • 4F1R: two parallel pairs of diodes in series in one direction.

These variants create asymmetric clipping and stronger even-order harmonic content.

Core/Src/LPFilter_1stOrder.c

Implements a first-order low-pass filter used for stability and bandwidth limiting.

Core/Src/RCFilter.c

Implements a first-order RC-style filter structure, used for high-pass / DC-blocking behaviour.

Getting started

1. Clone the repository

git clone https://github.com/frantic0/impedance-synthesis-audio-fx.git
cd impedance-synthesis-audio-fx

If the repository is renamed to the recommended URL:

git clone https://github.com/frantic0/sonic-impedance-fx.git
cd sonic-impedance-fx

2. Open in STM32CubeIDE

Open STM32CubeIDE and import the project:

File → Import → Existing Projects into Workspace

Alternatively, open DAC-ADC.ioc and regenerate/build from STM32CubeIDE.

3. Build

Build the project from STM32CubeIDE.

Check that the selected target matches your STM32H750 board and that ADC/DAC pins match the external analog front end.

4. Flash

Connect the board over ST-LINK and flash the firmware from STM32CubeIDE.

5. Connect the analog front end

Connect the ADC and DAC pins to the calibrated voltage-controlled current-source circuit.

Do not connect directly to a guitar pedal or external analog circuit without confirming:

  • ADC input protection,
  • DAC output scaling,
  • ground/reference configuration,
  • current limits,
  • power rails,
  • coupling capacitors,
  • expected signal voltage range.

Using with a Boss DS-1

A typical experimental setup is:

  1. Locate the DS-1 clipping diode pair, D4/D5.
  2. Remove, lift, or socket the diode pair so the clipping node can be accessed.
  3. Connect the synthetic impedance element in place of the diode pair.
  4. Use AC coupling where needed, since the DS-1 clipping stage is referenced to a virtual ground.
  5. Calibrate ADC/DAC gain and offset before running the experiment.
  6. Flash the firmware with the desired diode model.
  7. Test first with a function generator and oscilloscope before using guitar signals.

Selecting diode models

At present, diode variants are selected by editing DiodeClipper.c.

Recommended future interface:

typedef enum {
    DIODE_MODEL_1F1R,
    DIODE_MODEL_2F1R,
    DIODE_MODEL_4F1R
} DiodeModel;

This would make it easier to select clipping behaviours using GPIO, UART, MIDI, USB, or a control voltage.

Calibration notes

The synthetic impedance circuit is sensitive to gain, offset, latency, and high-frequency stability.

Before use, verify:

  • 0 V at the analog terminal maps to the ADC midpoint,
  • ADC and DAC level-shifting stages have matched gain and offset,
  • the value of Rl matches the measured output/current-setting resistor,
  • the DAC output is centred correctly when the input is centred,
  • the system remains stable with no input signal,
  • no high-frequency oscillation appears at the synthetic impedance terminal.

The low-pass filter cutoff is a tradeoff: lower cutoffs improve stability but can alter high-frequency clipping behaviour.

Related repository

The companion DAFx25 dataset and analysis repository is here:

https://github.com/frantic0/dafx25

It includes:

  • Analog Discovery 3 workspaces,
  • Python data-processing scripts,
  • MATLAB analysis scripts,
  • waveform and spectrum plots,
  • audio samples,
  • real diode measurements,
  • synthetic diode measurements,
  • in-circuit and out-of-circuit test datasets.

Suggested repository description

Use this as the GitHub repository description:

Programmable synthetic impedance for hybrid analog-digital guitar effects, demonstrated by replacing the Boss DS-1 diode clipping stage with STM32 DSP.

Suggested GitHub topics:

stm32, stm32h7, audio-effects, guitar-pedal, synthetic-impedance, virtual-analog, dsp, embedded-audio, boss-ds1, diode-clipping

Known limitations

  • This is a prototype, not a finished product.
  • Hardware documentation is currently minimal.
  • Calibration is manual.
  • Diode model variants are not yet runtime-selectable.
  • High-frequency accuracy is affected by filtering and loop latency.
  • Noise performance depends on the DAC, analog level shifting, and grounding.
  • The current implementation assumes one terminal of the synthetic impedance is tied to ground or a suitable AC reference.
  • Floating two-terminal impedance emulation would require additional analog circuitry.

Suggested improvements

High-impact next steps:

  1. Add the full hardware schematic and wiring diagram.
  2. Add a calibration guide with expected ADC/DAC readings.
  3. Add a safety section for connecting to pedals and external analog circuits.
  4. Convert commented diode variants into named model modes.
  5. Add UART / USB / MIDI control for runtime model selection.
  6. Add automated test firmware for latency, noise, and transfer-function checks.
  7. Add a docs/ folder with hardware, firmware, DS-1, and calibration notes.
  8. Add oscilloscope screenshots and audio examples.
  9. Add a license file.
  10. Package impedance models into reusable modules.

Citation

If you use this repository or build on the project, please cite:

@inproceedings{bernardo2025impedance,
  title     = {Impedance Synthesis for Hybrid Analog-Digital Audio Effects},
  author    = {Bernardo, Francisco and Davison, Matthew and McPherson, Andrew},
  booktitle = {Proceedings of the 28th International Conference on Digital Audio Effects (DAFx25)},
  year      = {2025},
  address   = {Ancona, Italy}
}

License

No license is currently specified here.

Recommended options:

  • MIT or BSD-3-Clause for firmware reuse,
  • CERN-OHL-S or CERN-OHL-P if hardware design files are added,
  • CC BY 4.0 for documentation, figures, and educational material.

Add a LICENSE file before encouraging reuse or external contributions.

Disclaimer

This is experimental research firmware for hybrid analog–digital audio circuits. Use care when connecting microcontroller hardware to powered analog circuits. Incorrect wiring, grounding, level shifting, or current limiting can damage the STM32 board, the analog circuit, test equipment, or audio hardware.

About

Programmable synthetic impedance for hybrid analog-digital effects for STM32

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages