Quantum State Superposition — User Guide

Quantum-inspired audio processing: applies iterative superposition mixing with probability amplitudes, phase-shifted time delays, and wave collapse decay, creating spectral interference patterns and evolving timbral states.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.1 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script implements quantum-inspired superposition processing — a metaphorical application of quantum mechanics concepts to audio transformation. The algorithm processes sound through multiple quantum "states," where each state mixes the current signal with phase-shifted, time-delayed versions of itself using probability amplitude weighting. Superposition strength determines the mixing ratio between original and transformed states, while phase shifts create spectral interference patterns via cosine/sine components. State offsets calculated from sample count create temporal delays that interact constructively and destructively. A collapse probability mechanism progressively reduces superposition strength across iterations, mimicking quantum measurement. Result: evolving timbral transformations with chorus-like phasing, comb filtering, spectral shifting, and gradually stabilizing texture as the "wavefunction collapses."

Key Features:

What is quantum-inspired audio processing? This is NOT actual quantum computing — it's metaphorical mapping of quantum mechanics concepts to audio transformation. Quantum mechanics principles borrowed: (1) Superposition: Particle exists in multiple states simultaneously until measurement → audio mixed with time-shifted copies creating composite state. (2) Probability amplitudes: Wave functions determining state likelihood → sinusoidal weighting of state contributions. (3) Phase relationships: Wave interference patterns → cosine/sine phase shifts creating spectral interactions. (4) Wave collapse: Measurement forces definite state → progressive decay reduces superposition strength. (5) Entanglement: Correlated states → forward/backward delays create temporal coupling. Result: Complex spectral and temporal transformations with evolving character. Mathematical structure inspired by quantum formalism but purely classical audio processing. Creates unique timbral effects difficult to achieve with traditional processing.

Technical Implementation: (1) State loop initialization: Calculate number of states (4-7), Determine initial superposition strength (fixed or random 0.3-0.9), Set phase shift range (fixed or random 0.1-6.28 rad). (2) Per-state processing: Calculate probability amplitude = sin(state × π / (states+1)), Determine phase shift (fixed value or random in range), Calculate state offset = samples / (base + state × increment), Apply superposition formula mixing original with delayed/phase-shifted versions. (3) Superposition formula: output = √(1-strength) × input + √(strength) × [cos(phase) × forward_delay + sin(phase) × backward_delay], Square root maintains energy conservation (probability normalization), Cosine/sine create quadrature phase relationship. (4) Collapse mechanism: After each state: strength = strength × decay_factor (typically 0.7-0.85), Progressive reduction mimics measurement-induced collapse. (5) Finalization: Peak normalization to 0.96, Optional auto-play. Key insight: Each iteration mixes current (already processed) signal with time-shifted copies, creating compound transformations. Phase shifts create spectral interference (constructive/destructive). Decaying superposition creates evolution from complex to stable state.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…Quantum_State_Superposition.praat.
  3. Choose Preset: Default, Gentle Drift, Intense Superposition, Phase Entanglement, or Custom.
  4. If Custom, set states (number of quantum iterations, 4-7 typical).
  5. Configure superposition: use_fixed_superposition (yes) with fixed_superposition value, OR random range via superposition_min/max.
  6. Configure phase: use_fixed_phase (yes) with fixed_phase_shift, OR random range via phase_shift_min/max.
  7. Set state_offset_base and increment (controls delay timing).
  8. Set superposition_decay (0.7-0.85, controls collapse rate).
  9. Click OK — processing completes instantly, auto-plays result.
Quick tip: Start with Default (balanced) preset — provides moderate transformation with clear quantum character. Try Gentle Quantum Drift for subtle chorus-like effect (4 states, gentle phase shifts). Use Intense Superposition for dramatic spectral transformation (6 states, high strength). Phase Entanglement creates complex interference patterns (7 states, wide phase range). Processing is instant — results appear immediately regardless of duration. Fixed vs random parameters: Fixed = reproducible, predictable effect; Random = varied, organic character each run. Lower superposition_decay (0.7) = faster collapse (more dramatic evolution); Higher decay (0.85) = slower collapse (gradual change). Result automatically normalized to 0.96 peak. Original sound preserved (script works on copy).
Important: CUMULATIVE PHASE EFFECTS — each state operates on result of previous state, creating compound transformations that can become extreme. High superposition strength (>0.8) with many states (7+) creates heavy spectral distortion. Very low state_offset_base (<5) creates short delays (comb filtering, metallic resonance). Very high offset_base (>20) creates sparse delays (obvious echoes). Phase_shift near π (3.14) creates maximum interference (potential phase cancellation, thinning). Phase_shift near 0 or 2π creates minimal interference (clearer, more transparent). No undo during processing but instant execution means rapid experimentation. Extreme settings may create unmusical results — start moderate. Decay values <0.6 cause very rapid collapse (first states dominate). Decay >0.9 maintains high strength throughout (uniform processing, less evolution). Random parameters create non-reproducible results — use fixed for repeatable effects.

Quantum Theory (Metaphorical)

Quantum Mechanics Analogy

Mapping Quantum Concepts to Audio

Conceptual framework:

QUANTUM MECHANICS → AUDIO PROCESSING Superposition (quantum): Particle in multiple states simultaneously |ψ⟩ = α|0⟩ + β|1⟩ (state vector) Superposition (audio): Signal mixed with time-shifted copies output = α × original + β × delayed Probability amplitudes (quantum): |α|² + |β|² = 1 (normalization) Complex numbers encode phase Probability amplitudes (audio): √(1-strength) and √(strength) coefficients Sum of squares = 1 (energy conservation) Wave collapse (quantum): Measurement forces definite state Superposition → single eigenstate Wave collapse (audio): Progressive decay of mixing strength Complex texture → simpler, stable state Phase interference (quantum): Wave functions add constructively/destructively Phase difference determines interference Phase interference (audio): Cosine/sine terms create spectral interactions Phase shift controls frequency cancellation/boost IMPORTANT: This is metaphorical, not literal quantum computing

Probability Amplitudes

Sinusoidal State Weighting

Amplitude calculation:

For each state s (1 to total_states): probAmplitude = sin(s × π / (states + 1)) Where: s = current state number (1, 2, 3, ...) states = total number of states π = 3.14159... Example: 5 states State 1: sin(1π/6) = sin(30°) = 0.5 State 2: sin(2π/6) = sin(60°) = 0.866 State 3: sin(3π/6) = sin(90°) = 1.0 (maximum) State 4: sin(4π/6) = sin(120°) = 0.866 State 5: sin(5π/6) = sin(150°) = 0.5 Characteristics: Symmetric around middle state Middle state has maximum amplitude (1.0) First and last states have reduced amplitude Forms bell curve distribution Purpose: Weights state contributions by position Middle states more influential Mimics quantum probability distribution Note: In current script, probAmplitude calculated but not used in formula Future enhancement: Could scale state effect

Superposition Formula

Core Transformation Equation

The quantum-inspired mixing formula:

output[i] = √(1 - strength) × input[i] + √(strength) × [cos(phase) × input[i + offset] + sin(phase) × input[i - offset]] Components: √(1 - strength) = Original signal coefficient (complement) √(strength) = Transformed signal coefficient cos(phase) = Forward delay component weight sin(phase) = Backward delay component weight input[i + offset] = Future samples (forward delay) input[i - offset] = Past samples (backward delay) Energy conservation: [√(1 - strength)]² + [√(strength)]² = 1 - strength + strength = 1 Maintains signal power (like quantum probability normalization) Example: strength=0.5, phase=π/4, offset=1000 samples Original contribution: √0.5 ≈ 0.707 (70.7%) Transformed contribution: √0.5 ≈ 0.707 (70.7%) Forward weight: cos(π/4) ≈ 0.707 Backward weight: sin(π/4) ≈ 0.707 Result: Equal mix of original and bidirectional delays

Square Root Normalization

Why square roots instead of linear weights?

📐 Mathematical Rationale

Linear mixing (without sqrt):

output = (1-s)×input + s×delayed

Energy: (1-s)² + s² ≠ 1 (except at 0 and 1)

Example s=0.5: 0.5² + 0.5² = 0.5 (50% energy loss!)


Square root mixing (quantum-inspired):

output = √(1-s)×input + √s×delayed

Energy: [√(1-s)]² + [√s]² = (1-s) + s = 1 (preserved!)

Example s=0.5: (√0.5)² + (√0.5)² = 1.0 (100% energy)


Quantum parallel:

In QM: |ψ⟩ = α|0⟩ + β|1⟩ where |α|² + |β|² = 1

Audio analog: √(1-s) and √s maintain normalization

Result: Constant energy regardless of mixing ratio

Phase Shift Effects

Cosine and Sine Components

Phase-dependent mixing:

Transformed component: √(strength) × [cos(phase) × forward + sin(phase) × backward] Phase angle determines forward/backward balance: phase = 0 rad (0°): cos(0) = 1.0, sin(0) = 0.0 Result: Pure forward delay, no backward phase = π/4 rad (45°): cos(π/4) ≈ 0.707, sin(π/4) ≈ 0.707 Result: Equal forward and backward phase = π/2 rad (90°): cos(π/2) = 0.0, sin(π/2) = 1.0 Result: Pure backward delay, no forward phase = π rad (180°): cos(π) = -1.0, sin(π) = 0.0 Result: Inverted forward delay (phase reversal) phase = 3π/2 rad (270°): cos(3π/2) = 0.0, sin(3π/2) = -1.0 Result: Inverted backward delay phase = 2π rad (360°): cos(2π) = 1.0, sin(2π) = 0.0 Result: Pure forward (same as 0°, cyclic) Spectral effects: Different phases create different interference patterns Certain frequencies constructive, others destructive Phase determines "color" of transformation

Interference Patterns

How phase creates spectral shaping:

Phase = 0 (cos=1, sin=0): Forward delay only creates comb filter Notches at frequencies where delay = odd quarter-wavelengths Bright, resonant character

Phase = π/4 (cos=0.707, sin=0.707): Equal forward/backward creates symmetric interference Balanced spectral response Chorus-like thickening

Phase = π/2 (cos=0, sin=1): Backward delay only (looking into past) Mirror-image comb filtering vs forward Different resonance pattern

Phase = π (cos=-1, sin=0): Inverted forward delay Maximum cancellation with original Thin, hollow character (phase cancellation)

Random phase (variable): Different interference each state Complex, evolving spectral texture Unpredictable but organic character

State Offset Calculation

Temporal Delay Determination

Offset formula:

For each state s: stateOffset = round(total_samples / (base + s × increment)) Where: total_samples = length of sound in samples base = state_offset_base parameter (8-12 typical) s = current state number (1, 2, 3, ...) increment = state_offset_increment parameter (1.5-3 typical) Example: 44100 samples (1 sec @ 44.1kHz), base=10, increment=2 State 1: offset = 44100 / (10 + 1×2) = 44100 / 12 = 3675 samples ≈ 83ms State 2: offset = 44100 / (10 + 2×2) = 44100 / 14 = 3150 samples ≈ 71ms State 3: offset = 44100 / (10 + 3×2) = 44100 / 16 = 2756 samples ≈ 62ms State 4: offset = 44100 / (10 + 4×2) = 44100 / 18 = 2450 samples ≈ 56ms State 5: offset = 44100 / (10 + 5×2) = 44100 / 20 = 2205 samples ≈ 50ms Pattern: Offsets decrease with each state Earlier states: Longer delays Later states: Shorter delays Creates hierarchical temporal structure Effect on timbre: Long offsets: Clear echoes, spacious Short offsets: Comb filtering, metallic Decreasing pattern: Evolving delay character

Offset Parameter Tuning

How parameters affect delay times:

High base (e.g., 15): offset = samples / (15 + s×increment) Smaller offsets → shorter delays Tighter comb filtering, denser texture More chorus/flanger-like Low base (e.g., 5): offset = samples / (5 + s×increment) Larger offsets → longer delays Obvious echoes, sparse texture More delay-like, rhythmic High increment (e.g., 4): Rapid decrease in offset across states State 1 vs State 5 very different Strong evolution of delay character Low increment (e.g., 1): Slow decrease in offset across states States similar to each other Subtle evolution, more uniform Typical combinations: base=10, inc=2: Balanced, moderate delays base=12, inc=3: Short delays, tight texture base=8, inc=1.5: Long delays, spacious base=9, inc=1.5: Phase Entanglement preset (complex)

Collapse Mechanism

Progressive Superposition Decay

Mimicking quantum measurement:

After each state iteration: superpositionStrength = superpositionStrength × superposition_decay Where: superposition_decay = user parameter (0.7-0.85 typical) Example: Initial strength = 0.75, decay = 0.75, 5 states After State 1: 0.75 × 0.75 = 0.5625 (56.25%) After State 2: 0.5625 × 0.75 = 0.4219 (42.19%) After State 3: 0.4219 × 0.75 = 0.3164 (31.64%) After State 4: 0.3164 × 0.75 = 0.2373 (23.73%) After State 5: 0.2373 × 0.75 = 0.1780 (17.80%) Evolution trajectory: State 1: High superposition (75%) → heavy mixing State 3: Medium superposition (32%) → moderate mixing State 5: Low superposition (18%) → light mixing Effect: Early states: Dramatic transformation Later states: Subtle refinement Creates temporal evolution in texture Mimics "collapse" toward definite state Quantum metaphor: High superposition = many states superposed Low superposition = approaching eigenstate Decay = measurement-induced decoherence

Decay Rate Effects

Tuning collapse speed:

Fast decay (0.7): Rapid strength reduction Early states dominant, later barely contribute Dramatic → stable evolution Clear "collapse" narrative

Medium decay (0.75): Balanced reduction (DEFAULT) All states contribute meaningfully Gradual evolution Natural transformation arc

Slow decay (0.85): Gentle reduction Late states still significant Uniform processing throughout Less sense of evolution

Very slow decay (0.9+): Minimal reduction Nearly uniform strength all states Static character, little evolution More like parallel processing

Very fast decay (0.6-): Extreme reduction Only first 2-3 states matter Later states negligible Truncated effect

Complete Processing Pipeline

INITIALIZATION: Copy selected Sound → "soundObj" Get total_samples (a) Determine initial superposition strength: IF use_fixed_superposition: strength = fixed_superposition ELSE: strength = random(superposition_min, superposition_max) ENDIF STATE ITERATION LOOP: FOR state = 1 to states: Calculate probability amplitude: probAmplitude = sin(state × π / (states + 1)) (Currently computed but not applied — reserved for future use) Determine phase shift: IF use_fixed_phase: phaseShift = fixed_phase_shift ELSE: phaseShift = random(phase_shift_min, phase_shift_max) ENDIF Calculate state offset: stateOffset = round(a / (state_offset_base + state × state_offset_increment)) Apply superposition formula: self = √(1 - strength) × self + √(strength) × [cos(phaseShift) × self[col + stateOffset] + sin(phaseShift) × self[col - stateOffset]] Where: self = current sample value (already processed by previous states) self[col + stateOffset] = forward-delayed sample self[col - stateOffset] = backward-delayed sample Apply collapse decay: strength = strength × superposition_decay ENDFOR FINALIZATION: Scale peak to scale_peak (0.96 default) IF play_after_processing: Play result ENDIF OUTPUT: Processed "soundObj" in Objects window Original sound preserved KEY INSIGHT: Each state processes result of previous state State 1 transforms original State 2 transforms State-1 result State 3 transforms State-2 result ...creates compound, cumulative effect

Preset Patterns

Preset Overview

PresetStatesStrengthPhase RangeCharacter
Default (balanced)50.3-0.80.1-6.28Moderate, balanced transformation
Gentle Quantum Drift40.2-0.50.1-3.14Subtle chorus-like, transparent
Intense Superposition60.6-0.90.2-6.0Heavy spectral transformation
Phase Entanglement70.4-0.90.5-5.5Complex interference patterns
CustomUserUserUserFull parameter control

Default (Balanced)

⚖️ Moderate Quantum Transformation

Parameters: States=5, Strength=0.3-0.8 (random), Phase=0.1-6.28 (full range), Offset base=10, increment=2, Decay=0.75

Character: Balanced mix of original and quantum-processed signal

Effect: Clear transformation without overwhelming source material

Use case: General-purpose quantum processing, starting point for