← Play Robot Organ
Contents
  1. 01The pipe
  2. 02Voicing
  3. 03The organ
  4. 04The cathedral
  5. 05The echo
  6. 06How we check it
  7. 07Sound in space
  8. 08Songs into organ music
  9. 09What is not done yet
  10. 10Sources

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.

Play Robot Organ

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.

Figure 1. One of our pipes, drawn at its real speaking length. Drag the drawing to turn it. Change the length, the height of the mouth and the wind. Then play the pipe. The model calculates the note that the pipe makes.

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/s

Middle 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.

wind+ noise jet delaycut-up / speed lipsoft limit air columndelay = period reflection bends the jettoe sets pressure
Figure 2. The loop in each pipe. The wave that returns from the air column moves the jet. When the total delay of the loop agrees with a mode of the air column, the pipe makes that note.

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

The measurements after each adjustment

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.

Figure 3. Open Diapason D♯4, voiced in your browser when this page opened. The chart limits pitch error to ±150 cents. The first tries are an octave or more wrong. Press a step to hear it.

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.

Figure 4. All 830 pipes at their real speaking lengths, on a windchest. The front rank is at the front. The other manual ranks stand in rows behind it. The pedal ranks are towers at the two sides. Drag the drawing to turn it.

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.

Figure 5. York Minster as the acoustic model shows it, from above. A brighter cell is higher. The central tower is about 55 m high and the aisles 14 m. The pink marks show the source and the listener of the measured recording (section 6).

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.

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 s

Figure 6. A clap or a chord below the central tower, heard from the nave through the traced echo. Sixty traced sound paths cross the plan at the speed of sound, divided by twelve.

To 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:

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.

Measured in the buildingOur model
Figure 7. Echo time (T30) in six octave bands. "Before tuning" is the model from the plan and the material tables only. This is a true prediction. "After tuning" adds one correction factor for each band. The factors come from the same recording.

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.

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.

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.

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

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.

Play Robot Organ

10Sources

  1. Julius O. Smith III, Physical Audio Signal Processing, CCRMA, Stanford University. Digital waveguides, including wind instruments.
  2. Digital waveguide synthesis, Wikipedia. An overview of the method.
  3. Organ pipe, Wikipedia. Flue pipes, their parts, and pipe length and pitch.
  4. National Pipe Organ Register, Survey D04217: York Minster. The stoplist our ranks are named from (1995 survey; the organ has since been restored).
  5. York Minster, Wikipedia, and the sources noted in our code (engine/minster.js) for the dimensions.
  6. ISO, ISO 9613-1:1993, Calculation of the absorption of sound by the atmosphere.
  7. M. R. Schroeder, New Method of Measuring Reverberation Time, Journal of the Acoustical Society of America 37, 409–412 (1965).
  8. ISO, ISO 3382-1:2009, Measurement of room acoustic parameters, part 1: performance spaces.
  9. OpenAIR, Audiolab, University of York, York Minster impulse responses (Damian T. Murphy). CC BY 4.0.
  10. OpenAIR, Audiolab, University of York, St Paul's Cathedral impulse responses, eight positions. CC BY 4.0.
  11. 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).
  12. Head-related transfer function, Wikipedia.
  13. MDN, PannerNode, the Web Audio API's HRTF spatialiser.
  14. The Mutopia Project, free sheet music and MIDI, including Bach organ works.
  15. 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.