Skip to content

Commit dae3f05

Browse files
committed
Initial Project Creation
0 parents  commit dae3f05

23 files changed

Lines changed: 1882 additions & 0 deletions

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### VisualStudio ###
2+
## Ignore Visual Studio temporary files, build results, and
3+
## files generated by popular Visual Studio add-ons.
4+
5+
# VS State
6+
.vs/
7+
.vscode/
8+
9+
# User-specific files
10+
*.suo
11+
*.user
12+
*.userosscache
13+
*.sln.docstates
14+
15+
# Private keys
16+
*.pfx
17+
18+
# User-specific files (MonoDevelop/Xamarin Studio)
19+
*.userprefs
20+
21+
# Build results
22+
[Dd]ebug/
23+
[Dd]ebugPublic/
24+
[Rr]elease/
25+
[Rr]eleases/
26+
x64/
27+
x86/
28+
build/
29+
bld/
30+
[Bb]in/
31+
[Oo]bj/

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "TASagentTwitchBotCore"]
2+
path = TASagentTwitchBotCore
3+
url = https://github.com/TASagent/TASagentTwitchBotCore
4+
[submodule "TASagentStreamBot.Plugin.XInput"]
5+
path = TASagentStreamBot.Plugin.XInput
6+
url = https://github.com/TASagent/TASagentStreamBot.Plugin.XInput

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TASagent Twitch Bot Demos License
2+
3+
Copyright (C) 2022 TASagent
4+
5+
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 3 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.
6+
7+
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# TASagentStreamBot KezBoard
2+
3+
Demonstrations of my extensible, modular C# [stream bot development framework](https://github.com/TASagent/TASagentTwitchBotCore) with rebinding midi input to keyboard output, and a keyboard input display.
4+
5+
## How do I use this?
6+
7+
Simply launch the executable. You can download the build program from the Releases.
8+
9+
To build the project, get the appropriate [NetCore 6 SDK (With AspNet)](https://dotnet.microsoft.com/download/dotnet/6.0), navigate to the project directory `cd TASagentStreamBot.Kezcade/TASagentStreamBot.Kezcade`, and build the DotNet project: `dotnet publish -c Release -r win-x64`.
10+
11+
## BrowserSources
12+
13+
In OBS, you can optionally add the following BrowserSource(s):
14+
15+
`http://localhost:5000/BrowserSource/PianoDisplay.html` - Piano input display overlay
16+

TASagentStreamBot.KezBoard.sln

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32112.339
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TASagentStreamBot.KezBoard", "TASagentStreamBot.KezBoard\TASagentStreamBot.KezBoard.csproj", "{4D0B41D4-6F6C-4AEB-AD33-8FE77839F163}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TASagentTwitchBotCore", "TASagentTwitchBotCore", "{343B5FF6-7D27-47EF-B1D0-3E2391C466F7}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TASagentTwitchBot.Core", "TASagentTwitchBotCore\TASagentTwitchBot.Core\TASagentTwitchBot.Core.csproj", "{95995E54-6A0B-42BA-8332-2437AD03F855}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TASagentTwitchBot.Plugin.ControllerSpy", "TASagentTwitchBotCore\TASagentTwitchBot.Plugin.ControllerSpy\TASagentTwitchBot.Plugin.ControllerSpy.csproj", "{5F5DB316-F8D0-43E2-AD22-537FE136B417}"
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BGC_Tools", "TASagentTwitchBotCore\BGC_Tools\BGC_Tools.csproj", "{68C04820-5AE8-4844-A0E0-F150B3950443}"
15+
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TASagentStreamBot.Plugin.XInput", "TASagentStreamBot.Plugin.XInput\TASagentStreamBot.Plugin.XInput.csproj", "{6442F06D-63D9-41BC-8B2E-46443F7388C7}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TASagentTwitchBot.Plugin.Audio.Midi", "TASagentTwitchBotCore\TASagentTwitchBot.Plugin.Audio.Midi\TASagentTwitchBot.Plugin.Audio.Midi.csproj", "{976EBA30-E996-45A7-872F-AFC8768F752D}"
19+
EndProject
20+
Global
21+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
22+
Debug|Any CPU = Debug|Any CPU
23+
Release|Any CPU = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{4D0B41D4-6F6C-4AEB-AD33-8FE77839F163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{4D0B41D4-6F6C-4AEB-AD33-8FE77839F163}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{4D0B41D4-6F6C-4AEB-AD33-8FE77839F163}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{4D0B41D4-6F6C-4AEB-AD33-8FE77839F163}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{95995E54-6A0B-42BA-8332-2437AD03F855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{95995E54-6A0B-42BA-8332-2437AD03F855}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{95995E54-6A0B-42BA-8332-2437AD03F855}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{95995E54-6A0B-42BA-8332-2437AD03F855}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{5F5DB316-F8D0-43E2-AD22-537FE136B417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{5F5DB316-F8D0-43E2-AD22-537FE136B417}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{5F5DB316-F8D0-43E2-AD22-537FE136B417}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{5F5DB316-F8D0-43E2-AD22-537FE136B417}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{68C04820-5AE8-4844-A0E0-F150B3950443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{68C04820-5AE8-4844-A0E0-F150B3950443}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{68C04820-5AE8-4844-A0E0-F150B3950443}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{68C04820-5AE8-4844-A0E0-F150B3950443}.Release|Any CPU.Build.0 = Release|Any CPU
42+
{6442F06D-63D9-41BC-8B2E-46443F7388C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43+
{6442F06D-63D9-41BC-8B2E-46443F7388C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
44+
{6442F06D-63D9-41BC-8B2E-46443F7388C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{6442F06D-63D9-41BC-8B2E-46443F7388C7}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{976EBA30-E996-45A7-872F-AFC8768F752D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{976EBA30-E996-45A7-872F-AFC8768F752D}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{976EBA30-E996-45A7-872F-AFC8768F752D}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{976EBA30-E996-45A7-872F-AFC8768F752D}.Release|Any CPU.Build.0 = Release|Any CPU
50+
EndGlobalSection
51+
GlobalSection(SolutionProperties) = preSolution
52+
HideSolutionNode = FALSE
53+
EndGlobalSection
54+
GlobalSection(NestedProjects) = preSolution
55+
{95995E54-6A0B-42BA-8332-2437AD03F855} = {343B5FF6-7D27-47EF-B1D0-3E2391C466F7}
56+
{5F5DB316-F8D0-43E2-AD22-537FE136B417} = {343B5FF6-7D27-47EF-B1D0-3E2391C466F7}
57+
{68C04820-5AE8-4844-A0E0-F150B3950443} = {343B5FF6-7D27-47EF-B1D0-3E2391C466F7}
58+
{976EBA30-E996-45A7-872F-AFC8768F752D} = {343B5FF6-7D27-47EF-B1D0-3E2391C466F7}
59+
EndGlobalSection
60+
GlobalSection(ExtensibilityGlobals) = postSolution
61+
SolutionGuid = {BAD37707-7585-4B6D-8C18-42873A67D53A}
62+
EndGlobalSection
63+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "6.0.5",
7+
"commands": [
8+
"dotnet-ef"
9+
]
10+
}
11+
}
12+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
namespace TASagentStreamBot.KezBoard;
2+
3+
public class Configurator : TASagentTwitchBot.Core.BaseConfigurator
4+
{
5+
public Configurator(
6+
TASagentTwitchBot.Core.Config.BotConfiguration botConfig,
7+
TASagentTwitchBot.Core.ICommunication communication,
8+
TASagentTwitchBot.Core.ErrorHandler errorHandler)
9+
: base(botConfig, communication, errorHandler)
10+
{
11+
12+
}
13+
14+
public override Task<bool> VerifyConfigured()
15+
{
16+
bool changed = false;
17+
18+
if (string.IsNullOrEmpty(botConfig.AuthConfiguration.Admin.PasswordHash))
19+
{
20+
botConfig.AuthConfiguration.Admin.PasswordHash = TASagentTwitchBot.Core.Cryptography.HashPassword("loltesting");
21+
botConfig.AuthConfiguration.Privileged.PasswordHash = TASagentTwitchBot.Core.Cryptography.HashPassword(Guid.NewGuid().ToString());
22+
botConfig.AuthConfiguration.User.PasswordHash = TASagentTwitchBot.Core.Cryptography.HashPassword(Guid.NewGuid().ToString());
23+
24+
changed = true;
25+
}
26+
27+
if (string.IsNullOrEmpty(botConfig.EffectOutputDevice) || string.IsNullOrEmpty(botConfig.VoiceOutputDevice))
28+
{
29+
List<string> devices = GetAudioOutputDevicesList();
30+
botConfig.EffectOutputDevice = devices[0];
31+
botConfig.VoiceOutputDevice = devices[0];
32+
33+
botConfig.MicConfiguration.Enabled = false;
34+
35+
changed = true;
36+
}
37+
38+
if (string.IsNullOrEmpty(botConfig.VoiceInputDevice))
39+
{
40+
List<string> devices = GetAudioInputDevicesList();
41+
botConfig.VoiceInputDevice = devices[0];
42+
43+
changed = true;
44+
}
45+
46+
47+
if (changed)
48+
{
49+
botConfig.Serialize();
50+
}
51+
52+
return Task.FromResult(true);
53+
}
54+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
using BGC.Audio;
3+
using TASagentTwitchBot.Plugin.Audio.Midi;
4+
using TASagentTwitchBot.Plugin.XInput;
5+
6+
namespace TASagentStreamBot.KezBoard;
7+
8+
public class ControllerMidiBinding : MidiKeyboardHandler.MidiBinding
9+
{
10+
private readonly MidiBindingConfig midiBindingConfig;
11+
private readonly IButtonPressDispatcher buttonPressDispatcher;
12+
private readonly IHubContext<Web.Hubs.PianoDisplayHub> pianoDisplayHubContext;
13+
14+
private IKeyPressListener? listener = null;
15+
16+
public ControllerMidiBinding(
17+
MidiBindingConfig midiBindingConfig,
18+
IButtonPressDispatcher buttonPressDispatcher,
19+
IHubContext<Web.Hubs.PianoDisplayHub> pianoDisplayHubContext)
20+
{
21+
this.midiBindingConfig = midiBindingConfig;
22+
this.buttonPressDispatcher = buttonPressDispatcher;
23+
this.pianoDisplayHubContext = pianoDisplayHubContext;
24+
}
25+
26+
public void SetTemporaryListener(IKeyPressListener listener) => this.listener = listener;
27+
public void ClearTemporaryListener() => listener = null;
28+
29+
public override IBGCStream CreateOutputStream(MidiKeyboardHandler midiKeyboardHandler) =>
30+
new BGC.Audio.Synthesis.SilenceStream(1, 256);
31+
32+
public override async void HandleNoteOff(int key)
33+
{
34+
if (listener is not null)
35+
{
36+
listener.HandleKeyUp(key);
37+
}
38+
else if (midiBindingConfig.KeyMapping.TryGetValue(key, out DirectXKeyStrokes keyStroke))
39+
{
40+
buttonPressDispatcher.TriggerKeyUp(keyStroke);
41+
}
42+
43+
await pianoDisplayHubContext.Clients.All.SendAsync("KeyUp", key);
44+
}
45+
46+
public override async void HandleNoteOn(int key)
47+
{
48+
if (listener is not null)
49+
{
50+
listener.HandleKeyDown(key);
51+
}
52+
else if (midiBindingConfig.KeyMapping.TryGetValue(key, out DirectXKeyStrokes keyStroke))
53+
{
54+
buttonPressDispatcher.TriggerKeyDown(keyStroke);
55+
}
56+
57+
await pianoDisplayHubContext.Clients.All.SendAsync("KeyDown", key);
58+
}
59+
60+
public override void CleanUp()
61+
{
62+
63+
}
64+
65+
protected override void ChildDisposal()
66+
{
67+
68+
}
69+
70+
}

0 commit comments

Comments
 (0)