Table of Contents > Understanding Sound in JES > Sound Functions in JES
Sound Functions in JES

This is a list of functions that you may find useful when you are creating programs to manipulate or create audio files in JES. Remember, these functions are part of a special library, and are not available in other Jython programming environments.
blockingPlay
Plays the sound provided as input, and makes sure that no other sound plays at the exact same time. (Try two play’s right after each other.)
getLength
Takes a sound as input and returns the number of samples in that sound.
getSample
Takes a Sample object and returns its value (between -32000 and 32000)

getSampleObjectAt

Takes a sound and an index (an integer value), and returns the Sample object at that index.
getSamples
Takes a sound as input and returns the Samples in that sound.
getSampleValueAt
Takes a sound and an index (an integer value), and returns the value of the sample (between -32000 and 32000) for that object.
getSamplingRate
Takes a sound as input and returns the number representing the number of samples in each second for the sound.
getSound
Takes a Sample object and returns the Sound that it remembers as its own.
makeSound Takes a filename as input, reads the file, and creates a sound from it. Returns the sound.
pickAFile Lets the user pick a file and returns the complete path name as a string. No input
play
Plays a sound provided as input. No return value.
playAtRate
Takes a sound and a rate (1.0 means normal speed, 2.0 is twice as fast, and 0.5 is half as fast), and plays the sound at that rate. The duration is always the same, e.g., if you play it twice as fast, the sound plays twice to fill the given time.
playAtRateDur
Takes a sound, a rate, and a duration as the number of samples to play.
setSample
Takes a Sample object and a value, and sets the sample to that value.
setSampleValueAt

Takes a sound, an index, and a value (should be between -32000 and 32000), and sets the value of the sample at the given index in the given sound to the given value.

writeSoundTo
Takes a sound and a filename (a string) and writes the sound to that file as a WAV file. (Make sure that the filename ends in “.wav” if you want the operating system to treat it right.)


jump to top