Пример #1
0
        public int[,] getIntData(int first, int last)
        {
            DataDescription dd  = new DataDescription();
            ByteBuffer      buf = getRawData(first, last, dd);

            int nSamples = dd.nSamples;
            int nChans   = dd.nChans;

            int[,] data = new int[nSamples, nChans];

            switch (dd.dataType)
            {
            case DataType.INT8:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (int)buf.get();
                    }
                }
                break;

            case DataType.INT16:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (int)buf.getShort();
                    }
                }
                break;

            case DataType.INT32:
                IntBuffer iBuf = buf.asIntBuffer();
                int[]     rowData;
                for (int n = 0; n < nSamples; n++)
                {
                    rowData = getRow <int>(data, n);
                    iBuf.get(rowData);
                }
                break;

            default:
                throw new IOException("Not supported yet - returning zeros.");
                break;
            }

            return(data);
        }
Пример #2
0
        public double[,] getDoubleData(int first, int last)
        {
            DataDescription dd  = new DataDescription();
            ByteBuffer      buf = getRawData(first, last, dd);

            int nSamples = dd.nSamples;
            int nChans   = dd.nChans;

            double[,] data = new double[nSamples, nChans];

            switch (dd.dataType)
            {
            case DataType.INT8:
                for (int i = 0; i < nSamples; i++)
                {
                    //data[i] = new double[nChans];
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (double)buf.get();
                    }
                }
                break;

            case DataType.INT16:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (double)buf.getShort();
                    }
                }
                break;

            case DataType.INT32:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (double)buf.getInt();
                    }
                }
                break;

            case DataType.INT64:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (double)buf.getLong();
                    }
                }
                break;

            case DataType.FLOAT32:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = buf.getFloat();
                    }
                }
                break;

            case DataType.FLOAT64:
                DoubleBuffer dBuf = buf.asDoubleBuffer();
                double[]     rowData;
                for (int n = 0; n < nSamples; n++)
                {
                    rowData = getRow <double>(data, n);
                    dBuf.get(rowData);
                }
                break;

            default:
                throw new IOException("Not supported yet - returning zeros.");
                break;
            }

            return(data);
        }
Пример #3
0
        public float[,] getFloatData(int first, int last)
        {
            DataDescription dd  = new DataDescription();
            ByteBuffer      buf = getRawData(first, last, dd);

            int nSamples = dd.nSamples;
            int nChans   = dd.nChans;

            float[,] data = new float[nSamples, nChans];

            switch (dd.dataType)
            {
            case DataType.INT8:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (float)buf.get();
                    }
                }
                break;

            case DataType.INT16:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (float)buf.getShort();
                    }
                }
                break;

            case DataType.INT32:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (float)buf.getInt();
                    }
                }
                break;

            case DataType.FLOAT32:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (float)buf.getFloat();
                    }
                }
                break;

            case DataType.FLOAT64:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (float)buf.getDouble();
                    }
                }
                break;

            default:
                throw new IOException("Not supported yet - returning zeros.");
                break;
            }

            return(data);
        }