Adds capability to persist spectral display fft size and frame rate

between sessions.
This commit is contained in:
denny
2016-01-23 14:07:01 -05:00
parent 94d85f636d
commit c922029233
4 changed files with 57 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ import org.jtransforms.fft.FloatFFT_1D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import properties.SystemProperties;
import sample.Buffer;
import sample.Listener;
import sample.SampleType;
@@ -61,6 +62,8 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
private ScheduledExecutorService mScheduler = Executors
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
public static final String FRAME_RATE_PROPERTY = "spectral.display.frame.rate";
private DFTSize mDFTSize = DFTSize.FFT04096;
private DFTSize mNewDFTSize = DFTSize.FFT04096;
@@ -89,7 +92,16 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
public DFTProcessor( SampleType sampleType )
{
setSampleType( sampleType );
setFrameRate( 20 );
loadSettings();
}
private void loadSettings()
{
int frameRate = SystemProperties.getInstance()
.get( DFTProcessor.FRAME_RATE_PROPERTY, 20 );
setFrameRate( frameRate );
}
public void dispose()
@@ -171,6 +183,10 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
mFrameRate = framesPerSecond;
SystemProperties properties = SystemProperties.getInstance();
properties.set( FRAME_RATE_PROPERTY, String.valueOf( mFrameRate ) );
properties.save();
calculateConsumptionRate();
restart();