added global stereo option to AudioDialog (TODO: use it)

removed '(*)' from AudioDialog (TODO: make everything immediate)
updated -help (this seems broken!)
This commit is contained in:
thrust26 2018-08-20 11:55:13 +02:00
parent 915e62f466
commit fb6c827470
5 changed files with 72 additions and 27 deletions

View File

@ -146,6 +146,13 @@ AudioSettings::ResamplingQuality AudioSettings::resamplingQuality()
return customSettings() ? normalizeResamplingQuality(mySettings->getInt(SETTING_RESAMPLING_QUALITY)) : myPresetResamplingQuality;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string AudioSettings::stereo() const
{
// 0 is a valid value -> keep it
return mySettings->getString(SETTING_STEREO);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 AudioSettings::volume() const
{
@ -253,6 +260,14 @@ void AudioSettings::setResamplingQuality(AudioSettings::ResamplingQuality resamp
normalize(*mySettings);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioSettings::setStereo(const string& mode)
{
if(!myIsPersistent) return;
mySettings->setValue(SETTING_STEREO, mode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioSettings::setVolume(uInt32 volume)
{

View File

@ -46,6 +46,7 @@ class AudioSettings
static constexpr const char* SETTING_BUFFER_SIZE = "audio.buffer_size";
static constexpr const char* SETTING_HEADROOM = "audio.headroom";
static constexpr const char* SETTING_RESAMPLING_QUALITY = "audio.resampling_quality";
static constexpr const char* SETTING_STEREO = "audio.stereo";
static constexpr const char* SETTING_VOLUME = "audio.volume";
static constexpr const char* SETTING_ENABLED = "audio.enabled";
@ -55,6 +56,7 @@ class AudioSettings
static constexpr uInt32 DEFAULT_BUFFER_SIZE = 3;
static constexpr uInt32 DEFAULT_HEADROOM = 2;
static constexpr ResamplingQuality DEFAULT_RESAMPLING_QUALITY = ResamplingQuality::lanczos_2;
static constexpr const char* DEFAULT_STEREO = "BYROM";
static constexpr uInt32 DEFAULT_VOLUME = 80;
static constexpr bool DEFAULT_ENABLED = true;
@ -81,6 +83,8 @@ class AudioSettings
ResamplingQuality resamplingQuality();
string stereo() const;
uInt32 volume() const;
bool enabled() const;
@ -97,6 +101,8 @@ class AudioSettings
void setResamplingQuality(ResamplingQuality resamplingQuality);
void setStereo(const string& mode);
void setVolume(uInt32 volume);
void setEnabled(bool isEnabled);

View File

@ -70,13 +70,14 @@ Settings::Settings(OSystem& osystem)
// Sound options
setInternal(AudioSettings::SETTING_ENABLED, AudioSettings::DEFAULT_ENABLED);
setInternal(AudioSettings::SETTING_VOLUME, AudioSettings::DEFAULT_VOLUME);
setInternal(AudioSettings::SETTING_STEREO, AudioSettings::DEFAULT_STEREO);
setInternal(AudioSettings::SETTING_PRESET, static_cast<int>(AudioSettings::DEFAULT_PRESET));
setInternal(AudioSettings::SETTING_SAMPLE_RATE, AudioSettings::DEFAULT_SAMPLE_RATE);
setInternal(AudioSettings::SETTING_FRAGMENT_SIZE, AudioSettings::DEFAULT_FRAGMENT_SIZE);
setInternal(AudioSettings::SETTING_BUFFER_SIZE, AudioSettings::DEFAULT_BUFFER_SIZE);
setInternal(AudioSettings::SETTING_HEADROOM, AudioSettings::DEFAULT_HEADROOM);
setInternal(AudioSettings::SETTING_RESAMPLING_QUALITY, static_cast<int>(AudioSettings::DEFAULT_RESAMPLING_QUALITY));
setInternal(AudioSettings::SETTING_VOLUME, AudioSettings::DEFAULT_VOLUME);
// Input event options
setInternal("keymap", "");
@ -445,13 +446,15 @@ void Settings::usage() const
<< endl
#ifdef SOUND_SUPPORT
<< " -audio.enabled <1|0> Enable audio\n"
<< " -audio.volume <number> Vokume (0 -- 100)\n"
<< " -audio.stereo <byrom|mono| Enable stereo mode\n"
<< " stereo>\n"
<< " -audio.preset <1-5> Audio preset (or 1 for custom)\n"
<< " -audio.sample_rate <number> Output sample rate (44100|48000|96000)\n"
<< " -audio.fragment_size <number> Fragment size (128|256|512|1024|2048|4096)\n"
<< " -audio.buffer_size <number> Max. number of additional half-frames to buffer (0 -- 20)\n"
<< " -audio.headroom <number> Additional half-frames to prebuffer (0 -- 20)\n"
<< " -audio.resampling_quality <1-3> Resampling quality\n"
<< " -audio.volume <number> Vokume (0 -- 100)\n"
<< endl
#endif
<< " -tia.zoom <zoom> Use the specified zoom level (windowed mode) for TIA image\n"

View File

@ -41,19 +41,20 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
const int VBORDER = 10;
const int HBORDER = 10;
const int INDENT = 20;
const int VGAP = 4;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight();
int xpos, ypos;
int lwidth = font.getStringWidth("Resampling quality "),
pwidth = font.getStringWidth("512 bytes");
int lwidth = font.getStringWidth("Volume "),
pwidth;
WidgetArray wid;
VariantList items;
// Set real dimensions
_w = 46 * fontWidth + HBORDER * 2;
_h = 11 * (lineHeight + 4) + VBORDER + _th;
_h = 11 * (lineHeight + VGAP) + VBORDER + _th;
xpos = HBORDER; ypos = VBORDER + _th;
@ -62,18 +63,31 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
mySoundEnableCheckbox = new CheckboxWidget(this, font, xpos, ypos,
"Enable sound", kSoundEnableChanged);
wid.push_back(mySoundEnableCheckbox);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
xpos += INDENT;
// Volume
myVolumeSlider = new SliderWidget(this, font, xpos, ypos,
"Volume ", 0, 0, 4 * fontWidth, "%");
"Volume", lwidth, 0, 4 * fontWidth, "%");
myVolumeSlider->setMinValue(1); myVolumeSlider->setMaxValue(100);
myVolumeSlider->setTickmarkInterval(4);
wid.push_back(myVolumeSlider);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
//
// Stereo sound
VarList::push_back(items, "By ROM", "BYROM");
VarList::push_back(items, "Off", "MONO");
VarList::push_back(items, "On", "STEREO");
pwidth = font.getStringWidth("By ROM");
myStereoSoundPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight,
items, "Stereo", lwidth);
wid.push_back(myStereoSoundPopup);
ypos += lineHeight + VGAP;
// Mode
items.clear();
VarList::push_back(items, "Low quality, medium lag", static_cast<int>(AudioSettings::Preset::lowQualityMediumLag));
VarList::push_back(items, "High quality, medium lag", static_cast<int>(AudioSettings::Preset::highQualityMediumLag));
VarList::push_back(items, "High quality, low lag", static_cast<int>(AudioSettings::Preset::highQualityLowLag));
@ -81,12 +95,14 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
VarList::push_back(items, "Custom", static_cast<int>(AudioSettings::Preset::custom));
myModePopup = new PopUpWidget(this, font, xpos, ypos,
font.getStringWidth("Ultry quality, minimal lag"), lineHeight,
items, "Mode (*) ", 0, kModeChanged);
items, "Mode", lwidth, kModeChanged);
wid.push_back(myModePopup);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
xpos += INDENT;
// Fragment size
pwidth = font.getStringWidth("512 bytes");
lwidth = font.getStringWidth("Resampling quality ");
items.clear();
VarList::push_back(items, "128 bytes", 128);
VarList::push_back(items, "256 bytes", 256);
@ -98,7 +114,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
pwidth, lineHeight,
items, "Fragment size (*) ", lwidth);
wid.push_back(myFragsizePopup);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
// Output frequency
items.clear();
@ -109,7 +125,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
pwidth, lineHeight,
items, "Sample rate (*) ", lwidth);
wid.push_back(myFreqPopup);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
// Resampling quality
items.clear();
@ -120,7 +136,7 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
pwidth, lineHeight,
items, "Resampling quality ", lwidth);
wid.push_back(myResamplingPopup);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
// Param 1
int swidth = pwidth+23;
@ -128,9 +144,8 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
"Headroom ", 0, kHeadroomChanged, 10 * fontWidth);
myHeadroomSlider->setMinValue(0); myHeadroomSlider->setMaxValue(AudioSettings::MAX_HEADROOM);
myHeadroomSlider->setTickmarkInterval(3);
wid.push_back(myHeadroomSlider);
ypos += lineHeight + 4;
ypos += lineHeight + VGAP;
// Param 2
myBufferSizeSlider = new SliderWidget(this, font, xpos, ypos, swidth, lineHeight,
@ -139,11 +154,6 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
myBufferSizeSlider->setTickmarkInterval(3);
wid.push_back(myBufferSizeSlider);
// Add message concerning usage
ypos = _h - fontHeight * 2 - 24;
const GUI::Font& infofont = instance().frameBuffer().infoFont();
new StaticTextWidget(this, infofont, HBORDER, ypos, "(*) Requires application restart");
// Add Defaults, OK and Cancel buttons
addDefaultsOKCancelBGroup(wid, font);
@ -155,11 +165,14 @@ void AudioDialog::loadConfig()
{
AudioSettings& audioSettings = instance().audioSettings();
// Enable sound
mySoundEnableCheckbox->setState(audioSettings.enabled());
// Volume
myVolumeSlider->setValue(audioSettings.volume());
// Enable sound
mySoundEnableCheckbox->setState(audioSettings.enabled());
// Stereo
myStereoSoundPopup->setSelected(audioSettings.stereo());
// Preset / mode
myModePopup->setSelected(static_cast<int>(audioSettings.preset()));
@ -193,12 +206,17 @@ void AudioDialog::saveConfig()
{
AudioSettings& audioSettings = instance().audioSettings();
// Enabled
audioSettings.setEnabled(mySoundEnableCheckbox->getState());
instance().sound().setEnabled(mySoundEnableCheckbox->getState());
// Volume
audioSettings.setVolume(myVolumeSlider->getValue());
instance().sound().setVolume(myVolumeSlider->getValue());
audioSettings.setEnabled(mySoundEnableCheckbox->getState());
instance().sound().setEnabled(mySoundEnableCheckbox->getState());
// Stereo
audioSettings.setStereo(myStereoSoundPopup->getSelectedTag().toString());
//TODO: instance().sound().setStereo(myStereoSoundPopup->getSelectedTag().toString());
AudioSettings::Preset preset = static_cast<AudioSettings::Preset>(myModePopup->getSelectedTag().toInt());
audioSettings.setPreset(preset);
@ -222,12 +240,13 @@ void AudioDialog::saveConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioDialog::setDefaults()
{
myResamplingPopup->setSelected(static_cast<int>(AudioSettings::DEFAULT_RESAMPLING_QUALITY));
myVolumeSlider->setValue(AudioSettings::DEFAULT_VOLUME);
mySoundEnableCheckbox->setState(AudioSettings::DEFAULT_ENABLED);
myVolumeSlider->setValue(AudioSettings::DEFAULT_VOLUME);
myStereoSoundPopup->setSelected(AudioSettings::DEFAULT_STEREO);
myModePopup->setSelected(static_cast<int>(AudioSettings::DEFAULT_PRESET));
if (AudioSettings::DEFAULT_PRESET == AudioSettings::Preset::custom) {
myResamplingPopup->setSelected(static_cast<int>(AudioSettings::DEFAULT_RESAMPLING_QUALITY));
myFragsizePopup->setSelected(AudioSettings::DEFAULT_FRAGMENT_SIZE);
myFreqPopup->setSelected(AudioSettings::DEFAULT_SAMPLE_RATE);
myHeadroomSlider->setValue(AudioSettings::DEFAULT_HEADROOM);
@ -246,6 +265,7 @@ void AudioDialog::updateEnabledState()
bool userMode = preset == AudioSettings::Preset::custom;
myVolumeSlider->setEnabled(active);
myStereoSoundPopup->setEnabled(active);
myModePopup->setEnabled(active);
myFragsizePopup->setEnabled(active && userMode);

View File

@ -62,6 +62,7 @@ class AudioDialog : public Dialog
PopUpWidget* myResamplingPopup;
SliderWidget* myHeadroomSlider;
SliderWidget* myBufferSizeSlider;
PopUpWidget* myStereoSoundPopup;
private:
// Following constructors and assignment operators not supported