diff --git a/Configurator/Configurator.cpp b/Configurator/Configurator.cpp index 64ea601..62cba7d 100644 --- a/Configurator/Configurator.cpp +++ b/Configurator/Configurator.cpp @@ -57,6 +57,7 @@ void Configurator::onInitDialog(HWND hDlg) useOriginalAPOPreMix = GetDlgItem(hDlg, IDC_USE_ORIGINAL_APO_PRE_MIX); useOriginalAPOPostMix = GetDlgItem(hDlg, IDC_USE_ORIGINAL_APO_POST_MIX); installModeComboBox = GetDlgItem(hDlg, IDC_INSTALL_MODE_COMBOBOX); + allowSilentBuffer = GetDlgItem(hDlg, IDC_ALLOW_SILENT_BUFFER); selectOneDeviceLabel = GetDlgItem(hDlg, IDC_SELECT_ONE_DEVICE); expandTroubleShooting(false); @@ -121,6 +122,29 @@ void Configurator::onInitDialog(HWND hDlg) } ComboBox_SetCurSel(installModeComboBox, 0); + LoadStringW(hInstance, IDS_ALLOW_SILENT_BUFFER, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); + SetWindowTextW(allowSilentBuffer, stringBuf); + + LoadStringW(hInstance, IDS_ALLOW_SILENT_BUFFER_TOOLTIP, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); + HWND tooltip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_ALWAYSTIP, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hDlg, NULL, + hInstance, NULL); + + if (tooltip != NULL) + { + TOOLINFO toolInfo = {0}; + toolInfo.cbSize = sizeof(toolInfo); + toolInfo.hwnd = hDlg; + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = (UINT_PTR)allowSilentBuffer; + toolInfo.lpszText = stringBuf; + SendMessage(tooltip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); + SendMessage(tooltip, TTM_SETMAXTIPWIDTH, 0, 400); + } + LoadStringW(hInstance, IDS_SELECT_ONE_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); SetWindowTextW(selectOneDeviceLabel, stringBuf); @@ -316,6 +340,7 @@ bool Configurator::onButtonClicked(unsigned sourceId) case IDC_USE_ORIGINAL_APO_PRE_MIX: case IDC_USE_ORIGINAL_APO_POST_MIX: case IDC_INSTALL_MODE_COMBOBOX: + case IDC_ALLOW_SILENT_BUFFER: { int index = TabCtrl_GetCurSel(categoryTabCtrl); HWND deviceList = deviceLists[index]; @@ -351,6 +376,9 @@ bool Configurator::onButtonClicked(unsigned sourceId) case IDC_INSTALL_MODE_COMBOBOX: info.selectedInstallState.installMode = (DeviceAPOInfo::InstallMode)ComboBox_GetCurSel(installModeComboBox); break; + case IDC_ALLOW_SILENT_BUFFER: + info.selectedInstallState.allowSilentBufferModification = Button_GetCheck(allowSilentBuffer) == BST_CHECKED; + break; } updateList(index, i); @@ -522,6 +550,7 @@ void Configurator::expandTroubleShooting(bool expand) ShowWindow(useOriginalAPOPreMix, showCmd); ShowWindow(useOriginalAPOPostMix, showCmd); ShowWindow(installModeComboBox, showCmd); + ShowWindow(allowSilentBuffer, showCmd); showCmd = expand && IsWindowEnabled(selectOneDeviceLabel) ? SW_SHOW : SW_HIDE; ShowWindow(selectOneDeviceLabel, showCmd); @@ -644,6 +673,7 @@ void Configurator::updateButtons(int listIndex) EnableWindow(useOriginalAPOPreMix, enable && hasOriginalAPOPreMix && installState.installPreMix); EnableWindow(useOriginalAPOPostMix, enable && !isInput && hasOriginalAPOPostMix && installState.installPostMix); EnableWindow(installModeComboBox, enable); + EnableWindow(allowSilentBuffer, enable); EnableWindow(selectOneDeviceLabel, !enable); Button_SetCheck(installPreMix, installState.installPreMix); @@ -654,6 +684,8 @@ void Configurator::updateButtons(int listIndex) if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1 ComboBox_SetCurSel(installModeComboBox, installState.installMode); + Button_SetCheck(allowSilentBuffer, installState.allowSilentBufferModification); + expandTroubleShooting(Button_GetCheck(toggleTroubleShooting) != 0); } diff --git a/Configurator/Configurator.h b/Configurator/Configurator.h index 86d48c4..88f256e 100644 --- a/Configurator/Configurator.h +++ b/Configurator/Configurator.h @@ -54,6 +54,7 @@ private: HWND useOriginalAPOPreMix; HWND useOriginalAPOPostMix; HWND installModeComboBox; + HWND allowSilentBuffer; HWND selectOneDeviceLabel; std::wstring cmdLine; diff --git a/Configurator/Configurator.rc b/Configurator/Configurator.rc index a87121a..cc2982e 100644 Binary files a/Configurator/Configurator.rc and b/Configurator/Configurator.rc differ diff --git a/Configurator/resource.h b/Configurator/resource.h index bb42efb..84f8dc4 100644 Binary files a/Configurator/resource.h and b/Configurator/resource.h differ diff --git a/DeviceAPOInfo.cpp b/DeviceAPOInfo.cpp index a72fe9d..888290f 100644 --- a/DeviceAPOInfo.cpp +++ b/DeviceAPOInfo.cpp @@ -39,6 +39,7 @@ using namespace std; #define childApoPath APP_REGPATH L"\\Child APOs" static const wchar_t* preMixChildGuidValueName = L"PreMixChild"; static const wchar_t* postMixChildGuidValueName = L"PostMixChild"; +static const wchar_t* allowSilentBufferValueName = L"AllowSilentBufferModification"; static const wchar_t* versionValueName = L"Version"; static const wchar_t* connectionValueName = L"{a45c254e-df1c-4efd-8020-67d146a850e0},2"; static const wchar_t* deviceValueName = L"{b3f8fa53-0004-438e-9003-51a46e139bfc},6"; @@ -229,6 +230,7 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid) currentInstallState.installPostMix = !isInput; currentInstallState.useOriginalAPOPreMix = true; currentInstallState.useOriginalAPOPostMix = !isInput; + currentInstallState.allowSilentBufferModification = false; if (!RegistryHelper::keyExists(keyPath + L"\\FxProperties")) { @@ -311,6 +313,9 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid) currentInstallState.installMode = INSTALL_SFX_EFX; else if (foundAt[SFX_INDEX] || foundAt[MFX_INDEX]) currentInstallState.installMode = INSTALL_SFX_MFX; + + if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, allowSilentBufferValueName)) + currentInstallState.allowSilentBufferModification = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, allowSilentBufferValueName) != L"false"; } else { @@ -490,6 +495,7 @@ void DeviceAPOInfo::install() RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName, preMixValue); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName, postMixValue); + RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, allowSilentBufferValueName, selectedInstallState.allowSilentBufferModification ? L"true" : L"false"); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, versionValueName, installVersion); if (selectedInstallState.installMode == INSTALL_LFX_GFX) diff --git a/DeviceAPOInfo.h b/DeviceAPOInfo.h index 0edb345..eb6eeb6 100644 --- a/DeviceAPOInfo.h +++ b/DeviceAPOInfo.h @@ -43,6 +43,7 @@ public: bool useOriginalAPOPreMix; bool useOriginalAPOPostMix; InstallMode installMode; + bool allowSilentBufferModification; InstallState() { @@ -51,6 +52,7 @@ public: useOriginalAPOPreMix = false; useOriginalAPOPostMix = false; installMode = INSTALL_LFX_GFX; + allowSilentBufferModification = false; } bool operator!=(InstallState& other) diff --git a/Editor/AnalysisThread.cpp b/Editor/AnalysisThread.cpp index 05177f2..1000f71 100644 --- a/Editor/AnalysisThread.cpp +++ b/Editor/AnalysisThread.cpp @@ -24,7 +24,6 @@ AnalysisThread::AnalysisThread() { - } AnalysisThread::~AnalysisThread() @@ -245,7 +244,7 @@ void AnalysisThread::run() double peakGain = -DBL_MAX; - for (int i = 0; i < frameCount; i++) + for (int i = 0; i < frameCount / 2; i++) { float sqrGain = freqData[i][0] * freqData[i][0] + freqData[i][1] * freqData[i][1]; if (sqrGain > peakGain) diff --git a/Editor/guis/GraphicEQFilterGUI.cpp b/Editor/guis/GraphicEQFilterGUI.cpp index 3ca45df..fcbd883 100644 --- a/Editor/guis/GraphicEQFilterGUI.cpp +++ b/Editor/guis/GraphicEQFilterGUI.cpp @@ -308,23 +308,29 @@ void GraphicEQFilterGUI::on_actionImport_triggered() if (file.open(QFile::ReadOnly)) { QTextStream stream(&file); - QString text = stream.readAll(); - if (!text.contains('.')) - text = text.replace(',', '.'); - QRegularExpressionMatchIterator it = numberRegEx.globalMatch(text); - while (it.hasNext()) + while (!stream.atEnd()) { - QRegularExpressionMatch match = it.next(); - QString freqString = match.captured(); - bool ok; - double freq = freqString.toDouble(&ok); - if (ok && it.hasNext()) + QString text = stream.readLine(); + if (text.startsWith('*')) + continue; + + if (!text.contains('.')) + text = text.replace(',', '.'); + QRegularExpressionMatchIterator it = numberRegEx.globalMatch(text); + while (it.hasNext()) { - match = it.next(); - QString gainString = match.captured(); - double gain = gainString.toDouble(&ok); - if (ok) - newNodes.push_back(FilterNode(freq, gain)); + QRegularExpressionMatch match = it.next(); + QString freqString = match.captured(); + bool ok; + double freq = freqString.toDouble(&ok); + if (ok && it.hasNext()) + { + match = it.next(); + QString gainString = match.captured(); + double gain = gainString.toDouble(&ok); + if (ok) + newNodes.push_back(FilterNode(freq, gain)); + } } } } diff --git a/EqualizerAPO.cpp b/EqualizerAPO.cpp index 28ea8c7..1bbb050 100644 --- a/EqualizerAPO.cpp +++ b/EqualizerAPO.cpp @@ -47,6 +47,8 @@ EqualizerAPO::EqualizerAPO(IUnknown* pUnkOuter) else this->pUnkOuter = reinterpret_cast(static_cast(this)); + allowSilentBufferModification = false; + childAPO = NULL; childRT = NULL; childCfg = NULL; @@ -142,6 +144,8 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData) childApoGuid = apoInfo.preMixChildGuid; else childApoGuid = apoInfo.postMixChildGuid; + + allowSilentBufferModification = apoInfo.currentInstallState.allowSilentBufferModification; } } catch (RegistryException e) @@ -425,18 +429,26 @@ void EqualizerAPO::APOProcess(UINT32 u32NumInputConnections, if (ppInputConnections[0]->u32BufferFlags == BUFFER_SILENT) { - unsigned outputFrameCount = ppOutputConnections[0]->u32ValidFrameCount * engine.getOutputChannelCount(); - boolean silent = true; - for (unsigned i = 0; i < outputFrameCount; i++) + if (allowSilentBufferModification) { - if (outputFrames[i] != 0.0) + unsigned outputFrameCount = ppOutputConnections[0]->u32ValidFrameCount * engine.getOutputChannelCount(); + boolean silent = true; + for (unsigned i = 0; i < outputFrameCount; i++) { - silent = false; - break; + if (abs(outputFrames[i]) > 1e-10) + { + silent = false; + break; + } } + // BUFFER_SILENT seems to be important for some sound card drivers, so only use BUFFER_VALID if there really is audio + ppOutputConnections[0]->u32BufferFlags = silent ? BUFFER_SILENT : BUFFER_VALID; + } + else + { + memset(outputFrames, 0, ppOutputConnections[0]->u32ValidFrameCount * engine.getOutputChannelCount() * sizeof(float)); + ppOutputConnections[0]->u32BufferFlags = BUFFER_SILENT; } - // BUFFER_SILENT seems to be important for some sound card drivers, so only use BUFFER_VALID if there really is audio - ppOutputConnections[0]->u32BufferFlags = silent ? BUFFER_SILENT : BUFFER_VALID; } else { diff --git a/EqualizerAPO.h b/EqualizerAPO.h index 2089fbf..b313382 100644 --- a/EqualizerAPO.h +++ b/EqualizerAPO.h @@ -72,6 +72,7 @@ private: long refCount; IUnknown* pUnkOuter; FilterEngine engine; + bool allowSilentBufferModification; void resetChild(); diff --git a/version.h b/version.h index bdb5792..5cefd4e 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #define MAJOR 1 #define MINOR 1 -#define REVISION 0 +#define REVISION 1