2015-10-19 16:04:11 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2015-10-19 19:06:15 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Sockets;
|
2015-10-19 16:04:11 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace MCAudioSpectrumAnalyzer
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
public static Form1 Instance;
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-10-19 19:06:15 +00:00
|
|
|
|
Instance = this;
|
|
|
|
|
Analyzer = new Analyzer(new ProgressBar(), new ProgressBar(), new ComboBox());
|
2015-10-19 16:04:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Set(List<byte> data)
|
|
|
|
|
{
|
|
|
|
|
if (data.Count < 16) return;
|
2015-10-28 11:25:15 +00:00
|
|
|
|
//for (int i = 0; i < data.Count / 2; i++)
|
|
|
|
|
/*for (int i = 0; i < 1; i++)
|
2015-10-19 19:06:15 +00:00
|
|
|
|
if (data[i] == 0)
|
|
|
|
|
SetBar((byte)i, 1);
|
|
|
|
|
else
|
2015-10-28 11:25:15 +00:00
|
|
|
|
SetBar((byte)i, data[i * 2]);*/
|
|
|
|
|
byte i = 10;
|
|
|
|
|
if (data[i] == 0)
|
|
|
|
|
SetBar(0, 1);
|
|
|
|
|
else
|
|
|
|
|
SetBar(0, data[i]);
|
2015-10-19 16:04:11 +00:00
|
|
|
|
}
|
2015-10-19 19:06:15 +00:00
|
|
|
|
|
2015-10-28 11:25:15 +00:00
|
|
|
|
/*
|
|
|
|
|
128.234 56 -622.622 -0.9 -21.1
|
|
|
|
|
|
|
|
|
|
Removed unnecessary block clearups
|
|
|
|
|
Made it catch up to 25 Hz
|
|
|
|
|
Fixed snow layer data value setting
|
|
|
|
|
*/
|
|
|
|
|
|
2015-10-19 19:06:15 +00:00
|
|
|
|
private UdpClient client = new UdpClient(AddressFamily.InterNetwork);
|
2015-10-19 16:04:11 +00:00
|
|
|
|
private void SetBar(byte index, byte data)
|
|
|
|
|
{
|
2015-10-23 22:33:04 +00:00
|
|
|
|
//byte value = (byte)((((double)data) / 255) * 80);
|
2015-10-19 19:06:15 +00:00
|
|
|
|
client.Send(new byte[2] { (byte)(index + 1), data }, 2, new IPEndPoint(IPAddress.Loopback, 5896));
|
2015-10-19 16:04:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 19:06:15 +00:00
|
|
|
|
private Analyzer Analyzer;
|
2015-10-19 16:04:11 +00:00
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-10-19 19:06:15 +00:00
|
|
|
|
Analyzer.Enable = !Analyzer.Enable;
|
|
|
|
|
button1.Text = (Analyzer.Enable ? "Disable" : "Enable");
|
2015-10-19 16:04:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|