Modeling Mersenne's Clavichord
Mason Malone / June 20, 2026 / view source
Introduction
I recently took part in a CAD contest hosted by Zoo, a very interesting CAD program intended for hardware design. My submission, Mersenne’s Clavichord, won first place. It’s a reconstruction of a 17th-century clavichord described by Marin Mersenne. This post will describe my experiences with Zoo and how I approached the model.
If you want to hear what this would sound like, check out the excellent album Mersenne’s Clavichord: Keyboard Music in 16th & 17th Century France, which was performed on a reconstruction of this same instrument built by Peter Bavington.
Mersenne’s Clavichord (Spotify link)
Background and History
What’s a Clavichord?
The clavichord is a keyboard instrument that was invented at some point before 1404, and flourished for centuries in Europe.1 It was a highly expressive instrument, but too quiet for concert use, and gradually faded away with the rise of the piano.2 Despite its weak sound, it was the preferred instrument for many composers, notably C.P.E. Bach, who considered it superior to the piano in many respects.3
I’ve been listening to classical music for over 20 years, but I was only vaguely aware of the clavichord until last year, when I randomly stumbled on the album Clavichord Recital by Gustav Leonhardt. I immediately fell in love with that album, but I began to wonder: why is this my first time hearing a clavichord? I had heard Bach played on the piano countless times, yet never the clavichord, despite it being the instrument on which he likely wrote many of his keyboard works.
At first, I thought the answer was that the piano was simply a superior instrument, so there was no reason to perform Bach on the clavichord anymore. But then in Leonhardt’s performance of the Sonata in B Minor, I heard what sounded like vibrato. “Surely that’s a recording error”, I thought, “everyone knows you can’t do vibrato on a keyboard instrument.” But I was wrong: unlike virtually every other keyboard instrument, you absolutely can perform vibrato on a clavichord, and it’s a consequence of how the action works.
Clavichord Action
A clavichord action is a simple class 1 lever, where one end of each key has a piece of metal called a “tangent”. When the other end of the key is pressed, the tangent rises and strikes the string. The distance between where the tangent strikes the string and the bridge is called the “sounding length” for that string.
By rocking the key slightly, the player can alter the tension of the string for the duration of the note, which changes the pitch. This is a form of vibrato unique to the clavichord, and is sometimes called “bebung”.4
Why Model a Clavichord?
Even though there are still instrument makers keeping the art of clavichord building alive, many aspects of their construction have been lost to time. Several modern clavichord builders, such as Peter Bavington and Pierre Verbeek, have done extensive work to rediscover these lost techniques.
Verbeek is an engineer and physicist who turned to clavichord construction in 2004. In 2011, he published a paper titled “The Urbino Clavichord Revisited”, in which he reverse-engineered how a 15th-century clavichord was built by analyzing an intarsia depicting it.
Verbeek’s paper fascinated me, partly because it treated clavichord reconstruction as a puzzle to be solved, and partly from his creative use of math and physics. Unlike every other paper I’ve read, Verbeek included a plethora of measurements and technical drawings. Still, even with all these details, I had trouble visualizing certain aspects of the instrument. It’s very difficult to accurately describe something as complex as a clavichord using only prose and technical drawings.
These days, engineers have largely migrated from technical drawings to CAD software. CAD software has many advantages for describing the kind of objects engineers typically work with:
- Accuracy. CAD models can express measurements to an arbitrary level of precision.
- Easy modification. The clavichord action diagram shown above is a simplified version of the one shown below.
- Error checking. Most CAD software lets you express the different parts of an object in terms of constraints and equations, which it will check for you automatically.
- Visualization. Nearly all CAD programs let you quickly render a 3D model, which allows quick verification.
Although clavichords are clearly not the kind of objects engineers typically work with, all these advantages are just as applicable to the work of people like Verbeek and Bavington.
I couldn’t find any published CAD models of a clavichord, so I took it upon myself to turn Verbeek’s paper into a model using OpenSCAD. After several weekends of work, I ended up with this:
OpenSCAD and Zoo
As much as I love OpenSCAD, I hesitate to recommend it to non-programmers, which is probably >90% of musicologists. OpenSCAD is designed for programmers: all geometry is expressed using a domain-specific language (DSL), and the editor provides little help in translating your ideas into code. Although the learning curve isn’t as steep as some other CAD programs, it’s still considerable for someone without a programming background.
Like OpenSCAD, Zoo is also code-based, but it includes several features to make it more accessible to non-programmers. The editor is far more intuitive and interactive, allowing point-and-click editing that automatically generates the appropriate code. More interestingly, it integrates with an LLM called Zookeeper, which can take plain English prose and translate it directly to KCL, their DSL.
Who is Mersenne?
For the contest, the clavichord I decided to model was described by the French polymath Marin Mersenne in his 1636 treatise Harmonie universelle.
Mersenne’s drawing of the clavichord
If you’re a programmer like me, you’ve probably heard of “Mersenne primes”: prime numbers of the form . Mersenne primes were one of Mersenne’s many contributions to math, but the application of math to music was what interested him the most.5 Mersenne sought to establish a science of music, and his work helped lay the foundations of modern acoustics.6
Modeling the Clavichord
First Attempt
To start, I tried feeding Zookeeper the drawing shown above, along with Mersenne’s description in the original French. The result was incoherent:
But expecting Zookeeper to generate a plausible instrument from Mersenne’s sparse and ambiguous description is unreasonable, because until recently, no human could either. Some scholars even questioned whether Mersenne was describing an actual instrument, or simply something he imagined.7 A better question would be “why didn’t Mersenne use Zoo?”, since all the ambiguities and inconsistencies would have been obvious had he tried to create a CAD model.
It wasn’t until Peter Bavington built a reconstruction in 2011, 375 years after Harmonie universelle, that it was clear the instrument Mersenne described was almost certainly real. Bavington explained his reconstruction in his excellent paper Reconstructing Mersenne’s Clavichord, which formed the basis of my attempts moving forward. Without Bavington’s work, this model wouldn’t have been possible.
Case
I decided to break up the model into discrete components and model each separately, starting with the case. Bavington provided exact dimensions on the case in Paris inches, which I converted to millimeters and put into a params.kcl file.
Then, I asked Zookeeper to generate the code for the five wooden boards that make up the case. The result it gave me was a good start, but needed manual editing.
Zookeeper tends to avoid code reuse, so to make edits easier, I created a cube() helper inspired by OpenSCAD and refactored the case to use that for 4 out of the 5 boards.
Toolbox and Right Compartment
The left side of the clavichord has a rectangular toolbox, which was typically used to hold spare parts and tools. Bavington’s reconstruction had a lid on the toolbox with a knob to open it, which I reproduced here. I didn’t know the appropriate terminology for the ornamentation around the lid, so I told Zookeeper to create a “stepped terrace” effect, with three steps leading to the base. Zookeeper handled that well.
I was also unsure of the terminology for the compartment to the right of the toolbox, so I called it the “right compartment”. It shares the same ornamentation as the toolbox, but without a knob.
Soundbox
The soundbox consists of the soundboard, the wrestplank, and the belly rail. The wrestplank holds tuning pins for all 70 strings, the soundboard acts as a diaphragm to transform vibrations into acoustic energy, and the belly rail supports the soundboard, with 7 openings.
These were straightforward to model, as each part can be modeled using the cube() function described earlier. The openings in the belly rail were achieved by using the subtract() function to cut out 7 holes using cubes generated via patternLinear3d().
Keyboard
The clavichord has 49 keys, ranging from to , with a standard 12-note octave. The number of octaves is therefore , the number of natural keys is , and the number of accidental keys is .
To find the coordinate of a natural key at index , we can simply multiply the index by the width of each natural key, which we can calculate by dividing the keywell length by the number of keys, and adding that to an offset . Here’s the resulting KCL code:
fn naturalKeyX(@naturalIdx) {
return keyStartX + naturalIdx * keywellLength / numNaturalKeys
}
To find the coordinate of an accidental at index , we can reuse if we can find the index of an adjacent natural key. Since each octave is the same, all we need to do is solve this for the first octave, since we can extrapolate to the others using modular arithmetic.
Let’s number each natural and accidental key for the first octave so we can determine how to map between the two:
When , then the adjacent natural key to the left has the same index. When , then the closest natural key has the index . Translating this to KCL is straightforward:
adjNaturalIdxFirstOctave = [0, 1, 3, 4, 5]
fn accidentalAdjNaturalIdx(@accidentalIdx) {
octaveIdx = floor(accidentalIdx / 5)
accidentalIdxInOctave = accidentalIdx % 5
return octaveIdx * 7 + adjNaturalIdxFirstOctave[accidentalIdxInOctave]
}
fn accidentalKeyX(@accidentalIdx) {
baseNaturalIdx = accidentalAdjNaturalIdx(accidentalIdx)
return naturalKeyX(baseNaturalIdx + 1) - (accidentalKeyWidth / 2)
}
Now that we can calculate the coordinate of each key, we can model them using the cube() function and position them using translate().
Initially, I used the map() function to transform an array of key indices to cubes, but I rewrote it to use patternTransform() for performance.
Strings and Bridges
Strings
The clavichord has 70 strings in groups of two. Each group is called a “course”, and each tangent strikes a single course. But wait, how can there be 49 keys and only 35 courses?
The answer is that this clavichord is fretted, which means multiple tangents share a single course. Most early clavichords were fretted, since they were easier to build and maintain. An obvious disadvantage of fretted clavichords is you can’t play multiple keys that share a course at the same time, which instrument makers tried to mitigate by fretting keys that aren’t typically played together.
Mersenne’s description of which keys were fretted is highly ambiguous. I used Bavington’s interpretation:8
If we take account of the fact that notes 41 [e2] and 46 [a2] are not included, the most likely meaning is that the top octave is fretted as follows:
c2–c#2 / d2–e♭2 / e2 (alone) / f2–f#2 / g2–g#2 / a2 (alone) / b♭2–b2–c3 (three together).…
Both Boxall and Brauchli propose that the fretting continued downwards with the same pattern until the 18th course (f–f#), in which case the number of notes and courses matches very nicely; this seemed the most likely solution, and I planned the reconstruction accordingly.
Zookeeper translated that description into this KCL function, which is perhaps a bit overcomplicated, but perfectly functional.
The strings themselves are simple cylinders with a diameter of 0.7mm, and I created a OpenSCAD-inspired cylinder() function to facilitate this.
Bridges
To support the strings, the clavichord has five bridges, which transfer vibrations to the soundboard. Thankfully, Mersenne’s description of the bridges is much clearer (translation courtesy of Bavington):
As for the bridges, the first carries six courses of strings, that is 12 [strings]. The second has 9 courses or 18, of which the first 8 are doubled and twisted together, so that there are 20 paired strings. The third bridge supports 8 courses, that is 16 [strings]. The fourth contains three courses or 6 strings, and the fifth has 9 courses: but one can make a single bridge instead of these five.
Again, Zookeeper quickly translated this into a KCL function.
While Zookeeper had no trouble with these kinds of mathematical exercises, it did struggle slightly with the shape of the bridges, particularly with respect to the sloping edges. The result I ended up with seems fairly close to Bavington’s reproduction. Not having built a clavichord myself, I’m unsure how important the shape of the bridges really is, but I hope to find out soon!
Key Levers
This is where it gets slightly tricky. The key levers attach to the corresponding key and support a tangent at the far end, which must be positioned such that when the tangent rises, it strikes the string to create the appropriate sounding length for the key. But how do we determine the sounding lengths for each key? Unlike Verbeek’s paper, Bavington didn’t include precise measurements for the sounding lengths. That means we need to calculate them ourselves.
Mersenne’s Laws
Thankfully, Mersenne gave us the tools to do this! The sounding length is related to the fundamental frequency, the tension of the string, and the mass per unit length of the string. Mersenne was the first to discover and prove the mathematical relationship between these variables, which is now known as Mersenne’s laws. The usual form of this relationship is given as:
where is the fundamental frequency, is the sounding length, is the force, and is the mass per unit length.
In The Science of Music, Mark Newman gives a more convenient form of this equation, assuming the strings are cylinders with constant density:
where is the string diameter, is the tension, and is the density. This is the version we’ll use.
Calculating the Frequency
The frequency for each key is determined by the temperament of the clavichord. In Mersenne’s day, the most common temperament was meantone temperament.9 Mersenne was an early advocate of equal temperament, which is the most common temperament used today.10 Mersenne proposed the following as the ratio of an equally-tempered semitone:11
The model includes both temperaments. For equal temperament, the following KCL code calculates the frequency for the key at index :
referencePitchA1 = 392
referenceA1KeyIdx = 33
equalTemperedSemitoneInterval = (2 / (3 - (2 ^ (1 / 2)))) ^ (1 / 4)
fn equalTemperedFrequencyForKey(@keyIdx) {
return referencePitchA1 * equalTemperedSemitoneInterval ^ (keyIdx - referenceA1KeyIdx)
}
The code for meantone is more complex, and I’m not fully confident it’s correct.
With the frequency out of the way, that leaves the string density and tension as the two remaining variables in Mersenne’s equation. If this were an unfretted clavichord, we could treat the tension as almost a free variable, since you can tune each key independently.
That’s not the case with a fretted clavichord. Changing the tension on a string affects all the keys that share that string. Sometimes you can work around that by bending the tangents sideways to alter the sounding length, but that quickly ruins the key levers.12 To change the temperament on a fretted clavichord without damaging it, you typically need to reposition the tangents, and the key levers supporting them.
Solving for the Sounding Length
We know that for fretted keys, we must keep the tension and density of the string constant for every key sharing that string, so let’s solve for that. Let be the fundamental frequency for the key at index :
Now, let’s calculate the frequency for an adjacent fretted key at index :
We can now easily solve for the sounding length of the key at index :
Solving for the Tangent Position
Once we have the sounding length, we need to use that to determine the position of the tangents. The coordinate of the tangent is related to the sounding length and the coordinate of the bridge:
Substituting the equation for above, we end up with:
This is the final equation implemented by the tangentXForKeyFn() function in string_utils.kcl.
fn tangentXForKeyFn(@keyIdx) {
return if keyIdx == 0 {
// Low C has fixed position relative to the toolbox
toolboxLength + 10mm
} else if courseIdxForKey(keyIdx) == courseIdxForKey(keyIdx - 1) {
// Fretted key. Calculate the sounding length using Mersenne's laws.
bridgeXForKey(keyIdx) - (
frequencyForKey(keyIdx - 1) * (
(bridgeXForKey(keyIdx - 1) - tangentXForKeyFn(keyIdx - 1))
/ frequencyForKey(keyIdx)
)
)
} else {
// Unfretted key. Just use fixed spacing from the previous tangent.
tangentXForKeyFn(keyIdx - 1) + tangentSpacing()
}
}
Putting all this together, we get the following.
All the Rest
With the most interesting components done, that leaves the balance bar, the balance pins, the frontboard, the rack, the slots, and the back rail. I won’t go into detail into each of these, except to add that the rack was the biggest challenge due to how it’s angled. The Urbino clavichord (and nearly all other clavichords I’ve seen) has a straight rack, which is much easier to model.
What’s Missing?
There’s still a lot missing here, notably:
- The left-hand bridge
- The two oblique compartments in the rear corners
- The lid
- A sloping soundboard. The soundboard on this model is flat, which Bavington says won’t work:
This is unavoidable, given the low treble bridge and the long distance between it and the tuning pins, and the fact that the strings run directly across the bridge without any bridge-pins or side-bearing.
Those are just the things I know. I haven’t built this (or any) clavichord before, so it’s likely there’s a lot more I don’t know about. If you notice anything, please contact me!
Conclusion
Overall, I was impressed with what Zoo and Zookeeper can do. As a layman in machine learning, I had assumed that the symbol grounding problem would be a nearly insurmountable barrier to the use of LLMs in CAD work, but Zookeeper has proven me wrong. Even though modeling historical instruments is clearly outside Zoo’s intended use case, I can see it being a very useful tool for musicologists.
My goal now is to build this instrument in real life. The prize for the contest was a Bambu Lab H2C, which I donated to Seattle Makers in exchange for help with this.
But this is a relatively large and complex instrument, so I’m going to start with simpler ones first to get experience. I’m currently working on a model of a keyed monochord based on a 15th-century design, which has the same action as a clavichord. My tentative plan is to use a laser cutter for the keyboard and key levers, which I anticipate will be the trickiest part.
-
Until I edited it, the Wikipedia article on the clavichord claimed it was invented in the early 14th century. I read both sources it cited, and neither substantiates that claim. Both state that the first unambiguous evidence was in the early 15th century. It’s probable it was invented earlier, but exact dating is difficult because literary sources of that time used the terms “clavichord” and “monochord” interchangeably. ↩︎
-
Brauchli, Bernard. The Clavichord. (Cambridge University Press, 1998), 1. ↩︎
-
Ibid., 216-217. ↩︎
-
Ibid., 267. ↩︎
-
Antoni Malet and Daniele Cozzoli, “Mersenne and Mixed Mathematics,” Perspectives on Science 18, no. 1 (2010): 1-8, https://muse.jhu.edu/article/372574. ↩︎
-
Zanzarella, Ivano, “The Growth of Modern Acoustics,” (2020), 18. ↩︎
-
Ripin, Edwin M., Early keyboard instruments, (WW Norton & Company, 1989), 155. ↩︎
-
Bavington, Peter, “Reconstructing Mersenne’s Clavichord,” De Clavicordio X (2012), 12-13. ↩︎
-
Rasch, Rudolf, “Tuning and temperament,” The Cambridge History of Western Music Theory (2006), Kobo ↩︎
-
Barbour, James Murray, Tuning and temperament: A historical survey, (Courier Corporation, 2004), 98. ↩︎
-
I got this claim from Mersenne’s Wikipedia article, but it doesn’t cite its sources, and I’m having trouble locating one. The closest I’ve found is Rasch’s “Tuning and Temperament”, which gives Mersenne’s string length tables, but not the closed-form equation. ↩︎
-
Brauchli, The Clavichord, 102. ↩︎