Added Qt GUI sound mute function. This function is accessible either via hot key or checkbox on sound config window. Mute state is a config parameter and will persist between application boots. Fixes issue #591
This commit is contained in:
parent
e06d1cd506
commit
739c01f051
|
@ -54,16 +54,21 @@ ConsoleSndConfDialog_t::ConsoleSndConfDialog_t(QWidget *parent)
|
||||||
|
|
||||||
// Enable Sound Select
|
// Enable Sound Select
|
||||||
enaChkbox = new QCheckBox(tr("Enable Sound"));
|
enaChkbox = new QCheckBox(tr("Enable Sound"));
|
||||||
|
// Speaker Mute Select
|
||||||
|
muteChkbox = new QCheckBox(tr("Mute Speaker Output"));
|
||||||
// Enable Low Pass Filter Select
|
// Enable Low Pass Filter Select
|
||||||
enaLowPass = new QCheckBox(tr("Enable Low Pass Filter"));
|
enaLowPass = new QCheckBox(tr("Enable Low Pass Filter"));
|
||||||
|
|
||||||
setCheckBoxFromProperty(enaChkbox, "SDL.Sound");
|
setCheckBoxFromProperty(enaChkbox, "SDL.Sound");
|
||||||
|
setCheckBoxFromProperty(muteChkbox, "SDL.Sound.Mute");
|
||||||
setCheckBoxFromProperty(enaLowPass, "SDL.Sound.LowPass");
|
setCheckBoxFromProperty(enaLowPass, "SDL.Sound.LowPass");
|
||||||
|
|
||||||
connect(enaChkbox, SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int)));
|
connect(enaChkbox, SIGNAL(stateChanged(int)), this, SLOT(enaSoundStateChange(int)));
|
||||||
|
connect(muteChkbox, SIGNAL(stateChanged(int)), this, SLOT(enaSpeakerMuteChange(int)));
|
||||||
connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int)));
|
connect(enaLowPass, SIGNAL(stateChanged(int)), this, SLOT(enaSoundLowPassChange(int)));
|
||||||
|
|
||||||
vbox1->addWidget(enaChkbox);
|
vbox1->addWidget(enaChkbox);
|
||||||
|
vbox1->addWidget(muteChkbox);
|
||||||
vbox1->addWidget(enaLowPass);
|
vbox1->addWidget(enaLowPass);
|
||||||
|
|
||||||
// Audio Quality Select
|
// Audio Quality Select
|
||||||
|
@ -330,6 +335,11 @@ void ConsoleSndConfDialog_t::periodicUpdate(void)
|
||||||
sprintf( stmp, "Sink Starve Count: %u", nes_shm->sndBuf.starveCounter );
|
sprintf( stmp, "Sink Starve Count: %u", nes_shm->sndBuf.starveCounter );
|
||||||
|
|
||||||
starveLbl->setText( tr(stmp) );
|
starveLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
if ( FCEUD_SoundIsMuted() != muteChkbox->isChecked() )
|
||||||
|
{
|
||||||
|
muteChkbox->setChecked( FCEUD_SoundIsMuted() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ConsoleSndConfDialog_t::setSliderEnables(void)
|
void ConsoleSndConfDialog_t::setSliderEnables(void)
|
||||||
|
@ -536,6 +546,11 @@ void ConsoleSndConfDialog_t::enaSoundStateChange(int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void ConsoleSndConfDialog_t::enaSpeakerMuteChange(int value)
|
||||||
|
{
|
||||||
|
FCEUD_MuteSoundOutput( value ? true : false );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void ConsoleSndConfDialog_t::enaSoundLowPassChange(int value)
|
void ConsoleSndConfDialog_t::enaSoundLowPassChange(int value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
|
|
@ -31,6 +31,7 @@ protected:
|
||||||
|
|
||||||
int sndQuality;
|
int sndQuality;
|
||||||
QCheckBox *enaChkbox;
|
QCheckBox *enaChkbox;
|
||||||
|
QCheckBox *muteChkbox;
|
||||||
QCheckBox *enaLowPass;
|
QCheckBox *enaLowPass;
|
||||||
QCheckBox *swapDutyChkbox;
|
QCheckBox *swapDutyChkbox;
|
||||||
QCheckBox *useGlobalFocus;
|
QCheckBox *useGlobalFocus;
|
||||||
|
@ -68,6 +69,7 @@ private slots:
|
||||||
void noiseChanged(int value);
|
void noiseChanged(int value);
|
||||||
void pcmChanged(int value);
|
void pcmChanged(int value);
|
||||||
void enaSoundStateChange(int value);
|
void enaSoundStateChange(int value);
|
||||||
|
void enaSpeakerMuteChange(int value);
|
||||||
void enaSoundLowPassChange(int value);
|
void enaSoundLowPassChange(int value);
|
||||||
void swapDutyCallback(int value);
|
void swapDutyCallback(int value);
|
||||||
void useGlobalFocusChanged(int value);
|
void useGlobalFocusChanged(int value);
|
||||||
|
|
|
@ -450,11 +450,11 @@ void consoleWin_t::winActiveChanged(void)
|
||||||
{
|
{
|
||||||
if ( hdl->isActive() )
|
if ( hdl->isActive() )
|
||||||
{
|
{
|
||||||
FCEUD_MuteSoundOutput(false);
|
FCEUD_MuteSoundWindow(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FCEUD_MuteSoundOutput(true);
|
FCEUD_MuteSoundWindow(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,6 +850,7 @@ void consoleWin_t::initHotKeys(void)
|
||||||
Hotkeys[HK_FRAME_ADVANCE].getShortcut()->setEnabled(false);
|
Hotkeys[HK_FRAME_ADVANCE].getShortcut()->setEnabled(false);
|
||||||
Hotkeys[HK_TURBO ].getShortcut()->setEnabled(false);
|
Hotkeys[HK_TURBO ].getShortcut()->setEnabled(false);
|
||||||
|
|
||||||
|
connect( Hotkeys[ HK_VOLUME_MUTE ].getShortcut(), SIGNAL(activated()), this, SLOT(muteSoundVolume(void)) );
|
||||||
connect( Hotkeys[ HK_VOLUME_DOWN ].getShortcut(), SIGNAL(activated()), this, SLOT(decrSoundVolume(void)) );
|
connect( Hotkeys[ HK_VOLUME_DOWN ].getShortcut(), SIGNAL(activated()), this, SLOT(decrSoundVolume(void)) );
|
||||||
connect( Hotkeys[ HK_VOLUME_UP ].getShortcut(), SIGNAL(activated()), this, SLOT(incrSoundVolume(void)) );
|
connect( Hotkeys[ HK_VOLUME_UP ].getShortcut(), SIGNAL(activated()), this, SLOT(incrSoundVolume(void)) );
|
||||||
|
|
||||||
|
@ -3704,6 +3705,13 @@ void consoleWin_t::setCustomAutoFire(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::muteSoundVolume(void)
|
||||||
|
{
|
||||||
|
FCEU_WRAPPER_LOCK();
|
||||||
|
FCEUD_SoundToggle();
|
||||||
|
FCEU_WRAPPER_UNLOCK();
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::incrSoundVolume(void)
|
void consoleWin_t::incrSoundVolume(void)
|
||||||
{
|
{
|
||||||
FCEU_WRAPPER_LOCK();
|
FCEU_WRAPPER_LOCK();
|
||||||
|
|
|
@ -405,6 +405,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void stopMovie(void);
|
void stopMovie(void);
|
||||||
void playMovieFromBeginning(void);
|
void playMovieFromBeginning(void);
|
||||||
void setCustomAutoFire(void);
|
void setCustomAutoFire(void);
|
||||||
|
void muteSoundVolume(void);
|
||||||
void incrSoundVolume(void);
|
void incrSoundVolume(void);
|
||||||
void decrSoundVolume(void);
|
void decrSoundVolume(void);
|
||||||
void toggleLagCounterDisplay(void);
|
void toggleLagCounterDisplay(void);
|
||||||
|
|
|
@ -295,11 +295,14 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut, const
|
||||||
case HK_SELECT_STATE_PREV:
|
case HK_SELECT_STATE_PREV:
|
||||||
name = "SelectStatePrev"; keySeq = ""; title = "Select Previous State Slot"; group = "State";
|
name = "SelectStatePrev"; keySeq = ""; title = "Select Previous State Slot"; group = "State";
|
||||||
break;
|
break;
|
||||||
|
case HK_VOLUME_MUTE:
|
||||||
|
name = "VolumeMute"; keySeq = ""; title = "Sound Volume Mute"; group = "Sound";
|
||||||
|
break;
|
||||||
case HK_VOLUME_DOWN:
|
case HK_VOLUME_DOWN:
|
||||||
name = "VolumeDown"; keySeq = "";
|
name = "VolumeDown"; keySeq = ""; title = "Sound Volume Down"; group = "Sound";
|
||||||
break;
|
break;
|
||||||
case HK_VOLUME_UP:
|
case HK_VOLUME_UP:
|
||||||
name = "VolumeUp"; keySeq = "";
|
name = "VolumeUp"; keySeq = ""; title = "Sound Volume Up"; group = "Sound";
|
||||||
break;
|
break;
|
||||||
case HK_FKB_ENABLE:
|
case HK_FKB_ENABLE:
|
||||||
name = "FKB_Enable"; keySeq = "ScrollLock"; title = "Toggle Family Keyboard Enable";
|
name = "FKB_Enable"; keySeq = "ScrollLock"; title = "Toggle Family Keyboard Enable";
|
||||||
|
@ -489,6 +492,7 @@ InitConfig()
|
||||||
|
|
||||||
// sound options
|
// sound options
|
||||||
config->addOption('s', "sound", "SDL.Sound", 1);
|
config->addOption('s', "sound", "SDL.Sound", 1);
|
||||||
|
config->addOption("soundMute", "SDL.Sound.Mute", 0);
|
||||||
config->addOption("volume", "SDL.Sound.Volume", 255);
|
config->addOption("volume", "SDL.Sound.Volume", 255);
|
||||||
config->addOption("trianglevol", "SDL.Sound.TriangleVolume", 255);
|
config->addOption("trianglevol", "SDL.Sound.TriangleVolume", 255);
|
||||||
config->addOption("square1vol", "SDL.Sound.Square1Volume", 255);
|
config->addOption("square1vol", "SDL.Sound.Square1Volume", 255);
|
||||||
|
|
|
@ -56,7 +56,7 @@ enum HOTKEY {
|
||||||
HK_CHEAT_MENU, HK_TOGGLE_ALL_CHEATS, HK_LOAD_LUA,
|
HK_CHEAT_MENU, HK_TOGGLE_ALL_CHEATS, HK_LOAD_LUA,
|
||||||
HK_MUTE_CAPTURE,
|
HK_MUTE_CAPTURE,
|
||||||
HK_FA_LAG_SKIP,
|
HK_FA_LAG_SKIP,
|
||||||
HK_VOLUME_DOWN, HK_VOLUME_UP,
|
HK_VOLUME_MUTE, HK_VOLUME_DOWN, HK_VOLUME_UP,
|
||||||
HK_FKB_ENABLE,
|
HK_FKB_ENABLE,
|
||||||
HK_MAX};
|
HK_MAX};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@ void WriteSound(int32 *Buffer, int Count);
|
||||||
int KillSound(void);
|
int KillSound(void);
|
||||||
uint32 GetMaxSound(void);
|
uint32 GetMaxSound(void);
|
||||||
uint32 GetWriteSound(void);
|
uint32 GetWriteSound(void);
|
||||||
|
bool FCEUD_SoundIsMuted(void);
|
||||||
void FCEUD_MuteSoundOutput(bool value);
|
void FCEUD_MuteSoundOutput(bool value);
|
||||||
|
void FCEUD_MuteSoundWindow(bool value);
|
||||||
|
|
||||||
void SilenceSound(int s); /* DOS and SDL */
|
void SilenceSound(int s); /* DOS and SDL */
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,10 @@ static unsigned int s_SampleRate = 44100;
|
||||||
static double noiseGate = 0.0;
|
static double noiseGate = 0.0;
|
||||||
static double noiseGateRate = 0.010;
|
static double noiseGateRate = 0.010;
|
||||||
static bool noiseGateActive = true;
|
static bool noiseGateActive = true;
|
||||||
static bool muteSoundOutput = false;
|
static bool windowSoundMute = false;
|
||||||
static bool fillInit = 1;
|
static bool fillInit = 1;
|
||||||
|
|
||||||
static int s_mute = 0;
|
static bool s_mute = false;
|
||||||
|
|
||||||
extern int EmulationPaused;
|
extern int EmulationPaused;
|
||||||
extern double frmRateAdjRatio;
|
extern double frmRateAdjRatio;
|
||||||
|
@ -99,7 +99,7 @@ fillaudio(void *udata,
|
||||||
noiseGateActive = 1;
|
noiseGateActive = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mute = EmulationPaused || muteSoundOutput;
|
mute = EmulationPaused || windowSoundMute || s_mute;
|
||||||
|
|
||||||
if ( mute || noiseGateActive )
|
if ( mute || noiseGateActive )
|
||||||
{
|
{
|
||||||
|
@ -207,6 +207,7 @@ InitSound()
|
||||||
}
|
}
|
||||||
|
|
||||||
// load configuration variables
|
// load configuration variables
|
||||||
|
g_config->getOption("SDL.Sound.Mute", &s_mute);
|
||||||
g_config->getOption("SDL.Sound.Rate", &soundrate);
|
g_config->getOption("SDL.Sound.Rate", &soundrate);
|
||||||
g_config->getOption("SDL.Sound.BufSize", &soundbufsize);
|
g_config->getOption("SDL.Sound.BufSize", &soundbufsize);
|
||||||
g_config->getOption("SDL.Sound.Volume", &soundvolume);
|
g_config->getOption("SDL.Sound.Volume", &soundvolume);
|
||||||
|
@ -524,7 +525,9 @@ FCEUD_SoundVolumeAdjust(int n)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_mute = 0;
|
s_mute = false;
|
||||||
|
g_config->setOption("SDL.Sound.Mute", s_mute);
|
||||||
|
|
||||||
FCEUI_SetSoundVolume(soundvolume);
|
FCEUI_SetSoundVolume(soundvolume);
|
||||||
g_config->setOption("SDL.Sound.Volume", soundvolume);
|
g_config->setOption("SDL.Sound.Volume", soundvolume);
|
||||||
|
|
||||||
|
@ -537,21 +540,34 @@ FCEUD_SoundVolumeAdjust(int n)
|
||||||
void
|
void
|
||||||
FCEUD_SoundToggle(void)
|
FCEUD_SoundToggle(void)
|
||||||
{
|
{
|
||||||
if(s_mute) {
|
FCEUD_MuteSoundOutput( !s_mute );
|
||||||
int soundvolume;
|
}
|
||||||
g_config->getOption("SDL.SoundVolume", &soundvolume);
|
|
||||||
|
|
||||||
s_mute = 0;
|
bool FCEUD_SoundIsMuted(void)
|
||||||
FCEUI_SetSoundVolume(soundvolume);
|
{
|
||||||
FCEU_DispMessage("Sound mute off.",0);
|
return s_mute;
|
||||||
} else {
|
|
||||||
s_mute = 1;
|
|
||||||
FCEUI_SetSoundVolume(0);
|
|
||||||
FCEU_DispMessage("Sound mute on.",0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FCEUD_MuteSoundOutput( bool value )
|
void FCEUD_MuteSoundOutput( bool value )
|
||||||
{
|
{
|
||||||
muteSoundOutput = value;
|
if (value != s_mute)
|
||||||
|
{
|
||||||
|
g_config->setOption("SDL.Sound.Mute", value);
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
FCEU_DispMessage("Sound mute on.",0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FCEU_DispMessage("Sound mute off.",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s_mute = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is used by the GUI to mute sound when main window is not in focus.
|
||||||
|
void FCEUD_MuteSoundWindow( bool value )
|
||||||
|
{
|
||||||
|
windowSoundMute = value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue