cz.cuni.jagrlib.iface
Interface SampleData

All Superinterfaces:
Property
All Known Implementing Classes:
DataMatrix, WAVFileFormatMapped

public interface SampleData
extends Property

General sampled data file (D-dimensional array of scalars).

Since:
0.10
See Also:
SampleData.java

Field Summary
static java.lang.String FREQUENCY
          Property name: frequency (in Hz).
static int SAMPLE_BYTE
          8-bit signed integer value.
static int SAMPLE_COMPLEX
          Complex number (double[2] array - uses double-sized array).
static int SAMPLE_DOUBLE
          floating-point (double precision) value.
static int SAMPLE_FLOAT
          floating-point (single precision) value.
static int SAMPLE_INT
          32-bit signed integer value.
static int SAMPLE_LONG
          64-bit signed integer value.
static int SAMPLE_RGBA
          RGB color (packed into one integer).
static int SAMPLE_SHORT
          16-bit signed integer value.
static java.lang.String SAMPLE_TYPE
          Property name: sample type.
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Method Summary
 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, complex).
 int getSamples(int[] from, int[] to, int[] data)
          Reads the given sample segment (integer formats: byte, short, int, RGBA).
 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).
 void resetData(int type, boolean mapped, int[] dim)
          (Re-)initialize the data array.
 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, complex).
 void setSamples(int[] from, int[] to, int[] data)
          Writes the given sample segment (integer formats: byte, short, int, RGBA).
 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).
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 

Field Detail

SAMPLE_BYTE

static final int SAMPLE_BYTE
8-bit signed integer value.

See Also:
Constant Field Values

SAMPLE_SHORT

static final int SAMPLE_SHORT
16-bit signed integer value.

See Also:
Constant Field Values

SAMPLE_INT

static final int SAMPLE_INT
32-bit signed integer value.

See Also:
Constant Field Values

SAMPLE_LONG

static final int SAMPLE_LONG
64-bit signed integer value.

See Also:
Constant Field Values

SAMPLE_FLOAT

static final int SAMPLE_FLOAT
floating-point (single precision) value.

See Also:
Constant Field Values

SAMPLE_DOUBLE

static final int SAMPLE_DOUBLE
floating-point (double precision) value.

See Also:
Constant Field Values

SAMPLE_COMPLEX

static final int SAMPLE_COMPLEX
Complex number (double[2] array - uses double-sized array).

See Also:
Constant Field Values

SAMPLE_RGBA

static final int SAMPLE_RGBA
RGB color (packed into one integer).

See Also:
Constant Field Values

SAMPLE_TYPE

static final java.lang.String SAMPLE_TYPE
Property name: sample type.

See Also:
Constant Field Values

FREQUENCY

static final java.lang.String FREQUENCY
Property name: frequency (in Hz).

See Also:
Constant Field Values
Method Detail

resetData

void resetData(int type,
               boolean mapped,
               int[] dim)
(Re-)initialize the data array.

Parameters:
type - Sample type (one of SAMPLE_* constants).
mapped - Should the array contain mapped values?
dim - Dimensions of an array.
See Also:
SAMPLE_BYTE, SAMPLE_SHORT, SAMPLE_INT, SAMPLE_LONG, SAMPLE_FLOAT, SAMPLE_DOUBLE, SAMPLE_COMPLEX, SAMPLE_RGBA

getSampleType

int getSampleType()
Returns actual sample type (SAMPLE_* constant).

Returns:
Sample type (SAMPLE_* constant).
See Also:
getDataDim(int[]), SAMPLE_BYTE, SAMPLE_SHORT, SAMPLE_INT, SAMPLE_LONG, SAMPLE_FLOAT, SAMPLE_DOUBLE, SAMPLE_COMPLEX, SAMPLE_RGBA

getDataDim

int getDataDim(int[] dim)
Returns actual array dimensions.

Parameters:
dim - Pre-allocated array to hold individual dimensions' sizes.
Returns:
Dimensionality (number of dimensions).
See Also:
getSampleType()

setSampleGeometry

void setSampleGeometry(double[] geom)
Sets the sample geometry (in regular sample matrix).

Parameters:
geom - Sample periods for all dimensions.
See Also:
getSampleGeometry(double[])

getSampleGeometry

void getSampleGeometry(double[] geom)
Gets the sample geometry (in regular sample matrix).

Parameters:
geom - Sample periods for all dimensions.
See Also:
setSampleGeometry(double[])

setSampleMapping

void setSampleMapping(java.lang.Object map,
                      int srcFrom,
                      int srcTo,
                      int dstFrom)
Sets (partially) the new sample mapping (for mapped arrays only).

Parameters:
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.
See Also:
getSampleMapping(java.lang.Object, int, int, int[])

getSampleMapping

java.lang.Object getSampleMapping(java.lang.Object map,
                                  int srcFrom,
                                  int srcTo,
                                  int[] bounds)
Retrieves the whole sample mapping (for mapped arrays only).

Parameters:
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).
See Also:
setSampleMapping(java.lang.Object, int, int, int)

getDataArray

java.lang.Object getDataArray(int[] dim)
Returns the original data array.

Parameters:
dim - Returned dimensionality (array of individual dimension sizes). Can be null.
Returns:
Packed 1D sample array (read / write access) or null if the service is not available.
See Also:
setDataArray(java.lang.Object, int, int[], int[])

setDataArray

void setDataArray(java.lang.Object data,
                  int srcFrom,
                  int[] dstFrom,
                  int[] dstTo)
Sets data array in the raw (internal) format. Can be used for data fragment or for the whole data array.

Parameters:
data - Packed 1D source data array (of apropriate type - integer has to be used for mapped types).
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).

getSamplesGeneral

int getSamplesGeneral(int[] from,
                      int[] to,
                      java.lang.Object data)
Reads the given sample segment (general data format).

Parameters:
from - Starting index.
to - Index after retrieved data.
data - Pre-allocated array to hold the result (packed 1D array).
Returns:
Number of returned samples.

setSamplesGeneral

void setSamplesGeneral(int[] from,
                       int[] to,
                       java.lang.Object data)
Writes the given sample segment (general data format).

Parameters:
from - Starting index.
to - Index after the written data.
data - Data to be written - in 1D array (integer indices for mapped data arrays).

getSamples

int getSamples(int[] from,
               int[] to,
               int[] data)
Reads the given sample segment (integer formats: byte, short, int, RGBA).

Parameters:
from - Starting index.
to - Index after retrieved data.
data - Pre-allocated array to hold the result.
Returns:
Number of returned samples.

getSamples

int getSamples(int[] from,
               int[] to,
               long[] data)
Reads the given sample segment (long format).

Parameters:
from - Starting index.
to - Index after retrieved data.
data - Pre-allocated array to hold the result.
Returns:
Number of returned samples.

getSamples

int getSamples(int[] from,
               int[] to,
               double[] data)
Reads the given sample segment (float formats: float, double, complex).

Parameters:
from - Starting index.
to - Index after retrieved data.
data - Pre-allocated array to hold the result (complex uses double-sized array).
Returns:
Number of returned samples.

setSamples

void setSamples(int[] from,
                int[] to,
                int[] data)
Writes the given sample segment (integer formats: byte, short, int, RGBA).

Parameters:
from - Starting index.
to - Index after written data.
data - Data to be written (1D array).

setSamples

void setSamples(int[] from,
                int[] to,
                long[] data)
Writes the given sample segment (long format).

Parameters:
from - Starting index.
to - Index after written data.
data - Data to be written (1D array).

setSamples

void setSamples(int[] from,
                int[] to,
                double[] data)
Writes the given sample segment (float formats: float, double, complex).

Parameters:
from - Starting index.
to - Index after written data.
data - Data to be written (1D array). Complex uses double-sized array.