< Summary

Information
Class: MusicTheory.Theory.Harmony.Key
Assembly: MusicTheory
File(s): /home/runner/work/MusicTheory/MusicTheory/Theory/Harmony/RomanNumeral.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 28
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_TonicMidi()100%11100%
ScaleDegreeMidi(...)100%22100%
.cctor()100%11100%

File(s)

/home/runner/work/MusicTheory/MusicTheory/Theory/Harmony/RomanNumeral.cs

#LineLine coverage
 1namespace MusicTheory.Theory.Harmony;
 2
 3public enum TonalFunction { Tonic, Subdominant, Dominant, Unknown }
 4
 5public enum RomanNumeral
 6{
 7    I, II, III, IV, V, VI, VII,
 8    i, ii, iii, iv, v, vi, vii
 9}
 10
 7238811public readonly record struct Key(int TonicMidi, bool IsMajor)
 12{
 1253013    public int ScaleDegreeMidi(int degree) => TonicMidi + (IsMajor ? MajorSteps[degree % 7] : MinorSteps[degree % 7]);
 114    private static readonly int[] MajorSteps = { 0, 2, 4, 5, 7, 9, 11 };
 115    private static readonly int[] MinorSteps = { 0, 2, 3, 5, 7, 8, 10 };
 16}
 17
 18public static class RomanNumeralUtils
 19{
 20    public static TonalFunction FunctionOf(RomanNumeral rn) => rn switch
 21    {
 22        RomanNumeral.I or RomanNumeral.i => TonalFunction.Tonic,
 23        RomanNumeral.III or RomanNumeral.iii or RomanNumeral.VI or RomanNumeral.vi => TonalFunction.Tonic,
 24        RomanNumeral.IV or RomanNumeral.iv or RomanNumeral.II or RomanNumeral.ii => TonalFunction.Subdominant,
 25        RomanNumeral.V or RomanNumeral.v or RomanNumeral.VII or RomanNumeral.vii => TonalFunction.Dominant,
 26        _ => TonalFunction.Unknown
 27    };
 28}