VisualSim.actor.lib.javasound
Class AudioCapture
- public class AudioCapture
- extends Source
- implements LiveSoundListener
- This
actor sequentially outputs audio samples that are captured from the
audio input port of the computer. The audio input port typically
corresponds to either the microphone input, line-in, or cd audio from
the cdrom or dvd drive. It is not possible to select the desired input
port under Java. This must be done from the operating system. This
actor should be fired often enough to prevent overflow of the internal
audio capture buffer. Overflow should be avoided, since it will result
in loss of data. Each captured audio sample is converted to a double
that may range from -1.0 to 1.0. Thus, the output type of this actor is
DoubleToken.
The following parameters should
be set accordingly. In all cases, an exception is thrown if an illegal
parameter value is used. Note that these parameters may be changed
while audio playback is active. If this actor is used in conjunction
with an AudioPlayer actor, changing a parameter will cause the
corresponding parameter value of the AudioPlayer to automatically be
set to the same value. This behavior is required because the
AudioCapture and AudioPlayer actors both share access to the audio
hardware, which is associated with a single sample rate, bit
resolution, and number of channels.
- sampleRate
should be set to the desired sample rate, in Hz. The default value is
8000. Allowable values are 8000, 11025, 22050, 44100, and 48000 Hz.
Note that Java does not support 96000 Hz operation, even if the audio
hardware supports it.
- bitsPerSample
should be set to the desired bit resolution. The default value is 16.
Allowable values are 8 and 16. Note that Java does not support 20 or 24
bit audio, even if the audio hardware supports it.
- channels
should be set to desired number of audio channels. The default value is
1 (for mono audio). Allowable values are 1 and 2 (for stereo). Note
that more than two channels of audio is not currently supported in
Java, even if the audio hardware supports it.
It should be noted that at most
one AudioCapture and one AudioPlayer actor may be used simultaneously.
Otherwise, an exception will occur. This restriction may be lifted in a
future version of this actor.
There are security issues
involved with accessing files and audio resources in applets. Applets
are not allowed to capture audio from the audio input port (e.g., the
microphone) by default since this could present a security risk.
Therefore, the actor will not run in an applet by default. The
.java.policy file may be modified to grant applets more privileges.
Note: Requires Java 2 v1.3.0 or later.
See Also:
- VisualSim.media.javasound.LiveSound
- AudioPlayer
- SoundReader
- SoundWriter
-
sampleRate
public Parameter sampleRate
- The desired sample rate to use, in Hz. The default value is an IntToken equal to 8000.
An exception will occur if this parameter is set to an unsupported sample rate.
bitsPerSample
public Parameter bitsPerSample
- The number desired number of bits per sample. The default value is an IntToken equal to 16.
An exception will occur if this parameter is set to an unsupported bit resolution.
channels
public Parameter channels
- The number of audio channels to use. The default value is an IntToken equal to 1.
An exception will occur if this parameter is set to an an unsupported channel number.
transferSize
public Parameter tranferSize
- The size of data transferred by each channel.
Created with the Personal Edition of HelpNDoc: Free Kindle producer