diff options
author | Alex Marsev <alex.marsev@gmail.com> | 2016-02-20 12:44:49 +0300 |
---|---|---|
committer | Alex Marsev <alex.marsev@gmail.com> | 2016-02-20 13:22:20 +0300 |
commit | b728fdcc811cb2043326591e8c335caa0d869586 (patch) | |
tree | b2ae835d51042734be36b5aee2d098623dd888e4 | |
parent | 5cd6b998a90c1b2d60c9fa5a486da2df23739c02 (diff) |
Add DspTempo/DspTempo2 selection
-rw-r--r-- | src/AudioRenderer.cpp | 21 | ||||
-rw-r--r-- | src/AudioRenderer.h | 6 | ||||
-rw-r--r-- | src/Interfaces.h | 8 | ||||
-rw-r--r-- | src/Settings.cpp | 27 | ||||
-rw-r--r-- | src/Settings.h | 5 |
5 files changed, 64 insertions, 3 deletions
diff --git a/src/AudioRenderer.cpp b/src/AudioRenderer.cpp index ff79204..dc0d7d9 100644 --- a/src/AudioRenderer.cpp +++ b/src/AudioRenderer.cpp @@ -426,6 +426,19 @@ namespace SaneAudioRenderer }
}
+ bool clearForTimestretch = false;
+ {
+ UINT32 timestretchMethod;
+ m_settings->GetTimestretchSettings(×tretchMethod);
+ const bool usePhaseVocoder = (timestretchMethod == ISettings::TIMESTRETCH_METHOD_PHASE_VOCODER);
+
+ if ((usePhaseVocoder && m_dspTempo1.Active()) ||
+ (!usePhaseVocoder && m_dspTempo2.Active()))
+ {
+ clearForTimestretch = true;
+ }
+ }
+
m_deviceSettingsSerial = newSettingsSerial;
std::unique_ptr<WCHAR, CoTaskMemFreeDeleter> systemDeviceId;;
@@ -442,6 +455,7 @@ namespace SaneAudioRenderer if ((clearForSystemChannelMixer) ||
(clearForCrossfeed) ||
+ (clearForTimestretch) ||
(m_device->IsExclusive() != !!settingsDeviceExclusive) ||
(m_device->GetBufferDuration() != settingsDeviceBuffer) ||
(!settingsDeviceDefault && *m_device->GetId() != settingsDeviceId.get()) ||
@@ -750,9 +764,14 @@ namespace SaneAudioRenderer const auto outChannels = m_device->GetWaveFormat()->nChannels;
const auto outMask = DspMatrix::GetChannelMask(*m_device->GetWaveFormat());
+ UINT32 timestretchMethod;
+ m_settings->GetTimestretchSettings(×tretchMethod);
+ const bool usePhaseVocoder = (timestretchMethod == ISettings::TIMESTRETCH_METHOD_PHASE_VOCODER);
+
m_dspMatrix.Initialize(inChannels, inMask, outChannels, outMask);
m_dspRate.Initialize(m_live || m_externalClock, inRate, outRate, outChannels);
- m_dspTempo.Initialize(m_rate, outRate, outChannels);
+ m_dspTempo1.Initialize(usePhaseVocoder ? 1.0 : m_rate, outRate, outChannels);
+ m_dspTempo2.Initialize(usePhaseVocoder ? m_rate : 1.0, outRate, outChannels);
m_dspCrossfeed.Initialize(m_settings, outRate, outChannels, outMask);
m_dspLimiter.Initialize(outRate, outChannels, m_device->IsExclusive());
m_dspDither.Initialize(m_device->GetDspFormat());
diff --git a/src/AudioRenderer.h b/src/AudioRenderer.h index edfe416..6e9e07d 100644 --- a/src/AudioRenderer.h +++ b/src/AudioRenderer.h @@ -82,7 +82,8 @@ namespace SaneAudioRenderer {
f(&m_dspMatrix);
f(&m_dspRate);
- f(&m_dspTempo);
+ f(&m_dspTempo1);
+ f(&m_dspTempo2);
f(&m_dspCrossfeed);
f(&m_dspVolume);
f(&m_dspBalance);
@@ -116,7 +117,8 @@ namespace SaneAudioRenderer DspMatrix m_dspMatrix;
DspRate m_dspRate;
- DspTempo2 m_dspTempo;
+ DspTempo m_dspTempo1;
+ DspTempo2 m_dspTempo2;
DspCrossfeed m_dspCrossfeed;
DspVolume m_dspVolume;
DspBalance m_dspBalance;
diff --git a/src/Interfaces.h b/src/Interfaces.h index 7eb0f63..a83b5c5 100644 --- a/src/Interfaces.h +++ b/src/Interfaces.h @@ -41,6 +41,14 @@ namespace SaneAudioRenderer STDMETHOD_(void, SetIgnoreSystemChannelMixer)(BOOL bEnable) = 0;
STDMETHOD_(BOOL, GetIgnoreSystemChannelMixer)() = 0;
+
+ enum
+ {
+ TIMESTRETCH_METHOD_SOLA = 0,
+ TIMESTRETCH_METHOD_PHASE_VOCODER = 1,
+ };
+ STDMETHOD(SetTimestretchSettings)(UINT32 uTimestretchMethod) = 0;
+ STDMETHOD_(void, GetTimestretchSettings)(UINT32* puTimestretchMethod) = 0;
};
_COM_SMARTPTR_TYPEDEF(ISettings, __uuidof(ISettings));
diff --git a/src/Settings.cpp b/src/Settings.cpp index 41341a9..f22999c 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -160,4 +160,31 @@ namespace SaneAudioRenderer return m_ignoreSystemChannelMixer;
}
+
+ STDMETHODIMP Settings::SetTimestretchSettings(UINT32 uTimestretchMethod)
+ {
+ if (uTimestretchMethod != TIMESTRETCH_METHOD_SOLA &&
+ uTimestretchMethod != TIMESTRETCH_METHOD_PHASE_VOCODER)
+ {
+ return E_INVALIDARG;
+ }
+
+ CAutoLock lock(this);
+
+ if (uTimestretchMethod != m_timestretchMethod)
+ {
+ m_timestretchMethod = uTimestretchMethod;
+ m_serial++;
+ }
+
+ return S_OK;
+ }
+
+ STDMETHODIMP_(void) Settings::GetTimestretchSettings(UINT32* puTimestretchMethod)
+ {
+ CAutoLock lock(this);
+
+ if (puTimestretchMethod)
+ *puTimestretchMethod = m_timestretchMethod;
+ }
}
diff --git a/src/Settings.h b/src/Settings.h index 7f9c8db..12c3b5a 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -36,6 +36,9 @@ namespace SaneAudioRenderer STDMETHODIMP_(void) SetIgnoreSystemChannelMixer(BOOL bEnable) override;
STDMETHODIMP_(BOOL) GetIgnoreSystemChannelMixer() override;
+ STDMETHODIMP SetTimestretchSettings(UINT32 uTimestretchMethod) override;
+ STDMETHODIMP_(void) GetTimestretchSettings(UINT32* puTimestretchMethod) override;
+
private:
std::atomic<UINT32> m_serial = 0;
@@ -53,5 +56,7 @@ namespace SaneAudioRenderer UINT32 m_crossfeedLevel = CROSSFEED_LEVEL_CMOY;
BOOL m_ignoreSystemChannelMixer = TRUE;
+
+ UINT32 m_timestretchMethod = TIMESTRETCH_METHOD_PHASE_VOCODER;
};
}
|