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