Bill Manaris : Fall 2006 / Python Media Sound API

Python Media API

Sound I/O

To input an external WAV file into an internal Sound encoding.
Also, to output an internal encoding to an external WAV file.

The following functions manipulate a sound.

Function

Description

pickAFile()

Lets the user pick a file and returns the complete path name as a string.

makeSound(filename)

Takes a filename as input, reads the file, and creates a sound from it. Returns the sound.

makeEmptySound(length)

Creates an empty sound with length samples. Returns the sound.

play(sound)

Plays a sound provided as input. No return value.

blockingPlay(sound)

Plays a sound provided as input and makes sure that no other sound plays at the exact same time. No return value.

writeSoundTo(sound,"file.wav")

Writes sound to the file called "file.wav". Returns nothing.

Definitions

Objects used internally to store external sounds:

Sound Functions

To access the internal Sound encoding:

getLength(sound)

Returns the number of samples in sound.

getSamplingRate(sound)

Returns the number of samples per second in sound.

getSamples(sound)

Returns a list of samples from sound.

getSampleValueAt(sound,index)

Returns the sample of sound at index.

setSampleValueAt(sound,index,value)

Sets the sample of sound at index to value.

(Printable View of http://www.cs.cofc.edu/~manaris/?n=Fall2006.PythonMediaSoundAPI)