More conversion from sound quality to sample rate.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@828 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
49b5ee430a
commit
437be084a9
|
@ -540,26 +540,24 @@ bool soundInit()
|
|||
return true;
|
||||
}
|
||||
|
||||
int soundGetQuality()
|
||||
long soundGetSampleRate()
|
||||
{
|
||||
return 44100 / soundSampleRate;
|
||||
return soundSampleRate;
|
||||
}
|
||||
|
||||
void soundSetQuality(int quality)
|
||||
void soundSetSampleRate(long sampleRate)
|
||||
{
|
||||
long newSampleRate = 44100 / quality;
|
||||
|
||||
if ( soundSampleRate != newSampleRate )
|
||||
if ( soundSampleRate != sampleRate )
|
||||
{
|
||||
if ( systemCanChangeSoundQuality() )
|
||||
{
|
||||
soundShutdown();
|
||||
soundSampleRate = newSampleRate;
|
||||
soundSampleRate = sampleRate;
|
||||
soundInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
soundSampleRate = newSampleRate;
|
||||
soundSampleRate = sampleRate;
|
||||
}
|
||||
|
||||
remake_stereo_buffer();
|
||||
|
|
|
@ -35,9 +35,8 @@ void soundShutdown();
|
|||
|
||||
//// GBA sound options
|
||||
|
||||
// Sets sample rate to 44100 / quality
|
||||
int soundGetQuality();
|
||||
void soundSetQuality( int quality );
|
||||
long soundGetSampleRate();
|
||||
void soundSetSampleRate(long sampleRate);
|
||||
|
||||
// Sound settings
|
||||
extern bool soundInterpolation; // 1 if PCM should have low-pass filtering
|
||||
|
|
|
@ -216,21 +216,19 @@ void gbSoundReset()
|
|||
}
|
||||
}
|
||||
|
||||
void gbSoundSetQuality(int quality)
|
||||
void gbSoundSetSampleRate( long sampleRate )
|
||||
{
|
||||
long newSampleRate = 44100 / quality;
|
||||
|
||||
if ( soundSampleRate != newSampleRate )
|
||||
if ( soundSampleRate != sampleRate )
|
||||
{
|
||||
if ( systemCanChangeSoundQuality() )
|
||||
{
|
||||
soundShutdown();
|
||||
soundSampleRate = newSampleRate;
|
||||
soundSampleRate = sampleRate;
|
||||
soundInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
soundSampleRate = newSampleRate;
|
||||
soundSampleRate = sampleRate;
|
||||
}
|
||||
|
||||
remake_stereo_buffer();
|
||||
|
@ -367,7 +365,7 @@ static void gbSoundReadGameOld(int version,gzFile gzFile)
|
|||
if ( version >= 7 )
|
||||
quality = utilReadInt( gzFile );
|
||||
|
||||
gbSoundSetQuality( quality );
|
||||
gbSoundSetSampleRate( 44100 / quality );
|
||||
|
||||
// Convert to format Gb_Apu uses
|
||||
gb_apu_state_t& s = state.apu;
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
//// GB sound options
|
||||
|
||||
// Sets sample rate to 44100 / quality
|
||||
void gbSoundSetQuality( int quality );
|
||||
void gbSoundSetSampleRate( long sampleRate );
|
||||
|
||||
// Manages declicking mode. When enabled, clicks are reduced. Note that clicks
|
||||
// are normal for GB and GBC sound hardware.
|
||||
|
|
|
@ -57,16 +57,17 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p
|
|||
else
|
||||
m_poVolumeComboBox->set_active(3);
|
||||
|
||||
VBA::Window::ESoundQuality eSoundQuality = (VBA::Window::ESoundQuality)m_poConfig->oGetKey<int>("quality");
|
||||
switch (eSoundQuality)
|
||||
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
|
||||
switch (iSoundSampleRate)
|
||||
{
|
||||
case VBA::Window::Sound44K:
|
||||
default:
|
||||
case 44100:
|
||||
m_poRateComboBox->set_active(2);
|
||||
break;
|
||||
case VBA::Window::Sound22K:
|
||||
case 22050:
|
||||
m_poRateComboBox->set_active(1);
|
||||
break;
|
||||
case VBA::Window::Sound11K:
|
||||
case 11025:
|
||||
m_poRateComboBox->set_active(0);
|
||||
break;
|
||||
}
|
||||
|
@ -110,16 +111,18 @@ void SoundConfigDialog::vOnRateChanged()
|
|||
switch (iRate)
|
||||
{
|
||||
case 0: // 11 KHz
|
||||
m_poConfig->vSetKey("quality", VBA::Window::Sound11K);
|
||||
m_poConfig->vSetKey("sample_rate", 11025);
|
||||
break;
|
||||
case 1: // 22 KHz
|
||||
m_poConfig->vSetKey("quality", VBA::Window::Sound22K);
|
||||
m_poConfig->vSetKey("sample_rate", 22050);
|
||||
break;
|
||||
case 2: // 44 KHz
|
||||
default:
|
||||
m_poConfig->vSetKey("quality", VBA::Window::Sound44K);
|
||||
m_poConfig->vSetKey("sample_rate", 44100);
|
||||
break;
|
||||
}
|
||||
|
||||
m_poWindow->vApplyConfigSoundSampleRate();
|
||||
}
|
||||
|
||||
} // namespace VBA
|
||||
|
|
|
@ -91,8 +91,8 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
|
|||
m_iShowSpeedMax (ShowDetailed),
|
||||
m_iSaveTypeMin (SaveAuto),
|
||||
m_iSaveTypeMax (SaveNone),
|
||||
m_iSoundQualityMin(Sound44K),
|
||||
m_iSoundQualityMax(Sound11K),
|
||||
m_iSoundSampleRateMin(11025),
|
||||
m_iSoundSampleRateMax(44100),
|
||||
m_fSoundVolumeMin (0.50f),
|
||||
m_fSoundVolumeMax (2.00f),
|
||||
m_iEmulatorTypeMin(EmulatorAuto),
|
||||
|
@ -692,9 +692,9 @@ void Window::vInitConfig()
|
|||
// Sound section
|
||||
//
|
||||
m_poSoundConfig = m_oConfig.poAddSection("Sound");
|
||||
m_poSoundConfig->vSetKey("mute", false );
|
||||
m_poSoundConfig->vSetKey("quality", Sound44K );
|
||||
m_poSoundConfig->vSetKey("volume", 1.00f );
|
||||
m_poSoundConfig->vSetKey("mute", false );
|
||||
m_poSoundConfig->vSetKey("sample_rate", 44100 );
|
||||
m_poSoundConfig->vSetKey("volume", 1.00f );
|
||||
|
||||
// Input section
|
||||
//
|
||||
|
@ -834,11 +834,11 @@ void Window::vCheckConfig()
|
|||
|
||||
// Sound section
|
||||
//
|
||||
iValue = m_poSoundConfig->oGetKey<int>("quality");
|
||||
iAdjusted = CLAMP(iValue, m_iSoundQualityMin, m_iSoundQualityMax);
|
||||
iValue = m_poSoundConfig->oGetKey<int>("sample_rate");
|
||||
iAdjusted = CLAMP(iValue, m_iSoundSampleRateMin, m_iSoundSampleRateMax);
|
||||
if (iValue != iAdjusted)
|
||||
{
|
||||
m_poSoundConfig->vSetKey("quality", iAdjusted);
|
||||
m_poSoundConfig->vSetKey("sample_rate", iAdjusted);
|
||||
}
|
||||
|
||||
fValue = m_poSoundConfig->oGetKey<float>("volume");
|
||||
|
@ -921,16 +921,16 @@ void Window::vApplyConfigVolume()
|
|||
soundSetVolume(fSoundVolume);
|
||||
}
|
||||
|
||||
void Window::vApplyConfigSoundQuality()
|
||||
void Window::vApplyConfigSoundSampleRate()
|
||||
{
|
||||
ESoundQuality eSoundQuality = (ESoundQuality)m_poSoundConfig->oGetKey<int>("quality");
|
||||
long iSoundSampleRate = m_poSoundConfig->oGetKey<int>("sample_rate");
|
||||
if (m_eCartridge == CartridgeGBA)
|
||||
{
|
||||
soundSetQuality(eSoundQuality);
|
||||
soundSetSampleRate(iSoundSampleRate);
|
||||
}
|
||||
else if (m_eCartridge == CartridgeGB)
|
||||
{
|
||||
gbSoundSetQuality(eSoundQuality);
|
||||
gbSoundSetSampleRate(iSoundSampleRate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1076,7 @@ bool Window::bLoadROM(const std::string & _rsFile)
|
|||
emulating = 1;
|
||||
m_bWasEmulating = false;
|
||||
|
||||
vApplyConfigSoundQuality();
|
||||
vApplyConfigSoundSampleRate();
|
||||
|
||||
vUpdateGameSlots();
|
||||
vHistoryAdd(_rsFile);
|
||||
|
|
|
@ -61,13 +61,6 @@ public:
|
|||
OutputXvideo
|
||||
};
|
||||
|
||||
enum ESoundQuality
|
||||
{
|
||||
Sound44K = 1,
|
||||
Sound22K = 2,
|
||||
Sound11K = 4
|
||||
};
|
||||
|
||||
// GB/GBA screen sizes
|
||||
const int m_iGBScreenWidth;
|
||||
const int m_iGBScreenHeight;
|
||||
|
@ -88,7 +81,7 @@ public:
|
|||
void vApplyConfigScreenArea();
|
||||
void vApplyConfigMute();
|
||||
void vApplyConfigVolume();
|
||||
void vApplyConfigSoundQuality();
|
||||
void vApplyConfigSoundSampleRate();
|
||||
void vUpdateScreen();
|
||||
|
||||
inline ECartridge eGetCartridge() const { return m_eCartridge; }
|
||||
|
@ -185,8 +178,8 @@ private:
|
|||
const int m_iShowSpeedMax;
|
||||
const int m_iSaveTypeMin;
|
||||
const int m_iSaveTypeMax;
|
||||
const int m_iSoundQualityMin;
|
||||
const int m_iSoundQualityMax;
|
||||
const int m_iSoundSampleRateMin;
|
||||
const int m_iSoundSampleRateMax;
|
||||
const float m_fSoundVolumeMin;
|
||||
const float m_fSoundVolumeMax;
|
||||
const int m_iEmulatorTypeMin;
|
||||
|
|
|
@ -733,7 +733,7 @@ void sdlReadPreferences(FILE *f)
|
|||
soundQuality = 2;
|
||||
break;
|
||||
}
|
||||
soundSetQuality(soundQuality);
|
||||
soundSetSampleRate(44100 / soundQuality);
|
||||
} else if(!strcmp(key, "soundEnable")) {
|
||||
int res = sdlFromHex(value) & 0x30f;
|
||||
soundSetEnable(res);
|
||||
|
|
Loading…
Reference in New Issue