How we built it
This started with Chimera, a voice synthesiser that builds a singing voice from a simulated throat: lungs, vocal folds, mouth, and no recordings. After using it for a cover of 10cc's I'm Not in Love, I started thinking about organs. The pipe organ was the original robot: a machine that turns air into music. I love reverb, the sound in churches, and particularly Bach's organ concertos, and wanted to see if I could model a real pipe organ in a real cathedral, semi-convincingly, without melting my MacBook Air.
Made by Andy. X · GitHub · The source code
01The pipe
Most organ pipes are flue pipes.3 A flue pipe has no reed and no parts that move.
Air from the windchest goes into a small hole at the bottom of the foot. This hole is the toe. The air goes up through the foot. Then it goes through a narrow slot, the flue, between the front of the foot and a flat plate, the languid. The flue makes a thin sheet of air, the jet. The jet moves up across the mouth and hits the sharp upper lip.
A jet that hits an edge is not stable. It moves quickly from the inside of the lip to the outside and back. Without a pipe, this makes only a quiet hiss.
Above the mouth is the body: a column of air with its own natural frequencies. Each movement of the jet pushes air into the column. A pressure wave goes up the column, reflects at the top and comes back. The returning wave moves the jet to the other side. The jet and the column then lock together. This loop makes the pipe speak.
The note
An open pipe speaks when its air column holds half a wavelength. A stopped pipe has a cap at the top. Its air column holds a quarter of a wavelength. Thus a stopped pipe speaks an octave lower than an open pipe of the same length.
f ≈ c / 2L (open) f ≈ c / 4L (stopped) c ≈ 343 m/sMiddle C (262 Hz) needs an open pipe of about 65 cm. The lowest note of the York Minster 32′ pedal stop (16 Hz) needs a pipe of about 10.5 m. The "feet" of a stop (8′, 4′, 16′, 32′) give the length of its lowest open pipe.
Our model
We use a jet-drive digital waveguide. This is a standard method to model wind instruments.12 The model has four parts. Each part is a few lines of code. The code operates 48,000 times each second for each pipe that sounds.
- The jet is a delay line. The delay is the time that the jet needs to cross the mouth. This time is the height of the mouth (the cut-up) divided by the speed of the jet. The pressure at the foot sets the speed,
U = √(2p / ρ). A smaller toe hole gives a slower jet and a longer delay. - The lip is a soft limit. It is a cubic curve that saturates, because the jet can put only a limited quantity of air into the pipe. An offset in the curve adds even harmonics. These harmonics give a principal its bright edge.
- The air column is a second delay line, one period long. The top of the column reflects the wave. An open pipe reflects it as positive, a stopped pipe as negative. The negative reflection removes the even harmonics. This gives a stopped flute its hollow sound.
- Losses are a gentle low-pass filter in the loop. Its corner frequency is a fixed number of harmonics above the note. Thus a rank keeps one tone colour from bass to treble. Organ builders call this scaling. Radiation from the mouth makes the sound brighter.
Two more parts make the start of the note sound real. First, a short burst of edge noise starts each note. Organ builders call this chiff. Second, a short surge of pressure occurs when the valve below the pipe opens.
Turbulence in the jet adds a small quantity of noise all the time. The wind supply also moves slightly. When many pipes play, the wind pressure decreases a little, as in a real bellows.
One fact is important for the next section. The note that the pipe makes depends on the travel time of the jet, compared with the period of the note. At about half a period, the pipe speaks its correct note. If the jet is too fast or too slow, the pipe jumps to a higher mode. That mode is an octave or more above the correct note. The voicer must prevent this jump.
02Voicing
A new pipe from the workshop is not ready to play. Pipe makers make each pipe rough on purpose. The pipe is a little too long, the mouth is too low, the toe is open and the languid has no nicks.
A voicer then adjusts each pipe by ear, one pipe at a time. Our program does the same work. It measures each result. It does not listen.
The four adjustments, in the order that a voicer uses
- Toe. The voicer opens or closes the hole in the foot. This sets the pressure at the mouth, and thus the loudness. It also changes the speed of the jet.
- Cut-up. The voicer raises the top of the mouth. A higher cut-up gives the jet a longer travel. The tone becomes rounder, and the pipe stops its jump to a higher note. This adjustment goes in one direction only, because the voicer cannot put back metal that is cut away.
- Nicks. The voicer cuts small nicks in the edge of the languid. The nicks break up the edge noise of the jet. Thus the note starts cleanly. This adjustment also goes in one direction only.
- Length. The voicer makes the top shorter or longer until the pipe is in tune. In a real organ, a tuning slide does this.
The measurements after each adjustment
- Pitch. The program uses autocorrelation. It compares the sound with the same sound one period later. The result is accurate to a part of a cent. A cent is one hundredth of a semitone.
- Level. The program measures the RMS level of the steady tone. It compares this level with the target for the rank.
- Tone. The program measures the spectral centroid, the centre of the harmonics. It counts the centroid in harmonics, so the value has the same meaning at all pitches.
- Onset. The program measures how long the note needs to become steady. It also measures the edge noise before the note.
Sometimes a pipe jumps to the wrong note. Then the program uses the travel time of the jet to find the correction. If the travel is too long, it gives the pipe more wind. If the travel is too short, it raises the mouth.
At the end, the program plays the pipe with eight different patterns of turbulence and wind. It accepts the pipe only when the pipe keeps its note in all eight tests.
We measured all 830 pipes. Each pipe ends within about one cent of perfect tuning. For 90% of the pipes, the level is within about 1.2 dB of its target.
We also did a stress test with turbulence patterns that the program did not use. In this test, about 0.5% of notes jumped to the wrong pitch. Thus a wrong note can still occur.
03The organ
One pipe makes one note in one tone colour. A row of pipes, with one pipe for each key, is a rank, or a stop.
Our organ has seventeen ranks. Their names come from the York Minster stoplist in the National Pipe Organ Register.4 The organist plays eleven ranks from the keyboards (the manuals) and six ranks from the pedals. Thus the organ has 830 pipes: 58 in each manual rank (C2 to A6) and 32 in each pedal rank.
- Principals and diapasons (8′, 4′, 2′) are open metal pipes. They make the main sound of the organ. An 8′ rank sounds at written pitch. A 4′ rank sounds one octave higher, and a 2′ rank two octaves higher.
- Stopped ranks and wooden ranks have darker, hollow tones. The negative reflection and a lower loss corner give these tones.
- Mixtures are ranks that sound a fifth or an octave above the note. Their pipes are very small. Near the top of the keyboard, a real mixture drops back an octave, because the pipes become too small to make. Our mixtures do the same.
- Pedal ranks go down to 32′. The lowest pipe sounds at 16 Hz. You feel this note more than you hear it. This pipe is slow to start. It needs about 0.7 seconds to reach full voice.
The same loop voices every pipe when the app starts. The work occurs in background threads (Web Workers) while you watch.
04The cathedral
To hear the organ in York Minster, the model needs the shape of the building and its materials.
We drew the building as a plan of cells. Each cell is 0.5 m square, and the plan has about 42,000 cells. Each cell is open air between a floor height and a ceiling height. Or it is solid: a pier, a wall, or outside.
Each surface has a material. Each material has an absorption value for six octave bands, from 125 Hz to 4 kHz. Limestone absorbs about 2–5% of the sound. Glass absorbs more at low frequencies. The wooden vaults and the oak choir stalls absorb more again.
The dimensions come from published sources.5 The building is 160 m long outside. The nave is 31 m wide and about 29.5 m high. The choir is 31 m high.
For some dimensions, we found no published value. Two examples are the height of the vault in the tower and the size of the piers. For these, we estimated the value. The code marks each estimate. The volume and shape of the building have the largest effect. The model does not include details smaller than half a metre.
05The echo
The echo of a cathedral is millions of reflections. They arrive over many seconds. We calculate them with ray tracing.
The model sends about 30,000 rays of sound from each part of the organ, in all directions. Then it follows each ray through the building.
- At each surface, a ray loses the part of its energy that the material absorbs. The model does this separately for each of the six bands.
- The surface reflects the ray in one of two ways. It can reflect the ray as a mirror does. Or it can send the ray in a random direction. The model sends 35% of rays in a random direction, because carved stone and pews spread the sound.
- Air also absorbs high frequencies over long distances. The model uses the values from ISO 9613-1.6 Thus the high frequencies of the echo stop first.
- When a ray goes through a sphere of 1.5 m around the listener, the model records its energy and its arrival time.
The result is an energy histogram for each band. The histogram shows how much sound arrives in each millisecond.
We measure the echo from the histogram as acousticians do. First, we add the energy from the end back to the start. This is the Schroeder integral.7 It gives a decay curve. Then we measure the curve as ISO 3382-1 specifies.8 T30 is the time that the sound needs to decrease by 60 dB. We calculate T30 from the slope of the curve between −5 dB and −35 dB.
T30 at 500 Hz, York Minster: measured 8.37 s model 8.37 sTo make the echo audible, we change the histogram into a two-ear impulse response. Noise in each band gets the shape of the traced energy. The direct sound arrives first. Each ear gets its own version. The sound arrives later at the far ear, and the head blocks part of it.
The browser then convolves the sound of the organ with this response, live. In the app, the bright lines are real ray paths from this trace.
06How we check it
The acoustics lab of the University of York publishes recordings of the echoes of real buildings. The library of recordings is OpenAIR.910 For each recording, the lab plays a test sound at one position and records it at a second position.
For some buildings, the lab recorded several pairs of positions. St Paul's Cathedral has eight.11 The positions are:
- below the dome to the nave, and the nave to below the dome
- two positions below the dome
- the choir
- the Geometric Staircase
- two positions in the Whispering Gallery
- the library.
York Minster has one pair, from below the central tower to the middle of the nave.
We put our source and our listener at the same two positions. Then we compare the results.
Hear the difference
Here is the same clap or chord, from below the tower of York Minster to the middle of the nave. You hear it once through the real recorded echo, and once through our model. The two have the same loudness.
The recording uses one microphone. Our model gives two ears. Thus our version sounds wider on headphones.
- Before tuning, the model was within 5–10% in the middle bands at York. At St Paul's, it was within 2–13% in all bands. At York, the low bands were too short. The real building has more low-frequency echo than the material tables show.
- After tuning, the model agrees with the recording within about 1%. But the tuning comes from the same recording. Thus this result is a fit, not an independent test.
- The independent test uses the other positions. We tuned St Paul's with the pair from below the dome to the nave only. The seven other recordings can show if the model gives the building, or only one measurement. We have not done this test yet.
- The sound that you hear is within about 5% up to 2 kHz. At 4 kHz, it is about 20% too long. In the lowest bands, the early sound is 5–7 dB weaker than in the real building. This can sound muddy. Thus we remove some low frequencies from the echo.
For the organ, the check is internal. Section 2 tells how the program measures the pitch, level, tone and steadiness of each pipe.
07Sound in space
The organ is not one point. It has six sources: the main manual pipes, the small upper ranks and the pedal pipes. Each of these is in two halves, the C side and the C♯ side. Real organs put alternate notes on the left and the right. Each source is where its pipes are drawn.
- The direct sound from each source goes through the head-related transfer function (HRTF) of the browser.1213 The HRTF is a set of filters, measured on human heads. It puts a sound to the left, the right, above or behind.
- The echo for each part of the organ comes from the traced two-ear response for that part.
- The listener is the camera. When the camera moves or turns, the direct sound moves around your head. Its level decreases with distance, in proportion to 1 / distance. The traced echo uses the same rule. Thus the direct sound and the echo keep the correct balance.
08Songs into organ music
The MIDI file of a pop song is for a band: drums, bass, guitars, pads and a vocal line. An organist does not play each track on each stop. Our arranger does the work of an organist.
- Roles. Each track becomes the tune, the harmony or the bass. The arranger does not play the drums. But it uses them to find the sections of the song.
- Divisions. The tune goes on the Great. The harmony goes on the Swell. The Swell pipes stand in a box with shutters. Thus the harmony is quieter than the tune, and it follows the volume changes in the song. The bass goes on the pedals. The arranger moves the bass line as one unit. The 16′ and 32′ stops start at the chorus.
- The section. The first 40 seconds of a song are often a slow introduction. Thus the arranger finds the chorus. It looks for the block of music that repeats most.
- The echo. Very fast repeated notes become unclear in an echo of eight seconds. Thus the arranger removes some of them. The full song plays at 82% speed, as an organist in a cathedral plays more slowly.
We check each arrangement with numbers before a person listens to it. We measure how many of the original notes it keeps. For the pop songs, this is 72–78%. Before, it was 18–61%. We also measure if each pitch class and the bass line stay, and how loud each part is in a render without echo.
The arranger finds the organ works of Bach and plays them as written. Some of the Bach MIDI files come from the Mutopia Project.14 The song search uses BitMidi.15
09What is not done yet
- No reed stops. Trumpets and tubas work differently: a brass tongue vibrates. They are the best stops to play a pop tune.
- No comparison with the real York organ. The stop names come from York. The pipe scales and wind pressures are general values. A recording of the real organ that plays the same notes can show the difference.
- No blind listening test. Listeners have not compared our echo with the recorded echo without knowing which is which.
- Phones. The app operates on recent iPhones. The full-organ Bach needs much processing power. When the side switch is on silent, Safari plays no sound.
Now hear it
The app builds the pipe, the organ and the echo in front of you. Then you can play songs, or play the organ yourself.
10Sources
- Julius O. Smith III, Physical Audio Signal Processing, CCRMA, Stanford University. Digital waveguides, including wind instruments.
- Digital waveguide synthesis, Wikipedia. An overview of the method.
- Organ pipe, Wikipedia. Flue pipes, their parts, and pipe length and pitch.
- National Pipe Organ Register, Survey D04217: York Minster. The stoplist our ranks are named from (1995 survey; the organ has since been restored).
- York Minster, Wikipedia, and the sources noted in our code (
engine/minster.js) for the dimensions. - ISO, ISO 9613-1:1993, Calculation of the absorption of sound by the atmosphere.
- M. R. Schroeder, New Method of Measuring Reverberation Time, Journal of the Acoustical Society of America 37, 409–412 (1965).
- ISO, ISO 3382-1:2009, Measurement of room acoustic parameters, part 1: performance spaces.
- OpenAIR, Audiolab, University of York, York Minster impulse responses (Damian T. Murphy). CC BY 4.0.
- OpenAIR, Audiolab, University of York, St Paul's Cathedral impulse responses, eight positions. CC BY 4.0.
- A. Foteinou, F. Stevens and D. T. Murphy, Revisiting the Acoustics of St Paul's Cathedral, London, Acoustics 7(3), 49 (2025). The 2022 measurements and the cathedral's dimensions. See also T. H. Lewers and J. S. Anderson, Some acoustical properties of St Paul's Cathedral, London, Journal of Sound and Vibration 92 (1984).
- Head-related transfer function, Wikipedia.
- MDN, PannerNode, the Web Audio API's HRTF spatialiser.
- The Mutopia Project, free sheet music and MIDI, including Bach organ works.
- BitMidi, a MIDI file library with an open search.
The line drawings use three.js. All of our own code, and every number on this page, is in the source on GitHub.