|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.DefaultProperty
cz.cuni.jagrlib.Piece
cz.cuni.jagrlib.DefaultFileFormat
cz.cuni.jagrlib.piece.WAVFileFormatMapped
public class WAVFileFormatMapped
WAV sound file filter.
Keeps data in disk file, accessed via memory-mapped mode in BitStream
.
Field Summary | |
---|---|
protected int |
bitsPerSample
Actual sample accuracy in bits. |
protected int |
blockAlign
Number of bytes in one time-slot. |
protected int |
bytesPerSample
Physical sample size in bytes. |
protected static java.lang.String |
CATEGORY
Object category. |
protected long |
dataOffset
Data offset within the binary file (in bytes). |
protected double |
duration
Sound duration in seconds. |
static java.lang.String |
DURATION
|
protected long |
frequency
Sampling frequency in Hz. |
protected boolean |
headerChanged
Was the binary header changed? |
protected int |
channels
Actual number of channels. |
static java.lang.String |
CHANNELS
|
protected boolean |
propChanged
File properties were changed (for commit() ). |
static RegPiece |
reg
Static registration instance for this class. |
protected long |
samples
Actual number of samples (time axis). |
protected int |
sampleType
Actual sample type. |
protected BitStream |
stream
Opened bit-stream or null . |
protected static long |
TAG_DATA
|
protected static long |
TAG_FMT
|
protected static long |
TAG_RIFF
|
protected static long |
TAG_WAVE
|
protected static java.lang.String |
TEMPLATE_NAME
Object template identifier. |
protected boolean |
writable
Is the WAV file writable? |
Fields inherited from class cz.cuni.jagrlib.Piece |
---|
info, pl, plugs, TEMPLATE_TYPE, userBreak |
Fields inherited from interface cz.cuni.jagrlib.iface.SampleData |
---|
FREQUENCY, SAMPLE_BYTE, SAMPLE_COMPLEX, SAMPLE_DOUBLE, SAMPLE_FLOAT, SAMPLE_INT, SAMPLE_LONG, SAMPLE_RGBA, SAMPLE_SHORT, SAMPLE_TYPE |
Fields inherited from interface cz.cuni.jagrlib.iface.Property |
---|
LOGGING, STATISTICS, TEXT_DESCRIPTION |
Fields inherited from interface cz.cuni.jagrlib.iface.DataFileFormat |
---|
DOUBLE_STREAM |
Constructor Summary | |
---|---|
WAVFileFormatMapped()
|
Method Summary | |
---|---|
void |
closeFile()
Closes the file (used in file-mapping mode). |
void |
commit()
Commits all previous changes ( set(java.lang.String, java.lang.Object) ) to the internal object state. |
java.lang.String[] |
fileNameMasks()
Returns file-name masks associated with the file-format type. |
java.lang.Object |
get(java.lang.String key)
Gets the given property. |
java.lang.Object |
getDataArray(int[] dim)
Returns the original data array. |
int |
getDataDim(int[] dim)
Returns actual array dimensions. |
void |
getSampleGeometry(double[] geom)
Gets the sample geometry (in regular sample matrix). |
java.lang.Object |
getSampleMapping(java.lang.Object map,
int srcFrom,
int srcTo,
int[] bounds)
Retrieves the whole sample mapping (for mapped arrays only). |
int |
getSamples(int[] from,
int[] to,
double[] data)
Reads the given sample segment (float formats: float, double). |
int |
getSamples(int[] from,
int[] to,
int[] data)
Reads the given sample segment (integer formats: byte, short, int). |
int |
getSamples(int[] from,
int[] to,
long[] data)
Reads the given sample segment (long format). |
int |
getSamplesGeneral(int[] from,
int[] to,
java.lang.Object data)
Reads the given sample segment (general data format). |
int |
getSampleType()
Returns actual sample type ( SAMPLE_* constant). |
int |
headerLength()
Length of file-format header (number of bytes which is necessary for file-format matching). |
protected int |
checkComponentClass(java.lang.Object array,
boolean allowDouble)
Checks array's component type. |
boolean |
loadFile(BitStream stream,
java.lang.Object support)
Retrieves data from the given BitStream . |
boolean |
loadFile(java.lang.String fileName,
java.lang.String detail)
Retrieves data from the given file (stream). |
double |
match(byte[] header,
java.lang.String fileName)
File-format match test. |
protected boolean |
readHeader()
Reads header of existing WAV file. |
void |
resetData(int type,
boolean mapped,
int[] dim)
(Re-)initialize the data array. |
boolean |
saveFile(BitStream stream,
java.lang.Object support)
Saves data to the given BitStream . |
boolean |
saveFile(java.lang.String fileName,
java.lang.String detail)
Saves data to the given file (stream). |
void |
set(java.lang.String key,
java.lang.Object value)
Sets the given property. |
void |
setDataArray(java.lang.Object data,
int srcFrom,
int[] dstFrom,
int[] dstTo)
Sets data array in the raw (internal) format. |
void |
setSampleGeometry(double[] geom)
Sets the sample geometry (in regular sample matrix). |
void |
setSampleMapping(java.lang.Object map,
int srcFrom,
int srcTo,
int dstFrom)
Sets (partially) the new sample mapping (for mapped arrays only). |
void |
setSamples(int[] from,
int[] to,
double[] data)
Writes the given sample segment (float formats: float, double). |
void |
setSamples(int[] from,
int[] to,
int[] data)
Writes the given sample segment (integer formats: byte, short, int). |
void |
setSamples(int[] from,
int[] to,
long[] data)
Writes the given sample segment (long format). |
void |
setSamplesGeneral(int[] from,
int[] to,
java.lang.Object data)
Writes the given sample segment (general data format). |
static int |
setTemplate(Template t,
int ord)
General-purpose registration routine. |
protected boolean |
writeHeader()
Synchronize disk file header with the actual object state. |
Methods inherited from class cz.cuni.jagrlib.DefaultFileFormat |
---|
init, readFloat, readLine, readParameters, readToken, readUnsigned16, readUnsigned16, readUnsigned32, writeFloat, writeLine, writeParameters, writeUnsigned16, writeUnsigned16, writeUnsigned32 |
Methods inherited from class cz.cuni.jagrlib.Piece |
---|
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop |
Methods inherited from class cz.cuni.jagrlib.DefaultProperty |
---|
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cz.cuni.jagrlib.Breakable |
---|
setProgressListener, stop |
Field Detail |
---|
protected BitStream stream
null
.
protected boolean writable
protected long samples
protected int channels
protected int blockAlign
protected int bitsPerSample
protected int bytesPerSample
protected long frequency
protected long dataOffset
protected boolean headerChanged
protected int sampleType
protected double duration
protected boolean propChanged
commit()
).
protected static final long TAG_RIFF
protected static final long TAG_WAVE
protected static final long TAG_FMT
protected static final long TAG_DATA
public static final java.lang.String CHANNELS
public static final java.lang.String DURATION
protected static final java.lang.String TEMPLATE_NAME
protected static final java.lang.String CATEGORY
public static final RegPiece reg
Constructor Detail |
---|
public WAVFileFormatMapped()
Method Detail |
---|
protected boolean readHeader()
true
if the header was OK.protected boolean writeHeader()
true
if the operation was successfull.protected int checkComponentClass(java.lang.Object array, boolean allowDouble)
-1
if array type is not compatible.public int headerLength()
headerLength
in interface DataFileFormat
headerLength
in class DefaultFileFormat
match(byte[], java.lang.String)
public double match(byte[] header, java.lang.String fileName)
match
in interface DataFileFormat
match
in class DefaultFileFormat
header
- Bytes from beginning of the file.fileName
- Optional file-name string.
0.0
.. no way,
0.5
.. maybe, 0.9
.. almost sure, 1.0
..
absolutely - no need to check another formats).headerLength()
,
fileNameMasks()
public java.lang.String[] fileNameMasks()
fileNameMasks
in interface DataFileFormat
fileNameMasks
in class DefaultFileFormat
null
.match(byte[], java.lang.String)
public boolean loadFile(java.lang.String fileName, java.lang.String detail) throws java.io.IOException
loadFile
in interface DataFileFormat
loadFile
in class DefaultFileFormat
fileName
- File-name (stream-name) to read from (can be null
).detail
- Further implementation-specific information ("r" or "rw" for mapped mode).
true
if the operation was successful.
java.io.IOException
loadFile(BitStream,Object)
,
saveFile(String,String)
,
closeFile()
public boolean loadFile(BitStream stream, java.lang.Object support) throws java.io.IOException
BitStream
. This metod is optional.
The stream should be opened before - only the BitStream.reOpen(boolean, java.lang.String)
call
can be used.
loadFile
in interface DataFileFormat
loadFile
in class DefaultFileFormat
stream
- Input bit-stream (opened - call BitStream.reOpen(boolean, java.lang.String)
first).support
- Implementation-specific data (e.g. second BitStream
for
file-formats with DataFileFormat.DOUBLE_STREAM
property).
true
if the operation was successful.
java.io.IOException
loadFile(String,String)
,
DataFileFormat.DOUBLE_STREAM
public boolean saveFile(java.lang.String fileName, java.lang.String detail)
saveFile
in interface DataFileFormat
saveFile
in class DefaultFileFormat
fileName
- File-name (stream-name) to write to (can be null
).detail
- Further implementation-specific information.
true
if the operation was successful.saveFile(BitStream,Object)
,
loadFile(String,String)
public boolean saveFile(BitStream stream, java.lang.Object support) throws java.io.IOException
BitStream
. This metod is optional.
The stream should be opened and empty - the reOpen(true,null)
call
is not required.
saveFile
in interface DataFileFormat
saveFile
in class DefaultFileFormat
stream
- Output bit-stream (opened and empty).support
- Implementation-specific data (e.g. second BitStream
for
file-formats with DataFileFormat.DOUBLE_STREAM
property).
true
if the operation was successful.
java.io.IOException
saveFile(String,String)
,
DataFileFormat.DOUBLE_STREAM
public void closeFile() throws java.io.IOException
closeFile
in interface DataFileFormat
closeFile
in class DefaultFileFormat
java.io.IOException
loadFile(String,String)
public void resetData(int type, boolean mapped, int[] dim)
resetData
in interface SampleData
type
- Sample type (one of SAMPLE_*
constants).mapped
- Should the array contain mapped values?dim
- Dimensions of an array.SampleData.SAMPLE_BYTE
,
SampleData.SAMPLE_SHORT
,
SampleData.SAMPLE_INT
,
SampleData.SAMPLE_LONG
,
SampleData.SAMPLE_FLOAT
,
SampleData.SAMPLE_DOUBLE
,
SampleData.SAMPLE_COMPLEX
,
SampleData.SAMPLE_RGBA
public int getSampleType()
SAMPLE_*
constant).
getSampleType
in interface SampleData
SAMPLE_*
constant).getDataDim(int[])
,
SampleData.SAMPLE_BYTE
,
SampleData.SAMPLE_SHORT
,
SampleData.SAMPLE_INT
,
SampleData.SAMPLE_LONG
,
SampleData.SAMPLE_FLOAT
,
SampleData.SAMPLE_DOUBLE
,
SampleData.SAMPLE_COMPLEX
,
SampleData.SAMPLE_RGBA
public int getDataDim(int[] dim)
getDataDim
in interface SampleData
dim
- Pre-allocated array to hold individual dimensions' sizes.
getSampleType()
public void setSampleGeometry(double[] geom)
setSampleGeometry
in interface SampleData
geom
- Sample periods for all dimensions.getSampleGeometry(double[])
public void getSampleGeometry(double[] geom)
getSampleGeometry
in interface SampleData
geom
- Sample periods for all dimensions.setSampleGeometry(double[])
public void setSampleMapping(java.lang.Object map, int srcFrom, int srcTo, int dstFrom)
setSampleMapping
in interface SampleData
map
- Mapping array to be set (should be an array of the apropriate type).srcFrom
- First source index (map[from]
).srcTo
- After the last source index.dstFrom
- First destination index.getSampleMapping(java.lang.Object, int, int, int[])
public java.lang.Object getSampleMapping(java.lang.Object map, int srcFrom, int srcTo, int[] bounds)
getSampleMapping
in interface SampleData
map
- Optional pre-allocated mapping array to be filled.srcFrom
- First index to be retrieved.srcTo
- After the last index to be retrieved.bounds
- Retrieved index bounds (bounds[0]
= the 1st mapped value
written in map[0], bounds[1]
= index after the last value).setSampleMapping(java.lang.Object, int, int, int)
public java.lang.Object getDataArray(int[] dim)
getDataArray
in interface SampleData
dim
- Returned dimensionality (array of individual dimension sizes). Can be null.
null
if the service is not
available.setDataArray(java.lang.Object, int, int[], int[])
public void setDataArray(java.lang.Object data, int srcFrom, int[] dstFrom, int[] dstTo)
setDataArray
in interface SampleData
data
- Packed 1D source data array (of apropriate type).srcFrom
- Source index to begin from.dstFrom
- Start of the region to be set. Can be null (instead of [0,0,0,..]).dstTo
- End of the region to be set. Can be null (instead of dim).public int getSamplesGeneral(int[] from, int[] to, java.lang.Object data)
getSamplesGeneral
in interface SampleData
from
- Starting index.to
- Index after retrieved data.data
- Pre-allocated array to hold the result (packed 1D array).
public void setSamplesGeneral(int[] from, int[] to, java.lang.Object data)
setSamplesGeneral
in interface SampleData
from
- Starting index.to
- Index after the written data.data
- Data to be written - in 1D array.public int getSamples(int[] from, int[] to, int[] data)
getSamples
in interface SampleData
from
- Starting index.to
- Index after retrieved data.data
- Pre-allocated array to hold the result.
public int getSamples(int[] from, int[] to, long[] data)
getSamples
in interface SampleData
from
- Starting index.to
- Index after retrieved data.data
- Pre-allocated array to hold the result.
public int getSamples(int[] from, int[] to, double[] data)
getSamples
in interface SampleData
from
- Starting index.to
- Index after retrieved data.data
- Pre-allocated array to hold the result (complex uses double-sized array).
public void setSamples(int[] from, int[] to, int[] data)
setSamples
in interface SampleData
from
- Starting index.to
- Index after written data.data
- Data to be written (1D array).public void setSamples(int[] from, int[] to, long[] data)
setSamples
in interface SampleData
from
- Starting index.to
- Index after written data.data
- Data to be written (1D array).public void setSamples(int[] from, int[] to, double[] data)
setSamples
in interface SampleData
from
- Starting index.to
- Index after written data.data
- Data to be written (1D array). Complex uses double-sized array.public void set(java.lang.String key, java.lang.Object value)
set
in interface Property
set
in class DefaultProperty
key
- Key string.value
- The new value.Property.commit()
public java.lang.Object get(java.lang.String key)
get
in interface Property
get
in class DefaultProperty
key
- Key string.
null
.public void commit()
set(java.lang.String, java.lang.Object)
) to the internal object state.
Non-mandatory.
commit
in interface Property
commit
in class DefaultProperty
public static int setTemplate(Template t, int ord)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |