예제 #1
0
        public short[,] getShortData(int first, int last)
        {
            DataDescription dd  = new DataDescription();
            ByteBuffer      buf = getRawData(first, last, dd);

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

            short[,] data = new short[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] = (short)buf.get();
                    }
                }
                break;

            case DataType.INT16:
                ShortBuffer sBuf = buf.asShortBuffer();
                short[]     rowData;
                for (int n = 0; n < nSamples; n++)
                {
                    rowData = getRow <short>(data, n);
                    sBuf.get(rowData);
                }
                break;

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

            return(data);
        }
예제 #2
0
        //as functions
        public ShortBuffer asShortBuffer()
        {
            ShortBuffer shortbuffer = new ShortBuffer(this);

            return(shortbuffer);
        }