Table of Contents

Class Microtones

Namespace
SunSharp
Assembly
SunSharp.dll

Provides conversion methods between SunVox pitch values and frequencies in Hz.

public static class Microtones
Inheritance
object
Microtones

Methods

FrequencyToPitch(double)

Converts a frequency in Hz to a SunVox pitch value.

public static double FrequencyToPitch(double frequency)

Parameters

frequency double

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

frequency float

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

noteName NoteName
octave int

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

pitch double

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

pitch float

Returns

float

Remarks

Formula: freq = 2^((30720 - pitch) / 3072) * 16.333984375

Exceptions

ArgumentException

Thrown when pitch results in an invalid frequency.