Knight's Tour Sonification — User Guide

Maps a validated 64-square knight's tour onto two audio controls: board X position controls constant-power stereo panning, and board Y position controls segment amplitude.

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

What this does

The script selects one Sound, converts it to mono when the input has more than one channel, divides the duration into 64 equal time intervals, and processes the intervals in the order of a predefined knight's tour. Each board coordinate controls two values:

Each interval is amplitude-scaled, panned to stereo with a sine/cosine constant-power law, and concatenated with the other 63 processed intervals. The result is a new stereo Sound; the selected source remains unchanged.

v0.4 tour validation: All five presets contain 64 unique board squares and legal knight moves between every consecutive pair. Before audio processing begins, the script also checks coordinate range, square uniqueness, and move legality at runtime. An invalid internal preset aborts processing rather than producing a misleading result.
Scope: The preset paths are fixed arrays, not tours generated interactively when the script runs. Labels such as Spiral-biased and Diagonal-biased identify the preset character; they should not be read as separate mathematical tour-generation algorithms implemented by the script.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…Knight's Tour Sonification.praat.
  3. Choose one of the five Tour_preset paths.
  4. Choose an Effect_preset. Use Custom if you want the four range fields to control the mapping directly.
  5. Choose a Visualization_mode.
  6. Set Play_result as desired and run the script.
Default behaviour: Warnsdorff tour, Custom effect ranges (intensity 0.30–1.00; stereo 0.00–1.00), Step-by-step with audio visualization, 0.03 s visualization delay, and final-result playback enabled.

Tour presets

Every preset is a complete 64-square knight's tour. The v0.4 integrity check verifies this again at runtime before mappings are calculated.

PresetStored nameStartEndNotes
Warnsdorff (Classic)Warnsdorff(1,1)(3,2)Fixed validated tour. Its end square is a legal knight move from its start, so this stored path is also closed.
Spiral-biased TourSpiral-biased(4,4)(4,3)Fixed validated tour with a center-originating bias in its stored ordering.
Diagonal-biased TourDiagonal-biased(1,1)(5,6)Fixed validated tour labelled for its intended diagonal character.
Center-start TourCenter-start(4,4)(3,8)Fixed validated tour beginning near the board centre.
Side-switching TourSide-switching(1,1)(7,4)Fixed validated tour labelled for frequent lateral changes in its stored ordering.

Runtime integrity test

For steps 1–64, the script checks that X and Y are each within 1…8, converts each coordinate pair to a unique square index, rejects repeated squares, and verifies each transition with |Δx|,|Δy| = (1,2) or (2,1).

Effect presets

Any effect preset other than Custom overwrites the four range fields before processing. The resulting endpoints are then clamped to 0…1 and ordered so the lower endpoint comes first.

Effect presetIntensity rangeStereo rangeStored name
CustomUses form values (defaults 0.30–1.00)Uses form values (defaults 0.00–1.00)custom
Full Range (dramatic)0.20–1.000.00–1.00full_range
Subtle Movement0.70–1.000.30–0.70subtle
Center Focused0.50–1.000.35–0.65center
Left-Heavy0.40–1.000.00–0.50left
Right-Heavy0.40–1.000.50–1.00right
Intensity Only (no pan)0.20–1.000.50–0.50intensity_only
Pan Only (no intensity)1.00–1.000.00–1.00pan_only

Audio mapping

Board coordinates → control values

For step k: rawStereo = (X[k] - 1) / 7 stereo[k] = stereo_min + rawStereo × (stereo_max - stereo_min) rawIntensity = (Y[k] - 1) / 7 intensity[k] = intensity_min + rawIntensity × (intensity_max - intensity_min) segmentDuration = sourceDuration / 64 startTime[k] = (k - 1) × segmentDuration

Intensity

The extracted mono segment is multiplied directly by intensity[k]. Because the allowed range is clamped to 0…1, the mapping can attenuate or leave a segment unchanged; it does not boost it above the source amplitude.

Constant-power stereo panning

panAngle = stereo[k] × π/2 leftGain = cos(panAngle) rightGain = sin(panAngle) stereo = 0.0 → leftGain=1, rightGain=0 stereo = 0.5 → leftGain≈0.707, rightGain≈0.707 stereo = 1.0 → leftGain=0, rightGain=1

The intensity multiplication happens before panning. The two panning gains therefore distribute the already-scaled mono segment between the output channels.

Processing pipeline

  1. Require exactly one selected Sound.
  2. Clamp and order the four Custom range endpoints; non-Custom effect presets first replace those values with their preset settings.
  3. If the selected Sound has more than one channel, use Praat's Convert to mono command to create a temporary mono working object.
  4. Load the selected fixed 64-square tour and run the tour-integrity checks.
  5. Calculate 64 equal time intervals and the X→stereo / Y→intensity mappings.
  6. For each interval, extract a rectangular segment with no crossfade, multiply it by the mapped intensity, create left/right copies, and apply the constant-power gains.
  7. Combine each pair into a stereo segment.
  8. Concatenate all 64 stereo segments in tour order.
  9. Remove temporary segment objects and any temporary mono conversion.
  10. Optionally draw the final visualization and play the final result.
No boundary smoothing: The script uses rectangular segment extraction and does not crossfade between adjacent segments. Abrupt changes in waveform value, intensity, or panning at segment boundaries can therefore produce audible discontinuities or clicks. This follows directly from the current implementation; it is not corrected automatically.
No final normalisation or limiter: The script does not peak-normalise the concatenated output. It also does not write a file to disk; the result remains a Praat Sound object unless you save it separately.

Visualization

The form provides four modes:

ModeDuring processingFinal drawingAudio during steps
Off (fastest processing)No drawingNoNo
Final onlyNo drawingYesNo
Real-time (visual only)Redraw after each step; pause by Visualization_delayYesNo
Step-by-step with audio (original)Redraw after each stepYesEach processed stereo segment is played
Visualization_delay: The explicit sleep is used only for Real-time (visual only). In Step-by-step with audio mode the segment playback itself provides the pacing, so the script does not add the visualization-delay sleep.

Figure contents

The visualization describes the control trajectory; it is not an audio waveform display.

Parameter reference

ParameterTypeDefaultImplemented behaviour
Tour_presetoptionmenuWarnsdorff (Classic)Selects one of five fixed validated 64-square tours.
Effect_presetoptionmenuCustomCustom uses the four range fields; every other choice overwrites them with preset values.
Intensity_minreal0.3Custom lower intensity endpoint. Clamped to 0…1.
Intensity_maxreal1.0Custom upper intensity endpoint. Clamped to 0…1. Endpoints are swapped if entered in reverse order.
Stereo_minreal0.0Custom lower pan endpoint. 0=left, 0.5=center, 1=right. Clamped to 0…1.
Stereo_maxreal1.0Custom upper pan endpoint. Clamped to 0…1. Endpoints are swapped if entered in reverse order.
Visualization_modeoptionmenuStep-by-step with audioOff, Final only, Real-time visual only, or Step-by-step with audio.
Visualization_delay_(s)positive0.03Pause between redraws in Real-time visual-only mode. Not added in the audio-step mode.
Play_resultbooleanyesPlays the complete concatenated result after processing.

Technical notes and edge cases

Input channel handling

The script accepts exactly one selected Sound. A mono Sound is processed directly. Any Sound with more than one channel is converted to mono before segmentation, so the original multichannel image is not retained.

Output

The output is stereo and is renamed source_KnightsTour_TourName, for example source_KnightsTour_Warnsdorff. The source object remains in Praat.

Range handling

Custom intensity and stereo endpoints are each clamped independently to 0…1, then swapped when necessary. This prevents out-of-range panning angles or intensity multipliers.

Timing

The source duration is divided mathematically by 64. Segment extraction occurs on Praat's sample grid, so the implementation should be understood as 64 equal requested time intervals rather than a separate resampling process.

Further Reading