Class Microtones
- Namespace
- SunSharp
- Assembly
- SunSharp.dll
Provides conversion methods between SunVox pitch values and frequencies in Hz.
public static class Microtones
- Inheritance
-
objectMicrotones
Methods
FrequencyToPitch(double)
Converts a frequency in Hz to a SunVox pitch value.
public static double FrequencyToPitch(double frequency)
Parameters
frequencydouble
Returns
- double
Remarks
Formula: pitch = 30720 - log2(freq / 16.333984375) * 3072
Exceptions
- ArgumentException
Thrown when frequency is not a positive finite number.
FrequencyToPitch(float)
Converts a frequency in Hz to a SunVox pitch value.
public static float FrequencyToPitch(float frequency)
Parameters
frequencyfloat
Returns
- float
Remarks
Formula: pitch = 30720 - log2(freq / 16.333984375) * 3072
Exceptions
- ArgumentException
Thrown when frequency is not a positive finite number.
NoteToPitch(NoteName, int)
Converts a musical note name and octave to a SunVox pitch value.
public static short NoteToPitch(NoteName noteName, int octave)
Parameters
noteNameNoteNameoctaveint
Returns
- short
The SunVox pitch value corresponding to the given note and octave.
Remarks
Supported range is from C0 (0x7800) to C10 (0x0000).
Exceptions
- ArgumentException
- ArgumentOutOfRangeException
PitchToFrequency(double)
Converts a SunVox pitch value to frequency in Hz.
public static double PitchToFrequency(double pitch)
Parameters
pitchdouble
Returns
- double
Remarks
Formula: freq = 2^((30720 - pitch) / 3072) * 16.333984375
Exceptions
- ArgumentException
Thrown when pitch results in an invalid frequency.
PitchToFrequency(float)
Converts a SunVox pitch value to frequency in Hz.
public static float PitchToFrequency(float pitch)
Parameters
pitchfloat
Returns
- float
Remarks
Formula: freq = 2^((30720 - pitch) / 3072) * 16.333984375
Exceptions
- ArgumentException
Thrown when pitch results in an invalid frequency.