mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
feat(settings): the simulator's OpenAL Soft options in the sound category
A new "Sound device and effects" section sets the eu07.ini keys the simulator reads for OpenAL Soft: sound.openal.renderer (device), sound.outputmode, sound.hrtf, sound.hrtf.profile, sound.resampler, sound.limiter, sound.frequency, sound.doppler, sound.efx.lowpass and sound.efx.airabsorption. The lists of devices, HRTF data sets and resamplers come from the OpenAL library in the game folder (OpenAL32.dll / libopenal.so.1), read in the background through NativeLibrary and function pointers (AllowUnsafeBlocks); without it, or with an older library, the lists hold the file's value and the library's choice. Names with spaces are written in quotes, an empty name takes its line out, and a key the file lacks is written only when it differs from the simulator's default, so saving with these left alone adds nothing. sound.maxsources is left out: OpenAL Soft gives at least 256 sources whatever is asked, so it would be a setting that does nothing; a line the file has stays as it is. A device name code page 1250 cannot hold, the encoding of eu07.ini, is not offered, as it would reach the simulator as question marks. HRTF data sets and resamplers are offered only with ASCII names, since the simulator looks those up by the library's own spelling. A value a slider can't show, outside its range or between its ticks, is kept by the page's shown-unlike bookkeeping until the slider is moved. Strings in en and pl with descriptions, labels in cz, hu and ru.
This commit is contained in:
@@ -1520,4 +1520,75 @@ public class SettingsStoreTests
|
||||
|
||||
Assert.Null(LineFor(installation, "blackbox"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_sound_device_options_left_alone_add_nothing_to_the_file()
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "width 1920\n"));
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = SavedLines(installation);
|
||||
foreach (var key in new[] { "sound.openal.renderer", "sound.outputmode", "sound.hrtf", "sound.hrtf.profile",
|
||||
"sound.resampler", "sound.limiter", "sound.frequency", "sound.maxsources",
|
||||
"sound.doppler", "sound.efx.lowpass", "sound.efx.airabsorption" })
|
||||
Assert.Null(LineFor(installation, key));
|
||||
Assert.Contains("width 1920\n", saved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_sound_device_options_survive_a_round_trip_with_names_in_quotes()
|
||||
{
|
||||
var installation = WithHome();
|
||||
installation.SettingsStore.Load();
|
||||
var s = installation.SettingsStore.Settings;
|
||||
s.AudioDevice = "OpenAL Soft on Speakers (Realtek(R) Audio)";
|
||||
s.AudioOutputMode = "headphones";
|
||||
s.AudioHrtf = "on";
|
||||
s.AudioHrtfProfile = "Built-In HRTF";
|
||||
s.AudioResampler = "Cubic";
|
||||
s.AudioLimiter = "off";
|
||||
s.AudioFrequency = 48000;
|
||||
s.AudioDoppler = 0.5;
|
||||
s.AudioLowpass = true;
|
||||
s.AudioAirAbsorption = 1.0;
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Equal("sound.openal.renderer \"OpenAL Soft on Speakers (Realtek(R) Audio)\"",
|
||||
LineFor(installation, "sound.openal.renderer"));
|
||||
Assert.Equal("sound.resampler Cubic", LineFor(installation, "sound.resampler"));
|
||||
Assert.Empty(BareSimulatorKeys(installation));
|
||||
|
||||
var again = WithHome(new InMemoryFileSystem().WithFile(UserIni, installation.Files.ReadAllText(UserIni)));
|
||||
again.SettingsStore.Load();
|
||||
var read = again.SettingsStore.Settings;
|
||||
Assert.Equal(s.AudioDevice, read.AudioDevice);
|
||||
Assert.Equal("headphones", read.AudioOutputMode);
|
||||
Assert.Equal("on", read.AudioHrtf);
|
||||
Assert.Equal("Built-In HRTF", read.AudioHrtfProfile);
|
||||
Assert.Equal("Cubic", read.AudioResampler);
|
||||
Assert.Equal("off", read.AudioLimiter);
|
||||
Assert.Equal(48000, read.AudioFrequency);
|
||||
Assert.Equal(0.5, read.AudioDoppler, 6);
|
||||
Assert.True(read.AudioLowpass);
|
||||
Assert.Equal(1.0, read.AudioAirAbsorption, 6);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_sound_name_set_back_to_the_librarys_choice_takes_its_line_out()
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem()
|
||||
.WithFile(UserIni, "sound.openal.renderer \"Old Device\"\nsound.resampler Cubic\n"));
|
||||
installation.SettingsStore.Load();
|
||||
Assert.Equal("Old Device", installation.SettingsStore.Settings.AudioDevice);
|
||||
|
||||
installation.SettingsStore.Settings.AudioDevice = "";
|
||||
installation.SettingsStore.Settings.AudioResampler = "";
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Null(LineFor(installation, "sound.openal.renderer"));
|
||||
Assert.Null(LineFor(installation, "sound.resampler"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user