ddf.minim
Class Minim

java.lang.Object
  extended byddf.minim.Minim

public class Minim
extends java.lang.Object

The Minim class is how you get what you want from JavaSound. There are methods for obtaining objects for playing audio files: AudioSample, AudioSnippet, and AudioPlayer. There are methods for obtaining an AudioRecorder, which is how you record audio to disk. There are methods for obtaining an AudioInput, which is how you can monitor the computer's line-in or microphone, depending on what the user has set as the record source. Finally there are methods for obtaining an AudioOutput, which is how you can play audio generated by your program. All of these classes are given AudioStreams by Minim, which are Threads that do the actual work of audio I/O. Because of this, you should always call the close method of an AudioXXX when you are finished with it.

Minim needs to know about your sketch so that it can load files from the sketches data directory. For this reason, before you do anything with Minim, you must call start.

Author:
Damien Di Fede

Field Summary
static javax.sound.sampled.AudioFileFormat.Type AIFC
          The .aifc file format.
static javax.sound.sampled.AudioFileFormat.Type AIFF
          The .aiff file format.
static javax.sound.sampled.AudioFileFormat.Type AU
          The .au file format.
static int MONO
          Specifies that you want a MONO AudioInput or AudioOutput
static javax.sound.sampled.AudioFileFormat.Type SND
          The .snd file format.
static int STEREO
          Specifies that you want a STEREO AudioInput or AudioOutput
static javax.sound.sampled.AudioFileFormat.Type WAV
          The .wav file format.
 
Method Summary
static AudioRecorder createRecorder(Recordable source, java.lang.String fileName, boolean buffered)
          Creates an AudioRecorder that will use source as its record source and that will save to the file name specified.
static void debug(java.lang.String s)
          Displays a debug message, but only if debugOn() has been called.
static void debugOff()
          Turns off debug messages.
static void debugOn()
          Turns on debug messages.
static void error(java.lang.String s)
          Used internally to report error messages.
static AudioInput getLineIn()
          Gets an AudioInput, to which you can attach AudioEffects.
static AudioInput getLineIn(int type)
          Gets an AudioInput, to which you can attach AudioEffects.
static AudioInput getLineIn(int type, int bufferSize)
          Gets an AudioInput, to which you can attach AudioEffects.
static AudioInput getLineIn(int type, int bufferSize, float sampleRate)
          Gets an AudioInput, to which you can attach AudioEffects.
static AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
          Gets an AudioInput, to which you can attach AudioEffects.
static AudioOutput getLineOut()
          Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.
static AudioOutput getLineOut(int type)
          Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.
static AudioOutput getLineOut(int type, int bufferSize)
          Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.
static AudioOutput getLineOut(int type, int bufferSize, float sampleRate)
          Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.
static AudioOutput getLineOut(int type, int bufferSize, float sampleRate, int bitDepth)
          Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.
static AudioPlayer loadFile(java.lang.String filename)
          Loads the requested file into an AudioPlayer with a buffer size of 1024 samples.
static AudioPlayer loadFile(java.lang.String filename, int bufferSize)
          Loads the requested file into an AudioPlayer with the request buffer size.
static AudioSample loadSample(java.lang.String filename)
          Loads the requested file into an AudioSample.
static AudioSample loadSample(java.lang.String filename, int bufferSize)
          Loads the requested file into an AudioSample.
static AudioSnippet loadSnippet(java.lang.String filename)
          Loads the requested file into an AudioSnippet
static void start(processing.core.PApplet pro)
          Starts Minim.
static void stop()
          Deprecated. This does nothing now, be sure to call close on anything you get from Minim.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONO

public static final int MONO
Specifies that you want a MONO AudioInput or AudioOutput

See Also:
Constant Field Values

STEREO

public static final int STEREO
Specifies that you want a STEREO AudioInput or AudioOutput

See Also:
Constant Field Values

WAV

public static javax.sound.sampled.AudioFileFormat.Type WAV
The .wav file format.


AIFF

public static javax.sound.sampled.AudioFileFormat.Type AIFF
The .aiff file format.


AIFC

public static javax.sound.sampled.AudioFileFormat.Type AIFC
The .aifc file format.


AU

public static javax.sound.sampled.AudioFileFormat.Type AU
The .au file format.


SND

public static javax.sound.sampled.AudioFileFormat.Type SND
The .snd file format.

Method Detail

error

public static void error(java.lang.String s)
Used internally to report error messages. These error messages will appear in the console area of the PDE if you are running a sketch from the PDE, otherwise they will appear in the Java Console.

Parameters:
s - the error message to report

debug

public static void debug(java.lang.String s)
Displays a debug message, but only if debugOn() has been called. The message will be displayed in the console area of the PDE, if you are running your sketch from the PDE. Otherwise, it will be displayed in the Java Console.

Parameters:
s - the message to display
See Also:
debugOn()

debugOn

public static void debugOn()
Turns on debug messages.


debugOff

public static void debugOff()
Turns off debug messages.


start

public static void start(processing.core.PApplet pro)
Starts Minim. It is necessary to call this so that Minim can properly open files.

Parameters:
pro - the sketch that is going to be using Minim

stop

public static void stop()
Deprecated. This does nothing now, be sure to call close on anything you get from Minim.

Stops Minim. A call to this method should be placed inside of the stop() function of your sketch. All of the audio input and output is handled in separate threads, calling this method will cause all of those threads to finish executing. Not calling this method could result in errors.


loadSample

public static AudioSample loadSample(java.lang.String filename)
Loads the requested file into an AudioSample.

Parameters:
filename - the file or URL that you want to load
Returns:
an AudioSample with a 1024 sample buffer
See Also:
loadSample(String, int), AudioSample

loadSample

public static AudioSample loadSample(java.lang.String filename,
                                     int bufferSize)
Loads the requested file into an AudioSample.

Parameters:
filename - the file or URL that you want to load
bufferSize - the sample buffer size you want
Returns:
an AudioSample with a sample buffer of the requested size

loadSnippet

public static AudioSnippet loadSnippet(java.lang.String filename)
Loads the requested file into an AudioSnippet

Parameters:
filename - the file or URL you want to load
Returns:
an AudioSnippet of the requested file or URL

loadFile

public static AudioPlayer loadFile(java.lang.String filename)
Loads the requested file into an AudioPlayer with a buffer size of 1024 samples.

Parameters:
filename - the file or URL you want to load
Returns:
an AudioPlayer with a 1024 sample buffer
See Also:
loadFile(String, int)

loadFile

public static AudioPlayer loadFile(java.lang.String filename,
                                   int bufferSize)
Loads the requested file into an AudioPlayer with the request buffer size.

Parameters:
filename - the file or URL you want to load
bufferSize - the sample buffer size you want
Returns:
an AudioPlayer with a sample buffer of the requested size

createRecorder

public static AudioRecorder createRecorder(Recordable source,
                                           java.lang.String fileName,
                                           boolean buffered)
Creates an AudioRecorder that will use source as its record source and that will save to the file name specified. The format of the file will be inferred from the extension in the file name. If the extension is not a recognized file type, this will return null. Be aware that if you choose buffered recording the call to AudioRecorder.save() will block until the entire buffer is written to disk. In the event that the buffer is very large, your sketch will noticably hang.

Parameters:
source - the Recordable object you want to use as a record source
fileName - the name of the file to record to
buffered - whether or not to use buffered recording
Returns:
an AudioRecorder for the record source

getLineIn

public static AudioInput getLineIn()
Gets an AudioInput, to which you can attach AudioEffects.

Returns:
an STEREO AudioInput with a 1024 sample buffer, a sample rate of 44100 and a bit depth of 16
See Also:
getLineIn(int, int, float, int)

getLineIn

public static AudioInput getLineIn(int type)
Gets an AudioInput, to which you can attach AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
Returns:
an AudioInput with the requested type, a 1024 sample buffer, a sample rate of 44100 and a bit depth of 16
See Also:
getLineIn(int, int, float, int)

getLineIn

public static AudioInput getLineIn(int type,
                                   int bufferSize)
Gets an AudioInput, to which you can attach AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioInput's sample buffer to be
Returns:
an AudioInput with the requested attributes, a sample rate of 44100 and a bit depth of 16
See Also:
getLineIn(int, int, float, int)

getLineIn

public static AudioInput getLineIn(int type,
                                   int bufferSize,
                                   float sampleRate)
Gets an AudioInput, to which you can attach AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioInput's sample buffer to be
sampleRate - the desired sample rate in Hertz (typically 44100)
Returns:
an AudioInput with the requested attributes and a bit depth of 16
See Also:
getLineIn(int, int, float, int)

getLineIn

public static AudioInput getLineIn(int type,
                                   int bufferSize,
                                   float sampleRate,
                                   int bitDepth)
Gets an AudioInput, to which you can attach AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioInput's sample buffer to be
sampleRate - the desired sample rate in Hertz (typically 44100)
bitDepth - the desired bit depth (typically 8)
Returns:
an AudioInput with the requested attributes

getLineOut

public static AudioOutput getLineOut()
Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.

Returns:
a STEREO AudioOutput with a 1024 sample buffer, a sample rate of 44100 and a bit depth of 16
See Also:
getLineOut(int, int, float, int)

getLineOut

public static AudioOutput getLineOut(int type)
Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
Returns:
an AudioOutput with the requested type, a 1024 sample buffer, a sample rate of 44100 and a bit depth of 16
See Also:
getLineOut(int, int, float, int)

getLineOut

public static AudioOutput getLineOut(int type,
                                     int bufferSize)
Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioOutput's sample buffer to be
Returns:
an AudioOutput with the requested attributes, a sample rate of 44100 and a bit depth of 16
See Also:
getLineOut(int, int, float, int)

getLineOut

public static AudioOutput getLineOut(int type,
                                     int bufferSize,
                                     float sampleRate)
Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioOutput's sample buffer to be
sampleRate - the desired sample rate in Hertz (typically 44100)
Returns:
an AudioOutput with the requested attributes and a bit depth of 16
See Also:
getLineOut(int, int, float, int)

getLineOut

public static AudioOutput getLineOut(int type,
                                     int bufferSize,
                                     float sampleRate,
                                     int bitDepth)
Gets an AudioOutput, to which you can attach AudioSignals and AudioEffects.

Parameters:
type - Minim.MONO or Minim.STEREO
bufferSize - how long you want the AudioOutput's sample buffer to be
sampleRate - the desired sample rate in Hertz (typically 44100)
bitDepth - the desired bit depth (typically 8)
Returns:
an AudioOutput with the requested attributes