aboutsummaryrefslogtreecommitdiff
path: root/AudioTester
diff options
context:
space:
mode:
authorbonmas14 <bonmas14@gmail.com>2023-10-26 14:17:12 +0300
committerbonmas14 <bonmas14@gmail.com>2023-10-26 14:17:12 +0300
commit0ee008ae77fb76cbe9fe151cc6c4bc9f89cb98a5 (patch)
tree3bd7d0169f38e38c53f16bba244381d5f348d0f3 /AudioTester
parent91d37e2f17ca0e3d9f122c54268356edb1fd2978 (diff)
downloadRayRoom-0ee008ae77fb76cbe9fe151cc6c4bc9f89cb98a5.tar.gz
RayRoom-0ee008ae77fb76cbe9fe151cc6c4bc9f89cb98a5.zip
- code cleanup and settings change
Diffstat (limited to 'AudioTester')
-rw-r--r--AudioTester/Core/RenderStreamer.cs12
-rw-r--r--AudioTester/Program.cs26
-rw-r--r--AudioTester/RayRoomSettings.cs8
3 files changed, 23 insertions, 23 deletions
diff --git a/AudioTester/Core/RenderStreamer.cs b/AudioTester/Core/RenderStreamer.cs
index 85f76a5..c7d2595 100644
--- a/AudioTester/Core/RenderStreamer.cs
+++ b/AudioTester/Core/RenderStreamer.cs
@@ -1,6 +1,4 @@
-using NAudio.Codecs;
-using NAudio.Wave;
-using NAudio.Wave.SampleProviders;
+using NAudio.Wave;
namespace AudioTester.Core
{
@@ -22,16 +20,16 @@ namespace AudioTester.Core
sample = 0;
streamReader = new AudioFileReader(@"Resources\test.wav");
-
+
provider = streamReader.ToSampleProvider();
}
public int Read(float[] buffer, int offset, int count)
{
- int length = provider.Read(buffer, offset, count);
-
+ int length = provider.Read(buffer, offset, count);
+
Console.WriteLine("i: {0}; o:{1}", count, length);
-
+
if (length < count)
{
streamReader.Position = 0;
diff --git a/AudioTester/Program.cs b/AudioTester/Program.cs
index 14212af..95d6049 100644
--- a/AudioTester/Program.cs
+++ b/AudioTester/Program.cs
@@ -9,35 +9,39 @@ 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();
+ AudioSimulator a = new AudioSimulator(new Settings(44100, 5, 330));
- var array = a.Simulate(Vector2.Zero, 360);
- var bitmap = new Bitmap(2000, 2000);
+ var array = a.Simulate(Vector2.Zero, 3600);
+ var bitmap = new Bitmap(width, height);
- Matrix2x2 mat = new Matrix2x2(Vector2.UnitX * 100f, Vector2.UnitY * -100f);
+ Matrix2x2 mat = new(Vector2.UnitX * scale, Vector2.UnitY * -scale);
- Pen background = new Pen(Color.FromArgb(5, Color.White), 4);
- Pen foreground = new Pen(Color.FromArgb(25, Color.White), 1);
+ 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(background, (array[i].a * mat + new Vector2(1000, 1000)).GetPoint(), (array[i].b * mat + new Vector2(1000, 1000)).GetPoint());
- g.DrawLine(foreground, (array[i].a * mat + new Vector2(1000, 1000)).GetPoint(), (array[i].b * mat + new Vector2(1000, 1000)).GetPoint());
+ g.DrawLine(foreground,
+ (array[i].a * mat + offset).GetPoint(),
+ (array[i].b * mat + offset).GetPoint());
}
}
- bitmap.Save("bitmap.bmp");
+ 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);
@@ -46,7 +50,7 @@ namespace AudioTester
while (wo.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
-
+
if (Console.KeyAvailable)
wo.Stop();
}
diff --git a/AudioTester/RayRoomSettings.cs b/AudioTester/RayRoomSettings.cs
index c469279..8b05bcd 100644
--- a/AudioTester/RayRoomSettings.cs
+++ b/AudioTester/RayRoomSettings.cs
@@ -7,11 +7,9 @@ namespace AudioTester
{
public static Settings GetSettingsFromWaveFromat(WaveFormat format, Settings baseSettings)
{
- return new Settings(format.SampleRate,
- baseSettings.maxRayReflections,
- baseSettings.maxDiffusionRays,
- baseSettings.fadeFactorPerMeter,
- baseSettings.speedOfSoundMetersPerSec);
+ return new Settings(format.SampleRate,
+ baseSettings.maxRayReflections,
+ baseSettings.speedOfSound);
}
}
}