mirror of https://github.com/AxioDL/amuse.git
Working soxr pitch-slewing
This commit is contained in:
parent
51892eccc1
commit
b2fa66b738
|
@ -29,7 +29,7 @@ public:
|
|||
double sampleRate, bool dynamicPitch);
|
||||
void resetSampleRate(double sampleRate);
|
||||
void setMatrixCoefficients(const float coefs[8]);
|
||||
void setPitchRatio(double ratio);
|
||||
void setPitchRatio(double ratio, bool slew);
|
||||
void start();
|
||||
void stop();
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual void setMatrixCoefficients(const float coefs[8])=0;
|
||||
|
||||
/** Called by client to dynamically adjust the pitch of voices with dynamic pitch enabled */
|
||||
virtual void setPitchRatio(double ratio)=0;
|
||||
virtual void setPitchRatio(double ratio, bool slew)=0;
|
||||
|
||||
/** Instructs platform to begin consuming sample data; invoking callback as needed */
|
||||
virtual void start()=0;
|
||||
|
|
|
@ -128,7 +128,7 @@ class Voice : public Entity
|
|||
void _macroKeyOff();
|
||||
void _macroSampleEnd();
|
||||
bool _advanceSample(int16_t& samp, int32_t& curPitch);
|
||||
void _setTotalPitch(int32_t cents);
|
||||
void _setTotalPitch(int32_t cents, bool slew);
|
||||
bool _isRecursivelyDead();
|
||||
void _bringOutYourDead();
|
||||
std::shared_ptr<Voice> _findVoice(int vid, std::weak_ptr<Voice> thisPtr);
|
||||
|
|
|
@ -33,9 +33,9 @@ void BooBackendVoice::setMatrixCoefficients(const float coefs[8])
|
|||
m_booVoice->setMonoMatrixCoefficients(coefs);
|
||||
}
|
||||
|
||||
void BooBackendVoice::setPitchRatio(double ratio)
|
||||
void BooBackendVoice::setPitchRatio(double ratio, bool slew)
|
||||
{
|
||||
m_booVoice->setPitchRatio(ratio);
|
||||
m_booVoice->setPitchRatio(ratio, slew);
|
||||
}
|
||||
|
||||
void BooBackendVoice::start()
|
||||
|
|
|
@ -124,13 +124,13 @@ void Voice::_doKeyOff()
|
|||
m_state.keyoffNotify(*this);
|
||||
}
|
||||
|
||||
void Voice::_setTotalPitch(int32_t cents)
|
||||
void Voice::_setTotalPitch(int32_t cents, bool slew)
|
||||
{
|
||||
//fprintf(stderr, "PITCH %d\n", cents);
|
||||
int32_t interval = cents - m_curSample->first.m_pitch * 100;
|
||||
double ratio = std::exp2(interval / 1200.0);
|
||||
m_sampleRate = m_curSample->first.m_sampleRate * ratio;
|
||||
m_backendVoice->setPitchRatio(ratio);
|
||||
m_backendVoice->setPitchRatio(ratio, slew);
|
||||
}
|
||||
|
||||
bool Voice::_isRecursivelyDead()
|
||||
|
@ -436,7 +436,7 @@ size_t Voice::supplyAudio(size_t samples, int16_t* data)
|
|||
}
|
||||
|
||||
if (refresh)
|
||||
_setTotalPitch(curPitch + m_pitchSweep1 + m_pitchSweep2 + m_pitchWheelVal);
|
||||
_setTotalPitch(curPitch + m_pitchSweep1 + m_pitchSweep2 + m_pitchWheelVal, true);
|
||||
}
|
||||
else
|
||||
memset(data, 0, sizeof(int16_t) * samples);
|
||||
|
@ -791,7 +791,7 @@ void Voice::setAdsr(ObjectId adsrId, bool dls)
|
|||
void Voice::setPitchFrequency(uint32_t hz, uint16_t fine)
|
||||
{
|
||||
m_sampleRate = hz + fine / 65536.0;
|
||||
m_backendVoice->setPitchRatio(1.0);
|
||||
m_backendVoice->setPitchRatio(1.0, false);
|
||||
m_backendVoice->resetSampleRate(m_sampleRate);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue