Bimodal Contour Grammar — User Guide

Generates phrase-level pitch contours from an Onset → Nucleus → Coda grammar, resynthesizes the selected sound with the generated contour, and draws the same pitch-event stream as a visual contour.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.7.1 (2026) License: MIT License Repo: GitHub
Contents:

What this does

Bimodal Contour Grammar generates a new pitch contour over the duration of the selected sound. Each phrase follows the rule Phrase → Onset + Nucleus + Coda. The onset is either a near-instantaneous upward jump or an upward glissando; the nucleus is either a plateau or a wobble; and the coda is a downward fall or deeper drop.

Every generated pitch point is sent through the same addPoint procedure: it is added to the output PitchTier and used to draw the main contour. The visual attributes are not identical to the audio dynamics: colour, line thickness, and dot size are driven by the source sound's measured intensity, while output loudness is controlled separately by phrase-level generated dynamics.

Channel behaviour: If the selected sound has more than one channel, the script converts it to mono before intensity analysis and Manipulation resynthesis. The generated output is therefore mono; the original stereo or multichannel spatial image is not preserved.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run Bimodal_Contour_Grammar.praat.
  3. Choose Custom or one of the five supplied presets.
  4. For Custom, set the base pitch range, gesture speed, interval scale, and wobble depth.
  5. Choose a random seed, colour scheme, line style, audio loudness settings, and display options.
  6. Click OK. The script generates the grammar, resynthesizes the sound, draws the visualization, and selects the resulting Sound object.
Random seed: 0 creates an unpredictable seed and prints the actual seed in the Info window. Any non-zero integer initializes the script's deterministic LCG and can reproduce the same grammar choices when the source duration and grammar/audio parameters are unchanged.

Presets

The presets override only the five grammar-shaping fields shown below. They do not override the seed, colour scheme, line style, dot sizes, loudness controls, grid, note labels, or playback setting.

PresetPitch base (Hz)Gesture scaleInterval scaleWobble depth
Customuses form valuesuses form valueuses form valueuses form value
Microtonal Murmur120–1601.80.251.5 Hz
Leaping Gestures80–2500.92.06.0 Hz
Rapid Stutter140–1800.30.53.0 Hz
Wide Arc60–3001.61.88.0 Hz
Gentle Drift100–2001.40.74.0 Hz

Grammar and gestures

S → Phrase + S
Phrase → Onset + Nucleus + Coda

Onset → JumpUp | GlissUp
Nucleus → Plateau | Wobble
Coda → Fall | DeepDrop

At the start of each full phrase, a new base pitch is drawn uniformly from Pitch_base_lo_Hz … Pitch_base_hi_Hz. The script also draws one phrase-level loudness offset within ±loudnessVariation.

Onset

GestureDurationPitch movementImplementation
JumpUprandom 0.05–0.15 × Gesture_scale+10 to +30 Hz × Interval_scaleThe change occurs within at most 1 ms, then the new pitch is held for the rest of the onset.
GlissUprandom 0.05–0.15 × Gesture_scale+20 to +50 Hz × Interval_scaleThe PitchTier interpolates from the starting pitch to the higher pitch across the full onset duration.

The sampled onset duration is shortened when necessary so that at least 0.30 × Gesture_scale seconds remain for the minimum nucleus and coda.

Nucleus

GestureDurationBehaviour
Plateaurandom 0.20–0.50 × Gesture_scaleHolds the current pitch.
Wobblerandom 0.20–0.50 × Gesture_scaleAdds random offsets within ±Wobble_depth_Hz at steps of 0.05 × Gesture_scale, with a 10 ms minimum step, then returns exactly to the centre pitch at the nucleus endpoint.

The nucleus is shortened when necessary to reserve at least 0.10 × Gesture_scale seconds for the coda.

Coda

GestureDurationPitch movement
Fallrandom 0.10–0.20 × Gesture_scale, limited by remaining time−20 to −40 Hz × Interval_scale
DeepDropsame duration rule−50 to −80 Hz × Interval_scale

Both codas are continuous downward PitchTier ramps. The resulting pitch is clamped to a minimum of 50 Hz.

Between phrases: when time remains, the grammar advances by a random 0.05–0.10 × Gesture_scale interval before the next phrase. This is not inserted silence. No extra pitch point is added during the interval, so the PitchTier linearly connects the previous coda endpoint to the next phrase's new base pitch.

If the remaining duration is shorter than 0.35 × Gesture_scale, the script does not start another full phrase. It holds the current pitch to the exact end of the Sound instead.

Parameters

Grammar parameters

ParameterDefaultBehaviour
Pitch_base_lo_Hz100Lower bound for each phrase's randomly selected base pitch. Must be lower than Pitch_base_hi_Hz.
Pitch_base_hi_Hz200Upper bound for phrase base pitch.
Gesture_scale1.0Multiplies gesture durations and inter-phrase interval. Internally clamped to 0.1–5.0.
Interval_scale1.0Multiplies JumpUp, GlissUp, Fall, and DeepDrop pitch distances. Internally clamped to 0.05–5.0.
Wobble_depth_Hz5.0Maximum positive/negative Wobble offset. Internally clamped to 0.1–50 Hz.

Randomness

ParameterDefaultBehaviour
randomSeed00 chooses an unpredictable seed; non-zero uses that exact seed for the custom LCG.

Colour and line style

ParameterDefaultBehaviour
colorSchemePitch+Loudness RainbowPitch-height rainbow / pitch-class colour wheel / source-intensity heatmap / octave spiral.
lineStyleThin continuous lineFixed-width line, source-intensity-dependent line width, or source-intensity-dependent dots.
minDotSize1.0Minimum painted-circle size in mm for the Dots style.
maxDotSize4.0Maximum painted-circle size in mm for the Dots style.

Audio synthesis

ParameterDefaultBehaviour
baseLoudness70Praat Scale intensity target for the resynthesized Sound, in Praat intensity dB (not dBFS).
loudnessVariation10Each phrase receives a random relative-dB offset within ± this value. The same range is also used to map source intensity to visual brightness/width/dot size.

Display and playback

ParameterDefaultBehaviour
showGridyesDraws horizontal semitone grid lines; C lines are emphasized.
showNoteLabelsyesWhen the grid is enabled, labels C notes at the left of the main contour.
playAfterGenerationyesAutomatically plays the generated Sound after processing.
The Picture geometry is fixed internally at 800 × 300 hundredths of an inch for the main contour setup; image width and height are not user parameters in the current form.

Audio processing

  1. The selected Sound is copied as mono, or converted to mono when the source has multiple channels.
  2. Praat Intensity is calculated with a 75 Hz minimum pitch and 0.01 s time step for visual loudness mapping.
  3. The grammar constructs a PitchTier over the Sound's actual startTime … endTime domain.
  4. A Manipulation object is created from the mono source with To Manipulation: 0.01, 75, 600.
  5. The Manipulation pitch tier is replaced by the grammar-generated PitchTier and resynthesized with Get resynthesis (overlap-add).
  6. If the result is non-silent, Praat Scale intensity sets its overall target to baseLoudness.
  7. An IntensityTier applies each phrase's random relative-dB offset. A phrase has a constant gain between its start and coda end; values interpolate across the inter-phrase intervals.
  8. A final attenuate-only peak safety is applied: if absolute peak exceeds 0.99, Scale peak: 0.99 is used. Quieter results are not boosted.
Pitch-resynthesis scope: the script uses Praat Manipulation/overlap-add with a 75–600 Hz analysis range. Results depend on usable periodicity in the source; noisy, strongly polyphonic, or otherwise poorly tracked material may resynthesize less predictably.

Visualization

The visualization is drawn in the Praat Picture window and uses the Sound's true start and end times. Its vertical MIDI range is derived from the current pitch parameters, including the 50 Hz floor and the possible upper gesture/wobble range.

Main contour

The main panel shows the generated grammar pitch points in MIDI-height coordinates. The same points are added to the PitchTier used for resynthesis.

Colour schemeMapping
Pitch+Loudness RainbowPitch height maps from blue at the lower display range toward red at the upper range; source intensity controls brightness.
PitchClass+Loudness WheelPitch class determines hue; source intensity controls brightness.
Intensity HeatmapSource intensity is mapped across a blue → green → red heat scale.
Octave SpiralPitch class determines hue; octave and source intensity jointly affect brightness.

For intensity-dependent line width or dots, the source Intensity value at each generated event is clipped to baseLoudness ± loudnessVariation and mapped to the requested visual range. This visual mapping does not display the generated phrase-level output gain.

Extended panels

Output and reproducibility

The Info window reports the actual seed. Reusing a non-zero seed preserves the sequence of grammar choices and phrase dynamics as long as the source duration and relevant grammar/audio parameters are unchanged. Visual style settings do not consume random draws, so changing colour or line style does not change the generated audio contour.