Added the beginning of a configuration dialog to the noise gate plugin

master
Lucas Murray 2013-03-10 17:54:54 +08:00
parent a4600d4980
commit 39f3675711
7 changed files with 206 additions and 0 deletions

View File

@ -17,6 +17,7 @@
********************************************************************************/
#include "NoiseGate.h"
#include "resource.h"
//============================================================================
// NoiseGateFilter class
@ -97,6 +98,77 @@ void NoiseGateFilter::ApplyNoiseGate(float *buffer, int totalFloats)
}
}
//============================================================================
// NoiseGateConfigWindow class
NoiseGateConfigWindow::NoiseGateConfigWindow(NoiseGate *parent, HWND parentHwnd)
: parent(parent)
, parentHwnd(parentHwnd)
, hwnd(NULL)
{
}
NoiseGateConfigWindow::~NoiseGateConfigWindow()
{
}
INT_PTR CALLBACK NoiseGateConfigWindow::DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Get the pointer to our class instance
NoiseGateConfigWindow *window = (NoiseGateConfigWindow *)GetWindowLongPtr(hwnd, DWLP_USER);
switch(message)
{
default:
// Unhandled
break;
case WM_INITDIALOG:
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
window = (NoiseGateConfigWindow *)lParam;
window->hwnd = hwnd;
window->MsgInitDialog();
return TRUE;
case WM_COMMAND:
if(window != NULL)
return window->MsgCommand(wParam, lParam);
break;
}
return FALSE;
}
/**
* Display the dialog and begin its message loop. Returns \t{true} if the
* user clicked the "OK" button.
*/
bool NoiseGateConfigWindow::Process()
{
INT_PTR res = DialogBoxParam(parent->hinstDLL, MAKEINTRESOURCE(IDD_CONFIGURENOISEGATE), parentHwnd, (DLGPROC)DialogProc, (LPARAM)this);
if(res == IDOK)
return true;
return false;
}
void NoiseGateConfigWindow::MsgInitDialog()
{
LocalizeWindow(hwnd);
}
INT_PTR NoiseGateConfigWindow::MsgCommand(WPARAM wParam, LPARAM lParam)
{
switch(LOWORD(wParam))
{
case IDOK:
EndDialog(hwnd, LOWORD(wParam)); // Return IDOK (1)
return TRUE;
case IDCANCEL:
EndDialog(hwnd, LOWORD(wParam)); // Return IDCANCEL (2)
return TRUE;
}
return FALSE;
}
//============================================================================
// NoiseGate class
@ -140,6 +212,12 @@ void NoiseGate::StreamStopped()
micSource = NULL;
}
void NoiseGate::ShowConfigDialog(HWND parentHwnd)
{
NoiseGateConfigWindow dialog(this, parentHwnd);
dialog.Process();
}
//============================================================================
// Plugin entry points
@ -159,6 +237,13 @@ void UnloadPlugin()
NoiseGate::instance = NULL;
}
void ConfigPlugin(HWND parentHwnd)
{
if(NoiseGate::instance == NULL)
return;
NoiseGate::instance->ShowConfigDialog(parentHwnd);
}
void OnStartStream()
{
if(NoiseGate::instance == NULL)

View File

@ -56,12 +56,53 @@ private:
void ApplyNoiseGate(float *buffer, int totalFloats);
};
//============================================================================
// NoiseGateConfigWindow class
class NoiseGateConfigWindow
{
//-----------------------------------------------------------------------
// Private members
private:
NoiseGate * parent;
HWND parentHwnd;
HWND hwnd;
//-----------------------------------------------------------------------
// Static methods
public:
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
//-----------------------------------------------------------------------
// Constructor/destructor
public:
NoiseGateConfigWindow(NoiseGate *parent, HWND parentHwnd);
~NoiseGateConfigWindow();
//-----------------------------------------------------------------------
// Methods
public:
bool Process();
//-----------------------------------------------------------------------
// Message processing
private:
void MsgInitDialog();
INT_PTR MsgCommand(WPARAM wParam, LPARAM lParam);
};
//============================================================================
// NoiseGate class
class NoiseGate
{
friend class NoiseGateFilter;
friend class NoiseGateConfigWindow;
//-----------------------------------------------------------------------
// Static members
@ -97,6 +138,7 @@ public:
public:
void StreamStarted();
void StreamStopped();
void ShowConfigDialog(HWND parentHwnd);
};
//============================================================================
@ -104,6 +146,7 @@ public:
extern "C" __declspec(dllexport) bool LoadPlugin();
extern "C" __declspec(dllexport) void UnloadPlugin();
extern "C" __declspec(dllexport) void ConfigPlugin(HWND parentHwnd);
extern "C" __declspec(dllexport) void OnStartStream();
extern "C" __declspec(dllexport) void OnStopStream();
extern "C" __declspec(dllexport) CTSTR GetPluginName();

43
NoiseGate/NoiseGate.rc Normal file
View File

@ -0,0 +1,43 @@
// Generated by ResEdit 1.5.11
// Copyright (C) 2006-2012
// http://www.resedit.net
#include "winres.h"
#include "commctrl.h"
#include "resource.h"
//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_CONFIGURENOISEGATE DIALOG 0, 0, 357, 282
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Plugins.NoiseGate.ConfigureTitle"
FONT 8, "Ms Shell Dlg"
{
DEFPUSHBUTTON "OK", IDOK, 232, 257, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 292, 257, 50, 14
CONTROL "", IDC_OPENTHRES_SLIDER, TRACKBAR_CLASS, WS_TABSTOP | TBS_VERT | TBS_BOTH | TBS_NOTICKS, 287, 37, 20, 145
CONTROL "", IDC_CLOSETHRES_SLIDER, TRACKBAR_CLASS, WS_TABSTOP | TBS_VERT | TBS_BOTH | TBS_NOTICKS, 267, 37, 20, 145
CONTROL "", IDC_CURVOL, PROGRESS_CLASS, PBS_VERTICAL, 307, 42, 15, 135
PUSHBUTTON "Plugins.NoiseGate.EnablePreview", IDC_PREVIEWON, 22, 26, 80, 14
GROUPBOX "Plugins.NoiseGate.Settings", IDC_STATIC, 25, 90, 145, 115
RTEXT "Plugins.NoiseGate.OpenThreshold", IDC_STATIC, 30, 107, 70, 8, SS_RIGHT
RTEXT "Plugins.NoiseGate.CloseThreshold", IDC_STATIC, 30, 127, 70, 8, SS_RIGHT
RTEXT "Plugins.NoiseGate.AttackTime", IDC_STATIC, 30, 147, 70, 8, SS_RIGHT
RTEXT "Plugins.NoiseGate.HoldTime", IDC_STATIC, 30, 167, 70, 8, SS_RIGHT
RTEXT "Plugins.NoiseGate.ReleaseTime", IDC_STATIC, 30, 187, 70, 8, SS_RIGHT
EDITTEXT IDC_CLOSETHRES_EDIT, 102, 122, 40, 14, ES_AUTOHSCROLL
EDITTEXT IDC_ATTACKTIME_EDIT, 102, 142, 40, 14, ES_AUTOHSCROLL
EDITTEXT IDC_HOLDTIME_EDIT, 102, 162, 40, 14, ES_AUTOHSCROLL
EDITTEXT IDC_RELEASETIME_EDIT, 102, 182, 40, 14, ES_AUTOHSCROLL
LTEXT "ms", IDC_STATIC, 147, 187, 10, 8, SS_LEFT
LTEXT "ms", IDC_STATIC, 147, 167, 10, 8, SS_LEFT
LTEXT "ms", IDC_STATIC, 147, 147, 10, 8, SS_LEFT
LTEXT "dB", IDC_STATIC, 147, 107, 10, 8, SS_LEFT
LTEXT "dB", IDC_STATIC, 147, 127, 10, 8, SS_LEFT
EDITTEXT IDC_OPENTHRES_EDIT, 102, 102, 40, 14, ES_AUTOHSCROLL
}

View File

@ -215,6 +215,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="NoiseGate.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OBSApi\OBSApi.vcxproj">
@ -222,6 +223,9 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="NoiseGate.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -23,5 +23,13 @@
<ClInclude Include="NoiseGate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="NoiseGate.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

14
NoiseGate/resource.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDD_CONFIGURENOISEGATE 101
#define IDC_CURVOL 1007
#define IDC_PREVIEWON 1010
#define IDC_OPENTHRES_EDIT 1016
#define IDC_CLOSETHRES_SLIDER 1018
#define IDC_OPENTHRES_SLIDER 1019
#define IDC_CLOSETHRES_EDIT 1020
#define IDC_RELEASETIME_EDIT 1024
#define IDC_HOLDTIME_EDIT 1025
#define IDC_ATTACKTIME_EDIT 1026

View File

@ -288,3 +288,12 @@ Settings.Advanced.AutomaticLatency "Automatic low latency mode:"
Plugins.NoiseGate.PluginName "Microphone Noise Gate"
Plugins.NoiseGate.PluginDescription "Reduces microphone noise by automatically muting the microphone if you are not talking."
Plugins.NoiseGate.ConfigureTitle "Configure microphone noise gate"
Plugins.NoiseGate.EnablePreview "Enable preview"
Plugins.NoiseGate.DisablePreview "Disable preview"
Plugins.NoiseGate.Settings "Settings"
Plugins.NoiseGate.OpenThreshold "Open threshold:"
Plugins.NoiseGate.CloseThreshold "Close threshold:"
Plugins.NoiseGate.AttackTime "Attack time:"
Plugins.NoiseGate.HoldTime "Hold time:"
Plugins.NoiseGate.ReleaseTime "Release time:"