Prof. Dobrian has written a MIDI Harmonizer using JavaScript and Max, which can be found on the Max Cookbook site.
JavaScript can also be used to access and manipulate samples stored in a buffer. The following code scans through a buffer looking for the largest difference in amplitude across approximately 50ms of sound; this location is most likely the location of a transient, i.e. a fast attack. This code can be used to automatically crop sounds that begin with silence.