To view this content, you need to install Java from java.com

This sketch demonstrates how to use the getFormat method of a Recordable class. The class used here is AudioOutput, but you can also get the format of AudioInput, AudioPlayer, and AudioSample objects. The getFormat method returns an object of type AudioFormat which is a class defined in the JavaSound API. An AudioFormat is a container for information about an audio source, such as the framerate, encoding and so forth. The following methods are available on an AudioFormat object and all are demonstrated in this sketch.

int getChannels()
Obtains the number of channels.

AudioFormat.Encoding getEncoding()
Obtains the type of encoding for sounds in this format.

float getFrameRate()
Obtains the frame rate in frames per second.

int getFrameSize()
Obtains the frame size in bytes.

float getSampleRate()
Obtains the sample rate.

int getSampleSizeInBits()
Obtains the size of a sample.

boolean isBigEndian()
Indicates whether the audio data is stored in big-endian or little-endian byte order.

boolean matches(AudioFormat format)
Indicates whether this format matches the one specified.

String toString()
Returns a string that describes the format, such as: "PCM SIGNED 22050 Hz 16 bit mono big-endian".

Source code: getFormat

Built with Processing