HearData: a sound player for data


The purpose of the program is to play sound of oscillating data stored in xy-formatted text files. Such a text file would contain (typically two) columns of data. For example, as is shown below, we may have a position-momentum plot:

 0.0		0.1
 0.35		0.8
 1.35		1.2
 2.0		0.4
 2.2		-0.1
 1.1		-1.3	
 ..		..
 ..		..
 ..		..
 

Say the above data is your PQ (momentum-position) data, for equispaced time points ti. The data in column 1 is Q(ti) and the data in column 2 is P(ti), where i is the time step index, i.e. the row index. Then you may play your data using the HearData app on this page. There are three requirements for the data:

(1) Your data should be oscillatory (about zero).
(2) There need to be enough samples.
(3) And finally, your data should represent functions of equispaced time points ti.


The data needs to be oscillatory, because your ear has a range of audible frequencies and cannot hear DC, and also because an algorithm that is used requires the data to be oscillatory about zero (more on this later). Regarding point (2): There need to be enough datapoints, since for only 1 second of sound (representing unmodified data) you would need 8000 datapoints. In typical simple numerical differential equations programming, one seldom records more than several thousand datapoints; playing out this data directly to sound would usually produce a burst of sound so short that it would impossible for the human ear and mind to get any qualitative impression of the data. There are several methods to modify the data. For example, a popular method would be to take a single frequency and modulate its amplitude by the magnitude of the data. In the current program we have implemented only one method. The method does not use amplitude modulation. Instead we play the sound directly---almost. But the raw datapoints are sliced into smaller segments of data which are played back and forth (and then back again); so, this way we only need one third of the samples per second that we would have needed if we had transcribed the raw data to sound directly. The raw data is also interpolated in such a way that twice as many points are produced from the raw data. Thus you need roughly 1300 samples (8000/3/2) to produce one second of sound. Regarding points (3): currently the interpolation is only implemented for equispaced points of time, and data can only be played as functions of the row index (not as a function of another column).


Secondly there are some computer system requirements for running the program.

The web applet is able to play sound with Netscape 4.x or newer browsers. The text buffers need to be large enough to hold the data you paste into it (not an observed problem on Unix work stations but on some PCs). You may want to read some testing information in the program info to avoid any unexpected behavior, then see for yourself. Sound does not seem to play on Netscape 3.x because this applet is not 100% Pure Java (sorry!!), since it needs to call a sound player function in the sun.audio library (which is outside the java.* library).

The java application variant of this program should run on any system capable of running Java.



Which program should you use?

The web based version is a good choice to demonstrate this program if you are on a Unix (or NT?) machine that is properly configured for multimedia. Remember that web based applets can not do file IO (including reading), hence you need to either paste your data from a good text editor, or you can also press the ``Paste Demo'' button to have a sample text of an chaotic damped and driven pendulum (velocity vs timestep) motion pasted in for you.

The java application is much nicer, because it will let you load your data file and also finally let you save the result as an (.au) sound file. The .au file is a standard format that you should be able to play with a mulitmedia tool on your system; there also exist tools that will let you manipulate the sound. However, to run the HearData java-app, you will need to download and install the files yourself. Naturally, you must also have java installed.



Applet


Run the applet.




Java Application


Get the archived files.


Directory of *.java files and *.class files




Quick directions

Applet: The first screen in the applet allows you to set some options before you process the sound. The options are:

1.) Volume; use the slider.
2.) Select the column of data to be processed for sound; enter a positive integer in the text field ``col= ... ''.
3.) Slice; this allows you to control how the data is to be cut up into slices (which are to be played back, forth, and back again). For example 10 Hz slice would be 100 ms long.

You may select these options as appropriate for the data you paste into the large text window. Press ``Paste Demo'' or paste in your own data, then press ``Enter and Process'' to process the data. Wait a couple of seconds. If there is an error your choices are to (press) ``Ignore..'' the error or press ``Clear'' to restart. Wait until the data is displayed graphically and you are given the options to ``Play'', ``Stop'', and ``Clear'' (restart).

Java Application: We assume that you are in a command prompt (shell). Go to the directory where the files are installed. Enter the following:

java HearData

A file dialog will appear. Load the demo data file: locate the file called demo.dat; select it, and press ``Open''. The next file dialog will appear asking you for a file to save, type some name ending in `.au', for example ``demo.au'', into the ``Selection'' field, and press ``Save''. Now wait until the applet constructs and pops up. From this point, the instructions should be very similar to instructions for the applet .

When you finally press ``quit'', go to the shell and observe that the shell asks you (prompts) whether you want to save the file. Press the appropriate key. The file will be saved before the program exits.


Links: Visualizing Physics with Sound