aboutsummaryrefslogtreecommitdiff
path: root/AudioTester/Program.cs
blob: 95d604933a95c54dfaebc867a64f01085ad2afc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using AudioTester.Core;
using AudioTester.Core.Extensions;
using NAudio.Wave;
using RayRoom.Core;
using System.Drawing;
using System.Numerics;

namespace AudioTester
{
    internal class Program
    {
        private const int width = 1280;
        private const int height = 720;
        private const float scale = 100;
#pragma warning disable CA1416 // Проверка совместимости платформы
        static void Main(string[] args)
        {
            AudioSimulator a = new AudioSimulator(new Settings(44100, 5, 330));

            var array = a.Simulate(Vector2.Zero, 3600);
            var bitmap = new Bitmap(width, height);

            Matrix2x2 mat = new(Vector2.UnitX * scale, Vector2.UnitY * -scale);

            Pen foreground = new(Color.FromArgb(20, Color.White), 1);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.Clear(Color.Black);

                Vector2 offset = new(width / 2, height / 2); 
                for (int i = 0; i < array.Length; i++)
                {
                    g.DrawLine(foreground, 
                        (array[i].a * mat + offset).GetPoint(), 
                        (array[i].b * mat + offset).GetPoint());
                }
            }

            bitmap.Save($"bitmap.png");
#pragma warning restore CA1416 // Проверка совместимости платформы
            return;
            var device = new RenderStreamer();

            using (var wo = new WasapiOut(NAudio.CoreAudioApi.AudioClientShareMode.Shared, 150))
            {
                wo.Init(device);
                wo.Play();

                while (wo.PlaybackState == PlaybackState.Playing)
                {
                    Thread.Sleep(100);

                    if (Console.KeyAvailable)
                        wo.Stop();
                }
            }
        }
    }
}