BGC Tools
Static Public Member Functions | Properties | Static Private Member Functions
BGC.Audio.FrequencyDomain Class Reference

Collection of common mathematical processes used in the Frequency-Domain. More...

Static Public Member Functions

static void Populate (Complex64[] buffer, in ComplexCarrierTone carrierTone, double amplitudeFactor=1.0, int sideFreqCount=20)
 
static void Populate (Complex64[] buffer, double frequency, Complex64 amplitude, int sideFreqCount=20)
 
static double GetComplexSampleFrequency (int bufferSize, int sample)
 
static double GetComplexFrequencySample (int bufferSize, double frequency)
 
static int GetComplexFrequencyBin (int bufferSize, double frequency)
 

Properties

static double SamplingRate [get, set]
 

Static Private Member Functions

static double GetComplexNormalizedDeviation (int bufferSize, double frequency)
 Get f_Delta * T More...
 

Detailed Description

Collection of common mathematical processes used in the Frequency-Domain.

Definition at line 9 of file FrequencyDomain.cs.

Member Function Documentation

◆ GetComplexFrequencyBin()

static int BGC.Audio.FrequencyDomain.GetComplexFrequencyBin ( int  bufferSize,
double  frequency 
)
static

◆ GetComplexFrequencySample()

static double BGC.Audio.FrequencyDomain.GetComplexFrequencySample ( int  bufferSize,
double  frequency 
)
static

◆ GetComplexNormalizedDeviation()

static double BGC.Audio.FrequencyDomain.GetComplexNormalizedDeviation ( int  bufferSize,
double  frequency 
)
staticprivate

Get f_Delta * T

◆ GetComplexSampleFrequency()

static double BGC.Audio.FrequencyDomain.GetComplexSampleFrequency ( int  bufferSize,
int  sample 
)
static

◆ Populate() [1/2]

static void BGC.Audio.FrequencyDomain.Populate ( Complex64 []  buffer,
in ComplexCarrierTone  carrierTone,
double  amplitudeFactor = 1.0,
int  sideFreqCount = 20 
)
inlinestatic

Definition at line 13 of file FrequencyDomain.cs.

Referenced by BGC.Audio.Synthesis.NoiseAudioClip._Initialize(), BGC.Audio.Synthesis.STMAudioClip._Initialize(), BGC.Audio.AnalyticStreams.AnalyticNoiseStream.Initialize(), and BGC.Audio.Synthesis.FrequencyDomainToneComposer.Read().

18  {
19  Populate(
20  buffer: buffer,
21  frequency: carrierTone.frequency,
22  amplitude: amplitudeFactor * carrierTone.amplitude,
23  sideFreqCount: sideFreqCount);
24  }
static void Populate(Complex64[] buffer, in ComplexCarrierTone carrierTone, double amplitudeFactor=1.0, int sideFreqCount=20)
Here is the caller graph for this function:

◆ Populate() [2/2]

static void BGC.Audio.FrequencyDomain.Populate ( Complex64 []  buffer,
double  frequency,
Complex64  amplitude,
int  sideFreqCount = 20 
)
inlinestatic

Definition at line 26 of file FrequencyDomain.cs.

References BGC.Mathematics.Complex64.FromPolarCoordinates(), and BGC.Mathematics.Complex64.Sqrt().

31  {
32  int bin = GetComplexFrequencyBin(
33  bufferSize: buffer.Length,
34  frequency: frequency);
35 
36  if (bin < 1 || bin > buffer.Length / 2)
37  {
38  //Skipping frequency as it's out of range
39  return;
40  }
41 
42  double normalizedDeviation = GetComplexNormalizedDeviation(
43  bufferSize: buffer.Length,
44  frequency: frequency);
45 
46  amplitude *= Math.Sqrt(buffer.Length);
47 
48  if (normalizedDeviation == 0.0)
49  {
50  //Perfect - No side terms
51  buffer[bin] += amplitude;
52  return;
53  }
54 
55  amplitude *= (Math.Sin(Math.PI * normalizedDeviation) / Math.PI) *
56  Complex64.FromPolarCoordinates(1.0, Math.PI * normalizedDeviation);
57 
58  for (int N = -sideFreqCount; N <= sideFreqCount; N++)
59  {
60  if (bin + N < 1 || bin + N > buffer.Length / 2)
61  {
62  //Skip frequencies out of range
63  continue;
64  }
65 
66  buffer[bin + N] += amplitude / (N - normalizedDeviation);
67  }
68  }
static Complex64 Sqrt(in Complex64 value)
The Square Root of a complex number
static double GetComplexNormalizedDeviation(int bufferSize, double frequency)
Get f_Delta * T
Represents a complex number with double-precision floating point components
Definition: Complex64.cs:39
static int GetComplexFrequencyBin(int bufferSize, double frequency)
static Complex64 FromPolarCoordinates(double magnitude, double phase)
Creates a complex number from a point&#39;s polar coordinates.
Here is the call graph for this function:

Property Documentation

◆ SamplingRate

double BGC.Audio.FrequencyDomain.SamplingRate
staticgetset

Definition at line 11 of file FrequencyDomain.cs.


The documentation for this class was generated from the following file: