When making sounds, the most fundamental way to create samples which represent pure and well defined waves is to use mathematically defined waves, for instance by explicit formulae as a function of time or sample number, assuming the samples are from a function of time with frequency spectrum limited to the Nyquist rate (half the sampling frequency). The latter is not completely true for the following example, but the spectrum is limited enough to give useful results.

This is where Tcl comes in to make a useful script which executes exactly the right commands to let us drive maxima and a dedicated C program to generate waveforms from powerful formulae. Not a very big script (not counting bwise along, because strictly speaking the below works mostly also without bwise) but one which calls two major applications (maxima and gcc), and which does the essential packing of a FORTRAN function in a suitable file, and finally automatically executes the compiled program, which writes a standard .wav file (see snack) to play with some media player.

Of course maxima must be present on the system and reachable according to the PATH shell variable (like wish and tclsh). I've done this setup on Linux, which when set up right gives excellent maxima and compile times, with complicated formulas (see below) a long wav file is created in under a second (!). I guess this Tcl/maxima/FORTRAN/C setup is therefore useful for general application, too.

You need to have these files in the current directory which contains the wav file and C loop part of the target program:

As a side remark: in Electrical Engineering and various other disciplines the above type of combined exponential / sine terms are very important and fundamental types of formulas which arise as the solution to important network theoretical linear but reactive circuits or systems differential equations.

Needless to say, because of the block facilities or bwise and general Tcl/Tk possibilities, a powerful environment can be made.

I made a good improvement by getting gnuplot called from maxima called from the main server tread of the cgi script chain and replacing the repeated call to the Maxima executable with a large memory space claiming exec call by an addition to the main (runtime gcc compiled) C/Fortran program, where a similar 0.1 second graph of 500x1000 pixels is made in C, written as .ppm file, and converted to .gif, which takes a lot less time: the C program is efficient in time and memory and so now the whole page solving a new formula and rendering it takes usually under 3 seconds to complete, with prettyprinting, graph, and sound files being made.

The C code can be found here [2] for those who want to experiment, and the tcl script code has certain execs commented out. The resulting graph (in this hacked version) looks like this:

Feel welcome to try some simple or difficult examples, for instance like this one:

N.B. Pressing the link probably won't work because the auto-link forgets the last two ))'s

which is instructing maxima over the 3 tcl wen scripts to solve a second order differential equation formally, and then the sound becomes like this: [3]

I've also made mid file renderings with mathematical waves from the program described on the other page I mentioned above, where the result is free from any of the modern mess that al kinds of transforms and sampling artifacts have all the time, and therefore very musical.

I'll think about making a package of the required programs (minus the C compiler, which could better be fast like gcc with ramdisk on a good linux machine), so that in combination with bwise interesting wave and signal processing research is possible. Oh yeah, and the fortran scene has made a frienly attempt to improve things by making an non-backward compatible main math library change which makes it necessary to update your compiler when you get a new fortan part.