Modeling a Panfulte

I'm working in OpenSCAD to draw up a 3D model of a pan flute that I could print out using a 3D printer and (with any luck!) play right there on the spot. I've looked up some of the formulas for determining the pitch of a open ended tube but I have some questions...

Wikipedia says that the formula for calculating the length L of a pipe with a frequency F is
L = (S/F) / 4
where S is the speed of sound.

It goes on to say:
"Because of a property of compression within the tube, the length must be a little shorter to correct flat pitch"
and also that:
"If you are a "perfectionist", multiply the bore diameter by 0.82 and subtract this value from the tube length. This compensates for internal compression slowing frequency and the lips partially covering the voicing."

I'm wondering where this 0.82 comes from, and across which values it will be relevant. Is that 0.82 going to give the 100% correct compensation for exactly one length? Or maybe one length-to-diameter ratio? If that's the case I could increase the diameter of the longer tubes, keeping the length to diameter ratio constant, and if not, I can keep the diameter constant for all pipes.

I don't understand what the wiki page means by "internal compression". That sounds like nonsense. FWIW this is also an issue in tuning pipe organs, and in the early 20th century reputable organ-builders were writing books stating that the speed of sound was faster in a narrow bore pipe than a wide bore one, which doesn't make any sense - but these bits of mythology linger on.

The formula L = (S/F) / 4 makes the assumption that the pressure at the open end of the tube is always exactly atmospheric. That is only an approximation, because the air outside the end of the tube also vibrates as well as the air inside. (If the air outside did not vibrate, you wouldn't hear any sound from the instrument).

For a reasonably "thin" pipe, you can get a better approximation to the pitch by taking the effective length of the pipe as slightly longer than the physical pipe, to account for the vibration of the air outside. For a cylindrical pipe a long distance from anything that interferes with the air flow, the correction factor for the length is about 0.3 times the diameter.

The airflow at the end of the pan pipes will be affected by the the player's face blocking part of the air flow and the player blowing across the end of the pipe, so presumably 0.82 times the diameter is a better correction factor than 0.3 for this situation.

I agree that the "internal compression" sounds like a bit of pfooey (the mean pressure has to be AP or air would flow in or out, to balance it, I think. Speed of sound in the tube must be the important factor, as you say.

The nebulous 'end effect' is always relevant. You cannot be sure where the tube actually ends . Starting from scratch - a fresh material, thickness and bore - the only way to get it really right is to fine tune the pipe with the end plug.

To get a set of pipes with perfect pitch, without a prelim experiment, would be asking too much, I think. Best to produce a prototype pipe (actually a selection of lengths) and to determine the speed and 'end effect' experimentally (i.e. the pitch you get). You can feed that back into the design formula and, even after just one iteration, you should get quite close.

You can find more information on the mouth/end correction here and in any good textbook on acoustics.
A pan flute is blown/excited at the open end. This might complicate matters a little.
As sophiecentaur said, pan pipes are tuned by moving a stop at the closed end until you have the exact pitch.

Thanks so much for all the replies everyone. It seems I'm definitely going to have to run a few prototype pipes to be able to get accurate pitch results, and that's fine. I'll look into the reading you all have provided and go from there.

I do have one more question, however. Depending on the diameter of the pipe compared to the length, you either get a "woodier" or "flutier" sound. Because most pan flutes are restricted to using the same width for all pipes (because, for instance, they are all made from the same bamboo), the timbre is forced to change throughout the range of the instrument.

I really like the idea of varying the diameter to keep the diameter/length ratio constant, and therefor keeping the timbre constant across the range of the instrument. My question is, would doing this make finding an approximation for end correction and mouth interference easier, harder, or would it have no effect?

Most musical instuments do not have constant timbre (in the mathematical sense of equal ratios of harmonics to fundamental) over their tonal range. (Well, very cheap electronic organs used to ... ).
A popular model for scaling organ pipes is to half the diameter every 17th pipe; see here (semitones/chromatic, of course. Your panflute is probably diatonic).
You´ll have to find a scaling formula that reflects your tonal ideal and practical considerations. (What is the largest and smallest diameter that can be comfortably and reliably blown?)
There is an alternative method of tuning panflutes: You pour molten wax into the pipes until they have the desired pitch. (Will only make the pitch sharper, of course)
And dont bother with extreme precision in determing end correction, use the standard approximation. I suppose you will get reasonable intonation based on this (and one or two testpipes to check); If you need better, you´ll have to fine tune individually. (Even your blowing style can change pitch!)
I don´t think anybody has worked out a satisfactory theory theory of mouth/lip influence on pan pipe tuning.

On the topic of timbre, I don't think it should be necessary to aim at constancy over the whole range. If panpipes sound the way they do then shouldn't you be aiming at a 'warts and all' model and make it sound the same?

When people started working on electronic music synthesis, they soon found that generating instrument sounds which were based just on scaled versions of one sampled note produced a really artificial sound. Quality differences as you move around the scale are the essence of an instrument.

I think your pipes would sound more convincing if you followed the same crude rules as the original design.

If you´ve followed the links in wikipedia, you´ve found a few "How to build a panflute" articles here. This one has a table with diameters, so you can get an idea of whats usual.
If you play solo, absolute pitch is not critical. If not, you´ll have to look for partners with tunable instruments (guitars, strings, good electronic pianos/organs) or you´ll have to fine tune. If you design enough material at the bottom of your pipes, you can scrape out some of it to get the pitch flatter.

That having been said - do you want a pan pipe or a new kind of instrument? It is the crudeness of a pan pipe that makes it so attractive. If you want a wind instrument that sounds classy, then you play a flute. If you want a drum, then you don't use stomps.

The whole project is quite interesting enough (I really like it) without trying to gild a lilly. Doesn't this thing need to sound indistinguishable from a real one, when they're both played behind a curtain?

That having been said - do you want a pan pipe or a new kind of instrument?

Doesn't this thing need to sound indistinguishable from a real one, when they're both played behind a curtain?

These questions bring a smile to my face because I'm going to be making it it microtonal ;)
I plan on using different historical tunings, as well as a more modern method for scale derivation called regular temperament. (If you know anything about it, I'm going to be focusing on the Hanson Temperament.) So do I want someone to be able to tell it's microtonal? Well, not in a bad way...

So over all? It's going to be a new instrument that draws from the simplicity of the pan flute to create a slightly more complex looking (but still easy to play) microtonal instrument. The effect that these concepts have on the design are that I am completely open to breaking some standard pan flute boundaries, even just for experiment's sake.

I did not realize that. I´m bit skeptical about the musical aspects, but you´re welcome.

Let me just point out a things I´ve learned about panflutes or haven´t said clearly enough.
(l: length; d: diameter)
- The correction of .82d is partly empirical in that it covers acoustic end correction and "normal" lip influence. (source: wikipedia)
- (The acoustical part is somewhere about .6d, IIRC. It applies to a free panpipe. See my link above)
- Resonance of a blown panpipe is not exactly the same frequency as resonance of a "free" pipe. (The difference does not matter much, really)
- (Your original question) l/d doesn´t matter in computing end correction if l >> d, so you´d better stay with, say, l > 5d.
- A more mathematical scaling rule (reported as observation of existing instruments in Fletcher/Rossing, The physics of musical instruments) is l ~ d2. (Solve for d, of course).

Why am I skeptical?
Good panflutists can play chromatic/all scales on a diatonic panflute by changing angle and lip covering. This also means that they are constantly checking and correcting intonation.
A microtonal panflute might appear as "cheating" compared to learning to play microtonal on a normal panflute.
Yes, there will be a problem with going "microtonal sharp". You might experiment with a small hole in the side of the pipe, a bit below the mouth. Normally covered with a finger and opened for going sharp. (Size and position will have effect on pitch, so the holes can all be the same position but different diameter, but don´t ask me to calculate this. Look at a few woodwinds to find a starting point for experiments).
And I fear it will be very difficult to play with more pipes than the traditional approach. That will partly depend on the kind of music you intend to play.

I wish you success and pleasure in designing, building and playing your novel instrument.