Version 1.0

Added: Configuration Editor, which allows to edit configurations in a graphical user interface. Contains GUIs for most commands supported by E-APO, but as lines can also be edited directly, all commands can be used.
Added: Command "GraphicEQ", which can act as a regular, fixed-band graphic equalizer (via the GUI) but also supports variable bands so that any desired frequency response can be specified. Internally, it is implemented via convolution with a generated IR.
Added: Command "Convolution", which allows to convolve the signal with a user-provided impulse response to achieve e.g. equalization or reverberation effects.
Improved: Configurator performs checks for registry values that are needed for the operation of E-APO, which may be changed by driver installations, fixing the values if necessary.
Improved: Configurator shows which is the default device as a hint to the user.
This commit is contained in:
jthedering committed 2015-09-27 16:01:21 +00:00
1 parent d68b958bc8
commit b8cdd47f71
284 files changed
+17622 -322

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#include <algorithm>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Ks.h>
#include <KsMedia.h>
#include "LogHelper.h"
#include "ChannelHelper.h"
using namespace std;
unordered_map<wstring, int> ChannelHelper::channelNameToPosMap;
unordered_map<int, wstring> ChannelHelper::channelPosToNameMap;
// must come last, so that the static members are already initialized
ChannelHelper ChannelHelper::instance;
ChannelHelper::ChannelHelper()
{
channelNameToPosMap[L"L"] = SPEAKER_FRONT_LEFT;
channelNameToPosMap[L"R"] = SPEAKER_FRONT_RIGHT;
channelNameToPosMap[L"C"] = SPEAKER_FRONT_CENTER;
channelNameToPosMap[L"SUB"] = SPEAKER_LOW_FREQUENCY;
channelNameToPosMap[L"RL"] = SPEAKER_BACK_LEFT;
channelNameToPosMap[L"RR"] = SPEAKER_BACK_RIGHT;
channelNameToPosMap[L"RC"] = SPEAKER_BACK_CENTER;
channelNameToPosMap[L"SL"] = SPEAKER_SIDE_LEFT;
channelNameToPosMap[L"SR"] = SPEAKER_SIDE_RIGHT;
for(unordered_map<wstring, int>::iterator it=channelNameToPosMap.begin(); it!=channelNameToPosMap.end(); it++)
channelPosToNameMap[it->second] = it->first;
}
int ChannelHelper::getDefaultChannelMask(int channelCount)
{
int channelMask;
switch(channelCount)
{
case 1:
channelMask = KSAUDIO_SPEAKER_MONO;
break;
case 2:
channelMask = KSAUDIO_SPEAKER_STEREO;
break;
case 4:
channelMask = KSAUDIO_SPEAKER_QUAD;
break;
case 6:
channelMask = KSAUDIO_SPEAKER_5POINT1_SURROUND;
break;
case 8:
channelMask = KSAUDIO_SPEAKER_7POINT1_SURROUND;
break;
default:
channelMask = 0;
}
return channelMask;
}
vector<wstring> ChannelHelper::getChannelNames(int channelCount, int channelMask)
{
vector<wstring> channelNames;
int c=1;
for(int i=0; i<31; i++)
{
int channelPos = 1<<i;
if(channelMask & channelPos)
{
if(channelPosToNameMap.find(channelPos) != channelPosToNameMap.end())
channelNames.push_back(channelPosToNameMap[channelPos]);
else
channelNames.push_back(to_wstring((unsigned long long)c));
c++;
}
}
// handle channels not covered by channelMask
for(; c<=channelCount; c++)
channelNames.push_back(to_wstring((unsigned long long)c));
return channelNames;
}
int ChannelHelper::getChannelIndex(std::wstring word, const std::vector<std::wstring>& channelNames, bool allowNew)
{
int channelIndex = -1;
if(iswdigit(word[0]))
{
channelIndex = wcstol(word.c_str(), NULL, 10) - 1;
if(channelIndex < 0 || channelIndex >= (int)channelNames.size())
{
LogFStatic(L"Channel number %s out of range (1 - %d)", word.c_str(), channelNames.size());
channelIndex = -1;
}
}
else
{
vector<wstring>::const_iterator pos = find(channelNames.begin(), channelNames.end(), word);
if(pos == channelNames.end())
{
//Special handling to accept "wrong", but unambiguous positions
if(word == L"SL")
pos = find(channelNames.begin(), channelNames.end(), L"RL");
else if(word == L"SR")
pos = find(channelNames.begin(), channelNames.end(), L"RR");
else if(word == L"RL")
pos = find(channelNames.begin(), channelNames.end(), L"SL");
else if(word == L"RR")
pos = find(channelNames.begin(), channelNames.end(), L"SR");
}
if(pos != channelNames.end())
channelIndex = (int)(pos - channelNames.begin());
else if(!allowNew)
LogFStatic(L"Invalid channel position %s", word.c_str());
}
return channelIndex;
}
+39
View File
@@ -0,0 +1,39 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
class ChannelHelper
{
public:
static int getDefaultChannelMask(int channelCount);
static std::vector<std::wstring> getChannelNames(int channelCount, int channelMask);
static int getChannelIndex(std::wstring word, const std::vector<std::wstring>& channelNames, bool allowNew = false);
private:
ChannelHelper();
static ChannelHelper instance;
static std::unordered_map<std::wstring, int> channelNameToPosMap;
static std::unordered_map<int, std::wstring> channelPosToNameMap;
};
+92
View File
@@ -0,0 +1,92 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#include <algorithm>
#include "GainIterator.h"
using namespace std;
GainIterator::GainIterator(const vector<FilterNode>& nodes)
{
this->nodes = nodes;
nodeLeft = NULL;
nodeRight = NULL;
}
double GainIterator::gainAt(double freq)
{
if(nodeLeft == NULL && nodeRight == NULL || nodeLeft != NULL && freq < nodeLeft->freq)
{
FilterNode findNode(freq, 0);
vector<FilterNode>::iterator it = lower_bound(nodes.begin(), nodes.end(), findNode);
if(it != nodes.begin())
nodeLeft = &*(it - 1);
if(it != nodes.end())
nodeRight = &*it;
if(nodeLeft != NULL && nodeRight != NULL)
{
logLeft = log(nodeLeft->freq);
logRightMinusLeft = log(nodeRight->freq) - logLeft;
}
}
else if(nodeRight != NULL && freq > nodeRight->freq)
{
vector<FilterNode>::iterator it = nodes.begin() + (nodeRight - &*nodes.begin());
while(it != nodes.end() && freq > it->freq)
{
it++;
}
if(it == nodes.end())
nodeRight = NULL;
else
nodeRight = &*it;
if(it != nodes.begin())
nodeLeft = &*(it - 1);
if(nodeLeft != NULL && nodeRight != NULL)
{
logLeft = log(nodeLeft->freq);
logRightMinusLeft = log(nodeRight->freq) - logLeft;
}
}
double dbGain;
if(nodeLeft == NULL)
{
if(nodeRight == NULL)
dbGain = 0.0;
else
dbGain = nodeRight->dbGain;
}
else if(nodeRight == NULL)
{
dbGain = nodeLeft->dbGain;
}
else
{
double t = (log(freq) - logLeft) / logRightMinusLeft;
dbGain = nodeLeft->dbGain + t * (nodeRight->dbGain - nodeLeft->dbGain);
}
return dbGain;
}
+53
View File
@@ -0,0 +1,53 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <vector>
struct FilterNode
{
double freq;
double dbGain;
FilterNode(double freq, double dbGain)
{
this->freq = freq;
this->dbGain = dbGain;
}
bool operator < (FilterNode other)
{
return freq < other.freq;
}
};
class GainIterator
{
public:
GainIterator(const std::vector<FilterNode>& nodes);
double gainAt(double freq);
private:
std::vector<FilterNode> nodes;
FilterNode* nodeLeft;
FilterNode* nodeRight;
double logLeft;
double logRightMinusLeft;
};
+2 -1
View File
@@ -17,6 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#include <cstdarg>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -87,7 +88,7 @@ void LogHelper::log(const char* file, int line, const void* caller, bool trace,
GetLocalTime(&___st);
DWORD threadId = GetCurrentThreadId();
fwprintf(fp, L"%04d-%02d-%02d %02d:%02d:%02d.%03d %d %08X (%S:%d): ",
___st.wYear, ___st.wMonth, ___st.wDay, ___st.wHour, ___st.wMinute, ___st.wSecond, ___st.wMilliseconds, threadId, (DWORD)caller, file, line);
___st.wYear, ___st.wMonth, ___st.wDay, ___st.wHour, ___st.wMinute, ___st.wSecond, ___st.wMilliseconds, threadId, (DWORD)(unsigned long long)caller, file, line);
}
if(trace)
+1
View File
@@ -17,6 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef _DEBUG
+46
View File
@@ -17,6 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#include <fstream>
#include <sstream>
#include <ObjBase.h>
@@ -110,6 +111,39 @@ unsigned long RegistryHelper::readDWORDValue(wstring key, wstring valuename)
return result;
}
vector<unsigned char> RegistryHelper::readBinaryValue(wstring key, wstring valuename)
{
HKEY keyHandle = openKey(key, KEY_QUERY_VALUE | KEY_WOW64_64KEY);
LSTATUS status;
DWORD type;
DWORD bufSize;
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, &type, NULL, &bufSize);
if(status != ERROR_SUCCESS)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
if(type != REG_BINARY)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Registry value " + key + L"\\" + valuename + L" has wrong type");
}
vector<unsigned char> result(bufSize, 0);
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, NULL, result.data(), &bufSize);
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
{
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
return result;
}
void RegistryHelper::writeValue(wstring key, wstring valuename, wstring value)
{
HKEY keyHandle = openKey(key, KEY_SET_VALUE | KEY_WOW64_64KEY);
@@ -122,6 +156,18 @@ void RegistryHelper::writeValue(wstring key, wstring valuename, wstring value)
throw RegistryException(L"Error while writing to registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
void RegistryHelper::writeDWORDValue(wstring key, wstring valuename, unsigned long value)
{
HKEY keyHandle = openKey(key, KEY_SET_VALUE | KEY_WOW64_64KEY);
LSTATUS status = RegSetValueExW(keyHandle, valuename.c_str(), 0, REG_DWORD, (const BYTE*)&value, sizeof(unsigned long));
RegCloseKey(keyHandle);
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while writing to registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
void RegistryHelper::writeMultiValue(wstring key, wstring valuename, wstring value)
{
HKEY keyHandle = openKey(key, KEY_SET_VALUE | KEY_WOW64_64KEY);
+7
View File
@@ -25,6 +25,11 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// {EACD2258-FCAC-4FF4-B36D-419E924A6D79}
const GUID EQUALIZERAPO_PRE_MIX_GUID = { 0xeacd2258, 0xfcac, 0x4ff4, { 0xb3, 0x6d, 0x41, 0x9e, 0x92, 0x4a, 0x6d, 0x79 } };
// {EC1CC9CE-FAED-4822-828A-82A81A6F018F}
const GUID EQUALIZERAPO_POST_MIX_GUID = { 0xec1cc9ce, 0xfaed, 0x4822, { 0x82, 0x8a, 0x82, 0xa8, 0x1a, 0x6f, 0x01, 0x8f } };
#define APP_REGPATH L"HKEY_LOCAL_MACHINE\\SOFTWARE\\EqualizerAPO"
class RegistryHelper
@@ -32,7 +37,9 @@ class RegistryHelper
public:
static std::wstring readValue(std::wstring key, std::wstring valuename);
static unsigned long readDWORDValue(std::wstring key, std::wstring valuename);
static std::vector<unsigned char> readBinaryValue(std::wstring key, std::wstring valuename);
static void writeValue(std::wstring key, std::wstring valuename, std::wstring value);
static void writeDWORDValue(std::wstring key, std::wstring valuename, unsigned long value);
static void writeMultiValue(std::wstring key, std::wstring valuename, std::wstring value);
static void deleteValue(std::wstring key, std::wstring valuename);
static void createKey(std::wstring key);
+20 -1
View File
@@ -17,6 +17,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "stdafx.h"
#include <string>
#include <sstream>
#define WIN32_LEAN_AND_MEAN
@@ -130,6 +131,24 @@ vector<wstring> StringHelper::split(const wstring& s, wchar_t splitChar, bool sk
return result;
}
wstring StringHelper::join(const vector<wstring>& strings, const wstring& separator)
{
wstringstream stream;
bool first = true;
for(vector<wstring>::const_iterator it = strings.cbegin(); it != strings.cend(); it++)
{
if(first)
first = false;
else
stream << separator;
stream << *it;
}
return stream.str();
}
wstring StringHelper::getSystemErrorString(long status)
{
wchar_t* buf;
@@ -143,4 +162,4 @@ wstring StringHelper::getSystemErrorString(long status)
}
else
return L"";
}
}
+1
View File
@@ -33,5 +33,6 @@ public:
static std::wstring toUpperCase(const std::wstring& s);
static std::wstring trim(const std::wstring& s);
static std::vector<std::wstring> split(const std::wstring& s, wchar_t splitChar, bool skipEmpty = true);
static std::wstring join(const std::vector<std::wstring>& strings, const std::wstring& separator);
static std::wstring getSystemErrorString(long status);
};