mirror of https://github.com/AxioDL/amuse.git
Use -10dB RMS formula for amplitude computation
This commit is contained in:
parent
491fa1cd6f
commit
fbafa397fe
|
@ -191,7 +191,7 @@ struct AppCallback : boo::IApplicationCallback
|
||||||
int8_t m_lastChanProg = -1;
|
int8_t m_lastChanProg = -1;
|
||||||
|
|
||||||
/* Control state */
|
/* Control state */
|
||||||
float m_volume = 0.5f;
|
float m_volume = 0.8f;
|
||||||
float m_modulation = 0.f;
|
float m_modulation = 0.f;
|
||||||
float m_pitchBend = 0.f;
|
float m_pitchBend = 0.f;
|
||||||
bool m_updateDisp = false;
|
bool m_updateDisp = false;
|
||||||
|
|
|
@ -20,10 +20,10 @@ public:
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
State m_phase = State::Attack; /**< Current envelope state */
|
State m_phase = State::Attack; /**< Current envelope state */
|
||||||
double m_attackTime = 0.01; /**< Time of attack in seconds */
|
double m_attackTime = 0.005; /**< Time of attack in seconds */
|
||||||
double m_decayTime = 0.0; /**< Time of decay in seconds */
|
double m_decayTime = 0.0; /**< Time of decay in seconds */
|
||||||
double m_sustainFactor = 1.0; /**< Evaluated sustain percentage */
|
double m_sustainFactor = 1.0; /**< Evaluated sustain percentage */
|
||||||
double m_releaseTime = 0.01; /**< Time of release in seconds */
|
double m_releaseTime = 0.005; /**< Time of release in seconds */
|
||||||
double m_releaseStartFactor = 0.0; /**< Level at whenever release event occurs */
|
double m_releaseStartFactor = 0.0; /**< Level at whenever release event occurs */
|
||||||
double m_curTime = 0.0; /**< Current time of envelope stage in seconds */
|
double m_curTime = 0.0; /**< Current time of envelope stage in seconds */
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -179,9 +179,9 @@ bool SongState::Channel::advance(Sequencer& seq, int32_t ticks)
|
||||||
/* See if there's an upcoming pitch change in this interval */
|
/* See if there's an upcoming pitch change in this interval */
|
||||||
const unsigned char* ptr = m_pitchWheelData;
|
const unsigned char* ptr = m_pitchWheelData;
|
||||||
uint32_t deltaTicks = DecodeRLE(ptr);
|
uint32_t deltaTicks = DecodeRLE(ptr);
|
||||||
if (deltaTicks != -1)
|
if (deltaTicks != 0xffffffff)
|
||||||
{
|
{
|
||||||
uint32_t nextTick = m_lastPitchTick + deltaTicks;
|
int32_t nextTick = m_lastPitchTick + deltaTicks;
|
||||||
if (pitchTick + remPitchTicks > nextTick)
|
if (pitchTick + remPitchTicks > nextTick)
|
||||||
{
|
{
|
||||||
/* Update pitch */
|
/* Update pitch */
|
||||||
|
@ -212,9 +212,9 @@ bool SongState::Channel::advance(Sequencer& seq, int32_t ticks)
|
||||||
/* See if there's an upcoming modulation change in this interval */
|
/* See if there's an upcoming modulation change in this interval */
|
||||||
const unsigned char* ptr = m_modWheelData;
|
const unsigned char* ptr = m_modWheelData;
|
||||||
uint32_t deltaTicks = DecodeRLE(ptr);
|
uint32_t deltaTicks = DecodeRLE(ptr);
|
||||||
if (deltaTicks != -1)
|
if (deltaTicks != 0xffffffff)
|
||||||
{
|
{
|
||||||
uint32_t nextTick = m_lastModTick + deltaTicks;
|
int32_t nextTick = m_lastModTick + deltaTicks;
|
||||||
if (modTick + remModTicks > nextTick)
|
if (modTick + remModTicks > nextTick)
|
||||||
{
|
{
|
||||||
/* Update modulation */
|
/* Update modulation */
|
||||||
|
|
|
@ -201,7 +201,8 @@ std::list<std::shared_ptr<Voice>>::iterator Voice::_destroyVoice(Voice* voice)
|
||||||
static void ApplyVolume(float vol, int16_t& samp)
|
static void ApplyVolume(float vol, int16_t& samp)
|
||||||
{
|
{
|
||||||
/* -10dB to 0dB mapped to full volume range */
|
/* -10dB to 0dB mapped to full volume range */
|
||||||
float factor = (std::pow(10.f, vol - 1.f) - 0.1f) * (1.f / 0.9f);
|
float factor = std::sqrt(std::pow(10.f, (vol - 1.f))) - 0.317f;
|
||||||
|
if (factor < 0.f) factor = 0.f;
|
||||||
samp *= factor;
|
samp *= factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue