use of com.xenoage.utils.jse.settings.Settings in project Zong by Xenoage.
the class AudioSettingsDialog method initialize.
public void initialize() {
// fill device names and select default value
List<String> deviceNames = SynthManager.getAudioMixers();
deviceNames.add(0, Lang.get(Voc.Default));
cmbDeviceName.setItems(observableArrayList(deviceNames));
cmbDeviceName.getSelectionModel().select(0);
// fill other settings
cmbSampleRateHz.setItems(observableArrayList("11025", "22050", "44100"));
cmbSampleRateHz.getSelectionModel().select(2);
cmbChannels.setItems(observableArrayList("1", "2"));
cmbChannels.getSelectionModel().select(1);
cmbBits.setItems(observableArrayList("8", "16"));
cmbBits.getSelectionModel().select(1);
cmbLatencyMs.setItems(observableArrayList("100", "200", "400", "800"));
cmbLatencyMs.getSelectionModel().select(0);
cmbMaxPolyphony.setItems(observableArrayList("32", "64", "96", "128", "256"));
cmbMaxPolyphony.getSelectionModel().select(1);
cmbInterpolation.setItems(observableArrayList(Lang.get(Voc.Linear), Lang.get(Voc.Cubic), Lang.get(Voc.Sinc), Lang.get(Voc.Point)));
cmbInterpolation.getSelectionModel().select(0);
// fill with current values, if available
Settings s = Settings.getInstance();
String file = SynthManager.configFile;
setValue(cmbDeviceName, s.getSetting("devicename", file));
setValue(cmbSampleRateHz, s.getSetting("samplerate", file));
setValue(cmbChannels, s.getSetting("channels", file));
setValue(cmbBits, s.getSetting("bits", file));
setValue(cmbLatencyMs, s.getSetting("latency", file));
setValue(cmbMaxPolyphony, s.getSetting("polyphony", file));
setValue(cmbInterpolation, s.getSetting("interpolation", file));
String soundbank = s.getSetting("soundbank", file);
if (soundbank != null && soundbank.length() > 0) {
try {
File soundbankFile = new File(soundbank);
if (soundbankFile.exists()) {
soundbankPath = soundbankFile.getAbsolutePath();
lblSoundbank.setText(soundbankFile.getName());
}
} catch (Exception ex) {
}
}
}
use of com.xenoage.utils.jse.settings.Settings in project Zong by Xenoage.
the class AudioSettingsDialog method onOK.
@FXML
void onOK(ActionEvent event) {
Settings s = Settings.getInstance();
String file = SynthManager.configFile;
s.setSetting("devicename", file, cmbDeviceName.getSelectionModel().getSelectedIndex() == 0 ? "" : getValue(cmbDeviceName));
s.setSetting("samplerate", file, getValue(cmbSampleRateHz));
s.setSetting("channels", file, getValue(cmbChannels));
s.setSetting("bits", file, getValue(cmbBits));
s.setSetting("latency", file, getValue(cmbLatencyMs));
s.setSetting("polyphony", file, getValue(cmbMaxPolyphony));
s.setSetting("interpolation", file, getValue(cmbInterpolation));
s.setSetting("soundbank", file, soundbankPath);
s.save(file);
onOK();
}
use of com.xenoage.utils.jse.settings.Settings in project Zong by Xenoage.
the class SynthManager method init.
/**
* Initializes the manager. Must be called at the beginning one time
* and each time when the audio settings should be reloaded.
* @param readSettings true, to load the settings from the configuration file.
* false, to use default settings (e.g. for an applet)
*/
public static void init(boolean readSettings) throws MidiUnavailableException {
// TIDY method (especially default settings)
if (instance == null) {
instance = new SynthManager();
}
if (readSettings) {
// load settings (or use default ones)
Settings s = Settings.getInstance();
String file = configFile;
String deviceName = s.getSetting("devicename", file);
float sampleRate = s.getSetting("samplerate", file, 44100);
int sampleSizeInBits = s.getSetting("bits", file, 16);
int channels = s.getSetting("channels", file, 2);
int latency = s.getSetting("latency", file, 100);
int polyphony = s.getSetting("polyphony", file, 64);
String interpolation = s.getSetting("interpolation", file, "linear");
String soundbank = s.getSetting("soundbank", file, null);
// init midi and soundbank
instance.initMidi(sampleRate, sampleSizeInBits, channels, latency, polyphony, deviceName, interpolation);
if (soundbank != null && soundbank.length() > 0) {
try {
instance.loadSoundbank(new File(soundbank));
} catch (InvalidFormatException ex) {
// TODO
}
}
} else {
instance.initMidi(44100, 16, 2, 100, 64, null, "linear");
}
}
Aggregations