Advice for variable sampling rate?


#1

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(R.id.eeg_tp9);
TextView fp1 = (TextView)findViewById(R.id.eeg_af7);
TextView fp2 = (TextView)findViewById(R.id.eeg_af8);
TextView tp10 = (TextView)findViewById(R.id.eeg_tp10);
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(R.id.tempoview);
    tempoview.setText(String.valueOf(tempo));

    TextView diceview = (TextView)findViewById(R.id.diceview);
    diceview.setText(String.valueOf(dice-1));

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

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 :)!