Skip to content

Commit

Permalink
Ready for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
BackTrak committed Dec 19, 2023
1 parent d8e80a8 commit 1368537
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 112 deletions.
Binary file added Images/action20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/blue.xcf
Binary file not shown.
Binary file removed Images/blue72.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
4 changes: 0 additions & 4 deletions Images/camera-lens-svgrepo-com.svg

This file was deleted.

Binary file modified Images/categoryIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/default.xcf
Binary file not shown.
48 changes: 48 additions & 0 deletions Images/equalizer-1-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/gray.xcf
Binary file not shown.
Binary file removed Images/gray72.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
Binary file removed Images/green.xcf
Binary file not shown.
Binary file removed Images/green72.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
Binary file removed Images/icon.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
Binary file removed Images/pluginAction.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
Binary file removed Images/pluginIcon.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
Binary file modified Images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/zhgold72.png
Binary file not shown.
Binary file removed Images/[email protected]
Binary file not shown.
18 changes: 6 additions & 12 deletions PropertyInspector/PluginActionPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
</div>

<div class="sdpi-item" id="gradient_color_select">
<div class="sdpi-item-label">Custom Color</div>
<div class="sdpi-item-label">Gradient Color</div>
<select class="sdProperty sdpi-item-value select" id="gradient_color" oninput="setSettings()">
<option value="AliceBlue">AliceBlue</option>
<option value="AntiqueWhite">AntiqueWhite</option>
Expand Down Expand Up @@ -342,17 +342,6 @@
}
}

function pollForControls() {
if (websocket == null) {
setTimeout(pollForControls, 100);
}
else {
onSelectionChange();
}
}

pollForControls();

document.addEventListener('websocketCreate', function () {
websocket.addEventListener('message', function (event) {
console.log("Got message event!", event.data);
Expand All @@ -370,6 +359,11 @@
message.payload.DeviceList.forEach((element) => {
$('#visualizer_device').append('<option value="' + element.ID + '">' + element.Name + '</option>');
});

$('#visualizer_device').val(message.payload.SelectedDevice).change();

// Set dropdown visibility once all the values and selected options have been set.
onSelectionChange();
}
});

Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
# Stream Deck Visualizer
# Stream Deck Visualizer

This plugin is used is used to visualize audio input / output from any sound device you have attached to your PC.

Pre-requisites.
* Install the latest version of [dotnet](https://dotnet.microsoft.com/en-us/download)
To install, clone or download the repo, and build it.
* Run the `install.bat`

I have submitted this to the Elgato marketplace, so most people should install it from there after it's been accepted.


### Thank Yous
* BarRaider: https://github.com/BarRaider/streamdeck-tools
* Mark Heath / NAudio: https://github.com/naudio/NAudio
* Icooon Mono: https://icooon-mono.com

# Stream Info
I stream every night at 10pm Central on Twitch. If you like League of Legends and a chill stream, come and check me out!

https://www.twitch.tv/b4cktr4k
52 changes: 5 additions & 47 deletions VisualizerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ public class VisualizerPlugin : KeypadBase

private bool _wasEnabledOnLastTick = false;

//https://stackoverflow.com/questions/18813112/naudio-fft-result-gives-intensity-on-all-frequencies-c-sharp/20414331#20414331

// Other inputs are also usable. Just look through the NAudio library.
//private IWaveIn waveIn;
//private static int fftLength = 8192; // NAudio fft wants powers of two!
//private static int fftLength = 512; // NAudio fft wants powers of two!
// There might be a sample aggregator in NAudio somewhere but I made a variation for my needs
//private SampleAggregator sampleAggregator = new SampleAggregator(fftLength);
// https://stackoverflow.com/questions/18813112/naudio-fft-result-gives-intensity-on-all-frequencies-c-sharp/20414331#20414331

private WasapiCapture _audioDevice = null;
private double[] _audioValues;
Expand Down Expand Up @@ -83,34 +76,21 @@ public VisualizerPlugin(SDConnection connection, InitialPayload payload) : base(
while (_visualizerActive == true)
{
RenderData();
Thread.Sleep(15);
Thread.Sleep(20);
}
}
});

connection.OnSendToPlugin += Connection_OnSendToPlugin;

//sampleAggregator.FftCalculated += new EventHandler<FftEventArgs>(FftCalculated);
//sampleAggregator.PerformFFT = true;

CaptureTargetAudioDevice();
SendCurrentAudioDevices(connection);

//connection.SendToPropertyInspectorAsync(JObject.Parse($"{{'currentTime': '{DateTime.Now.ToString()}'}}"));
}

private void Connection_OnSendToPlugin(object sender, SDEventReceivedEventArgs<SendToPlugin> e)
{
if(e.Event.Payload.TryGetValue("property_inspector", out var value) == true && value.Value<String>() == "propertyInspectorConnected")
SendCurrentAudioDevices((SDConnection)sender);

// +e.Event.Payload {
// {
// "property_inspector": "propertyInspectorConnected"
//}
// }
// Newtonsoft.Json.Linq.JObject

}

private void SendCurrentAudioDevices(SDConnection connection)
Expand All @@ -121,22 +101,9 @@ private void SendCurrentAudioDevices(SDConnection connection)
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active | DeviceState.Unplugged)
.Select(p => new { Name = p.FriendlyName, ID = p.ID });

var deviceList = new { DeviceList = devices };

//NameValueCollection devices = new NameValueCollection();


var deviceList = new { DeviceList = devices, SelectedDevice = _targetDeviceID };

//foreach (var device in _deviceEnum.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active | DeviceState.Unplugged))
// devices.Add(device.FriendlyName, device.ID);

var json = JsonConvert.SerializeObject(deviceList);



var jobjectDevices = JObject.Parse(json);

//var jobjectDevices = JObject.FromObject(devices);
var jobjectDevices = JObject.FromObject(deviceList);

connection.SendToPropertyInspectorAsync(jobjectDevices);
}
Expand All @@ -146,9 +113,6 @@ private void CaptureTargetAudioDevice()
if (_audioDevice != null)
_audioDevice.StopRecording();

// Here you decide what you want to use as the waveIn.
// There are many options in NAudio and you can use other streams/files.
// Note that the code varies for each different source.
if (String.IsNullOrWhiteSpace(_targetDeviceID) == true)
{
_audioDevice = new WasapiLoopbackCapture();
Expand All @@ -169,11 +133,6 @@ private void CaptureTargetAudioDevice()
// If the target device could not be loaded, then just grab the default output device.
_audioDevice = new WasapiLoopbackCapture();
}

//if (targetDevice != null)
// _audioDevice = new WasapiLoopbackCapture(targetDevice);
//else

}

WaveFormat fmt = _audioDevice.WaveFormat;
Expand Down Expand Up @@ -219,7 +178,6 @@ private void RenderData()
{
try
{

double[] paddedAudio = FftSharp.Pad.ZeroPad(_audioValues);
double[] fftMag = FftSharp.Transform.FFTmagnitude(paddedAudio);
Array.Copy(fftMag, _fftValues, fftMag.Length);
Expand All @@ -234,7 +192,7 @@ private void RenderData()
peaks[i] -= max[i] / 20;

// Decay max over a longer time so that a loud sound doesn't pin the levels too low over time.
max[i] -= max[i] / 2000;
//max[i] -= max[i] / 2000;


double rangeMax = 0;
Expand Down
52 changes: 9 additions & 43 deletions com.zaphop.visualizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,6 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Images\blue.xcf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\default.xcf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\gray.xcf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\green.xcf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Install.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -165,6 +153,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="previews\Preview.xcf" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
Expand All @@ -173,13 +162,10 @@
<Content Include="DistributionTool.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\blue72%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\blue72.png">
<Content Include="Images\action20%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\camera-lens-svgrepo-com.svg">
<Content Include="Images\action20.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\categoryIcon%402x.png">
Expand All @@ -188,43 +174,23 @@
<Content Include="Images\categoryIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\gray72%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\gray72.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\green72%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\green72.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\icon%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\pluginAction%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\pluginAction.png">
<Content Include="Images\equalizer-1-svgrepo-com.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\pluginIcon%402x.png">
<Content Include="Images\zaphop logo gold.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\pluginIcon.png">
<Content Include="Images\zaphop logo.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\zhgold72%402x.png">
<Content Include="Images\zhgold288%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\zhgold72.png">
<Content Include="Images\zhgold288.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="LICENSE.txt" />
<Content Include="previews\Preview.png" />
<Content Include="PropertyInspector\PluginActionPI.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"Actions": [
{
"Icon": "Images/zhgold72",
"Icon": "Images/action20",
"Name": "Visualizer",
"States": [
{
"Image": "Images/zhgold72",
"Image": "Images/action20",
"TitleAlignment": "bottom",
"FontSize": "7"
}
Expand All @@ -21,9 +21,9 @@
"Description": "Visualizer",
"Name": "Visualizer",
"Category": "Visualizer",
"CategoryIcon": "Images/zhgold72",
"Icon": "Images/zhgold72",
"URL": "https://www.zaphop.com",
"CategoryIcon": "Images/categoryIcon",
"Icon": "Images/zhgold288",
"URL": "https://github.com/BackTrak/StreamDeckVisualizerPlugin",
"Version": "1.0",
"PropertyInspectorPath": "PropertyInspector/PluginActionPI.html",
"OS": [
Expand Down
Binary file added previews/Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added previews/Preview.xcf
Binary file not shown.

0 comments on commit 1368537

Please sign in to comment.