Advice for variable sampling rate?


Im trying to write an Android app that allows the user to record and export data at a rate of their choosing, but Im having trouble getting around the sampling rate - as soon as samples per second get over thirty or so, the output data gets lots of identical results - any advice on this? My code is based off the testlibmuse android project.

I think the problem is that I’m taking data from the buffer which only updates sixty or so times per second - hence when I sample the buffer in the snippet below I often read the same value twice.

private void updateEeg() {
TextView tp9 = (TextView)findViewById(;
TextView fp1 = (TextView)findViewById(;
TextView fp2 = (TextView)findViewById(;
TextView tp10 = (TextView)findViewById(;
tp9.setText(String.format("%6.2f", eegBuffer[0]));
fp1.setText(String.format("%6.2f", eegBuffer[1]));
fp2.setText(String.format("%6.2f", eegBuffer[2]));
tp10.setText(String.format("%6.2f", eegBuffer[3]));

    TextView tempoview = (TextView)findViewById(;

    TextView diceview = (TextView)findViewById(;

    dicevalue = (int)Math.round(eegBuffer[3]+eegBuffer[2]+eegBuffer[1]+eegBuffer[0])%dice;

Any advice on how to either get the eegBuffer values to update more often or how to replace them with the raw data packets? I’m still rather new to Java.

Thanks for your help :)!