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