Praat AudioTools Audio Quantizer
Quantize a monophonic voice or instrumental performance to a musical grid, or learn the microtiming of a short reference performance and transfer its rhythmic feel. Native Praat onset analysis, voice-aware time mapping, selectable WSOLA/PSOLA resynthesis, and an independent click-track preview.
What this does
Audio Quantizer is an offline, onset-based timing processor for monophonic audio such as sung phrases, flute, or single-line instrumental playing. Select a Sound in Praat, define a tempo and rhythmic subdivision, and generate a new Sound whose detected note onsets move toward a timing grid. The original recording remains unchanged.
The timing grid can be mathematically straight or can inherit the microtiming of a short audio reference. Unlike MIDI quantization, the processor must first infer the beginnings of acoustic events. Unlike simple chopping and reassembly, it calculates a monotonic time map across the complete recording.
Main capabilities:
- Three grid types: Straight grid, Learned groove from a reference Sound, and Groove from a groove Table.
- Five rhythmic divisions: quarter notes, eighth notes, sixteenth notes, eighth-note triplets, and sixteenth-note triplets.
- Four onset-input methods: intensity slope, spectral flux, hybrid analysis, or manual onset TextGrid.
- Two independent strengths: Groove strength changes the grid; Quantization strength determines how far the target audio moves toward it.
- Voice-aware processing: selectable Voice-safe or Standard stretch profiles; WSOLA is the default resynthesis engine, with PSOLA available.
- Independent auditory clock: optional stereo preview with quantized audio in the left channel and click track in the right.
- Inspectable results: optional onset TextGrid, native Praat Picture visualization, numerical mapping check, and re-detection of attacks in the processed Sound.
- Native Praat workflow: no Python, external program, temporary WAV, or disk file is required during execution.
Quick start
- Load a mono Sound into Praat and select it in the Objects window.
- Run
Audio_Quantizer.praat. - Keep Grid type = Straight grid for a first test. Set Tempo BPM and Grid division (for example 120 BPM and eighth notes).
- Choose Quantization strength and, if needed, a maximum onset shift. Start with a moderate strength for vocal material.
- Leave Automatic - Hybrid, WSOLA, and Voice-safe selected. Turn on Click track = Grid subdivision to hear the grid.
- Press OK. Praat creates a processed mono Sound and, if clicks are enabled, a stereo preview. With Play result enabled, the preview is played automatically.
- Inspect the Info report or optional Picture window. Listen to the mono result separately when judging timbre and artifacts.
Core concept and signal flow
The user supplies BPM. The script does not estimate the target performance's tempo automatically. Its reference-learning mode can fit the supplied reference tempo slightly (within a limited tolerance), but still requires a plausible tempo and meaningful bar alignment.
Three grid modes
| Grid type | Required objects | What it does |
|---|---|---|
| Straight grid | One selected mono Sound | Moves detected onsets toward regularly spaced beats or subdivisions. |
| Learned groove from a reference Sound | Two selected mono Sound objects | Detects events in a reference, learns its timing deviations by rhythmic slot, and uses the learned timing grid for the target Sound. |
| Groove from a groove Table | One mono Sound and one compatible Table | Applies a groove learned in a previous run, without analyzing the reference audio again. |
These modes share the same downstream onset-to-target mapping, collision handling, duration constraints, and resynthesis engines. The important distinction is which grid positions the solver receives.
Object selection and dialogs
Select exactly one mono Sound. No additional dialog is needed unless you enable Advanced settings.
Select exactly two mono Sounds. In the second dialog explicitly identify the reference Sound; the other becomes the target. The shorter Sound is merely the initial suggestion, not an automatic final decision.
Select the target mono Sound and one Table previously produced by the script. The Table's subdivision must match the chosen Grid division.
For Selected TextGrid, also select one TextGrid containing a point tier, preferably named onsets. In reference-learning mode this TextGrid is used for the target; the reference itself is analyzed automatically with Hybrid detection.
Tempo, rhythmic division and grid origin
Tempo BPM is quarter-note BPM, accepted between 20 and 300. The subdivision determines the distance between possible timing targets.
| Division | Units per quarter beat | At 120 BPM |
|---|---|---|
| Quarter notes (1/4) | 1 | 500 ms |
| Eighth notes (1/8) | 2 | 250 ms |
| Sixteenth notes (1/16) | 4 | 125 ms |
| Eighth-note triplets (1/8T) | 3 | 166.7 ms |
| Sixteenth-note triplets (1/16T) | 6 | 83.3 ms |
The script rejects a grid interval shorter than 30 ms. For Grid origin, choose First detected onset (default), Beginning of Sound, or Manual offset in milliseconds relative to the Sound's beginning.
Onset detection and note-level validation
An onset is an acoustically inferred attack or new event. It is not a MIDI note-on message and is not guaranteed to coincide with a musically intended note boundary. The four modes are:
| Method | Evidence used | When it helps |
|---|---|---|
| Intensity slope | Rapid positive changes in sound level | Clearly articulated repeated notes or separated attacks. |
| Spectral flux | Positive changes in spectral shape; a local frequency maximum helps suppress vibrato-related movement | Pitch or timbre changes without a large level increase. |
| Hybrid (default) | Intensity changes combined with spectral novelty | A practical starting point for solo voice and flute. |
| Selected TextGrid | Point times supplied by the user | Legato phrases, ambiguous articulation or cases requiring manual onset control. |
Automatic processing includes an energy gate, an adaptive threshold, local peak picking, short backwards refinement toward the start of an attack, and a minimum-separation rule (80 ms by default). Onset sensitivity defaults to 1.5; higher values lower the threshold and generally produce more candidates.
With Note validation on (default, under Advanced settings), candidate attacks are checked for evidence including onset of voicing, a meaningful pitch transition, re-articulation, an unvoiced lead into a new note, or sufficiently strong acoustic evidence. Pitch is supplementary: the method can retain clear attacks even without stable pitch.
Quantization strength and displacement limits
Two distinct operations occur: first the timing grid is constructed, and only then is each target onset moved toward its nearest permissible grid position.
| Control | Default | Meaning |
|---|---|---|
| Quantization strength | 100% | 0% requests no timing change; 100% requests the complete move to the selected grid, subject to feasibility. |
| Maximum onset shift | 0 ms = Auto | Auto allows approximately half a grid interval; any positive value is a manual displacement ceiling. |
| Minimum onset separation | 80 ms (Advanced) | Controls how closely automatic onset candidates may be retained; it is not the musical grid interval. |
Two detected events may compete for one grid point. The script considers neighboring slots and applies an order-preserving constraint solver. It does not delete or merge notes to achieve perfect alignment. If an exact destination is unsafe, it reports a partial adjustment or an unquantized collision.
Learning a groove from a short reference Sound
Select Learned groove from a reference Sound and then choose the reference in the second dialog. The source should contain clear, repeated rhythmic events. A short drum pattern, articulated instrumental figure or repeated vocal rhythm is usually easier to analyze than an unarticulated legato line.
| Reference-dialog setting | Default | Purpose |
|---|---|---|
| Reference sound | Shorter of the two Sounds suggested | Choose which selected Sound supplies the timing pattern. |
| Reference tempo BPM | Same as target BPM | Nominal tempo used to assign reference attacks to slots. |
| Reference downbeat | First detected onset | Choose a detected onset or a manually specified position as the reference phase. |
| Reference offset ms | 0 | Reference downbeat relative to the reference Sound start when Manual offset is used. |
| Beats per bar | 4 | Pattern organization; accepted up to 16. |
| Pattern length bars | 1 | Number of bars per repeating template; accepted up to 8. |
| Groove strength percent | 100% | How strongly the learned deviations shift the target grid. |
| Click follows | Groove grid | Choose groove timing or straight timing for the click reference. |
| Keep groove Table | No | Keep an additional reusable Praat Table in the Objects list. |
The reference detector must find at least four accepted onsets. The script assigns each reference onset to a nominal slot, then performs a two-pass least-squares fit of tempo and phase. A fitted reference tempo is adopted only if the grid interval differs by no more than 8% from the supplied tempo. Otherwise the user-supplied reference tempo remains in effect.
For each slot in the repeating pattern, the script calculates a median normalized timing offset across observed repetitions and an estimated spread. Multiple attacks assigned to the same slot are resolved by retaining the closer event. Beat-slot offsets are adjusted to preserve the reference clock on average. Unobserved slots remain straight; no timing deviation is invented for them.
How groove transfer works
Instead of storing deviations only in milliseconds, Audio Quantizer stores each slot's offset as a fraction of that grid interval. This allows a groove recorded at one BPM to be applied at another BPM.
| Example event | At 120 BPM / eighth notes | At 90 BPM / eighth notes |
|---|---|---|
| Straight offbeat | 250 ms after beat | 333.3 ms after beat |
| Performed offbeat | 285 ms after beat | About 380 ms after beat at full transfer |
| Relative delay | +35 ms = +0.14 slot | About +46.7 ms = +0.14 slot |
Here, the learned offset is 14% of an eighth-note slot, so it scales with the destination tempo. Actual learned values are capped to plus or minus 0.45 of a grid interval to maintain an ordered grid.
Why Groove strength and Quantization strength are separate
Groove strength = 0% keeps the applied timing grid straight, even if the template contains offsets. Groove strength = 100% uses the full allowed reference timing deviations. Quantization strength = 50%, for example, then requests that the target recording travel only halfway toward this newly shaped grid. Further constraints may reduce the realized movement.
It is the timing organization of the reference that is transferred. The melody, note sequence, articulation, timbral identity, and dynamics of the target are not copied from the reference or replaced.
Groove Table: keeping and reusing a learned pattern
Enable Keep groove Table in the Learned groove dialog to leave a reusable Praat Table in the Objects list. A subsequent run can use Grid type = Groove from a groove Table, with the target Sound and this Table selected.
Each row represents one slot in the pattern; the Table includes columns such as:
| Column | Meaning |
|---|---|
slot, beat, sub | Slot index and its beat/subdivision position. |
offset_frac | Normalized signed deviation from the straight slot. |
offset_ms_ref | Corresponding deviation in milliseconds at the fitted reference tempo. |
n_obs | Number of observed reference events for that slot. |
spread_frac | Robust variability estimate (MAD-based). |
units_per_beat, beats_per_bar, ref_bpm | Subdivision, bar organization, and fitted reference BPM metadata. |
units_per_beat as the saved Table. A groove learned with eighth notes cannot be loaded directly as a sixteenth-note template in this implementation. The Table remains in Praat memory; this script does not automatically save it to a file or make it persist after Praat closes.Elastic time mapping and collision-safe quantization
The processor creates a strictly ordered mapping between source time and destination time. Source anchors include the Sound beginning, accepted note onsets, and Sound ending. The two ends are fixed so the mapping aims to preserve the complete duration.
A chain-constraint solver combines the requested destinations with maximum displacement, minimum spacing, and allowed local stretching. The solution avoids reversed or collapsed events. If the solver cannot place an onset exactly on the requested grid position, the event is constrained rather than discarded.
Time change is distributed according to acoustic stretchability: silence is given greater weight than stable voiced material, unvoiced material less weight, and protected attacks approximately zero weight. The script builds a continuously sampled, weighted DurationTier and verifies the integrated duration at each onset anchor before synthesizing sound.
WSOLA and PSOLA: two resynthesis engines
| Engine | Behavior | Practical use |
|---|---|---|
| WSOLA (default) | Waveform-similarity overlap-add. Uses approximately 30 ms grains, 15 ms overlap, and a local waveform alignment search around the nominal source position. The resynthesis engine does not depend on pitch-period tracking. | Recommended initial choice for sung voice and melodic material when PSOLA alters timbre excessively. |
| PSOLA | Native Praat Manipulation with a DurationTier and overlap-add resynthesis. The selected pitch floor and ceiling influence periodicity tracking. | Alternative for signals where Praat's pitch-synchronous processing produces the preferred result. |
The onset detector and stretchability analysis can still analyze Pitch when WSOLA is selected. "WSOLA: no pitch analysis" refers to its time-synthesis engine, not a promise that no pitch information is ever used anywhere in the script.
When Quantization strength is 0%, or the requested mapping contains no actual movement, the script creates an unprocessed copy rather than unnecessarily resynthesizing the source.
Voice-safe and Standard profiles
| Control | Voice-safe (default) | Standard |
|---|---|---|
| Local ratio for voiced material | 0.80 to 1.25 | 0.65 to 1.55 |
| Attack protection | 40 ms | 20 ms |
| Silence ratio limits | 0.25 to 3.0 | 0.25 to 3.0 |
| Unvoiced ratio limits | 0.80 to 1.25 | 0.80 to 1.25 |
| Intended tradeoff | More conservative vocal correction | Greater freedom to reach grid positions |
Voice-safe does not restrict every region of the file to 0.80-1.25. Silence can absorb much larger timing changes. This intentional asymmetry protects voiced material where possible, but can also result in incomplete quantization of densely sung passages.
The profile selects ratio and attack-protection values; it does not automatically reduce the Quantization strength. The main form's default strength is still 100%. For expressive singing, choose a moderate strength if naturalness matters more than full grid alignment.
Click-track listening preview
The optional click provides an independent timing reference. It is not generated from where the processed attacks happened to land. When enabled, the script keeps the processed mono Sound and also creates a stereo preview:
| Click track setting | Result |
|---|---|
| Off (default) | No stereo click preview is created. |
| Quarter-note beats | One click per quarter-note beat. |
| Grid subdivision (beats accented) | Clicks at the selected subdivision, with a different accent for quarter-note beats. |
Each click is a short, approximately 5 ms windowed tone. Beat clicks use 2,000 Hz; subdivision clicks use 1,500 Hz at 60% of beat-click amplitude. The default Click level is 0.25 and is adjustable in Advanced settings.
In either Groove mode, a second-dialog setting Click follows selects Groove grid (default) or Straight grid. This is an important musical distinction: a groove-quantized performance is not necessarily supposed to coincide with a perfectly straight metronome.
Output Sounds, optional TextGrid and final selection
| Object | When created | Purpose |
|---|---|---|
Original_Quantized_120BPM_8th | Always after successful processing | Primary mono Sound, available for playback or subsequent AudioTools processing. |
Original_Quantized_120BPM_8th_Click | When Click track is enabled | Stereo listening preview: left audio, right click. |
..._onsets (TextGrid) | When Keep onset TextGrid is enabled | Original onset times and mapped target times shown on a common output-oriented timeline. |
groove_ReferenceName (Table) | When learning a groove with Keep groove Table enabled | Reusable slot offsets and reference statistics. |
Output names vary with the actual input name, BPM, grid division, and whether the groove is active. If Play result is enabled, Praat plays the stereo click preview when present; otherwise it plays the mono result. The created outputs are selected at the end of the run.
The optional TextGrid has two point tiers: Quantized_Onsets and Original_Onsets. The second tier retains pre-quantization timestamps for comparison; these are not physical attacks in the output Sound. If Keep onset TextGrid is off, no diagnostic TextGrid remains.
Analysis report: how to read the numbers
With Show analysis report enabled (default), Praat's Info window summarizes the full run.
| Report area | Key quantities |
|---|---|
| Audio and settings | Input duration, sampling rate, BPM, grid interval, origin, detection method, engine, profile and strength. |
| Detection | Candidate and accepted onset counts; grid-fit phase concentration, mean distances to straight/groove grid, and collision counts. |
| Time mapping | On requested target, exactly on a grid point, constrained, unchanged, maximum/mean shift and local ratio range. |
| Groove template | Reference tempo and fit, per-slot offset, observations, spread, observed vs unobserved slots, and whether a Table was kept. |
| Numerical verification | DurationTier point count, predicted/actual duration and maximum integrated anchor error. |
| Measured output check | Re-detected acoustic attacks, matches within 40 ms, missing/extra events, and attack-to-target / attack-to-grid timing error. |
| Click and warnings | Click frequency/rate, reference origin, stereo preview name, and warnings when the grid fit or processing is problematic. |
A low grid-fit concentration warns that the source performance does not clearly correspond to the selected tempo/division/phase. A quantizer can still produce an output in such a case, but its timing corrections may be musically arbitrary.
Five-panel Praat Picture visualization
With Draw visualization enabled (default), the script draws a native, approximately eight-inch Praat Picture layout. This is a diagnostic display, not an external image file.
| Panel | What it shows |
|---|---|
| 1. Original Sound | Source waveform, grid lines and red onset markers. |
| 2. Onset mapping | Lines connecting source timestamps to intended output timestamps; colors distinguish on-target, constrained and retained events. |
| 3. Quantized Sound | Output waveform, mapped onset targets in blue, and attacks re-detected in the output in green. |
| 4. Local time ratio | The changing time ratio, the 1.0 unchanged baseline, and voiced-ratio limits. |
| 5. Summary | Onset counts, displacements, timing-map verification and measured attack errors. |
For a learned groove, the grid lines refer to the selected groove-adjusted grid when Groove strength is nonzero. This makes the timing transformation visible as a musical mapping rather than as a generic audio effect.
Advanced settings
Enable Advanced settings on the main form to open a second dialog before processing.
| Parameter | Initial value | Purpose |
|---|---|---|
| Minimum onset separation ms | 80 | Minimum accepted distance between automatic onset candidates. |
| Pitch floor Hz / Pitch ceiling Hz | 75 / 600 | Pitch-analysis range for PSOLA resynthesis; may need adjustment for the instrument. |
| Minimum / Maximum local time ratio | From Voice-safe or Standard profile | Voiced-material expansion/compression limits; changing them makes this a custom configuration. |
| Attack protection ms | 40 Voice-safe / 20 Standard | Time region around attacks protected from stretching. |
| Click level | 0.25 | Output click amplitude; the script caps it at 1. |
| Note validation | On | Enable/disable pitch, articulation and other evidence checks on detected attacks. |
| Engine self test | Off | Run neutral resynthesis for direct sample-level comparison with input. |
Compositional workflows
| Study | Suggested experiment |
|---|---|
| A. Straight corrective quantization | Quantize a flute line to eighth notes at the intended BPM. Compare strength 25%, 50% and 100% while listening to the same click. |
| B. Voice-safe correction | Apply moderate onset displacement with WSOLA and Voice-safe. Compare intelligibility, breath, vibrato and onset placement to the original. |
| C. Groove learned from a rhythm pattern | Select a sung target and a short percussion reference. Learn a one-bar groove, then compare straight and groove clicks. |
| D. Tempo-independent groove identity | Learn at one reference BPM and transfer to a target at another BPM. The relative timing deviation scales with the target grid interval. |
| E. Reuse a groove template | Keep the Groove Table, then apply it to multiple separate mono Sounds with the same grid subdivision. |
| F. Human timing vs ideal meter | Compare Groove strength 0%, 50% and 100% while keeping Quantization strength fixed. |
| G. Manual onset intervention | Use a curated TextGrid for an ambiguous vocal legato passage; examine whether the mapped events improve timing without inventing attacks. |
| H. Resynthesis comparison | Apply one timing map with WSOLA and PSOLA and compare timbre, attacks, numerical timing and the neutral engine test. |
Performance study: inherited microtiming
Record a short, clearly articulated rhythmic phrase and learn its groove. Apply the resulting template to another melodic line, first at low Quantization strength, then at a stronger setting. Compare two outputs that share identical pitches and words but reflect different timing organizations. The experiment distinguishes the source of timing from the sound being transformed.
Diagnostics and troubleshooting
| Symptom | Check / remedy |
|---|---|
| No output or wrong selected objects | Check the required mono Sound count for the chosen grid mode; choose the reference explicitly when learning. |
| Reference groove fails | Reference must be mono, at least 0.5 s long, and contain at least four accepted onsets. Try a clearer repeated rhythmic example. |
| Groove Table rejected | Use a Table created by Audio Quantizer; match the grid subdivision used when it was learned (units_per_beat). |
| Timing seems unrelated to the music | Check target BPM, grid origin, reference downbeat, reference BPM and pattern length; read the grid-fit warning. |
| Too few or too many onsets | Change detection mode and Onset sensitivity. Adjust minimum onset separation or use a curated onset TextGrid. |
| Dense notes refuse to quantize fully | Review collisions, maximum shift and Voice-safe constraints. Preserving the event order takes priority over perfect grid alignment. |
| Singing is distorted | Reduce Quantization strength or manual shift limit; use Voice-safe WSOLA and Engine self test; inspect whether too many non-note events were detected. |
| Click sounds out of time | Check whether it follows Straight or Groove grid, and verify the target grid origin. The click intentionally does not follow detected output attacks. |
| Click plays only from the right | This is intentional: stereo preview is left = audio, right = metronome. Use a suitable listening setup. |
| Unmatched measured attacks | The output detector may miss borderline events. Inspect the Picture and listen; the measured count is not a complete perceptual correctness score. |
| Very slow processing | WSOLA can create many short in-memory Sound objects. Test shorter excerpts and disable optional diagnostics when not needed. |
Installation and requirements
Audio Quantizer is a single native Praat script. It requires a Praat version supporting the commands used by the script (including arrays, matrices, Table commands and the selected resynthesis functions). There is no Python package or second executable to install.
plugin_AudioTools/
Dynamics & Envelope/
Audio_Quantizer.praat
... (other existing AudioTools modules)
In Praat, load or select the required mono Sound object(s) and use Praat → Open Praat script... (or your existing AudioTools launcher/menu) to run the script. Select the correct objects before opening the form. For groove Table reuse, a compatible Table must already be present in Praat's Objects list.
In-memory processing and object safety
The script keeps the original user objects intact. It creates analysis objects and temporary grains inside Praat, then removes them during the normal processing path. No intermediary WAV, Python process, shell command or online service is required. The resulting mono Sound, optional stereo click preview, optional onset TextGrid and optional new groove Table are the intended persistent objects in the Objects window.
Play result plays the click preview when available; otherwise it plays the mono Sound. Finishing a successful run selects its output objects. The optional Groove Table is retained for reuse inside the current Praat session, not silently written to disk.
Limitations and performance considerations
- Monophonic focus: the target and reference Sounds must be mono. The processor is not a general polyphonic beat or drum quantizer.
- Reference interpretation is user-guided: BPM, bar organization, downbeat and pattern length matter. A pickup note or incorrect phase can produce the wrong groove.
- Groove represents timing offsets: it does not capture dynamics, articulation, timbre, note probabilities or pitch relationships.
- One repeating groove pattern: variation across different sections of a composition is reduced to slot-wise statistics; a gradually changing feel is not modeled independently by bar.
- Missing slots stay straight: events absent from the reference cannot provide evidence for a per-slot deviation.
- Strict timing limits are intentional: some note attacks remain off-grid to prevent event collisions, extreme stretching or damage to voiced material.
- Source onset estimates are imperfect: legato, phonetic transitions, vibrato, breath noise and repeated notes can confound automatic detection.
- WSOLA is not artifact-free: even waveform-based alignment may create smearing or discontinuities when local temporal changes are large.
- Numerical grid agreement is not identical to sound quality: the time-map integral, re-detected onset errors and critical listening answer different questions.
- Performance can scale poorly: the current WSOLA implementation makes many short Praat Sounds in memory, so test long recordings cautiously.
- No automatic disk persistence: a Groove Table must be deliberately saved through Praat's normal object-save workflow if needed across sessions.
Practical recommendation: first evaluate a short straight-grid example, then learn a groove from a short, clearly articulated reference. Keep the click enabled during timing checks, but evaluate the separate mono output for sound quality.