-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerator.cs
More file actions
47 lines (44 loc) · 1.29 KB
/
Copy pathGenerator.cs
File metadata and controls
47 lines (44 loc) · 1.29 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFT
{
public static class Generator
{
public static int[] GetSin(int length, double hzRad = 6.28, int amplitude = 128)
{
int[] buf = new int[length];
for (var i = 0; i < length; i++)
{
int v = (int)(Math.Sin(i / hzRad) * amplitude);
if (v > 129) v = 129;
if (v < -129) v = -129;
buf[i] = v;
}
return buf;
}
public static int[] GetMeandr(int length, double hzRad = 6.28, int amplitude = 128)
{
int[] buf = new int[length];
for (var i = 0; i < length; i++)
{
int v = (int)(Math.Sin(i / hzRad) * amplitude);
if (v > 0) v = amplitude;
if (v < 0) v = -amplitude;
buf[i] = v;
}
return buf;
}
public static int[] CombineSignal(int[] signal1, int[] signal2)
{
int[] buf = new int[signal1.Length];
for (var i = 0; i < signal1.Length; i++)
{
buf[i] = signal1[i] + signal2[i];
}
return buf;
}
}
}