Virtual String Apparatus

Here you'll find binaries for a simulation of a vibrating string excited by an oscillator. You can vary the oscillator's frequency and amplitude, as well as the string's tension, decay time, and mass density.

Source code is available at github

Virtual String Apparatus

Bill Thibault and Bill Pezzaglia, California State University East Bay, 2013.

Overview

We have created a computer program that simulates a vibrating string, and allows the user to perform experiments similar to those performed with an actual vibrating string apparatus used in physics lab experiments. Our simulation is unique in several respects: it produces the sound due to the vibrating string, it has a high-quality 3d display, it runs on multiple platforms (Linux and Mac currently, Windows support in-progress), and it computes and displays the frequency spectrum of the sound. It allows for interactive control of the string parameters, which can be set to mimic the conditions seen by students in the real-world lab experiment.

The program will be used as a pre-lab exercise for students in one of the author's freshman physics lab sections in the Spring 2013 quarter, by making a download of the program available to students on Blackboard. We plan to survey students' attitudes on the usefulness of the simulator in helping students understand the physical properties of vibrating strings, primarily "resonance" phenomemon and its relation to frequency. We will develop an inquiry-based lab experiment around this and the related physics lab experiment.

We have a working version of the software, and are currently adding the finishing touches to the implementation. These include a graphical user interface with sliders and buttons, and an improved physics model in the underlying string simulation.

The project can be seen as addressing the CSUEB Institutional Learning Outcome for "critical thinking." Students are presented with phenomena in two settings (virtual and real) and can synthesize knowledge from them. They can also directly manipulate "assumptions" about the properties of the string, such as the string's density, and see how the change affects the behavior of the model in ways not possible in the physics lab. It can also address the "integration of ideas" ILO, especially for students that delve into the details of how the simulator works, e.g. computer science students.

Background

Our initial model is based on an algorithm from computer music for simulating vibrating strings [Cook]. This model represents the string as a series of connected point masses that are restricted to up-down motion, and connected via spring-like forces to the neighboring two masses. One end of the string is fixed, and the other end is moved up and down at a frequency the user can control. The tension in the string, and the speed of the vibration can be controlled. The nature of such vibrating physical objects is that at specific frequencies, the string will exhibit very large motions: this is the resonance phenomenon. Another property seen in nature, is that the frequencies at which the resonances occur are multiples of the "fundamental frequency". When one end of the string is vibrated at the string fundamental frequency, which depends on the tension and other properties of the string, the string will move back and forth, while the ends remain still. At twice the fundamental frequency, the string will move back and forth in two sections, with a stationary point at the center of the string. At three times the fundamental, there are 3 vibrating sections, etc.

This behavior mirrors the actual physics experiment, in which a computer-controlled vibrator is attached to one end of the string, and the other end loops over a pulley and ends in a holder on which masses of various sizes can be placed to adjust the string tension. In the physics lab, students vary the vibrator frequency and search for resonant frequencies by watching for a large string response. By asking students to find the resonant frequencies, it is hope they can be led to "discover" their relationship as "harmonic": whole number multiples of the fundamental frequency. This is the goal of the inquiry-based lab design we are developing.

The initial impetus comes from one author's use of string simulation as a problem in graduate computer science courses concerned with efficient use of computer hardware such as clusters of many networked computers, modern multicore CPUs, and graphics cards (GPUs): CS 6580 Distributed Systems and CS 6575 Parallel Programming. The current implementation does not yet exploit these advanced techniques, but students in the courses could be presented with the code and extend it to support them, in one scenario. This would likely improve student engagement, as the simulator provides the interactive control to make it more "fun."

The Simulator

Along with the simulated string, we make available (on github) source code for the basic string simulation, and a less-physically-correct but cheaper-to-compute string simulation (Karplus-Strong) that supports multiple strings, allowing investigation of harmonies between multiple strings (a sort of simulated harp).

Technically speaking, for each audio sample output, each of the string masses is moved based on the positions of their neighbors. This movement is repeated twice per audio sample to improve accuracy. The position of the string at one specific positions (i.e, the "pickup" of an electric guitar) is then output as sound. Actually, two pickup positions are used, one each for the two stereo channels. Pickups are placed at 1/13-th and 1/5-th of the total length. Audio output uses the RtAudio library.

For each video frame rendered, the minimum and maximum positions of each mass are tracked since the last video frame was rendered. The string is drawn in two passes, first as a single transparent polygon, varying the transparency between the two vertical extreme positions based on a formula for the appearance of a sinusoidally vibrating object[SPIE]. A second pass traces the boundary of the polygon drawn in the first pass, making the string visible when stationary. This approximates fairly well the appearance seen in the actual lab experiment.

The frequency spectrum of the audio detected at one pickup is fed to an open-source implementation of the Fast Fourier Transform [libfftw3], and displayed.

The 3D graphics library used is "ssg" (simple scence graph) written by one author for his computer graphics and animation classes. The GUI controls are created using the Fast Light Toolkit (FLTK) 1.3.2.

Dissemination Plans

Once running on all three platforms (Windows, Mac, Linux) we'll make it available on sites such as Merlot. We'll also use it in our other classes as useful.

Bibliography