Skip to content

cmpnnt/AudioElectronicsCalculator

Repository files navigation

Audio Electronics Calculator

A richly formatted, interactive command-line calculator for electronics engineers, audio enthusiasts, guitar pedal designers, and eurorack synthesizer builders. Skip the mental unit conversions — enter values the way you think about them (4.7k, 47u, 2.2M) and get auto-scaled, readable results.


Features

  • 61 calculations across 10 categories covering resistors, capacitors, inductors, filters, op-amps, oscillators, and more
  • Intelligent unit parsing — accepts standard SI notation (4.7k, 47u) and EE notation (4k7, 2M2)
  • Auto-scaled output — results automatically formatted in the most readable unit (e.g., 1.23 kΩ, 470 nF)
  • Formula display — every result shows the underlying formula to reinforce understanding
  • Eurorack-focused — includes 1V/oct converters, VCO/VCA/VCF, ADSR timing, MIDI conversion, and a power budget calculator
  • Rich terminal UI — colored output, panels, and tables via Spectre.Console

Requirements


Installation & Running

# Clone or download the project, then navigate to the project directory
cd AudioElectronicsCalculator

# Run directly
dotnet run

# Or build and run the executable
dotnet build -c Release
./bin/Release/net10.0/AudioElectronicsCalculator

Usage

Launch the application and navigate menus using arrow keys and Enter. Each calculation prompts you for the required values and displays formatted results.

Unit Input Syntax

You can enter component values in several formats:

Input Value Notes
4.7k 4,700 Standard SI suffix
4k7 4,700 EE notation
47u 0.000047 Microfarads, microhenries, etc.
47µ 0.000047 Unicode mu accepted
100n 0.0000001 Nanofarads, etc.
2.2M 2,200,000 Megaohms, etc.
1000 1,000 Bare number also accepted

Supported multipliers: p (10⁻¹²), n (10⁻⁹), u/µ (10⁻⁶), m (10⁻³), k (10³), M (10⁶), G (10⁹)


Calculator Categories

1. Resistors

Calculation Description
Series resistance Total R for resistors in series
Parallel resistance Total R for 2 or more resistors in parallel
Ohm's Law Solves for V, I, or R given the other two
Voltage divider Output voltage from R1, R2, and Vin
Power dissipation Power from V and R, I and R, or V and I
Color code decoder 4-band and 5-band resistor color codes → resistance value

2. Capacitors

Calculation Description
Series capacitance Total C for capacitors in series
Parallel capacitance Total C for capacitors in parallel
Capacitive reactance Xc = 1 / (2πfC)
RC time constant τ = RC
Charge/discharge voltage Voltage across capacitor at time t
Stored energy E = ½CV²

3. Inductors

Calculation Description
Series inductance Total L for inductors in series
Parallel inductance Total L for inductors in parallel
Inductive reactance XL = 2πfL
RL time constant τ = L/R
Stored energy E = ½LI²

4. Impedance & AC Analysis

Calculation Description
RC series impedance Z and phase angle for RC in series
RL series impedance Z and phase angle for RL in series
RLC series impedance Z, phase angle, and resonance analysis
RLC parallel impedance Parallel RLC analysis
Resonant frequency f = 1 / (2π√LC)
Q factor Quality factor from R, L, C
Phase angle Voltage vs. current phase relationship

5. Filters

Calculation Description
RC low-pass cutoff fc = 1 / (2πRC)
RC high-pass cutoff fc = 1 / (2πRC)
RL low-pass/high-pass fc = R / (2πL)
RLC band-pass Center frequency and bandwidth
RLC band-stop (notch) Notch frequency from L and C
Sallen-Key low-pass 2nd-order Sallen-Key with Q factor
Sallen-Key high-pass 2nd-order Sallen-Key with Q factor
State-Variable Filter VCF topology used in eurorack modules
Multiple Feedback (MFB) MFB low-pass with gain and Q
Q factor Filter quality factor calculation

6. Op-Amp Configurations

Calculation Description
Inverting amplifier Gain = −Rf/Rin
Non-inverting amplifier Gain = 1 + Rf/R1
Summing amplifier Weighted sum of multiple inputs
Difference amplifier Differential gain from R1 and R2
Instrumentation amplifier Gain from R1, R2, Rgain
Integrator Output voltage for given input and time
Differentiator Output voltage for given dV/dt
Transimpedance amplifier I → V conversion (TIA/current sense)

7. Comparators & Schmitt Triggers

Calculation Description
Non-inverting Schmitt Upper and lower threshold voltages
Inverting Schmitt Threshold voltages for inverting topology
Hysteresis voltage Vhys from R1, R2, and supply
Schmitt from supply Threshold calculation from Vcc

8. Oscillators & VCO

Calculation Description
555 astable Frequency and duty cycle from R1, R2, C
555 monostable Pulse width from R and C
1V/Oct converter Pitch frequency from control voltage
MIDI ↔ frequency Convert MIDI note number to/from Hz
Musical intervals Frequency ratios for semitones and octaves
LC oscillator Resonant frequency from L and C

9. Envelope Generators & VCA

Calculation Description
ADSR timing Attack/decay/release times from RC constants
Exponential envelope Voltage at time t on exponential curve
OTA-based VCA Gain for LM13700 / CA3080 OTA circuits
Linear vs. exponential VCA Response curve comparison

10. Utility & Signal

Calculation Description
Decibels Voltage and power ratio ↔ dB conversion
Diode reference Forward voltage drop table by diode type
Zener clamp Clamping voltage and power dissipation
Rectifier output DC output for half-wave, full-wave, and bridge rectifiers
BJT calculations Beta/gain, voltage divider bias point
JFET drain current Id from Shockley equation (Idss, Vp)
LM317 regulator Output voltage from R1, R2, and Vref
Ripple voltage Ripple on filtered supply from C, I, and frequency
Eurorack power budget Per-rail current budget with +12V/−12V/+5V status
Wheatstone bridge Balance check and unknown resistance solver

Project Structure

AudioElectronicsCalculator/
├── AudioElectronicsCalculator/              # Main application
│   ├── Program.cs                           # Entry point and top-level menu
│   ├── AudioElectronicsCalculator.csproj    # .NET 10.0 project file
│   ├── Core/
│   │   ├── UnitParser.cs                    # SI/EE unit input parsing
│   │   └── UnitFormatter.cs                 # Auto-scaling result formatting
│   ├── Menus/
│   │   └── MenuHelpers.cs                   # Prompt and display helpers (Spectre.Console)
│   └── Calculators/
│       ├── Resistors.cs
│       ├── Capacitors.cs
│       ├── Inductors.cs
│       ├── ImpedanceAC.cs
│       ├── Filters.cs
│       ├── OpAmps.cs
│       ├── Comparators.cs
│       ├── Oscillators.cs
│       ├── EnvelopeVca.cs
│       └── Utility.cs
└── AudioElectronicsCalculator.Tests/        # Unit tests (TUnit)
    ├── AudioElectronicsCalculator.Tests.csproj
    ├── ResistorMathTests.cs
    ├── CapacitorMathTests.cs
    ├── InductorMathTests.cs
    ├── ImpedanceMathTests.cs
    ├── FilterMathTests.cs
    ├── OpAmpMathTests.cs
    ├── ComparatorMathTests.cs
    ├── OscillatorMathTests.cs
    ├── EnvelopeMathTests.cs
    └── UtilityMathTests.cs

Dependencies

Package Version Purpose
Spectre.Console 0.54.0 Rich terminal UI (colors, tables, prompts)
TUnit 1.19.57 Unit test framework (test project only)

Extending the Application

The modular structure makes adding new calculations straightforward:

  1. Add a new static method to the appropriate Calculators/*.cs file (or create a new file for a new category)
  2. Use MenuHelpers.AskValue() to gather user input with automatic unit parsing
  3. Use UnitFormatter.FormatXxx() methods to display auto-scaled results via MenuHelpers.ShowResult()
  4. Wire the new menu entry in Program.cs

Target Audience

  • Electronics engineers doing quick component calculations
  • DIY audio and guitar pedal designers
  • Eurorack synthesizer module builders
  • Students learning analog electronics

License

This software is covered by the terms of the Mozilla Public License 2.0.

About

A simple command-line electronics calculator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages