< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FunctionOf(...)100%1515100%

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
 11public readonly record struct Key(int TonicMidi, bool IsMajor)
 12{
 13    public int ScaleDegreeMidi(int degree) => TonicMidi + (IsMajor ? MajorSteps[degree % 7] : MinorSteps[degree % 7]);
 14    private static readonly int[] MajorSteps = { 0, 2, 4, 5, 7, 9, 11 };
 15    private static readonly int[] MinorSteps = { 0, 2, 3, 5, 7, 8, 10 };
 16}
 17
 18public static class RomanNumeralUtils
 19{
 39520    public static TonalFunction FunctionOf(RomanNumeral rn) => rn switch
 39521    {
 14522        RomanNumeral.I or RomanNumeral.i => TonalFunction.Tonic,
 3323        RomanNumeral.III or RomanNumeral.iii or RomanNumeral.VI or RomanNumeral.vi => TonalFunction.Tonic,
 11824        RomanNumeral.IV or RomanNumeral.iv or RomanNumeral.II or RomanNumeral.ii => TonalFunction.Subdominant,
 9825        RomanNumeral.V or RomanNumeral.v or RomanNumeral.VII or RomanNumeral.vii => TonalFunction.Dominant,
 126        _ => TonalFunction.Unknown
 39527    };
 28}