Skip to content

Commit 96aa87e

Browse files
committed
Adding full piano display, demo images, integrating updated class registration
1 parent dae3f05 commit 96aa87e

File tree

11 files changed

+237
-94
lines changed

11 files changed

+237
-94
lines changed

Assets/boardOverlayDemo.png

249 KB
Loading

Assets/fullBoardOverlayDemo.png

253 KB
Loading

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@ To build the project, get the appropriate [NetCore 6 SDK (With AspNet)](https://
1212

1313
In OBS, you can optionally add the following BrowserSource(s):
1414

15-
`http://localhost:5000/BrowserSource/PianoDisplay.html` - Piano input display overlay
15+
`http://localhost:5000/BrowserSource/PianoDisplay.html` - Small Piano input display overlay
1616

17+
![Partial Board](Assets/boardOverlayDemo.png)
18+
19+
20+
21+
`http://localhost:5000/BrowserSource/FullPianoDisplay.html` - Full Piano input display overlay
22+
23+
![Full Board](Assets/fullBoardOverlayDemo.png)

TASagentStreamBot.KezBoard/KezboardView.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class KezBoardView : TASagentTwitchBot.Core.View.BasicView, IKeyPressList
1616
private readonly ControllerMidiBinding controllerMidiBinding;
1717
private readonly MidiBindingConfig midiBindingConfig;
1818
private readonly ICommunication communication;
19-
private readonly MidiKeyboardHandler midiKeyboardHandler;
19+
private readonly IMidiDeviceManager midiDeviceManager;
2020

2121
private State state = State.Playing;
2222
private List<string> midiDevices;
@@ -26,7 +26,7 @@ public KezBoardView(
2626
BotConfiguration botConfig,
2727
MidiBindingConfig midiBindingConfig,
2828
ICommunication communication,
29-
MidiKeyboardHandler midiKeyboardHandler,
29+
IMidiDeviceManager midiDeviceManager,
3030
ControllerMidiBinding controllerMidiBinding,
3131
ApplicationManagement applicationManagement)
3232
: base(
@@ -36,16 +36,16 @@ public KezBoardView(
3636
{
3737
this.controllerMidiBinding = controllerMidiBinding;
3838
this.midiBindingConfig = midiBindingConfig;
39-
this.midiKeyboardHandler = midiKeyboardHandler;
39+
this.midiDeviceManager = midiDeviceManager;
4040
this.communication = communication;
4141

42-
midiDevices = midiKeyboardHandler.GetMidiDevices();
42+
midiDevices = midiDeviceManager.GetMidiDevices();
4343
bool setDevice = false;
4444

4545
if (!string.IsNullOrEmpty(midiBindingConfig.MidiDevice) && midiDevices.Contains(midiBindingConfig.MidiDevice))
4646
{
4747
//Restore saved device
48-
setDevice = midiKeyboardHandler.UpdateCurrentMidiDevice(midiBindingConfig.MidiDevice);
48+
setDevice = midiDeviceManager.UpdateMidiDevice(0, midiBindingConfig.MidiDevice);
4949

5050
if (setDevice)
5151
{
@@ -56,7 +56,7 @@ public KezBoardView(
5656
if (!setDevice && midiDevices.Count > 0)
5757
{
5858
//Set to first device
59-
setDevice = midiKeyboardHandler.UpdateCurrentMidiDevice(midiDevices[0]);
59+
setDevice = midiDeviceManager.UpdateMidiDevice(0, midiDevices[0]);
6060

6161
if (setDevice)
6262
{
@@ -119,7 +119,7 @@ private void PrintInstructions()
119119
"Press ESCAPE to Abort device selection.\n" +
120120
"Press the NUMBER corresponding to a midi device below to select that device.");
121121

122-
midiDevices = midiKeyboardHandler.GetMidiDevices();
122+
midiDevices = midiDeviceManager.GetMidiDevices();
123123
if (midiDevices.Count > 0)
124124
{
125125
communication.SendDebugMessage($"Midi Devices:\n{string.Join("\n", midiDevices.Select((x,i) => $" {i+1}) {x}"))}");
@@ -431,7 +431,7 @@ private void HandleSettingDeviceKeys(in ConsoleKeyInfo input)
431431
if (value < midiDevices.Count)
432432
{
433433
midiBindingConfig.MidiDevice = midiDevices[value];
434-
midiKeyboardHandler.UpdateCurrentMidiDevice(midiBindingConfig.MidiDevice);
434+
midiDeviceManager.UpdateMidiDevice(0, midiBindingConfig.MidiDevice);
435435

436436
midiBindingConfig.Serialize();
437437

TASagentStreamBot.KezBoard/Program.cs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,49 @@
3131

3232
//Core Agnostic Systems
3333
builder.Services
34-
.AddSingleton<TASagentTwitchBot.Core.Config.BotConfiguration>(TASagentTwitchBot.Core.Config.BotConfiguration.GetConfig(defaultConfig))
35-
.AddSingleton<TASagentTwitchBot.Core.ICommunication, TASagentTwitchBot.Core.CommunicationHandler>()
36-
.AddSingleton<TASagentTwitchBot.Core.ErrorHandler>()
37-
.AddSingleton<TASagentTwitchBot.Core.ApplicationManagement>()
38-
.AddSingleton<TASagentTwitchBot.Core.IMessageAccumulator, TASagentTwitchBot.Core.MessageAccumulator>();
34+
.AddTASSingleton(TASagentTwitchBot.Core.Config.BotConfiguration.GetConfig(defaultConfig))
35+
.AddTASSingleton<TASagentTwitchBot.Core.CommunicationHandler>()
36+
.AddTASSingleton<TASagentTwitchBot.Core.ErrorHandler>()
37+
.AddTASSingleton<TASagentTwitchBot.Core.ApplicationManagement>()
38+
.AddTASSingleton<TASagentTwitchBot.Core.MessageAccumulator>();
3939

4040
//Custom Core Systems
4141
builder.Services
42-
.AddSingleton<TASagentTwitchBot.Core.View.IConsoleOutput, TASagentStreamBot.KezBoard.KezBoardView>();
42+
.AddTASSingleton<TASagentStreamBot.KezBoard.KezBoardView>();
4343

4444
//Custom Configurator
4545
builder.Services
46-
.AddSingleton<TASagentTwitchBot.Core.IConfigurator, TASagentStreamBot.KezBoard.Configurator>();
46+
.AddTASSingleton<TASagentStreamBot.KezBoard.Configurator>();
4747

4848
//Core Audio System
4949
builder.Services
50-
.AddSingleton<TASagentTwitchBot.Core.Audio.IAudioPlayer, TASagentTwitchBot.Core.Audio.AudioPlayer>()
51-
.AddSingleton<TASagentTwitchBot.Core.Audio.IMicrophoneHandler, TASagentTwitchBot.Core.Audio.MicrophoneHandler>()
52-
.AddSingleton<TASagentTwitchBot.Core.Audio.ISoundEffectSystem, TASagentTwitchBot.Core.Audio.SoundEffectSystem>();
50+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.NAudioDeviceManager>()
51+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.NAudioPlayer>()
52+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.NAudioMicrophoneHandler>()
53+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.SoundEffectSystem>();
5354

5455
//Core Audio Effects System
5556
builder.Services
56-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectSystem, TASagentTwitchBot.Core.Audio.Effects.AudioEffectSystem>()
57-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.ChorusEffectProvider>()
58-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.EchoEffectProvider>()
59-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.FrequencyModulationEffectProvider>()
60-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.FrequencyShiftEffectProvider>()
61-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.NoiseVocoderEffectProvider>()
62-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.PitchShiftEffectProvider>()
63-
.AddSingleton<TASagentTwitchBot.Core.Audio.Effects.IAudioEffectProvider, TASagentTwitchBot.Core.Audio.Effects.ReverbEffectProvider>();
57+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.AudioEffectSystem>()
58+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.ChorusEffectProvider>()
59+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.EchoEffectProvider>()
60+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.FrequencyModulationEffectProvider>()
61+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.FrequencyShiftEffectProvider>()
62+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.NoiseVocoderEffectProvider>()
63+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.PitchShiftEffectProvider>()
64+
.AddTASSingleton<TASagentTwitchBot.Core.Audio.Effects.ReverbEffectProvider>();
6465

6566
//Core Midi System
6667
builder.Services.RegisterMidiServices();
6768

6869
//Custom Midi Components
6970
builder.Services
70-
.AddSingleton<TASagentStreamBot.KezBoard.MidiBindingConfig>(TASagentStreamBot.KezBoard.MidiBindingConfig.GetConfig())
71-
.AddSingleton<TASagentStreamBot.KezBoard.ControllerMidiBinding>();
72-
73-
//Core Scripting
74-
builder.Services
75-
.AddSingleton<TASagentTwitchBot.Core.Scripting.IScriptManager, TASagentTwitchBot.Core.Scripting.ScriptManager>()
76-
.AddSingletonRedirect<TASagentTwitchBot.Core.Scripting.IScriptRegistrar, TASagentTwitchBot.Core.Scripting.ScriptManager>();
71+
.AddTASSingleton(TASagentStreamBot.KezBoard.MidiBindingConfig.GetConfig())
72+
.AddTASSingleton<TASagentStreamBot.KezBoard.ControllerMidiBinding>();
7773

7874
//XInput Services
7975
builder.Services
80-
.AddSingleton<TASagentTwitchBot.Plugin.XInput.IButtonPressDispatcher, TASagentTwitchBot.Plugin.XInput.ButtonPressDispatcher>();
76+
.AddTASSingleton<TASagentTwitchBot.Plugin.XInput.ButtonPressDispatcher>();
8177

8278
//Routing
8379
builder.Services.Configure<ForwardedHeadersOptions>(options =>
@@ -146,22 +142,24 @@
146142
TASagentTwitchBot.Core.ErrorHandler errorHandler = app.Services.GetRequiredService<TASagentTwitchBot.Core.ErrorHandler>();
147143
TASagentTwitchBot.Core.ApplicationManagement applicationManagement = app.Services.GetRequiredService<TASagentTwitchBot.Core.ApplicationManagement>();
148144

149-
app.Services.GetRequiredService<TASagentTwitchBot.Core.Audio.IMicrophoneHandler>();
150-
app.Services.GetRequiredService<TASagentTwitchBot.Core.IMessageAccumulator>();
145+
foreach (TASagentTwitchBot.Core.IStartupListener startupListener in app.Services.GetServices<TASagentTwitchBot.Core.IStartupListener>())
146+
{
147+
startupListener.NotifyStartup();
148+
}
151149

152-
app.Services.ConstructRequiredMidiServices();
153150

154151
TASagentStreamBot.KezBoard.ControllerMidiBinding midiBinding =
155152
app.Services.GetRequiredService<TASagentStreamBot.KezBoard.ControllerMidiBinding>();
156153

154+
IMidiDeviceManager midiDeviceManager = app.Services.GetRequiredService<IMidiDeviceManager>();
157155
MidiKeyboardHandler midiKeyboardHandler = app.Services.GetRequiredService<MidiKeyboardHandler>();
158156

159157
midiKeyboardHandler.BindToCustomBinding(midiBinding);
160158

161-
List<string> midiDevices = midiKeyboardHandler.GetMidiDevices();
159+
List<string> midiDevices = midiDeviceManager.GetMidiDevices();
162160
if (midiDevices.Count > 0)
163161
{
164-
midiKeyboardHandler.UpdateCurrentMidiDevice(midiDevices[0]);
162+
midiDeviceManager.UpdateMidiDevice(0, midiDevices[0]);
165163
}
166164

167165
//

TASagentStreamBot.KezBoard/TASagentStreamBot.KezBoard.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
11-
<PrivateAssets>all</PrivateAssets>
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13-
</PackageReference>
14-
</ItemGroup>
15-
169
<ItemGroup>
1710
<ProjectReference Include="..\TASagentStreamBot.Plugin.XInput\TASagentStreamBot.Plugin.XInput.csproj" />
1811
<ProjectReference Include="..\TASagentTwitchBotCore\BGC_Tools\BGC_Tools.csproj" />

TASagentStreamBot.KezBoard/wwwroot/Assets/css/pianoDisplay.css

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
11
.Keyboard {
2-
display: inline-block;
3-
position: relative;
42
margin: 0px;
53
padding: 0px;
64
border-style: none;
7-
user-select: none;
8-
cursor: default;
9-
width: 715px;
10-
height: 151px;
5+
height: 160px;
6+
width: 100%
7+
}
8+
9+
.BlackKeySet {
10+
display: block;
11+
position: absolute;
12+
left: 30px;
13+
}
14+
15+
.WhiteKeySet {
16+
display: block;
17+
position: absolute;
1118
}
1219

1320
.Key {
1421
border-color: rgb(0, 0, 0);
1522
top: 0px;
1623
display: inline-block;
17-
position: absolute;
1824
margin: 0px;
1925
padding: 0px;
2026
border-style: solid;
27+
border-width: 4px;
28+
vertical-align: top;
2129
}
2230

2331
.WhiteKey {
2432
background-color: rgb(255, 255, 255);
25-
border-width: 4px;
26-
width: 41px;
27-
height: 149px;
28-
vertical-align: top;
33+
width: 38px;
34+
height: 150px;
35+
margin-right: -8px;
36+
margin-left: 0px;
2937
}
3038

3139
.BlackKey {
3240
background-color: rgb(0, 0, 0);
33-
border-width: 4px;
34-
width: 23px;
41+
position: relative;
42+
margin-left: 0px;
43+
margin-right: 10px;
44+
margin-bottom: 48px;
45+
width: 20px;
46+
height: 90px;
47+
}
48+
49+
.BlackKeySpacer {
50+
border-style: none;
51+
width: 20px;
3552
height: 90px;
53+
margin-left: 0px;
54+
margin-right: 18px;
55+
}
56+
57+
.BlackKeyLeft {
58+
left: -2px;
59+
}
60+
61+
.BlackKeyCenter {
62+
left: 0px;
63+
}
64+
65+
.BlackKeyRight {
66+
left: 2px;
3667
}
3768

3869
.WhiteKey.On {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="icon" href="data:,">
7+
<title>Piano Display</title>
8+
9+
<script src="/Assets/libs/jquery/3.6.0/jquery.min.js"></script>
10+
<script src="/Assets/libs/signalr/6.0.0/signalr.min.js"></script>
11+
<link rel="stylesheet" type="text/css" href="/Assets/css/pianoDisplay.css" />
12+
</head>
13+
<body>
14+
<div class="Keyboard">
15+
<span class="WhiteKeySet">
16+
<span class="Key WhiteKey" id="k24"></span>
17+
<span class="Key WhiteKey" id="k26"></span>
18+
<span class="Key WhiteKey" id="k28"></span>
19+
<span class="Key WhiteKey" id="k29"></span>
20+
<span class="Key WhiteKey" id="k31"></span>
21+
<span class="Key WhiteKey" id="k33"></span>
22+
<span class="Key WhiteKey" id="k35"></span>
23+
<span class="Key WhiteKey" id="k36"></span>
24+
<span class="Key WhiteKey" id="k38"></span>
25+
<span class="Key WhiteKey" id="k40"></span>
26+
<span class="Key WhiteKey" id="k41"></span>
27+
<span class="Key WhiteKey" id="k43"></span>
28+
<span class="Key WhiteKey" id="k45"></span>
29+
<span class="Key WhiteKey" id="k47"></span>
30+
<span class="Key WhiteKey" id="k48"></span>
31+
<span class="Key WhiteKey" id="k50"></span>
32+
<span class="Key WhiteKey" id="k52"></span>
33+
<span class="Key WhiteKey" id="k53"></span>
34+
<span class="Key WhiteKey" id="k55"></span>
35+
<span class="Key WhiteKey" id="k57"></span>
36+
<span class="Key WhiteKey" id="k59"></span>
37+
<span class="Key WhiteKey" id="k60"></span>
38+
<span class="Key WhiteKey" id="k62"></span>
39+
<span class="Key WhiteKey" id="k64"></span>
40+
<span class="Key WhiteKey" id="k65"></span>
41+
<span class="Key WhiteKey" id="k67"></span>
42+
<span class="Key WhiteKey" id="k69"></span>
43+
<span class="Key WhiteKey" id="k71"></span>
44+
<span class="Key WhiteKey" id="k72"></span>
45+
<span class="Key WhiteKey" id="k74"></span>
46+
<span class="Key WhiteKey" id="k76"></span>
47+
<span class="Key WhiteKey" id="k77"></span>
48+
<span class="Key WhiteKey" id="k79"></span>
49+
<span class="Key WhiteKey" id="k81"></span>
50+
<span class="Key WhiteKey" id="k83"></span>
51+
<span class="Key WhiteKey" id="k84"></span>
52+
<span class="Key WhiteKey" id="k86"></span>
53+
<span class="Key WhiteKey" id="k88"></span>
54+
<span class="Key WhiteKey" id="k89"></span>
55+
<span class="Key WhiteKey" id="k91"></span>
56+
<span class="Key WhiteKey" id="k93"></span>
57+
<span class="Key WhiteKey" id="k95"></span>
58+
<span class="Key WhiteKey" id="k96"></span>
59+
</span>
60+
<div class="BlackKeySet">
61+
<span class="Key BlackKey BlackKeyLeft" id="k25"></span>
62+
<span class="Key BlackKey BlackKeyRight" id="k27"></span>
63+
<span class="Key BlackKeySpacer"></span>
64+
<span class="Key BlackKey BlackKeyLeft" id="k30"></span>
65+
<span class="Key BlackKey BlackKeyCenter" id="k32"></span>
66+
<span class="Key BlackKey BlackKeyRight" id="k34"></span>
67+
<span class="Key BlackKeySpacer"></span>
68+
<span class="Key BlackKey BlackKeyLeft" id="k37"></span>
69+
<span class="Key BlackKey BlackKeyRight" id="k39"></span>
70+
<span class="Key BlackKeySpacer"></span>
71+
<span class="Key BlackKey BlackKeyLeft" id="k42"></span>
72+
<span class="Key BlackKey BlackKeyCenter" id="k44"></span>
73+
<span class="Key BlackKey BlackKeyRight" id="k46"></span>
74+
<span class="Key BlackKeySpacer"></span>
75+
<span class="Key BlackKey BlackKeyLeft" id="k49"></span>
76+
<span class="Key BlackKey BlackKeyRight" id="k51"></span>
77+
<span class="Key BlackKeySpacer"></span>
78+
<span class="Key BlackKey BlackKeyLeft" id="k54"></span>
79+
<span class="Key BlackKey BlackKeyCenter" id="k56"></span>
80+
<span class="Key BlackKey BlackKeyRight" id="k58"></span>
81+
<span class="Key BlackKeySpacer"></span>
82+
<span class="Key BlackKey BlackKeyLeft" id="k61"></span>
83+
<span class="Key BlackKey BlackKeyRight" id="k63"></span>
84+
<span class="Key BlackKeySpacer"></span>
85+
<span class="Key BlackKey BlackKeyLeft" id="k66"></span>
86+
<span class="Key BlackKey BlackKeyCenter" id="k68"></span>
87+
<span class="Key BlackKey BlackKeyRight" id="k70"></span>
88+
<span class="Key BlackKeySpacer"></span>
89+
<span class="Key BlackKey BlackKeyLeft" id="k73"></span>
90+
<span class="Key BlackKey BlackKeyRight" id="k75"></span>
91+
<span class="Key BlackKeySpacer"></span>
92+
<span class="Key BlackKey BlackKeyLeft" id="k78"></span>
93+
<span class="Key BlackKey BlackKeyCenter" id="k80"></span>
94+
<span class="Key BlackKey BlackKeyRight" id="k82"></span>
95+
<span class="Key BlackKeySpacer"></span>
96+
<span class="Key BlackKey BlackKeyLeft" id="k85"></span>
97+
<span class="Key BlackKey BlackKeyRight" id="k87"></span>
98+
<span class="Key BlackKeySpacer"></span>
99+
<span class="Key BlackKey BlackKeyLeft" id="k90"></span>
100+
<span class="Key BlackKey BlackKeyCenter" id="k92"></span>
101+
<span class="Key BlackKey BlackKeyRight" id="k94"></span>
102+
</div>
103+
</div>
104+
105+
<script src="/Assets/js/pianoDisplay.js"></script>
106+
</body>
107+
</html>

0 commit comments

Comments
 (0)