Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added audio visualization for stairway to heaven #15

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Halovision/Halovision.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
<None Include="Resources\rewind.mp3" />
<None Include="Resources\return.mp3" />
<None Include="Resources\enter.mp3" />
<None Include="Resources\guitar.mp3" />
<None Include="Resources\glitch.mp3" />
<Content Include="x64\concrt140.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
53 changes: 51 additions & 2 deletions Halovision/PluginHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
Expand Down Expand Up @@ -238,7 +239,7 @@ public override double Value
{
get
{
history.Add(Convert.ToInt32(Device.GetVision()));
history.Add(Device.GetVision());
if (history.Count > 1000) { history.RemoveAt(0); }

int tossValue = 0;
Expand All @@ -258,6 +259,11 @@ public override double Value
tossValue = 0;
}

if (tossValue == 999 - tossHalfLife)
{
PlayGlitch();
}

Device.SetTossValue(tossValue);
return tossValue;
}
Expand All @@ -267,6 +273,22 @@ public override void Dispose()
{
Device.Dispose();
}

private void PlayGlitch()
{
try
{
MemoryStream mp3file = new MemoryStream(Properties.Resources.glitch);
Mp3FileReader mp3reader = new Mp3FileReader(mp3file);
var waveOut = new WaveOutEvent();
waveOut.Init(mp3reader);
waveOut.Play();
}
catch (Exception ex)
{

}
}
}
}

Expand Down Expand Up @@ -484,6 +506,7 @@ public override bool Initialize()
}

List<int> history = new List<int>();
int previousValue = 0;

public override double Value
{
Expand All @@ -500,7 +523,7 @@ public override double Value
int eyeMoveMax = Device.GetEyeMoveMax();
int idleTicks = Device.GetIdleTicks();

history.Add(Convert.ToInt32(Device.GetVision()));
history.Add(Device.GetVision());
if (history.Count > 768) { history.RemoveAt(0); }

// Check for blinks
Expand Down Expand Up @@ -604,6 +627,16 @@ public override double Value
{ return 888; }

if (intBlinks > 10) { intBlinks = 10; }

if (previousValue != intBlinks)
{
if (previousValue < intBlinks)
{
if (Device.Auralize) PluckString();
}
previousValue = intBlinks;
}

return intBlinks * 100;
}
}
Expand All @@ -612,6 +645,22 @@ public override void Dispose()
{
Device.Dispose();
}

private void PluckString()
{
try
{
MemoryStream mp3file = new MemoryStream(Properties.Resources.guitar);
Mp3FileReader mp3reader = new Mp3FileReader(mp3file);
var waveOut = new WaveOutEvent();
waveOut.Init(mp3reader);
waveOut.Play();
}
catch (Exception ex)
{

}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Halovision/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: AssemblyVersion("1.2.5.0")]
[assembly: AssemblyFileVersion("1.2.5.0")]
20 changes: 20 additions & 0 deletions Halovision/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Halovision/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
<data name="g" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\g.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="glitch" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\glitch.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="guitar" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\guitar.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="h" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\h.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
Binary file added Halovision/Resources/glitch.mp3
Binary file not shown.
Binary file added Halovision/Resources/guitar.mp3
Binary file not shown.
6 changes: 3 additions & 3 deletions Installer/Lucid Scribe Halovision.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -11352,15 +11352,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe Halovision"
"ProductCode" = "8:{0A90DC5A-E6FE-4BD8-A9F4-E377E67BD83F}"
"PackageCode" = "8:{C140AB67-58D5-4B5E-9B04-41683F4AD0BB}"
"ProductCode" = "8:{0D9CC507-CE76-4FD9-99D0-774734E8C965}"
"PackageCode" = "8:{B2C9CCE1-2D02-44FC-96D5-D34D5898A95A}"
"UpgradeCode" = "8:{CAAB2187-AD23-435C-A3DB-568744247625}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.2.4"
"ProductVersion" = "8:1.2.5"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucidcode.com/Contact"
Expand Down