Grainfreeze by aquanode (Written in JUCE/C++ with the help of Claude AI)

Grainfreeze is a real-time phase vocoder–based time-stretching and freeze processor.
It loads an audio file into memory and resynthesizes it using FFT analysis and
overlap-add techniques.

Version 1.1 introduces a waveform display, where the 10 loudest frequencies are highlighted with their note name. Please note that this plugin is CPU-intensive!

The processor operates in two modes:
normal playback and freeze mode.

--------------------------------------------------
Core Processing Overview
--------------------------------------------------

Audio is processed using a Short-Time Fourier Transform (STFT).

1. A windowed block of audio is read from the loaded file.
2. The block is transformed into the frequency domain using an FFT.
3. Magnitude and phase are extracted for each frequency bin.
4. Phase differences between frames are tracked to calculate true frequency.
5. Phases are advanced according to the time-stretch factor.
6. The signal is transformed back to the time domain using an inverse FFT.
7. The result is overlap-added into an output accumulator buffer.

This allows time stretching without changing pitch.

--------------------------------------------------
Time Stretching
--------------------------------------------------

Time stretch is controlled by modifying the phase advance during resynthesis.

- Stretch = 1.0 → normal playback
- Stretch > 1.0 → slower playback
- Stretch < 1.0 → faster playback

Playback position advances at:
    playbackSpeed = 1.0 / timeStretch

--------------------------------------------------
FFT and Hop Size
--------------------------------------------------

FFT Size determines frequency resolution and latency.
Larger FFT sizes produce smoother, more stable results but increase CPU usage.

Hop Size is derived as:
    hopSize = FFTSize / hopDivisor

Smaller hop sizes create more overlap, improving smoothness at higher CPU cost.

--------------------------------------------------
Windowing
--------------------------------------------------

Each FFT frame is windowed before analysis and after synthesis.

Supported window types:
- Hann: general-purpose, smooth
- Blackman-Harris: better frequency isolation, cleaner highs

--------------------------------------------------
Freeze Mode
--------------------------------------------------

In freeze mode, playback position no longer advances automatically.

Instead:
- A target playback position is set via the UI playhead.
- A smoothed value glides toward this target using a time constant (glide).
- The same FFT frame region is repeatedly resynthesized.

This creates a sustained, frozen spectral texture.

--------------------------------------------------
Freeze Glide
--------------------------------------------------

Glide controls how quickly the frozen position moves when changed.
It uses a smoothed value to avoid clicks and discontinuities.

--------------------------------------------------
Micro Movement
--------------------------------------------------

Micro Movement introduces small random offsets to the playback position
while frozen.

This prevents static phasing artifacts by slightly decorrelating grains.

--------------------------------------------------
High Frequency Boost
--------------------------------------------------

High frequencies tend to lose energy in phase vocoder processing.
HF Boost compensates by scaling magnitudes proportionally to frequency.

--------------------------------------------------
Crossfading
--------------------------------------------------

Overlap-add and windowing provide smooth transitions between grains.
Crossfade length is measured in hop units and helps avoid clicks
when playback position changes.

--------------------------------------------------
Output
--------------------------------------------------

The processed signal is written into a circular accumulation buffer
and read out sample-by-sample to produce continuous audio output.

Stereo output is produced by duplicating the mono-processed signal
to both channels.

--------------------------------------------------
Controls
--------------------------------------------------

Load Audio        Loads an audio file into the plugin.
Play / Stop       Starts or stops audio playback.
Freeze            Enables freeze mode (holds a spectral snapshot).
Time Stretch      Controls playback speed. < 1.0 = faster, > 1.0 = slower.
FFT Size          Sets FFT resolution. Higher values = smoother sound, more latency.
Hop Div           Controls overlap between FFT frames. Lower values = smoother, higher CPU use.
Freeze Glide      Smooths transitions when moving the playhead in freeze mode. Only active when Freeze is enabled.
HF Boost          Boosts high frequencies in the processed sound.
Micro Move        Adds subtle random motion to grains to avoid static sound.
Window            Selects FFT window type. Hann = softer, Blackman-Harris = cleaner highs.
X-Fade Len        Length of crossfades between grains. Higher values = smoother transitions.
Waveform Display  Shows loaded audio waveform. Click or drag to move the playhead.