Spectral Morph — User Guide
STFT spectral morphing between two Sounds, with proportional time mapping, two spectral interpolation modes, a controllable morph-frequency band, and weight-normalized overlap-add reconstruction.
What this does
Spectral Morph creates a time-varying spectral transition between two selected Sounds. Each source is analyzed in overlapping short-time frames. The script maps both sources proportionally onto one common output timeline, transforms each frame to a complex spectrum, and blends the spectra according to a morph curve that moves from A toward B.
The transformation can interpolate spectral magnitude while retaining A as the phase reference, or it can interpolate the full complex spectrum. A user-defined frequency limit determines which bins participate in the morph; frequencies above that limit remain from Sound A. The processed frames are reconstructed with periodic sqrt-Hann analysis/synthesis windows and overlap-weight normalization.
m varies from 0 to 1 over the chosen region. At m=0, the processed spectrum is A. As m increases, bins below Morph max freq move toward B according to the selected morph mode, while higher bins remain A.Quick start
- Select exactly two Sound objects. The first selected Sound is A; the second is B.
- Run
Spectral_Morph.praat. - Choose a preset or Custom.
- Use Start morph and End morph to place the transition on the output timeline.
End morph = 0means the end of the output. - Choose Log magnitude for magnitude morphing with A-reference phase, or Full complex to interpolate real and imaginary spectral values.
- Set Morph max freq to define the highest frequency that participates in the morph.
- Leave Safety peak = 0.99 for attenuation-only peak protection, or set it to 0 to disable the safety stage.
Processing pipeline
1. Prepare the two sources
Both working copies are shifted internally to start at time 0. Depending on Speed mode, they are resampled to the processing rate. The final output is later restored to Sound A's original sampling rate and start time.
2. Build one common timeline
The output duration is the longer of the two working sources. Each source is mapped proportionally across that duration:
B time = output time × (duration B / output duration)
This uses the whole duration of both sources. If one source is shorter, its frame centres are sampled more slowly across the longer output timeline.
3. Analyze overlapping frames
The window length is converted to an even number of samples, with a minimum of 64 samples. Hop size is exactly half the window length. Each frame is multiplied by a periodic sqrt-Hann window:
Fixed zero padding around each source guarantees a complete frame at the beginning and end.
4. Morph the spectra
Each windowed frame is converted with To Spectrum: "no", so no additional FFT zero-padding is requested. Bins at or below Morph max freq are transformed according to the chosen morph mode. Higher bins are copied from A.
5. Reconstruct with overlap-add
After inverse transformation, the same sqrt-Hann window is applied again. Frames are added directly to the preallocated output Sound. A separate weight buffer accumulates the effective Hann overlap, and the final output is divided sample-by-sample by that weight. This also corrects the beginning and end of the file, where ordinary 50% overlap is incomplete.
6. Restore output format and apply safety attenuation
If a reduced processing rate was used, the result is resampled back to Sound A's original rate. The output start time is restored to Sound A's xmin. The Safety stage only attenuates when the peak exceeds the chosen limit; it never boosts a quieter result.
Morph modes
Log magnitude (A-reference phase)
Below the morph-frequency limit, magnitudes are interpolated geometrically:
The phase normally follows A. If A is effectively near zero relative to B in a bin, B phase is used as a fallback so the interpolated magnitude can still be represented. At m=0, A is returned exactly. At m=1, the magnitude equals B below the morph limit, while the phase remains A-referenced except where the fallback is used.
Full complex (blend phase too)
Real and imaginary FFT values are linearly interpolated:
This interpolates magnitude and phase together. At a frame where m=0, the spectrum is A. At m=1, bins below the morph limit are B. Bins above the limit remain A in both modes.
Presets
Presets override Window, Morph max freq, Speed mode, Morph mode, and Curve type. Morph-region times, Safety peak, visualization, and playback remain user-controlled.
| Preset | Window | Morph max | Processing rate | Mode | Curve |
|---|---|---|---|---|---|
| Custom | User | User | User | User | User |
| Tonal Sustained | 60 ms | 8000 Hz | 22050 Hz | Log magnitude | Cosine |
| Percussive | 30 ms | 10000 Hz | 22050 Hz | Log magnitude | Linear |
| Voice Morph | 50 ms | 6000 Hz | 22050 Hz | Log magnitude | Cosine |
| Texture Blend | 80 ms | 12000 Hz | Full | Full complex | Cosine |
| Fast Preview | 120 ms | 5000 Hz | 11025 Hz | Log magnitude | Linear |
Parameters
| Parameter | Default | What it controls |
|---|---|---|
| Preset | Custom | Selects a predefined analysis/morph strategy or leaves all relevant controls manual. |
| Start_morph_s | 0 | Output-relative time at which m begins rising from 0. |
| End_morph_s | 0 | Time at which m reaches 1. A value of 0, or an end not later than the start, resolves to the output end. |
| Curve_type | Cosine | Linear ramp, or cosine S-curve 0.5 - 0.5 cos(πu). |
| Window_ms | 60 | Requested STFT window length. Internally clamped to 2–1000 ms, converted to an even sample count, and kept at least 64 samples. |
| Morph_max_freq_Hz | 8000 | Actual DSP boundary. Bins above it remain from A. It is clamped to the processing Nyquist frequency and to at least 20 Hz. |
| Speed_mode | 22050 Hz processing | Full uses the higher of A and B sample rates; reduced modes process at 22050 or 11025 Hz. Final output always returns to A's sample rate. |
| Morph_mode | Log magnitude | Geometric magnitude interpolation with A-reference phase, or linear interpolation of the complete complex spectrum. |
| Safety_peak | 0.99 | Attenuation-only final peak ceiling. Set 0 to disable. Values are clamped to 0–1. |
| Draw_visualization | On | Draws the AudioTools diagnostic page. Does not alter the audio path. |
| Play_output | On | Plays the finished Sound after processing. |
Input & output behavior
Exactly two selected Sound objects.
A_SpectralMorph_BThe longer of the two working source durations.
Sound A's original sample rate.
Sound A's original
xmin.None. The same inputs and settings are deterministic.
Channel handling
- If A and B have the same number of channels, channels are morphed pairwise.
- If A is mono and B is multichannel, A is reused for every B channel.
- If B is mono and A is multichannel, B is reused for every A channel.
- If both are multichannel with different channel counts, processing stops with an explicit error.
Level behavior
There is no automatic peak normalization and no forced fade-in/fade-out. With Safety peak enabled, only outputs above the selected ceiling are scaled down. Outputs already below the ceiling retain their natural level.
Reduced-rate processing
The 22050 Hz and 11025 Hz modes intentionally reduce analysis bandwidth and computation. The result is then resampled back to A's sample rate; resampling restores the file rate, not spectral content that was unavailable at the lower processing Nyquist frequency.
Visualization
The v3.2 AudioTools visualization is diagnostic only. It converts multichannel sources to mono copies for drawing while leaving audio processing multichannel.
- A waveform
- B waveform
- Output waveform
- A and B spectrograms
- Output spectrogram
- Morph-factor curve across the common timeline
- Summary strip with morph mode, morph-frequency limit, actual window length, frame count, channel strategy, processing/output rates, and final peak
Notes & limitations
- Proportional time mapping aligns beginnings and ends, but it does not detect or align musical events, phonemes, attacks, or beats.
- Log-magnitude mode does not become the literal B waveform at
m=1; it reaches B magnitude below the morph limit while retaining A-reference phase where available. - Full-complex interpolation can create cancellations when A and B have different phases.
- Window length sets the usual STFT time/frequency trade-off.
- The morph-frequency limit is applied per FFT bin; effective frequency resolution is set by the actual window length and processing sample rate.