way of saving improved

This commit is contained in:
Harrison Deng 2017-09-10 21:16:47 -05:00
parent 1b61d8ba50
commit d257d2df60
2 changed files with 9 additions and 9 deletions

View File

@ -28,9 +28,9 @@ public class HorizontalVisualizer extends VisualizerCore {
bar = new Texture(pixmap);
pixmap.dispose();
barCount = 70;
barWidth = MathUtils.round(width/barCount);
barWidth = MathUtils.ceil(width/barCount);
spaceBetweenBars = 10;
barWidth -= spaceBetweenBars/2;
barWidth -= spaceBetweenBars;
smoothRange = 4;
barHeights = new int[barCount];
}
@ -44,7 +44,6 @@ public class HorizontalVisualizer extends VisualizerCore {
barHeights[i] += Math.abs(audioPCM[j+i*binsPerBar]);
}
barHeights[i] /= binsPerBar;
barHeights[i] ++;
barHeights[i] *= 5;
}
@ -69,7 +68,7 @@ public class HorizontalVisualizer extends VisualizerCore {
@Override
public void setMDP(MusicDataPack mdp) {
super.setMDP(mdp);
float validBins = (4000/((mdp.getSampleRate()/2)/((audioPCM.length/2)+1)));
float validBins = (5000/((mdp.getSampleRate()/2)/((audioPCM.length/2)+1)));
Gdx.app.debug("Visualizer", "valid frequency bins " + validBins);
binsPerBar = MathUtils.round((validBins/barCount));
}

View File

@ -27,7 +27,7 @@ public class OptionsPage extends Page {
private ProgressBar fxVolSlider;
private TextField directoryField;
public OptionsPage(final RhythmBullet core, final Vector3 targetPosition, final MoreOptionsPage moreOptionsPage, SongController sc) {
public OptionsPage(RhythmBullet core, Vector3 targetPosition, MoreOptionsPage moreOptionsPage, SongController sc) {
optionsTable.defaults().spaceLeft(40f).padTop(5f).padBottom(5f).left();
Label optionGeneralTitle = new Label("General", core.getDefaultSkin(), "large-font", core.getDefaultSkin().getColor("default"));
@ -38,7 +38,7 @@ public class OptionsPage extends Page {
Label musicVolSliderLabel = new Label("Music Volume: ", core.getDefaultSkin());
optionsTable.add(musicVolSliderLabel).padRight(12f).left();
musicVolSlider = new Slider(0, 100, 0.1f, false, core.getDefaultSkin());
musicVolSlider.setValue(core.getPrefs().getFloat("music vol", 100f));
musicVolSlider.setValue(core.getPrefs().getFloat("music vol", 100f)*100f);
optionsTable.add(musicVolSlider).prefWidth(790).left();
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", core.getDefaultSkin());
musicVolSlider.addListener(new ChangeListener() {
@ -46,6 +46,8 @@ public class OptionsPage extends Page {
public void changed(ChangeEvent event, Actor actor) {
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
sc.getCurrentSong().getPlaybackMusic().setVolume(musicVolSlider.getPercent());
core.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
}
});
optionsTable.add(musicVolPercentage).expandX();
@ -55,13 +57,14 @@ public class OptionsPage extends Page {
Label fxVolSliderLabel = new Label("FX Volume: ", core.getDefaultSkin());
optionsTable.add(fxVolSliderLabel).padRight(12f).left();
fxVolSlider = new Slider(0, 100, 1, false, core.getDefaultSkin());
fxVolSlider.setValue(core.getPrefs().getFloat("fx vol", 100f));
fxVolSlider.setValue(core.getPrefs().getFloat("fx vol", 100f)*100f);
optionsTable.add(fxVolSlider).prefWidth(790);
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", core.getDefaultSkin());
fxVolSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
core.getPrefs().putFloat("fx vol", fxVolSlider.getPercent());
}
});
@ -140,8 +143,6 @@ public class OptionsPage extends Page {
public void saveOptions(Preferences prefs) {
Gdx.app.debug("Preferences", "Saved all basic options page values.");
prefs.putFloat("music vol", musicVolSlider.getPercent());
prefs.putFloat("fx vol", fxVolSlider.getPercent());
prefs.putString("music dir", directoryField.getText());
}
}