Sending changes to a plugin
This commit is contained in:
parent
c514afacd6
commit
3ecb1440a2
3 changed files with 17 additions and 31 deletions
|
@ -35,7 +35,8 @@ namespace MCAudioSpectrumAnalyzer
|
|||
_t = new Timer();
|
||||
_t.Tick += _t_Tick;
|
||||
//_t.Interval = 25; //40hz refresh rate
|
||||
_t.Interval = 50; //20 Hz
|
||||
//_t.Interval = 50; //20 Hz
|
||||
_t.Interval = 1000;
|
||||
_t.Enabled = false;
|
||||
_l = left;
|
||||
_r = right;
|
||||
|
|
13
MCAudioSpectrumAnalyzer/Form1.Designer.cs
generated
13
MCAudioSpectrumAnalyzer/Form1.Designer.cs
generated
|
@ -28,18 +28,9 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(25, 29);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(349, 156);
|
||||
this.textBox1.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(417, 90);
|
||||
|
@ -56,17 +47,13 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(733, 299);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Diagnostics;
|
|||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
@ -15,39 +17,35 @@ namespace MCAudioSpectrumAnalyzer
|
|||
public partial class Form1 : Form
|
||||
{
|
||||
public static Form1 Instance;
|
||||
private static StreamWriter sw = new StreamWriter(new FileStream("output.txt", FileMode.Create));
|
||||
private static int X = 0;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
Instance = this; //TODO: Send to a Java plugin instead
|
||||
Instance = this;
|
||||
Analyzer = new Analyzer(new ProgressBar(), new ProgressBar(), new ComboBox());
|
||||
}
|
||||
|
||||
public void Set(List<byte> data)
|
||||
{
|
||||
if (data.Count < 16) return;
|
||||
data.ForEach(entry => SetBar(entry, entry));
|
||||
for (int i = 0; i < data.Count / 2; i++)
|
||||
if (data[i] == 0)
|
||||
SetBar((byte)i, 1);
|
||||
else
|
||||
SetBar((byte)i, (byte)(data[i] * 2));
|
||||
}
|
||||
|
||||
|
||||
private UdpClient client = new UdpClient(AddressFamily.InterNetwork);
|
||||
private void SetBar(byte index, byte data)
|
||||
{
|
||||
byte value = (byte)((((double)data) / 255) * 80);
|
||||
textBox1.AppendText("SetBar: " + value + "\n");
|
||||
sw.WriteLine(string.Concat("#", X++, ",64,0" + ":@"));
|
||||
sw.WriteLine(string.Concat("scoreboard players set t", (X + 1).ToString(), " tracks ", value));
|
||||
sw.WriteLine("");
|
||||
}
|
||||
|
||||
~Form1()
|
||||
{
|
||||
sw.Close();
|
||||
client.Send(new byte[2] { (byte)(index + 1), data }, 2, new IPEndPoint(IPAddress.Loopback, 5896));
|
||||
}
|
||||
|
||||
private Analyzer Analyzer;
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
new Analyzer(new ProgressBar(), new ProgressBar(), new ComboBox()).Enable = true;
|
||||
button1.Enabled = false;
|
||||
button1.Text = "Close to stop";
|
||||
Analyzer.Enable = !Analyzer.Enable;
|
||||
button1.Text = (Analyzer.Enable ? "Disable" : "Enable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue