mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-15 16:47:37 +00:00
Fix volume
This commit is contained in:
parent
99f00f3898
commit
7d20a4c870
@ -24,7 +24,7 @@ class MxSoundManager : public MxAudioManager {
|
|||||||
|
|
||||||
inline ma_engine* GetEngine() { return &m_engine; }
|
inline ma_engine* GetEngine() { return &m_engine; }
|
||||||
|
|
||||||
MxS32 GetAttenuation(MxU32 p_volume);
|
float GetAttenuation(MxU32 p_volume);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init();
|
void Init();
|
||||||
|
|||||||
@ -90,13 +90,11 @@ class MxWavePresenter : public MxSoundPresenter {
|
|||||||
WaveFormat* m_waveFormat; // 0x54
|
WaveFormat* m_waveFormat; // 0x54
|
||||||
ma_pcm_rb m_rb;
|
ma_pcm_rb m_rb;
|
||||||
ma_sound m_sound;
|
ma_sound m_sound;
|
||||||
MxU32 m_chunkLength; // 0x5c
|
MxU32 m_chunkLength; // 0x5c
|
||||||
MxU32 m_lockSize; // 0x60
|
MxBool m_started; // 0x65
|
||||||
MxU8 m_writtenChunks; // 0x64
|
MxBool m_is3d; // 0x66
|
||||||
MxBool m_started; // 0x65
|
MxS8 m_silenceData; // 0x67
|
||||||
MxBool m_is3d; // 0x66
|
MxBool m_paused; // 0x68
|
||||||
MxS8 m_silenceData; // 0x67
|
|
||||||
MxBool m_paused; // 0x68
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MXWAVEPRESENTER_H
|
#endif // MXWAVEPRESENTER_H
|
||||||
|
|||||||
@ -188,15 +188,15 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100aecf0
|
// FUNCTION: LEGO1 0x100aecf0
|
||||||
MxS32 MxSoundManager::GetAttenuation(MxU32 p_volume)
|
float MxSoundManager::GetAttenuation(MxU32 p_volume)
|
||||||
{
|
{
|
||||||
// The unit for p_volume is percent, rounded to integer.
|
// [library:audio] Convert DSOUND attenutation units to linear miniaudio volume
|
||||||
// Convert to DSOUND attenuation units: -10000 (silent) to 0 (loudest).
|
|
||||||
if (p_volume == 0) {
|
if (p_volume == 0) {
|
||||||
return DSBVOLUME_MIN;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_volumeAttenuation[p_volume - 1];
|
return ma_volume_db_to_linear((float) g_volumeAttenuation[p_volume - 1] / 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100aed10
|
// FUNCTION: LEGO1 0x100aed10
|
||||||
|
|||||||
@ -22,8 +22,6 @@ void MxWavePresenter::Init()
|
|||||||
SDL_zero(m_rb);
|
SDL_zero(m_rb);
|
||||||
SDL_zero(m_sound);
|
SDL_zero(m_sound);
|
||||||
m_chunkLength = 0;
|
m_chunkLength = 0;
|
||||||
m_lockSize = 0;
|
|
||||||
m_writtenChunks = 0;
|
|
||||||
m_started = FALSE;
|
m_started = FALSE;
|
||||||
m_is3d = FALSE;
|
m_is3d = FALSE;
|
||||||
m_paused = FALSE;
|
m_paused = FALSE;
|
||||||
@ -267,7 +265,8 @@ void MxWavePresenter::SetVolume(MxS32 p_volume)
|
|||||||
m_volume = p_volume;
|
m_volume = p_volume;
|
||||||
if (ma_sound_get_engine(&m_sound)) {
|
if (ma_sound_get_engine(&m_sound)) {
|
||||||
MxS32 volume = p_volume * MxOmni::GetInstance()->GetSoundManager()->GetVolume() / 100;
|
MxS32 volume = p_volume * MxOmni::GetInstance()->GetSoundManager()->GetVolume() / 100;
|
||||||
ma_sound_set_volume(&m_sound, (float) volume / 100.0f);
|
float attenuation = MxOmni::GetInstance()->GetSoundManager()->GetAttenuation(volume);
|
||||||
|
ma_sound_set_volume(&m_sound, attenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_criticalSection.Leave();
|
m_criticalSection.Leave();
|
||||||
@ -280,7 +279,6 @@ void MxWavePresenter::Enable(MxBool p_enable)
|
|||||||
MxSoundPresenter::Enable(p_enable);
|
MxSoundPresenter::Enable(p_enable);
|
||||||
|
|
||||||
if (p_enable) {
|
if (p_enable) {
|
||||||
m_writtenChunks = 0;
|
|
||||||
m_started = FALSE;
|
m_started = FALSE;
|
||||||
}
|
}
|
||||||
else if (ma_sound_get_engine(&m_sound)) {
|
else if (ma_sound_get_engine(&m_sound)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user