Back to project page Visu.
The source code is released under:
Apache License
If you think the Android project Visu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/***************************************************************************************** * StorageBuffer.java * * Buffer de almacenamiento. * ****************************************************************************************/ /*ww w. j a va 2s . c o m*/ package com.ufavaloro.android.visu.storage; import java.util.ArrayList; import com.ufavaloro.android.visu.storage.datatypes.AcquisitionData; public class SamplesBuffer { // Buffer private short[] mSamplesBuffer; // Puntero de almacenamiento private int mStoringIndex; // Tiempo de guardado en segundos private double mSaveTime = 5; /***************************************************************************************** * M?todos principales * *****************************************************************************************/ // Constructor public SamplesBuffer(AcquisitionData acquisitionData, String units) { double fs = acquisitionData.getFs(); double ts = 1 / fs; int samplesPerPackage = acquisitionData.getSamplesPerPackage(); int i = 0; while(i*samplesPerPackage*ts < mSaveTime) i++; mSamplesBuffer = new short[i * samplesPerPackage]; } public SamplesBuffer() { // TODO Auto-generated constructor stub } // M?todo para almacenar muestras public void storeSamples(short[] x) { // Almaceno for(int i=0; i<x.length; i++) { mSamplesBuffer[mStoringIndex] = x[i]; // Incremento ?ndices mStoringIndex++; // Si llego al m?ximo, pongo ?ndices en cero if(mStoringIndex == mSamplesBuffer.length) mStoringIndex = 0; } } /***************************************************************************************** * Getters * *****************************************************************************************/ public int getStoringIndex() { return mStoringIndex; } public int getSize() { return mSamplesBuffer.length; } public short[] getBuffer() { return mSamplesBuffer; } public void createSamplesBuffer(ArrayList<Short> samplesBuffer) { mSamplesBuffer = new short[samplesBuffer.size()]; for(int i = 0; i < samplesBuffer.size(); i++) { mSamplesBuffer[i] = samplesBuffer.get(i); } } }//StoringBuffer