## Tuesday, August 12, 2008

### Whitney's pendulum waveform generator

In my August 8 post on the John Whitney Music Box, I mentioned a opto-mechanical device that Whitney used in the 1930s to generate waveforms which were imprinted on the optical soundtrack of some of his early experimental films. It is described, in the sources I've found, as consisting of 20 pendulums (presumably all swinging at different rates) connected in some fashion to an aperture or series of apertures which controlled light passing through to expose the film sound track. I mentioned in the post that I wanted to write a simulation of this, if I could figure out how it worked.

So my guess for the construction of the mechanism is something like this:

20 pendulums in a column file, front to back, with a light path running through them. Each pendulum has a shutter attached to its arm that blocks half of the path with the pendulum at rest; at one extreme the path is full open, and at the other the path is fully blocked. In an idealized form, one can see that the amount of light allowed through by any one pendulum is described by a sine wave (or more specifically, a cosine wave, assuming that all of the pendulums are started by being released from the full-open end of the swing). The light source is placed at one end of the file, and the camera which records the optical soundtrack at the other end. The pendulums all have different effective lengths, and will swing at different rates when released.

One big decision that I had to think about was the light source. Was it a simple light bulb, acting as a point source, or was it a focused beam? Not being able to decide, I resolved to try it both ways. With the setup I described above, it makes a considerable difference. Consider: A point source of light (this is true for sound too) can be visualized as a bunch of rays shooting out in all directions from the source. No two of the rays are parallel; there is always an angle (no matter how slight) between any two, and as you move further away from the source, the rays will spread further apart. If you place any solid obstacle with a cutout opening in front of the point souce, the rays that pass through the opening it will continue to spread out, and so at a sufficient distance, the opening will in turn look like a point source, just weaker. Another obstacle with an opening placed in front of that will, in turn, look like a still weaker point source. This is true even if the obstacles aren't all in a perfect line; some light will still get through. And the effect is enhanced if the light is contained by a reflective tube in between the obstacles.

A beam source behaves differently. In a focused beam, all of the rays (in theory) are parallel; there is no spreading. An obstacle placed in the beam, with an opening that is outside of the beam, will admit no light through. An obstacle with an opening that is in the beam will let some portion of the light through, in a shape that is described by the intersection of the shape of the beam and the shape of the obstacle. If a subsequent obstacle blocks out this part of the beam, then no light will get through at all even though the second obstacle might have an opening elsewhere. Only the light rays that have a straight path through all of the openings can pass. If no such path exists, no light gets through. (Ignoring edge diffraction effects.)

I decided to simulate the second case first. In doing so, in order to simply the math, I made one further assumption: that all of the pendulums had their shutters on the same side, and in the same shape. That is, there would be no case where one pendulum was blocking the left half of the beam and the other pendulum was blocking the right half; a "less closed" shutter would always pass all of the light admitted by any preceding "more closed" shutter. Doing so made the computation of the amount of light passed by all of the pendulums easy; it is simply the least amount of light passed by any individual pendulum, or:

min(pendulum1, pendulum2,pendulum3,...)

I simulated the motion of all of the pendulums as simple sine waves, ignoring nasty real-world unpleasantries such as friction, diffraction, unintentional coupling, etc. I ignored the bit about running all of the pendulums at subsonic rates and speeding them up; I reasoned that in the digital domain, that would have exactly the same result as running the pendulums at higher rates to begin with, so why bother? Instead, I just ran them at audio rates (or nearly) to start with. I figure that the difference in speeds between the slowest and fastest pendulums could not have been huge; probably the slowest pendulum would have cycled once per 5 seconds, and the fastest one at 3-4 Hz at most. And most likely the recording speed was no more than 1:20 of the playback speed; much slower and they would have run into problems with getting a reasonably linear exposure on the film (what the photographers call "reciprocity failure").

I wrote up the sim in Csound and ran it with six different sets of parameters for the pendulum rates. The audio result is here (it is an uncompressed AIFF file, 16-bit, 44.1, mono). There are six different sound samples in the file, each five seconds long, with a short amount of silence in between. The parameters for each sample are:

1. Slowest pendulum at 10 Hz, with each additional one 10 Hz higher (20 Hz, 30 Hz, etc.).
2. Slowest pendulum at 20 Hz, with each additional one 20 Hz higher.
3. Slowest pendulum at 50 Hz, with each additional one 50 Hz higher.
4. Slowest pendulum at 1 Hz, with each additional one 13 Hz higher.
5. Slowest pendulum at 8 Hz, with each additional one 5 Hz higher.
6. Slowest pendulum at 200 Hz, with each additional one 6.33 Hz higher.
I had suspected that the output would consist largely of short spikes with a large DC component, due to the fact that at any given time, there is a high probability of at least one aperture being completely closed. This turned out to be the case, and I made no attempt to filter out the DC offset in the simulation. (Most computer sound cards will filter it out in the analog domain.) Samples 1, 4, 5, and 6 produced the most interesting results. Below are some graphs of the waveforms. (Not that they are not all to the same scale.)

Sample 1:

Sample 4 (note the long-period amplitude variation):

Sample 5 (note the mirror-image symmetry of all of the pairs of spikes):

Sample 6 (again, note the mirror-image symmetry):

(I was mildly amused to note, when I imported the files, that all of the waveforms are inverted. I don't know if Csound generated them that way, or if they got that way somehow in the process of importing them into Metro so I could look at the graphs.)

For the second run, I change the simulation from a beam-source light to a point source. In this simulation, each pendulum shutter cuts off a certain percentage of the light, the next one cuts off a percentage of the light that passed through the first one, and so on. If all of the percent-open values are expressed in the range 0-1, as they are in the sim, then the computation becomes:

pendulum1 * pendulum2 * pendulum3 * ...

It's interesting to note that the communativity of multiplication implies that the order of the pendulums does not matter. That seems counterintuitive somehow, yet the math demands that it must be the case. In any case, the results weren't nearly as interesting. I ran it with the same set of parameters as for the first run. Here is the audio file. Nearly all of them came out looking and sounding like the graph below, which is from sample 6:

I'm not sure why these seem so much "orderly" than the samples in the first run; I had halfway expected the opposite. Still interesting, but not quite as much as the first set. Either, though, would have been an absolutely startling thing to hear coming out of a movie projector in 1938! Keep in mind as you listen to these that only a handful of people in the world had been exposed to any kind of electronic music at this point in history.

I plan to do some more work on this. One thing I want to explore: adding friction to the pendulums, in some fashion, to make them "run down". Currently, the pendulums have perpetual motion; they cycle at the exact same amplitude indefinitely. Recall from your high school physics that a pendulum's period depends only on its center of mass; as it loses energy, the cycle rate remains the same, with only the amplitude -- how far it swings to the sides -- decreasing. Having them all run down together, at the same rate per unit of real time, probably wouldn't be very interesting; the overall amplitude would just decrease. However, real pendulums won't do that anway. They will run down according to the number of cycles they have made, or the (angular) distance they have traveled, which means that faster ones run down sooner than slower ones. I want to add that to the sim and see what I get.

I also want to play with some different shutter sizes and shapes. For example, the shutter could be constructed such that the light is totally blocked at the center and open at either end of the swing. Or, it could be cut such that the pattern of variation as the pendulum swings is something other than a sine wave.

Below is the source code for the Csound orchestra (the .orc file). Instrument 101 was used to produce the first run, and Instrument 102 was used to produce the second run. Watch out for line wrap.

`; Simulates pendulums with individual aperatures, beam light source; Assumes aperature is full open with pendulum at 0 deg, full close at 180 deginstr 101; Assign initial parametersifreq = p4 ; Base frequencyiinc = p5 ; Frequency incrementiscale = p6 ; Output scaling, 0-1; Table namesitsine = 1; Compute the phase for each of the pendulumsaph1 phasor ifreqaph2 phasor ifreq+iincaph3 phasor ifreq+(iinc*2)aph4 phasor ifreq+(iinc*3)aph5 phasor ifreq+(iinc*4)aph6 phasor ifreq+(iinc*5)aph7 phasor ifreq+(iinc*6)aph8 phasor ifreq+(iinc*7)aph9 phasor ifreq+(iinc*8)aph10 phasor ifreq+(iinc*9)aph11 phasor ifreq+(iinc*10)aph12 phasor ifreq+(iinc*11)aph13 phasor ifreq+(iinc*12)aph14 phasor ifreq+(iinc*13)aph15 phasor ifreq+(iinc*14)aph16 phasor ifreq+(iinc*15)aph17 phasor ifreq+(iinc*16)aph18 phasor ifreq+(iinc*17)aph19 phasor ifreq+(iinc*18)aph20 phasor ifreq+(iinc*19); Extract the waveform samplesasine1 tablei aph1, itsine, 1, 0, 1asine2 tablei aph2, itsine, 1, 0, 1asine3 tablei aph3, itsine, 1, 0, 1asine4 tablei aph4, itsine, 1, 0, 1asine5 tablei aph5, itsine, 1, 0, 1asine6 tablei aph6, itsine, 1, 0, 1asine7 tablei aph7, itsine, 1, 0, 1asine8 tablei aph8, itsine, 1, 0, 1asine9 tablei aph9, itsine, 1, 0, 1asine10 tablei aph10, itsine, 1, 0, 1asine11 tablei aph11, itsine, 1, 0, 1asine12 tablei aph12, itsine, 1, 0, 1asine13 tablei aph13, itsine, 1, 0, 1asine14 tablei aph14, itsine, 1, 0, 1asine15 tablei aph15, itsine, 1, 0, 1asine16 tablei aph16, itsine, 1, 0, 1asine17 tablei aph17, itsine, 1, 0, 1asine18 tablei aph18, itsine, 1, 0, 1asine19 tablei aph19, itsine, 1, 0, 1asine20 tablei aph20, itsine, 1, 0, 1; Do the min function on all the samplesaout min asine1, asine2, asine3, asine4, asine5, asine6, asine7, asine8, asine9, asine10, asine11, asine12, asine13, asine14, asine15, asine16, asine17, asine18, asine19, asine20; Outputaout = aout*iscale*20000out aout; display aout, .01endin`

`; Same as above except the light source is a point source.; Assumes aperature is full open with pendulum at 0 deg, full close at 180 deginstr 102; Assign initial parametersifreq = p4 ; Base frequencyiinc = p5 ; Frequency incrementiscale = p6 ; Output scaling, 0-1; Table namesitsine = 1; Compute the phase for each of the pendulumsaph1 phasor ifreqaph2 phasor ifreq+iincaph3 phasor ifreq+(iinc*2)aph4 phasor ifreq+(iinc*3)aph5 phasor ifreq+(iinc*4)aph6 phasor ifreq+(iinc*5)aph7 phasor ifreq+(iinc*6)aph8 phasor ifreq+(iinc*7)aph9 phasor ifreq+(iinc*8)aph10 phasor ifreq+(iinc*9)aph11 phasor ifreq+(iinc*10)aph12 phasor ifreq+(iinc*11)aph13 phasor ifreq+(iinc*12)aph14 phasor ifreq+(iinc*13)aph15 phasor ifreq+(iinc*14)aph16 phasor ifreq+(iinc*15)aph17 phasor ifreq+(iinc*16)aph18 phasor ifreq+(iinc*17)aph19 phasor ifreq+(iinc*18)aph20 phasor ifreq+(iinc*19); Extract the waveform samplesasine1 tablei aph1, itsine, 1, 0, 1asine2 tablei aph2, itsine, 1, 0, 1asine3 tablei aph3, itsine, 1, 0, 1asine4 tablei aph4, itsine, 1, 0, 1asine5 tablei aph5, itsine, 1, 0, 1asine6 tablei aph6, itsine, 1, 0, 1asine7 tablei aph7, itsine, 1, 0, 1asine8 tablei aph8, itsine, 1, 0, 1asine9 tablei aph9, itsine, 1, 0, 1asine10 tablei aph10, itsine, 1, 0, 1asine11 tablei aph11, itsine, 1, 0, 1asine12 tablei aph12, itsine, 1, 0, 1asine13 tablei aph13, itsine, 1, 0, 1asine14 tablei aph14, itsine, 1, 0, 1asine15 tablei aph15, itsine, 1, 0, 1asine16 tablei aph16, itsine, 1, 0, 1asine17 tablei aph17, itsine, 1, 0, 1asine18 tablei aph18, itsine, 1, 0, 1asine19 tablei aph19, itsine, 1, 0, 1asine20 tablei aph20, itsine, 1, 0, 1; Do the min function on all the samplesaout = asine1*asine2*asine3*asine4*asine5*asine6*asine7*asine8*asine9*asine10*asine11*asine12*asine13*asine14*asine15*asine16*asine17*asine18*asine19*asine20; Outputaout = aout*iscale*20000out aoutdisplay aout, .01endin`

Below is the score file (the .sco file). It is set up for the second run; to change it to do the first run, change all of the instrument numbers from 102 to 101.

`; Function tables; Cosinef 1 0 16385 9 1 1 90; base incr ampl; inst start duration freq menti 102 0 5 10 10 1i 102 5.5 5 20 20 1i 102 11 5 50 50 0.8i 102 16.5 5 1 13 1i 102 22 5 8 5 1i 102 27.5 5 200 6.33 1`