
AudioReadBuffer |
ptolemy.actor.lib.javasound.AudioReadBuffer |
This actor reads a sound file into a buffer and outputs the the
sample value at the specified buffer element. The sound file
is read from the URL specified by the <i>sourceURL</i>
parameter. Although the sound file must be specified
as a URL, it is still possible to specify files on the local
file system.
<p>
In each iteration, an IntToken is read from the input port, if
there is a token available. This token specifies the address of
the buffer element to read from. The address is zero-based, so
address 0 corresponds to the first element and addres
<i>bufferLength</i> -1 corresponds to the last element. The sample
value at the specified buffer location is converted to a DoubleToken
and sent to the output port.
<p>
If an element outside of the valid address range is specified, then
a DoubleToken with value 0.0 is output. If the the specified address
is greater than <i>bufferLength</i> -1, then this actor will return
false in postfire.
<p>
This actor does not currently support multichannel sound files, so
if a stereo sound file is specified, only the left channel will be
used. This limitation may be lifted in a future version of this actor.
<p>
The audio samples that are read from the file are
converted to DoubleTokens that may range from [-1.0, 1.0].
Thus, the output type of this actor is DoubleToken.
<p>
<b>Usage</b>
<p>
The <i>sourceURL</i> parameter should be set to the name of the file,
specified as a fully qualified URL. It is possible to load a file
from the local file system by using the prefix "file://" instead of
"http://". Relative file paths are allowed. To specify a file
relative to the current directory, use "../" or "./". For example,
if the current directory contains a file called "test.wav", then
<i>sourceURL</i> should be set to "file:./test.wav". If the parent
directory contains a file called "test.wav", then <i>sourceURL</i>
should be set to "file:../test.wav". To reference the file
test.wav, located at "/tmp/test.wav", <i>sourceURL</i>
should be set to "file:///tmp/test.wav" The default value is
"file:///tmp/test.wav".
<p>
There are security issues involved with accessing files and audio
resources in applets. Applets are only allowed access to files
specified by a URL and located on the machine from which the
applet is loaded. The .java.policy file may be modified to grant
applets more privileges.
<p>FIXME: This actor should extend AudioReadBuffer?
<p>
Note: Requires Java 2 v1.3.0 or later.
Author(s): Brian K. Vogel
Version:$Id: AudioReadBuffer.doc.html,v 1.1 2006/02/22 18:40:26 mangal Exp $
Pt.Proposed Rating:Red (vogel)
Pt.Accepted Rating:Red (vogel)
bufferLength
The length of the audio buffer to use. The default value
is 8000.